stm class/intel_th: Updates for v5.1
Subsystems (5)
Alexander Shishkin
maintainerHi Greg,
Second attempt. Added stable CC and Fixes tags to fixes.
Here are the STM and Intel TH changes that I have for v5.1. Nothing big, a few fixes that are too late for the v5.0 and a few minor cleanups and a documentation update. All sparse/smatch/coccinelle/cppcheck/checkpatch clean as usual, courtesy of aiaiai.
Individual patches follow. Please consider pulling or applying. Thanks!
The following changes since commit bfeffd155283772bbe78c6a05dec7c0128ee500c:
Linux 5.0-rc1 (2019-01-06 17:08:20 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/ash/stm.git tags/intel_th-stm-for-greg-20190221
for you to fetch changes up to 4c3cef46a96e8f623d1edf03424880ebc901b068:
stm class: Prevent division by zero (2019-02-21 15:29:26 +0200)
----------------------------------------------------------------
stm class/intel_th: Updates for v5.1
These are:
* 2 bugfixes in stm class
* one bugfix in intel_th
* a few minor cleanups
----------------------------------------------------------------
Alexander Shishkin (4):
intel_th: Update ABI documentation
intel_th: Only create useful device nodes
intel_th: Don't reference unassigned outputs
stm class: Prevent division by zero
Andy Shevchenko (1):
intel_th: pti: Use sysfs_match_string() helper
Gustavo A. R. Silva (1):
intel_th: Mark expected switch fall-throughs
Zhi Jin (1):
stm class: Fix an endless loop in channel allocation
.../testing/sysfs-bus-intel_th-output-devices | 6 ++++-- drivers/hwtracing/intel_th/core.c | 6 +++++- drivers/hwtracing/intel_th/gth.c | 4 ++++ drivers/hwtracing/intel_th/pti.c | 16 +++++++--------- drivers/hwtracing/intel_th/sth.c | 4 ++++ drivers/hwtracing/stm/core.c | 11 ++++++++--- 6 files changed, 32 insertions(+), 15 deletions(-)
Signature · 1 line
2.20.1
Alexander Shishkin
maintainer[GIT PULL v1 1/7] intel_th: Update ABI documentation
Commit a753bfcfdb1f3 ("intel_th: Make the switch allocate its subdevices") changed the behavior so that the output port devices are created only for the ports reported by the hardware and their initial state is "unassigned" until a corresponding output port driver is loaded. Reflect this fact in the ABI documentation.
--- Documentation/ABI/testing/sysfs-bus-intel_th-output-devices | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Documentation/ABI/testing/sysfs-bus-intel_th-output-devices +4 -2
@@ -3,11 +3,13 @@ Date: June 2015 KernelVersion: 4.3 Contact: Alexander Shishkin <[email protected]> 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 Date: June 2015 KernelVersion: 4.3 Contact: Alexander Shishkin <[email protected]> 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.
Signature · 1 line
2.20.1
Alexander Shishkin
maintainer[GIT PULL v1 2/7] intel_th: Mark expected switch fall-throughs
In reply to Alexander ShishkinFrom: "Gustavo A. R. Silva" <[email protected]>
In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through.
This patch fixes the following warnings:
drivers/hwtracing/intel_th/sth.c: In function ‘sth_stm_packet’:drivers/hwtracing/intel_th/sth.c:86:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
reg += 4;
~~~~^~~~drivers/hwtracing/intel_th/sth.c:87:2: note: here
case STP_PACKET_XSYNC:
^~~~drivers/hwtracing/intel_th/sth.c:88:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
reg += 8;
~~~~^~~~drivers/hwtracing/intel_th/sth.c:89:2: note: here
case STP_PACKET_TRIG:
^~~~
Warning level 3 was used: -Wimplicit-fallthrough=3
This patch is part of the ongoing efforts to enable -Wimplicit-fallthrough.
--- drivers/hwtracing/intel_th/sth.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/hwtracing/intel_th/sth.c +4 -0
@@ -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 */ case STP_PACKET_GERR : reg +=4 ; +/* fall through */ +case STP_PACKET_XSYNC : reg +=8 ; +/* fall through */ +case STP_PACKET_TRIG :if (flags &STP_PACKET_TIMESTAMPED ) reg +=4 ;
Signature · 1 line
2.20.1
Alexander Shishkin
maintainer[GIT PULL v1 3/7] intel_th: Only create useful device nodes
In reply to Alexander ShishkinRight now, the driver will create a device node for each output port, with the intent to provide read access to that port's data. However, only the memory ports are readable this way (msc0, msc1). Other output ports don't need device nodes, so remove them.
--- drivers/hwtracing/intel_th/core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/hwtracing/intel_th/core.c +5 -1
@@ -422,6 +422,7 @@ static const struct intel_th_subdevice {unsigned nres;unsigned type;unsigned otype; +bool mknode;unsigned scrpd;int id; } intel_th_subdevices[] = {
@@ -456,6 +457,7 @@ static const struct intel_th_subdevice { .name = "msc", .id = 0, .type = INTEL_TH_OUTPUT, + .mknode = true, .otype = GTH_MSU, .scrpd = SCRPD_MEM_IS_PRIM_DEST | SCRPD_MSC0_IS_ENABLED, },
@@ -476,6 +478,7 @@ static const struct intel_th_subdevice { .name = "msc", .id = 1, .type = INTEL_TH_OUTPUT, + .mknode = true, .otype = GTH_MSU, .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 ) { - 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.port =-1 ; thdev->output.scratchpad = subdev->scrpd;
Signature · 1 line
2.20.1
Alexander Shishkin
maintainer[GIT PULL v1 4/7] intel_th: pti: Use sysfs_match_string() helper
In reply to Alexander ShishkinFrom: Andy Shevchenko <[email protected]>
Use sysfs_match_string() helper instead of open coded variant.
--- drivers/hwtracing/intel_th/pti.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/hwtracing/intel_th/pti.c +7 -9
@@ -272,19 +272,17 @@ static ssize_t lpp_dest_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) {struct pti_device *pti =dev_get_drvdata (dev); -ssize_t ret = -EINVAL ;int i; -for (i =0 ; i <ARRAY_SIZE (lpp_dest_str); i++) -if (sysfs_streq (buf, lpp_dest_str[i])) -break ; + i =sysfs_match_string (lpp_dest_str, buf); +if (i <0 ) +return i; -if (i <ARRAY_SIZE (lpp_dest_str) && pti->lpp_dest_mask &BIT (i)) { - pti->lpp_dest = i; - ret = size; - } +if (!(pti->lpp_dest_mask &BIT (i))) +return -EINVAL ; -return ret; + pti->lpp_dest = i; +return size; }static DEVICE_ATTR_RW (lpp_dest);
Signature · 1 line
2.20.1
Alexander Shishkin
maintainer[GIT PULL v1 5/7] intel_th: Don't reference unassigned outputs
In reply to Alexander ShishkinWhen an output port driver is removed, also remove references to it from any masters. Failing to do this causes a NULL ptr dereference when configuring another output port:
Quoted 8 lines
BUG: unable to handle kernel NULL pointer dereference at 000000000000000d RIP: 0010:master_attr_store+0x9d/0x160 [intel_th_gth] Call Trace: dev_attr_store+0x1b/0x30 sysfs_kf_write+0x3c/0x50 kernfs_fop_write+0x125/0x1a0 __vfs_write+0x3a/0x190 ? __vfs_write+0x5/0x190
Quoted 8 lines
? _cond_resched+0x1a/0x50 ? rcu_all_qs+0x5/0xb0 ? __vfs_write+0x5/0x190 vfs_write+0xb8/0x1b0 ksys_write+0x55/0xc0 __x64_sys_write+0x1a/0x20 do_syscall_64+0x5a/0x140 entry_SYSCALL_64_after_hwframe+0x44/0xa9
--- drivers/hwtracing/intel_th/gth.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/hwtracing/intel_th/gth.c +4 -0
@@ -607,6 +607,7 @@ static void intel_th_gth_unassign(struct intel_th_device *thdev, {struct gth_device *gth =dev_get_drvdata (&thdev->dev);int port = othdev->output.port; +int master;if (thdev->host_mode)return ;
@@ -615,6 +616,9 @@ static void intel_th_gth_unassign(struct intel_th_device *thdev, othdev->output.port =-1 ; othdev->output.active = false; gth->output[port].output =NULL ; +for (master =0 ; master <TH_CONFIGURABLE_MASTERS ; master++) +if (gth->master[master] == port) + gth->master[master] =-1 ;spin_unlock (>h->gth_lock); }
Signature · 1 line
2.20.1
Alexander Shishkin
maintainer[GIT PULL v1 6/7] stm class: Fix an endless loop in channel allocation
In reply to Alexander ShishkinFrom: Zhi Jin <[email protected]>
There is a bug in the channel allocation logic that leads to an endless loop when looking for a contiguous range of channels in a range with a mixture of free and occupied channels. For example, opening three consequtive channels, closing the first two and requesting 4 channels in a row will trigger this soft lockup. The bug is that the search loop forgets to skip over the range once it detects that one channel in that range is occupied.
Restore the original intent to the logic by fixing the omission.
--- drivers/hwtracing/stm/core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hwtracing/stm/core.c +3 -0
@@ -244,6 +244,9 @@ static int find_free_channels(unsigned long *bitmap, unsigned int start, ;if (i == width)return pos; + +/* step over [pos..pos+i) to continue search */ + pos += i; }return -1 ;
Signature · 1 line
2.20.1
Alexander Shishkin
maintainer[GIT PULL v1 7/7] stm class: Prevent division by zero
In reply to Alexander ShishkinUsing STP_POLICY_ID_SET ioctl command with dummy_stm device, or any STM device that supplies zero mmio channel size, will trigger a division by zero bug in the kernel.
Prevent this by disallowing channel widths other than 1 for such devices.
--- drivers/hwtracing/stm/core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/hwtracing/stm/core.c +5 -3
@@ -735,7 +735,7 @@ static int stm_char_policy_set_ioctl(struct stm_file *stmf, void __user *arg)struct stm_device *stm = stmf->stm;struct stp_policy_id *id;char *ids[] = {NULL ,NULL }; -int ret = -EINVAL ; +int ret = -EINVAL , wlimit =1 ;u32 size;if (stmf->output.nr_chans)
@@ -763,8 +763,10 @@ static int stm_char_policy_set_ioctl(struct stm_file *stmf, void __user *arg)if (id->__reserved_0 || id->__reserved_1) goto err_free; -if (id->width <1 || - id->width >PAGE_SIZE / stm->data->sw_mmiosz) +if (stm->data->sw_mmiosz) + wlimit =PAGE_SIZE / stm->data->sw_mmiosz; + +if (id->width <1 || id->width > wlimit) goto err_free; ids[0 ] = id->id;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerQuoted 10 lines · Alexander Shishkin
Hi Greg,
Second attempt. Added stable CC and Fixes tags to fixes.
Here are the STM and Intel TH changes that I have for v5.1. Nothing big, a few fixes that are too late for the v5.0 and a few minor cleanups and a documentation update. All sparse/smatch/coccinelle/cppcheck/checkpatch clean as usual, courtesy of aiaiai.
Individual patches follow. Please consider pulling or applying. Thanks!
Quoted 7 lines
The following changes since commit
bfeffd155283772bbe78c6a05dec7c0128ee500c:Linux 5.0-rc1 (2019-01-06 17:08:20 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/ash/stm.gittags/intel_th-stm-for-greg-20190221
Much better, thanks, pulled and pushed out.
greg k-h
Alexander Shishkin
maintainerQuoted 13 lines · Greg Kroah-Hartman
Quoted 12 lines · Alexander Shishkin
Hi Greg,
Second attempt. Added stable CC and Fixes tags to fixes.
Here are the STM and Intel TH changes that I have for v5.1. Nothing big, a few fixes that are too late for the v5.0 and a few minor cleanups and a documentation update. All sparse/smatch/coccinelle/cppcheck/checkpatch clean as usual, courtesy of aiaiai.
Individual patches follow. Please consider pulling or applying. Thanks!The following changes since commit
bfeffd155283772bbe78c6a05dec7c0128ee500c:
Quoted 7 lines
Quoted 5 lines
Linux 5.0-rc1 (2019-01-06 17:08:20 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/ash/stm.gittags/intel_th-stm-for-greg-20190221Much better, thanks, pulled and pushed out.
This is super embarrassing, but 5/7 in this set has an off-by-one. A fix is headed to your inbox [1]. Will do better next time!
[1] https://marc.info/?l=linux-kernel&m=155142781026182
Thanks,
--
Alex