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

coresight: tmc: adding sysFS management entries

Adding management registers that convey implementation
specific characteristics. Those are useful for trace
configuration and collection along with general trouble
shooting.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Mathieu Poirier and committed by
Greg Kroah-Hartman
7d83d177 960e3095

+118 -62
+77
Documentation/ABI/testing/sysfs-bus-coresight-devices-tmc
··· 6 6 formatter after a defined number of words have been stored 7 7 following the trigger event. Additional interface for this 8 8 driver are expected to be added as it matures. 9 + 10 + What: /sys/bus/coresight/devices/<memory_map>.tmc/mgmt/rsz 11 + Date: March 2016 12 + KernelVersion: 4.7 13 + Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 14 + Description: (R) Defines the size, in 32-bit words, of the local RAM buffer. 15 + The value is read directly from HW register RSZ, 0x004. 16 + 17 + What: /sys/bus/coresight/devices/<memory_map>.tmc/mgmt/sts 18 + Date: March 2016 19 + KernelVersion: 4.7 20 + Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 21 + Description: (R) Shows the value held by the TMC status register. The value 22 + is read directly from HW register STS, 0x00C. 23 + 24 + What: /sys/bus/coresight/devices/<memory_map>.tmc/mgmt/rrp 25 + Date: March 2016 26 + KernelVersion: 4.7 27 + Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 28 + Description: (R) Shows the value held by the TMC RAM Read Pointer register 29 + that is used to read entries from the Trace RAM over the APB 30 + interface. The value is read directly from HW register RRP, 31 + 0x014. 32 + 33 + What: /sys/bus/coresight/devices/<memory_map>.tmc/mgmt/rwp 34 + Date: March 2016 35 + KernelVersion: 4.7 36 + Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 37 + Description: (R) Shows the value held by the TMC RAM Write Pointer register 38 + that is used to sets the write pointer to write entries from 39 + the CoreSight bus into the Trace RAM. The value is read directly 40 + from HW register RWP, 0x018. 41 + 42 + What: /sys/bus/coresight/devices/<memory_map>.tmc/mgmt/trg 43 + Date: March 2016 44 + KernelVersion: 4.7 45 + Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 46 + Description: (R) Similar to "trigger_cntr" above except that this value is 47 + read directly from HW register TRG, 0x01C. 48 + 49 + What: /sys/bus/coresight/devices/<memory_map>.tmc/mgmt/ctl 50 + Date: March 2016 51 + KernelVersion: 4.7 52 + Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 53 + Description: (R) Shows the value held by the TMC Control register. The value 54 + is read directly from HW register CTL, 0x020. 55 + 56 + What: /sys/bus/coresight/devices/<memory_map>.tmc/mgmt/ffsr 57 + Date: March 2016 58 + KernelVersion: 4.7 59 + Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 60 + Description: (R) Shows the value held by the TMC Formatter and Flush Status 61 + register. The value is read directly from HW register FFSR, 62 + 0x300. 63 + 64 + What: /sys/bus/coresight/devices/<memory_map>.tmc/mgmt/ffcr 65 + Date: March 2016 66 + KernelVersion: 4.7 67 + Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 68 + Description: (R) Shows the value held by the TMC Formatter and Flush Control 69 + register. The value is read directly from HW register FFCR, 70 + 0x304. 71 + 72 + What: /sys/bus/coresight/devices/<memory_map>.tmc/mgmt/mode 73 + Date: March 2016 74 + KernelVersion: 4.7 75 + Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 76 + Description: (R) Shows the value held by the TMC Mode register, which 77 + indicate the mode the device has been configured to enact. The 78 + The value is read directly from the MODE register, 0x028. 79 + 80 + What: /sys/bus/coresight/devices/<memory_map>.tmc/mgmt/devid 81 + Date: March 2016 82 + KernelVersion: 4.7 83 + Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 84 + Description: (R) Indicates the capabilities of the Coresight TMC. 85 + The value is read directly from the DEVID register, 0xFC8,
+41 -62
drivers/hwtracing/coresight/coresight-tmc.c
··· 556 556 .llseek = no_llseek, 557 557 }; 558 558 559 - static ssize_t status_show(struct device *dev, 560 - struct device_attribute *attr, char *buf) 561 - { 562 - unsigned long flags; 563 - u32 tmc_rsz, tmc_sts, tmc_rrp, tmc_rwp, tmc_trg; 564 - u32 tmc_ctl, tmc_ffsr, tmc_ffcr, tmc_mode, tmc_pscr; 565 - u32 devid; 566 - struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent); 559 + #define coresight_tmc_simple_func(name, offset) \ 560 + coresight_simple_func(struct tmc_drvdata, name, offset) 567 561 568 - pm_runtime_get_sync(drvdata->dev); 569 - spin_lock_irqsave(&drvdata->spinlock, flags); 570 - CS_UNLOCK(drvdata->base); 562 + coresight_tmc_simple_func(rsz, TMC_RSZ); 563 + coresight_tmc_simple_func(sts, TMC_STS); 564 + coresight_tmc_simple_func(rrp, TMC_RRP); 565 + coresight_tmc_simple_func(rwp, TMC_RWP); 566 + coresight_tmc_simple_func(trg, TMC_TRG); 567 + coresight_tmc_simple_func(ctl, TMC_CTL); 568 + coresight_tmc_simple_func(ffsr, TMC_FFSR); 569 + coresight_tmc_simple_func(ffcr, TMC_FFCR); 570 + coresight_tmc_simple_func(mode, TMC_MODE); 571 + coresight_tmc_simple_func(pscr, TMC_PSCR); 572 + coresight_tmc_simple_func(devid, CORESIGHT_DEVID); 571 573 572 - tmc_rsz = readl_relaxed(drvdata->base + TMC_RSZ); 573 - tmc_sts = readl_relaxed(drvdata->base + TMC_STS); 574 - tmc_rrp = readl_relaxed(drvdata->base + TMC_RRP); 575 - tmc_rwp = readl_relaxed(drvdata->base + TMC_RWP); 576 - tmc_trg = readl_relaxed(drvdata->base + TMC_TRG); 577 - tmc_ctl = readl_relaxed(drvdata->base + TMC_CTL); 578 - tmc_ffsr = readl_relaxed(drvdata->base + TMC_FFSR); 579 - tmc_ffcr = readl_relaxed(drvdata->base + TMC_FFCR); 580 - tmc_mode = readl_relaxed(drvdata->base + TMC_MODE); 581 - tmc_pscr = readl_relaxed(drvdata->base + TMC_PSCR); 582 - devid = readl_relaxed(drvdata->base + CORESIGHT_DEVID); 574 + static struct attribute *coresight_tmc_mgmt_attrs[] = { 575 + &dev_attr_rsz.attr, 576 + &dev_attr_sts.attr, 577 + &dev_attr_rrp.attr, 578 + &dev_attr_rwp.attr, 579 + &dev_attr_trg.attr, 580 + &dev_attr_ctl.attr, 581 + &dev_attr_ffsr.attr, 582 + &dev_attr_ffcr.attr, 583 + &dev_attr_mode.attr, 584 + &dev_attr_pscr.attr, 585 + &dev_attr_devid.attr, 586 + NULL, 587 + }; 583 588 584 - CS_LOCK(drvdata->base); 585 - spin_unlock_irqrestore(&drvdata->spinlock, flags); 586 - pm_runtime_put(drvdata->dev); 587 - 588 - return sprintf(buf, 589 - "Depth:\t\t0x%x\n" 590 - "Status:\t\t0x%x\n" 591 - "RAM read ptr:\t0x%x\n" 592 - "RAM wrt ptr:\t0x%x\n" 593 - "Trigger cnt:\t0x%x\n" 594 - "Control:\t0x%x\n" 595 - "Flush status:\t0x%x\n" 596 - "Flush ctrl:\t0x%x\n" 597 - "Mode:\t\t0x%x\n" 598 - "PSRC:\t\t0x%x\n" 599 - "DEVID:\t\t0x%x\n", 600 - tmc_rsz, tmc_sts, tmc_rrp, tmc_rwp, tmc_trg, 601 - tmc_ctl, tmc_ffsr, tmc_ffcr, tmc_mode, tmc_pscr, devid); 602 - 603 - return -EINVAL; 604 - } 605 - static DEVICE_ATTR_RO(status); 606 - 607 - static ssize_t trigger_cntr_show(struct device *dev, 608 - struct device_attribute *attr, char *buf) 589 + ssize_t trigger_cntr_show(struct device *dev, 590 + struct device_attribute *attr, char *buf) 609 591 { 610 592 struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent); 611 593 unsigned long val = drvdata->trigger_cntr; ··· 612 630 } 613 631 static DEVICE_ATTR_RW(trigger_cntr); 614 632 615 - static struct attribute *coresight_etb_attrs[] = { 633 + static struct attribute *coresight_tmc_attrs[] = { 616 634 &dev_attr_trigger_cntr.attr, 617 - &dev_attr_status.attr, 618 635 NULL, 619 636 }; 620 - ATTRIBUTE_GROUPS(coresight_etb); 621 637 622 - static struct attribute *coresight_etr_attrs[] = { 623 - &dev_attr_trigger_cntr.attr, 624 - &dev_attr_status.attr, 625 - NULL, 638 + static const struct attribute_group coresight_tmc_group = { 639 + .attrs = coresight_tmc_attrs, 626 640 }; 627 - ATTRIBUTE_GROUPS(coresight_etr); 628 641 629 - static struct attribute *coresight_etf_attrs[] = { 630 - &dev_attr_trigger_cntr.attr, 631 - &dev_attr_status.attr, 642 + static const struct attribute_group coresight_tmc_mgmt_group = { 643 + .attrs = coresight_tmc_mgmt_attrs, 644 + .name = "mgmt", 645 + }; 646 + 647 + const struct attribute_group *coresight_tmc_groups[] = { 648 + &coresight_tmc_group, 649 + &coresight_tmc_mgmt_group, 632 650 NULL, 633 651 }; 634 - ATTRIBUTE_GROUPS(coresight_etf); 635 652 636 653 static int tmc_probe(struct amba_device *adev, const struct amba_id *id) 637 654 { ··· 706 725 desc->pdata = pdata; 707 726 desc->dev = dev; 708 727 desc->subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER; 728 + desc->groups = coresight_tmc_groups; 709 729 710 730 if (drvdata->config_type == TMC_CONFIG_TYPE_ETB) { 711 731 desc->type = CORESIGHT_DEV_TYPE_SINK; 712 732 desc->ops = &tmc_etb_cs_ops; 713 - desc->groups = coresight_etb_groups; 714 733 } else if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) { 715 734 desc->type = CORESIGHT_DEV_TYPE_SINK; 716 735 desc->ops = &tmc_etr_cs_ops; 717 - desc->groups = coresight_etr_groups; 718 736 } else { 719 737 desc->type = CORESIGHT_DEV_TYPE_LINKSINK; 720 738 desc->subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_FIFO; 721 739 desc->ops = &tmc_etf_cs_ops; 722 - desc->groups = coresight_etf_groups; 723 740 } 724 741 725 742 drvdata->csdev = coresight_register(desc);