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

coresight: etm3x: breaking down sysFS status interface

SysFS rules stipulate that only one value can be conveyed per
file. As such splitting the "status" interface in individual files.

This is also useful for user space applications - that way they can
probe each file individually rather than having to parse a list of entries.

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
7253e4c9 adfad874

+121 -56
+70 -7
Documentation/ABI/testing/sysfs-bus-coresight-devices-etm3x
··· 8 8 of coresight components linking the source to the sink is 9 9 configured and managed automatically by the coresight framework. 10 10 11 - What: /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/status 12 - Date: November 2014 13 - KernelVersion: 3.19 14 - Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 15 - Description: (R) List various control and status registers. The specific 16 - layout and content is driver specific. 17 - 18 11 What: /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/addr_idx 19 12 Date: November 2014 20 13 KernelVersion: 3.19 ··· 244 251 KernelVersion: 3.19 245 252 Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 246 253 Description: (RW) Define the event that controls the trigger. 254 + 255 + What: /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/mgmt/etmccr 256 + Date: September 2015 257 + KernelVersion: 4.4 258 + Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 259 + Description: (RO) Print the content of the ETM Configuration Code register 260 + (0x004). The value is read directly from the HW. 261 + 262 + What: /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/mgmt/etmccer 263 + Date: September 2015 264 + KernelVersion: 4.4 265 + Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 266 + Description: (RO) Print the content of the ETM Configuration Code Extension 267 + register (0x1e8). The value is read directly from the HW. 268 + 269 + What: /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/mgmt/etmscr 270 + Date: September 2015 271 + KernelVersion: 4.4 272 + Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 273 + Description: (RO) Print the content of the ETM System Configuration 274 + register (0x014). The value is read directly from the HW. 275 + 276 + What: /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/mgmt/etmidr 277 + Date: September 2015 278 + KernelVersion: 4.4 279 + Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 280 + Description: (RO) Print the content of the ETM ID register (0x1e4). The 281 + value is read directly from the HW. 282 + 283 + What: /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/mgmt/etmcr 284 + Date: September 2015 285 + KernelVersion: 4.4 286 + Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 287 + Description: (RO) Print the content of the ETM Main Control register (0x000). 288 + The value is read directly from the HW. 289 + 290 + What: /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/mgmt/etmtraceidr 291 + Date: September 2015 292 + KernelVersion: 4.4 293 + Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 294 + Description: (RO) Print the content of the ETM Trace ID register (0x200). 295 + The value is read directly from the HW. 296 + 297 + What: /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/mgmt/etmteevr 298 + Date: September 2015 299 + KernelVersion: 4.4 300 + Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 301 + Description: (RO) Print the content of the ETM Trace Enable Event register 302 + (0x020). The value is read directly from the HW. 303 + 304 + What: /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/mgmt/etmtsscr 305 + Date: September 2015 306 + KernelVersion: 4.4 307 + Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 308 + Description: (RO) Print the content of the ETM Trace Start/Stop Conrol 309 + register (0x018). The value is read directly from the HW. 310 + 311 + What: /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/mgmt/etmtecr1 312 + Date: September 2015 313 + KernelVersion: 4.4 314 + Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 315 + Description: (RO) Print the content of the ETM Enable Conrol #1 316 + register (0x024). The value is read directly from the HW. 317 + 318 + What: /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/mgmt/etmtecr2 319 + Date: September 2015 320 + KernelVersion: 4.4 321 + Contact: Mathieu Poirier <mathieu.poirier@linaro.org> 322 + Description: (RO) Print the content of the ETM Enable Conrol #2 323 + register (0x01c). The value is read directly from the HW.
+51 -49
drivers/hwtracing/coresight/coresight-etm3x.c
··· 313 313 dev_dbg(drvdata->dev, "cpu: %d enable smp call done\n", drvdata->cpu); 314 314 } 315 315 316 - static int etm_trace_id_simple(struct etm_drvdata *drvdata) 317 - { 318 - if (!drvdata->enable) 319 - return drvdata->traceid; 320 - 321 - return (etm_readl(drvdata, ETMTRACEIDR) & ETM_TRACEID_MASK); 322 - } 323 - 324 316 static int etm_trace_id(struct coresight_device *csdev) 325 317 { 326 318 struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); ··· 1498 1506 } 1499 1507 static DEVICE_ATTR_RW(timestamp_event); 1500 1508 1501 - static ssize_t status_show(struct device *dev, 1502 - struct device_attribute *attr, char *buf) 1503 - { 1504 - int ret; 1505 - unsigned long flags; 1506 - struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); 1507 - 1508 - pm_runtime_get_sync(drvdata->dev); 1509 - spin_lock_irqsave(&drvdata->spinlock, flags); 1510 - 1511 - CS_UNLOCK(drvdata->base); 1512 - ret = sprintf(buf, 1513 - "ETMCCR: 0x%08x\n" 1514 - "ETMCCER: 0x%08x\n" 1515 - "ETMSCR: 0x%08x\n" 1516 - "ETMIDR: 0x%08x\n" 1517 - "ETMCR: 0x%08x\n" 1518 - "ETMTRACEIDR: 0x%08x\n" 1519 - "Enable event: 0x%08x\n" 1520 - "Enable start/stop: 0x%08x\n" 1521 - "Enable control: CR1 0x%08x CR2 0x%08x\n" 1522 - "CPU affinity: %d\n", 1523 - drvdata->etmccr, drvdata->etmccer, 1524 - etm_readl(drvdata, ETMSCR), etm_readl(drvdata, ETMIDR), 1525 - etm_readl(drvdata, ETMCR), etm_trace_id_simple(drvdata), 1526 - etm_readl(drvdata, ETMTEEVR), 1527 - etm_readl(drvdata, ETMTSSCR), 1528 - etm_readl(drvdata, ETMTECR1), 1529 - etm_readl(drvdata, ETMTECR2), 1530 - drvdata->cpu); 1531 - CS_LOCK(drvdata->base); 1532 - 1533 - spin_unlock_irqrestore(&drvdata->spinlock, flags); 1534 - pm_runtime_put(drvdata->dev); 1535 - 1536 - return ret; 1537 - } 1538 - static DEVICE_ATTR_RO(status); 1539 - 1540 1509 static ssize_t cpu_show(struct device *dev, 1541 1510 struct device_attribute *attr, char *buf) 1542 1511 { ··· 1584 1631 &dev_attr_ctxid_mask.attr, 1585 1632 &dev_attr_sync_freq.attr, 1586 1633 &dev_attr_timestamp_event.attr, 1587 - &dev_attr_status.attr, 1588 1634 &dev_attr_traceid.attr, 1589 1635 &dev_attr_cpu.attr, 1590 1636 NULL, 1591 1637 }; 1592 - ATTRIBUTE_GROUPS(coresight_etm); 1638 + 1639 + #define coresight_simple_func(name, offset) \ 1640 + static ssize_t name##_show(struct device *_dev, \ 1641 + struct device_attribute *attr, char *buf) \ 1642 + { \ 1643 + struct etm_drvdata *drvdata = dev_get_drvdata(_dev->parent); \ 1644 + return scnprintf(buf, PAGE_SIZE, "0x%x\n", \ 1645 + readl_relaxed(drvdata->base + offset)); \ 1646 + } \ 1647 + DEVICE_ATTR_RO(name) 1648 + 1649 + coresight_simple_func(etmccr, ETMCCR); 1650 + coresight_simple_func(etmccer, ETMCCER); 1651 + coresight_simple_func(etmscr, ETMSCR); 1652 + coresight_simple_func(etmidr, ETMIDR); 1653 + coresight_simple_func(etmcr, ETMCR); 1654 + coresight_simple_func(etmtraceidr, ETMTRACEIDR); 1655 + coresight_simple_func(etmteevr, ETMTEEVR); 1656 + coresight_simple_func(etmtssvr, ETMTSSCR); 1657 + coresight_simple_func(etmtecr1, ETMTECR1); 1658 + coresight_simple_func(etmtecr2, ETMTECR2); 1659 + 1660 + static struct attribute *coresight_etm_mgmt_attrs[] = { 1661 + &dev_attr_etmccr.attr, 1662 + &dev_attr_etmccer.attr, 1663 + &dev_attr_etmscr.attr, 1664 + &dev_attr_etmidr.attr, 1665 + &dev_attr_etmcr.attr, 1666 + &dev_attr_etmtraceidr.attr, 1667 + &dev_attr_etmteevr.attr, 1668 + &dev_attr_etmtssvr.attr, 1669 + &dev_attr_etmtecr1.attr, 1670 + &dev_attr_etmtecr2.attr, 1671 + NULL, 1672 + }; 1673 + 1674 + static const struct attribute_group coresight_etm_group = { 1675 + .attrs = coresight_etm_attrs, 1676 + }; 1677 + 1678 + 1679 + static const struct attribute_group coresight_etm_mgmt_group = { 1680 + .attrs = coresight_etm_mgmt_attrs, 1681 + .name = "mgmt", 1682 + }; 1683 + 1684 + static const struct attribute_group *coresight_etm_groups[] = { 1685 + &coresight_etm_group, 1686 + &coresight_etm_mgmt_group, 1687 + NULL, 1688 + }; 1593 1689 1594 1690 static int etm_cpu_callback(struct notifier_block *nfb, unsigned long action, 1595 1691 void *hcpu)