Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+32 -15
+4 -2
Documentation/ABI/testing/sysfs-bus-intel_th-output-devices
··· 3 3 KernelVersion: 4.3 4 4 Contact: Alexander Shishkin <alexander.shishkin@linux.intel.com> 5 5 Description: (RW) Writes of 1 or 0 enable or disable trace output to this 6 - output device. Reads return current status. 6 + output device. Reads return current status. Requires that the 7 + correstponding output port driver be loaded. 7 8 8 9 What: /sys/bus/intel_th/devices/<intel_th_id>-msc<msc-id>/port 9 10 Date: June 2015 10 11 KernelVersion: 4.3 11 12 Contact: Alexander Shishkin <alexander.shishkin@linux.intel.com> 12 13 Description: (RO) Port number, corresponding to this output device on the 13 - switch (GTH). 14 + switch (GTH) or "unassigned" if the corresponding output 15 + port driver is not loaded.
+5 -1
drivers/hwtracing/intel_th/core.c
··· 422 422 unsigned nres; 423 423 unsigned type; 424 424 unsigned otype; 425 + bool mknode; 425 426 unsigned scrpd; 426 427 int id; 427 428 } intel_th_subdevices[] = { ··· 457 456 .name = "msc", 458 457 .id = 0, 459 458 .type = INTEL_TH_OUTPUT, 459 + .mknode = true, 460 460 .otype = GTH_MSU, 461 461 .scrpd = SCRPD_MEM_IS_PRIM_DEST | SCRPD_MSC0_IS_ENABLED, 462 462 }, ··· 478 476 .name = "msc", 479 477 .id = 1, 480 478 .type = INTEL_TH_OUTPUT, 479 + .mknode = true, 481 480 .otype = GTH_MSU, 482 481 .scrpd = SCRPD_MEM_IS_PRIM_DEST | SCRPD_MSC1_IS_ENABLED, 483 482 }, ··· 638 635 } 639 636 640 637 if (subdev->type == INTEL_TH_OUTPUT) { 641 - thdev->dev.devt = MKDEV(th->major, th->num_thdevs); 638 + if (subdev->mknode) 639 + thdev->dev.devt = MKDEV(th->major, th->num_thdevs); 642 640 thdev->output.type = subdev->otype; 643 641 thdev->output.port = -1; 644 642 thdev->output.scratchpad = subdev->scrpd;
+4
drivers/hwtracing/intel_th/gth.c
··· 607 607 { 608 608 struct gth_device *gth = dev_get_drvdata(&thdev->dev); 609 609 int port = othdev->output.port; 610 + int master; 610 611 611 612 if (thdev->host_mode) 612 613 return; ··· 616 615 othdev->output.port = -1; 617 616 othdev->output.active = false; 618 617 gth->output[port].output = NULL; 618 + for (master = 0; master < TH_CONFIGURABLE_MASTERS; master++) 619 + if (gth->master[master] == port) 620 + gth->master[master] = -1; 619 621 spin_unlock(&gth->gth_lock); 620 622 } 621 623
+7 -9
drivers/hwtracing/intel_th/pti.c
··· 272 272 const char *buf, size_t size) 273 273 { 274 274 struct pti_device *pti = dev_get_drvdata(dev); 275 - ssize_t ret = -EINVAL; 276 275 int i; 277 276 278 - for (i = 0; i < ARRAY_SIZE(lpp_dest_str); i++) 279 - if (sysfs_streq(buf, lpp_dest_str[i])) 280 - break; 277 + i = sysfs_match_string(lpp_dest_str, buf); 278 + if (i < 0) 279 + return i; 281 280 282 - if (i < ARRAY_SIZE(lpp_dest_str) && pti->lpp_dest_mask & BIT(i)) { 283 - pti->lpp_dest = i; 284 - ret = size; 285 - } 281 + if (!(pti->lpp_dest_mask & BIT(i))) 282 + return -EINVAL; 286 283 287 - return ret; 284 + pti->lpp_dest = i; 285 + return size; 288 286 } 289 287 290 288 static DEVICE_ATTR_RW(lpp_dest);
+4
drivers/hwtracing/intel_th/sth.c
··· 84 84 /* Global packets (GERR, XSYNC, TRIG) are sent with register writes */ 85 85 case STP_PACKET_GERR: 86 86 reg += 4; 87 + /* fall through */ 88 + 87 89 case STP_PACKET_XSYNC: 88 90 reg += 8; 91 + /* fall through */ 92 + 89 93 case STP_PACKET_TRIG: 90 94 if (flags & STP_PACKET_TIMESTAMPED) 91 95 reg += 4;
+8 -3
drivers/hwtracing/stm/core.c
··· 244 244 ; 245 245 if (i == width) 246 246 return pos; 247 + 248 + /* step over [pos..pos+i) to continue search */ 249 + pos += i; 247 250 } 248 251 249 252 return -1; ··· 735 732 struct stm_device *stm = stmf->stm; 736 733 struct stp_policy_id *id; 737 734 char *ids[] = { NULL, NULL }; 738 - int ret = -EINVAL; 735 + int ret = -EINVAL, wlimit = 1; 739 736 u32 size; 740 737 741 738 if (stmf->output.nr_chans) ··· 763 760 if (id->__reserved_0 || id->__reserved_1) 764 761 goto err_free; 765 762 766 - if (id->width < 1 || 767 - id->width > PAGE_SIZE / stm->data->sw_mmiosz) 763 + if (stm->data->sw_mmiosz) 764 + wlimit = PAGE_SIZE / stm->data->sw_mmiosz; 765 + 766 + if (id->width < 1 || id->width > wlimit) 768 767 goto err_free; 769 768 770 769 ids[0] = id->id;