stm class/intel_th: Updates for v5.1

These are:
   * 2 bugfixes in stm class
   * one bugfix in intel_th
   * a few minor cleanups
 -----BEGIN PGP SIGNATURE-----
 
 iJkEABEIAEEWIQQSviFCoXpKPDNATbnrxfYkYwVX/wUCXG7HqCMcYWxleGFuZGVy
 LnNoaXNoa2luQGxpbnV4LmludGVsLmNvbQAKCRDrxfYkYwVX/4+gAP4kcSiNaRBa
 M+0/vceK2AxiRSoMt81kOYEQDNGK2QJLGAD+NjbFXmgl32jFqKbpj+O+kraWPb3P
 eJV7+nHj/nB72dM=
 =8AhL
 -----END PGP SIGNATURE-----

Merge tag 'intel_th-stm-for-greg-20190221' of git://git.kernel.org/pub/scm/linux/kernel/git/ash/stm into char-misc-next

Alexander writes:

stm class/intel_th: Updates for v5.1

These are:
  * 2 bugfixes in stm class
  * one bugfix in intel_th
  * a few minor cleanups

* tag 'intel_th-stm-for-greg-20190221' of git://git.kernel.org/pub/scm/linux/kernel/git/ash/stm:
  stm class: Prevent division by zero
  stm class: Fix an endless loop in channel allocation
  intel_th: Don't reference unassigned outputs
  intel_th: pti: Use sysfs_match_string() helper
  intel_th: Only create useful device nodes
  intel_th: Mark expected switch fall-throughs
  intel_th: Update ABI documentation
This commit is contained in:
Greg Kroah-Hartman 2019-02-21 17:12:17 +01:00
commit 7f2b8af282
6 changed files with 32 additions and 15 deletions

View File

@ -3,11 +3,13 @@ Date: June 2015
KernelVersion: 4.3 KernelVersion: 4.3
Contact: Alexander Shishkin <alexander.shishkin@linux.intel.com> Contact: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Description: (RW) Writes of 1 or 0 enable or disable trace output to this Description: (RW) Writes of 1 or 0 enable or disable trace output to this
output device. Reads return current status. output device. Reads return current status. Requires that the
correstponding output port driver be loaded.
What: /sys/bus/intel_th/devices/<intel_th_id>-msc<msc-id>/port What: /sys/bus/intel_th/devices/<intel_th_id>-msc<msc-id>/port
Date: June 2015 Date: June 2015
KernelVersion: 4.3 KernelVersion: 4.3
Contact: Alexander Shishkin <alexander.shishkin@linux.intel.com> Contact: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Description: (RO) Port number, corresponding to this output device on the Description: (RO) Port number, corresponding to this output device on the
switch (GTH). switch (GTH) or "unassigned" if the corresponding output
port driver is not loaded.

View File

@ -422,6 +422,7 @@ static const struct intel_th_subdevice {
unsigned nres; unsigned nres;
unsigned type; unsigned type;
unsigned otype; unsigned otype;
bool mknode;
unsigned scrpd; unsigned scrpd;
int id; int id;
} intel_th_subdevices[] = { } intel_th_subdevices[] = {
@ -456,6 +457,7 @@ static const struct intel_th_subdevice {
.name = "msc", .name = "msc",
.id = 0, .id = 0,
.type = INTEL_TH_OUTPUT, .type = INTEL_TH_OUTPUT,
.mknode = true,
.otype = GTH_MSU, .otype = GTH_MSU,
.scrpd = SCRPD_MEM_IS_PRIM_DEST | SCRPD_MSC0_IS_ENABLED, .scrpd = SCRPD_MEM_IS_PRIM_DEST | SCRPD_MSC0_IS_ENABLED,
}, },
@ -476,6 +478,7 @@ static const struct intel_th_subdevice {
.name = "msc", .name = "msc",
.id = 1, .id = 1,
.type = INTEL_TH_OUTPUT, .type = INTEL_TH_OUTPUT,
.mknode = true,
.otype = GTH_MSU, .otype = GTH_MSU,
.scrpd = SCRPD_MEM_IS_PRIM_DEST | SCRPD_MSC1_IS_ENABLED, .scrpd = SCRPD_MEM_IS_PRIM_DEST | SCRPD_MSC1_IS_ENABLED,
}, },
@ -635,7 +638,8 @@ intel_th_subdevice_alloc(struct intel_th *th,
} }
if (subdev->type == INTEL_TH_OUTPUT) { if (subdev->type == INTEL_TH_OUTPUT) {
thdev->dev.devt = MKDEV(th->major, th->num_thdevs); if (subdev->mknode)
thdev->dev.devt = MKDEV(th->major, th->num_thdevs);
thdev->output.type = subdev->otype; thdev->output.type = subdev->otype;
thdev->output.port = -1; thdev->output.port = -1;
thdev->output.scratchpad = subdev->scrpd; thdev->output.scratchpad = subdev->scrpd;

View File

@ -607,6 +607,7 @@ static void intel_th_gth_unassign(struct intel_th_device *thdev,
{ {
struct gth_device *gth = dev_get_drvdata(&thdev->dev); struct gth_device *gth = dev_get_drvdata(&thdev->dev);
int port = othdev->output.port; int port = othdev->output.port;
int master;
if (thdev->host_mode) if (thdev->host_mode)
return; return;
@ -615,6 +616,9 @@ static void intel_th_gth_unassign(struct intel_th_device *thdev,
othdev->output.port = -1; othdev->output.port = -1;
othdev->output.active = false; othdev->output.active = false;
gth->output[port].output = NULL; gth->output[port].output = NULL;
for (master = 0; master < TH_CONFIGURABLE_MASTERS; master++)
if (gth->master[master] == port)
gth->master[master] = -1;
spin_unlock(&gth->gth_lock); spin_unlock(&gth->gth_lock);
} }

View File

@ -272,19 +272,17 @@ static ssize_t lpp_dest_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t size) const char *buf, size_t size)
{ {
struct pti_device *pti = dev_get_drvdata(dev); struct pti_device *pti = dev_get_drvdata(dev);
ssize_t ret = -EINVAL;
int i; int i;
for (i = 0; i < ARRAY_SIZE(lpp_dest_str); i++) i = sysfs_match_string(lpp_dest_str, buf);
if (sysfs_streq(buf, lpp_dest_str[i])) if (i < 0)
break; return i;
if (i < ARRAY_SIZE(lpp_dest_str) && pti->lpp_dest_mask & BIT(i)) { if (!(pti->lpp_dest_mask & BIT(i)))
pti->lpp_dest = i; return -EINVAL;
ret = size;
}
return ret; pti->lpp_dest = i;
return size;
} }
static DEVICE_ATTR_RW(lpp_dest); static DEVICE_ATTR_RW(lpp_dest);

View File

@ -84,8 +84,12 @@ static ssize_t notrace sth_stm_packet(struct stm_data *stm_data,
/* Global packets (GERR, XSYNC, TRIG) are sent with register writes */ /* Global packets (GERR, XSYNC, TRIG) are sent with register writes */
case STP_PACKET_GERR: case STP_PACKET_GERR:
reg += 4; reg += 4;
/* fall through */
case STP_PACKET_XSYNC: case STP_PACKET_XSYNC:
reg += 8; reg += 8;
/* fall through */
case STP_PACKET_TRIG: case STP_PACKET_TRIG:
if (flags & STP_PACKET_TIMESTAMPED) if (flags & STP_PACKET_TIMESTAMPED)
reg += 4; reg += 4;

View File

@ -244,6 +244,9 @@ static int find_free_channels(unsigned long *bitmap, unsigned int start,
; ;
if (i == width) if (i == width)
return pos; return pos;
/* step over [pos..pos+i) to continue search */
pos += i;
} }
return -1; return -1;
@ -732,7 +735,7 @@ static int stm_char_policy_set_ioctl(struct stm_file *stmf, void __user *arg)
struct stm_device *stm = stmf->stm; struct stm_device *stm = stmf->stm;
struct stp_policy_id *id; struct stp_policy_id *id;
char *ids[] = { NULL, NULL }; char *ids[] = { NULL, NULL };
int ret = -EINVAL; int ret = -EINVAL, wlimit = 1;
u32 size; u32 size;
if (stmf->output.nr_chans) if (stmf->output.nr_chans)
@ -760,8 +763,10 @@ static int stm_char_policy_set_ioctl(struct stm_file *stmf, void __user *arg)
if (id->__reserved_0 || id->__reserved_1) if (id->__reserved_0 || id->__reserved_1)
goto err_free; goto err_free;
if (id->width < 1 || if (stm->data->sw_mmiosz)
id->width > PAGE_SIZE / stm->data->sw_mmiosz) wlimit = PAGE_SIZE / stm->data->sw_mmiosz;
if (id->width < 1 || id->width > wlimit)
goto err_free; goto err_free;
ids[0] = id->id; ids[0] = id->id;