Commit 8be7dfc6 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'coresight-next-v6.1' of...

Merge tag 'coresight-next-v6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/coresight/linux into char-misc-next

Suzuki writes:
  "coresight: Changes for v6.1

   Coresight trace subsystem updates for v6.1 includes:
     - Support for HiSilicon PTT trace
     - Coresight cleanup of sysfs accessor functions, reduced
       code size.
     - Expose coresight timestamp source for ETMv4+
     - DT binding updates to include missing properties
     - Minor documentation, Kconfig text fixes.

   Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>"

* tag 'coresight-next-v6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/coresight/linux:
  hwtracing: hisi_ptt: Fix up for "iommu/dma: Make header private"
  MAINTAINERS: Add maintainer for HiSilicon PTT driver
  docs: trace: Add HiSilicon PTT device driver documentation
  hwtracing: hisi_ptt: Add tune function support for HiSilicon PCIe Tune and Trace device
  hwtracing: hisi_ptt: Add trace function support for HiSilicon PCIe Tune and Trace device
  iommu/arm-smmu-v3: Make default domain type of HiSilicon PTT device to identity
  coresight: cti-sysfs: Mark coresight_cti_reg_store() as __maybe_unused
  coresight: Make new csdev_access offsets unsigned
  coresight: cti-sysfs: Re-use same functions for similar sysfs register accessors
  coresight: Re-use same function for similar sysfs register accessors
  coresight: Simplify sysfs accessors by using csdev_access abstraction
  coresight: Remove unused function parameter
  coresight: etm4x: docs: Add documentation for 'ts_source' sysfs interface
  coresight: etm4x: Expose default timestamp source in sysfs
  dt-bindings: arm: coresight-tmc: Add 'iommu' property
  dt-bindings: arm: coresight: Add 'power-domains' property
  coresight: docs: Fix a broken reference
  coresight: trbe: fix Kconfig "its" grammar
parents 4ba028e4 5fc1531d
...@@ -516,3 +516,11 @@ Contact: Mathieu Poirier <mathieu.poirier@linaro.org> ...@@ -516,3 +516,11 @@ Contact: Mathieu Poirier <mathieu.poirier@linaro.org>
Description: (Read) Returns the number of special conditional P1 right-hand keys Description: (Read) Returns the number of special conditional P1 right-hand keys
that the trace unit can use (0x194). The value is taken that the trace unit can use (0x194). The value is taken
directly from the HW. directly from the HW.
What: /sys/bus/coresight/devices/etm<N>/ts_source
Date: October 2022
KernelVersion: 6.1
Contact: Mathieu Poirier <mathieu.poirier@linaro.org> or Suzuki K Poulose <suzuki.poulose@arm.com>
Description: (Read) When FEAT_TRF is implemented, value of TRFCR_ELx.TS used for
trace session. Otherwise -1 indicates an unknown time source. Check
trcidr0.tssize to see if a global timestamp is available.
What: /sys/devices/hisi_ptt<sicl_id>_<core_id>/tune
Date: October 2022
KernelVersion: 6.1
Contact: Yicong Yang <yangyicong@hisilicon.com>
Description: This directory contains files for tuning the PCIe link
parameters(events). Each file is named after the event
of the PCIe link.
See Documentation/trace/hisi-ptt.rst for more information.
What: /sys/devices/hisi_ptt<sicl_id>_<core_id>/tune/qos_tx_cpl
Date: October 2022
KernelVersion: 6.1
Contact: Yicong Yang <yangyicong@hisilicon.com>
Description: (RW) Controls the weight of Tx completion TLPs, which influence
the proportion of outbound completion TLPs on the PCIe link.
The available tune data is [0, 1, 2]. Writing a negative value
will return an error, and out of range values will be converted
to 2. The value indicates a probable level of the event.
What: /sys/devices/hisi_ptt<sicl_id>_<core_id>/tune/qos_tx_np
Date: October 2022
KernelVersion: 6.1
Contact: Yicong Yang <yangyicong@hisilicon.com>
Description: (RW) Controls the weight of Tx non-posted TLPs, which influence
the proportion of outbound non-posted TLPs on the PCIe link.
The available tune data is [0, 1, 2]. Writing a negative value
will return an error, and out of range values will be converted
to 2. The value indicates a probable level of the event.
What: /sys/devices/hisi_ptt<sicl_id>_<core_id>/tune/qos_tx_p
Date: October 2022
KernelVersion: 6.1
Contact: Yicong Yang <yangyicong@hisilicon.com>
Description: (RW) Controls the weight of Tx posted TLPs, which influence the
proportion of outbound posted TLPs on the PCIe link.
The available tune data is [0, 1, 2]. Writing a negative value
will return an error, and out of range values will be converted
to 2. The value indicates a probable level of the event.
What: /sys/devices/hisi_ptt<sicl_id>_<core_id>/tune/rx_alloc_buf_level
Date: October 2022
KernelVersion: 6.1
Contact: Yicong Yang <yangyicong@hisilicon.com>
Description: (RW) Control the allocated buffer watermark for inbound packets.
The packets will be stored in the buffer first and then transmitted
either when the watermark reached or when timed out.
The available tune data is [0, 1, 2]. Writing a negative value
will return an error, and out of range values will be converted
to 2. The value indicates a probable level of the event.
What: /sys/devices/hisi_ptt<sicl_id>_<core_id>/tune/tx_alloc_buf_level
Date: October 2022
KernelVersion: 6.1
Contact: Yicong Yang <yangyicong@hisilicon.com>
Description: (RW) Control the allocated buffer watermark of outbound packets.
The packets will be stored in the buffer first and then transmitted
either when the watermark reached or when timed out.
The available tune data is [0, 1, 2]. Writing a negative value
will return an error, and out of range values will be converted
to 2. The value indicates a probable level of the event.
...@@ -61,6 +61,9 @@ properties: ...@@ -61,6 +61,9 @@ properties:
maxItems: 1 maxItems: 1
description: Address translation error interrupt description: Address translation error interrupt
power-domains:
maxItems: 1
in-ports: in-ports:
$ref: /schemas/graph.yaml#/properties/ports $ref: /schemas/graph.yaml#/properties/ports
additionalProperties: false additionalProperties: false
......
...@@ -98,6 +98,9 @@ properties: ...@@ -98,6 +98,9 @@ properties:
base cti node if compatible string arm,coresight-cti-v8-arch is used, base cti node if compatible string arm,coresight-cti-v8-arch is used,
or may appear in a trig-conns child node when appropriate. or may appear in a trig-conns child node when appropriate.
power-domains:
maxItems: 1
arm,cti-ctm-id: arm,cti-ctm-id:
$ref: /schemas/types.yaml#/definitions/uint32 $ref: /schemas/types.yaml#/definitions/uint32
description: description:
......
...@@ -54,6 +54,9 @@ properties: ...@@ -54,6 +54,9 @@ properties:
- const: apb_pclk - const: apb_pclk
- const: atclk - const: atclk
power-domains:
maxItems: 1
in-ports: in-ports:
$ref: /schemas/graph.yaml#/properties/ports $ref: /schemas/graph.yaml#/properties/ports
......
...@@ -54,6 +54,9 @@ properties: ...@@ -54,6 +54,9 @@ properties:
- const: apb_pclk - const: apb_pclk
- const: atclk - const: atclk
power-domains:
maxItems: 1
qcom,replicator-loses-context: qcom,replicator-loses-context:
type: boolean type: boolean
description: description:
......
...@@ -54,6 +54,9 @@ properties: ...@@ -54,6 +54,9 @@ properties:
- const: apb_pclk - const: apb_pclk
- const: atclk - const: atclk
power-domains:
maxItems: 1
in-ports: in-ports:
$ref: /schemas/graph.yaml#/properties/ports $ref: /schemas/graph.yaml#/properties/ports
additionalProperties: false additionalProperties: false
......
...@@ -73,6 +73,9 @@ properties: ...@@ -73,6 +73,9 @@ properties:
- const: apb_pclk - const: apb_pclk
- const: atclk - const: atclk
power-domains:
maxItems: 1
arm,coresight-loses-context-with-cpu: arm,coresight-loses-context-with-cpu:
type: boolean type: boolean
description: description:
......
...@@ -27,6 +27,9 @@ properties: ...@@ -27,6 +27,9 @@ properties:
compatible: compatible:
const: arm,coresight-static-funnel const: arm,coresight-static-funnel
power-domains:
maxItems: 1
in-ports: in-ports:
$ref: /schemas/graph.yaml#/properties/ports $ref: /schemas/graph.yaml#/properties/ports
......
...@@ -27,6 +27,9 @@ properties: ...@@ -27,6 +27,9 @@ properties:
compatible: compatible:
const: arm,coresight-static-replicator const: arm,coresight-static-replicator
power-domains:
maxItems: 1
in-ports: in-ports:
$ref: /schemas/graph.yaml#/properties/ports $ref: /schemas/graph.yaml#/properties/ports
additionalProperties: false additionalProperties: false
......
...@@ -61,6 +61,9 @@ properties: ...@@ -61,6 +61,9 @@ properties:
- const: apb_pclk - const: apb_pclk
- const: atclk - const: atclk
power-domains:
maxItems: 1
out-ports: out-ports:
$ref: /schemas/graph.yaml#/properties/ports $ref: /schemas/graph.yaml#/properties/ports
additionalProperties: false additionalProperties: false
......
...@@ -55,6 +55,12 @@ properties: ...@@ -55,6 +55,12 @@ properties:
- const: apb_pclk - const: apb_pclk
- const: atclk - const: atclk
iommus:
maxItems: 1
power-domains:
maxItems: 1
arm,buffer-size: arm,buffer-size:
$ref: /schemas/types.yaml#/definitions/uint32 $ref: /schemas/types.yaml#/definitions/uint32
deprecated: true deprecated: true
......
...@@ -54,6 +54,9 @@ properties: ...@@ -54,6 +54,9 @@ properties:
- const: apb_pclk - const: apb_pclk
- const: atclk - const: atclk
power-domains:
maxItems: 1
in-ports: in-ports:
$ref: /schemas/graph.yaml#/properties/ports $ref: /schemas/graph.yaml#/properties/ports
additionalProperties: false additionalProperties: false
......
...@@ -33,6 +33,9 @@ properties: ...@@ -33,6 +33,9 @@ properties:
Handle to the cpu this ETE is bound to. Handle to the cpu this ETE is bound to.
$ref: /schemas/types.yaml#/definitions/phandle $ref: /schemas/types.yaml#/definitions/phandle
power-domains:
maxItems: 1
out-ports: out-ports:
description: | description: |
Output connections from the ETE to legacy CoreSight trace bus. Output connections from the ETE to legacy CoreSight trace bus.
......
...@@ -117,7 +117,8 @@ divide into below cases: ...@@ -117,7 +117,8 @@ divide into below cases:
Device Tree Bindings Device Tree Bindings
-------------------- --------------------
See Documentation/devicetree/bindings/arm/coresight-cpu-debug.txt for details. See Documentation/devicetree/bindings/arm/arm,coresight-cpu-debug.yaml for
details.
How to use the module How to use the module
......
...@@ -71,6 +71,20 @@ the ‘TRC’ prefix. ...@@ -71,6 +71,20 @@ the ‘TRC’ prefix.
---- ----
:File: ``ts_source`` (ro)
:Trace Registers: None.
:Notes:
When FEAT_TRF is implemented, value of TRFCR_ELx.TS used for trace session. Otherwise -1
indicates an unknown time source. Check trcidr0.tssize to see if a global timestamp is
available.
:Example:
``$> cat ts_source``
``$> 1``
----
:File: ``addr_idx`` (rw) :File: ``addr_idx`` (rw)
:Trace Registers: None. :Trace Registers: None.
:Notes: :Notes:
......
This diff is collapsed.
...@@ -33,3 +33,4 @@ Linux Tracing Technologies ...@@ -33,3 +33,4 @@ Linux Tracing Technologies
coresight/index coresight/index
user_events user_events
rv/index rv/index
hisi-ptt
...@@ -9180,6 +9180,14 @@ S: Supported ...@@ -9180,6 +9180,14 @@ S: Supported
F: Documentation/admin-guide/perf/hns3-pmu.rst F: Documentation/admin-guide/perf/hns3-pmu.rst
F: drivers/perf/hisilicon/hns3_pmu.c F: drivers/perf/hisilicon/hns3_pmu.c
HISILICON PTT DRIVER
M: Yicong Yang <yangyicong@hisilicon.com>
L: linux-kernel@vger.kernel.org
S: Maintained
F: Documentation/ABI/testing/sysfs-devices-hisi_ptt
F: Documentation/trace/hisi-ptt.rst
F: drivers/hwtracing/ptt/
HISILICON QM DRIVER HISILICON QM DRIVER
M: Weili Qian <qianweili@huawei.com> M: Weili Qian <qianweili@huawei.com>
M: Zhou Wang <wangzhou1@hisilicon.com> M: Zhou Wang <wangzhou1@hisilicon.com>
......
...@@ -1021,6 +1021,7 @@ ...@@ -1021,6 +1021,7 @@
#define SYS_MPIDR_SAFE_VAL (BIT(31)) #define SYS_MPIDR_SAFE_VAL (BIT(31))
#define TRFCR_ELx_TS_SHIFT 5 #define TRFCR_ELx_TS_SHIFT 5
#define TRFCR_ELx_TS_MASK ((0x3UL) << TRFCR_ELx_TS_SHIFT)
#define TRFCR_ELx_TS_VIRTUAL ((0x1UL) << TRFCR_ELx_TS_SHIFT) #define TRFCR_ELx_TS_VIRTUAL ((0x1UL) << TRFCR_ELx_TS_SHIFT)
#define TRFCR_ELx_TS_GUEST_PHYSICAL ((0x2UL) << TRFCR_ELx_TS_SHIFT) #define TRFCR_ELx_TS_GUEST_PHYSICAL ((0x2UL) << TRFCR_ELx_TS_SHIFT)
#define TRFCR_ELx_TS_PHYSICAL ((0x3UL) << TRFCR_ELx_TS_SHIFT) #define TRFCR_ELx_TS_PHYSICAL ((0x3UL) << TRFCR_ELx_TS_SHIFT)
......
...@@ -175,6 +175,7 @@ obj-$(CONFIG_USB4) += thunderbolt/ ...@@ -175,6 +175,7 @@ obj-$(CONFIG_USB4) += thunderbolt/
obj-$(CONFIG_CORESIGHT) += hwtracing/coresight/ obj-$(CONFIG_CORESIGHT) += hwtracing/coresight/
obj-y += hwtracing/intel_th/ obj-y += hwtracing/intel_th/
obj-$(CONFIG_STM) += hwtracing/stm/ obj-$(CONFIG_STM) += hwtracing/stm/
obj-$(CONFIG_HISI_PTT) += hwtracing/ptt/
obj-y += android/ obj-y += android/
obj-$(CONFIG_NVMEM) += nvmem/ obj-$(CONFIG_NVMEM) += nvmem/
obj-$(CONFIG_FPGA) += fpga/ obj-$(CONFIG_FPGA) += fpga/
......
...@@ -5,4 +5,6 @@ source "drivers/hwtracing/stm/Kconfig" ...@@ -5,4 +5,6 @@ source "drivers/hwtracing/stm/Kconfig"
source "drivers/hwtracing/intel_th/Kconfig" source "drivers/hwtracing/intel_th/Kconfig"
source "drivers/hwtracing/ptt/Kconfig"
endmenu endmenu
...@@ -193,10 +193,10 @@ config CORESIGHT_TRBE ...@@ -193,10 +193,10 @@ config CORESIGHT_TRBE
depends on ARM64 && CORESIGHT_SOURCE_ETM4X depends on ARM64 && CORESIGHT_SOURCE_ETM4X
help help
This driver provides support for percpu Trace Buffer Extension (TRBE). This driver provides support for percpu Trace Buffer Extension (TRBE).
TRBE always needs to be used along with it's corresponding percpu ETE TRBE always needs to be used along with its corresponding percpu ETE
component. ETE generates trace data which is then captured with TRBE. component. ETE generates trace data which is then captured with TRBE.
Unlike traditional sink devices, TRBE is a CPU feature accessible via Unlike traditional sink devices, TRBE is a CPU feature accessible via
system registers. But it's explicit dependency with trace unit (ETE) system registers. But its explicit dependency with trace unit (ETE)
requires it to be plugged in as a coresight sink device. requires it to be plugged in as a coresight sink device.
To compile this driver as a module, choose M here: the module will be To compile this driver as a module, choose M here: the module will be
......
...@@ -365,26 +365,15 @@ static const struct etr_buf_operations etr_catu_buf_ops = { ...@@ -365,26 +365,15 @@ static const struct etr_buf_operations etr_catu_buf_ops = {
.get_data = catu_get_data_etr_buf, .get_data = catu_get_data_etr_buf,
}; };
coresight_simple_reg32(struct catu_drvdata, devid, CORESIGHT_DEVID);
coresight_simple_reg32(struct catu_drvdata, control, CATU_CONTROL);
coresight_simple_reg32(struct catu_drvdata, status, CATU_STATUS);
coresight_simple_reg32(struct catu_drvdata, mode, CATU_MODE);
coresight_simple_reg32(struct catu_drvdata, axictrl, CATU_AXICTRL);
coresight_simple_reg32(struct catu_drvdata, irqen, CATU_IRQEN);
coresight_simple_reg64(struct catu_drvdata, sladdr,
CATU_SLADDRLO, CATU_SLADDRHI);
coresight_simple_reg64(struct catu_drvdata, inaddr,
CATU_INADDRLO, CATU_INADDRHI);
static struct attribute *catu_mgmt_attrs[] = { static struct attribute *catu_mgmt_attrs[] = {
&dev_attr_devid.attr, coresight_simple_reg32(devid, CORESIGHT_DEVID),
&dev_attr_control.attr, coresight_simple_reg32(control, CATU_CONTROL),
&dev_attr_status.attr, coresight_simple_reg32(status, CATU_STATUS),
&dev_attr_mode.attr, coresight_simple_reg32(mode, CATU_MODE),
&dev_attr_axictrl.attr, coresight_simple_reg32(axictrl, CATU_AXICTRL),
&dev_attr_irqen.attr, coresight_simple_reg32(irqen, CATU_IRQEN),
&dev_attr_sladdr.attr, coresight_simple_reg64(sladdr, CATU_SLADDRLO, CATU_SLADDRHI),
&dev_attr_inaddr.attr, coresight_simple_reg64(inaddr, CATU_INADDRLO, CATU_INADDRHI),
NULL, NULL,
}; };
......
...@@ -70,24 +70,24 @@ struct catu_drvdata { ...@@ -70,24 +70,24 @@ struct catu_drvdata {
static inline u32 \ static inline u32 \
catu_read_##name(struct catu_drvdata *drvdata) \ catu_read_##name(struct catu_drvdata *drvdata) \
{ \ { \
return coresight_read_reg_pair(drvdata->base, offset, -1); \ return csdev_access_relaxed_read32(&drvdata->csdev->access, offset); \
} \ } \
static inline void \ static inline void \
catu_write_##name(struct catu_drvdata *drvdata, u32 val) \ catu_write_##name(struct catu_drvdata *drvdata, u32 val) \
{ \ { \
coresight_write_reg_pair(drvdata->base, val, offset, -1); \ csdev_access_relaxed_write32(&drvdata->csdev->access, val, offset); \
} }
#define CATU_REG_PAIR(name, lo_off, hi_off) \ #define CATU_REG_PAIR(name, lo_off, hi_off) \
static inline u64 \ static inline u64 \
catu_read_##name(struct catu_drvdata *drvdata) \ catu_read_##name(struct catu_drvdata *drvdata) \
{ \ { \
return coresight_read_reg_pair(drvdata->base, lo_off, hi_off); \ return csdev_access_relaxed_read_pair(&drvdata->csdev->access, lo_off, hi_off); \
} \ } \
static inline void \ static inline void \
catu_write_##name(struct catu_drvdata *drvdata, u64 val) \ catu_write_##name(struct catu_drvdata *drvdata, u64 val) \
{ \ { \
coresight_write_reg_pair(drvdata->base, val, lo_off, hi_off); \ csdev_access_relaxed_write_pair(&drvdata->csdev->access, val, lo_off, hi_off); \
} }
CATU_REG32(control, CATU_CONTROL); CATU_REG32(control, CATU_CONTROL);
......
...@@ -60,6 +60,34 @@ EXPORT_SYMBOL_GPL(coresight_barrier_pkt); ...@@ -60,6 +60,34 @@ EXPORT_SYMBOL_GPL(coresight_barrier_pkt);
static const struct cti_assoc_op *cti_assoc_ops; static const struct cti_assoc_op *cti_assoc_ops;
ssize_t coresight_simple_show_pair(struct device *_dev,
struct device_attribute *attr, char *buf)
{
struct coresight_device *csdev = container_of(_dev, struct coresight_device, dev);
struct cs_pair_attribute *cs_attr = container_of(attr, struct cs_pair_attribute, attr);
u64 val;
pm_runtime_get_sync(_dev->parent);
val = csdev_access_relaxed_read_pair(&csdev->access, cs_attr->lo_off, cs_attr->hi_off);
pm_runtime_put_sync(_dev->parent);
return sysfs_emit(buf, "0x%llx\n", val);
}
EXPORT_SYMBOL_GPL(coresight_simple_show_pair);
ssize_t coresight_simple_show32(struct device *_dev,
struct device_attribute *attr, char *buf)
{
struct coresight_device *csdev = container_of(_dev, struct coresight_device, dev);
struct cs_off_attribute *cs_attr = container_of(attr, struct cs_off_attribute, attr);
u64 val;
pm_runtime_get_sync(_dev->parent);
val = csdev_access_relaxed_read32(&csdev->access, cs_attr->off);
pm_runtime_put_sync(_dev->parent);
return sysfs_emit(buf, "0x%llx\n", val);
}
EXPORT_SYMBOL_GPL(coresight_simple_show32);
void coresight_set_cti_ops(const struct cti_assoc_op *cti_op) void coresight_set_cti_ops(const struct cti_assoc_op *cti_op)
{ {
cti_assoc_ops = cti_op; cti_assoc_ops = cti_op;
......
...@@ -163,48 +163,82 @@ static struct attribute *coresight_cti_attrs[] = { ...@@ -163,48 +163,82 @@ static struct attribute *coresight_cti_attrs[] = {
/* register based attributes */ /* register based attributes */
/* macro to access RO registers with power check only (no enable check). */ /* Read registers with power check only (no enable check). */
#define coresight_cti_reg(name, offset) \ static ssize_t coresight_cti_reg_show(struct device *dev,
static ssize_t name##_show(struct device *dev, \ struct device_attribute *attr, char *buf)
struct device_attribute *attr, char *buf) \ {
{ \ struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); \ struct cs_off_attribute *cti_attr = container_of(attr, struct cs_off_attribute, attr);
u32 val = 0; \ u32 val = 0;
pm_runtime_get_sync(dev->parent); \
spin_lock(&drvdata->spinlock); \
if (drvdata->config.hw_powered) \
val = readl_relaxed(drvdata->base + offset); \
spin_unlock(&drvdata->spinlock); \
pm_runtime_put_sync(dev->parent); \
return sprintf(buf, "0x%x\n", val); \
} \
static DEVICE_ATTR_RO(name)
/* coresight management registers */ pm_runtime_get_sync(dev->parent);
coresight_cti_reg(devaff0, CTIDEVAFF0); spin_lock(&drvdata->spinlock);
coresight_cti_reg(devaff1, CTIDEVAFF1); if (drvdata->config.hw_powered)
coresight_cti_reg(authstatus, CORESIGHT_AUTHSTATUS); val = readl_relaxed(drvdata->base + cti_attr->off);
coresight_cti_reg(devarch, CORESIGHT_DEVARCH); spin_unlock(&drvdata->spinlock);
coresight_cti_reg(devid, CORESIGHT_DEVID); pm_runtime_put_sync(dev->parent);
coresight_cti_reg(devtype, CORESIGHT_DEVTYPE); return sysfs_emit(buf, "0x%x\n", val);
coresight_cti_reg(pidr0, CORESIGHT_PERIPHIDR0); }
coresight_cti_reg(pidr1, CORESIGHT_PERIPHIDR1);
coresight_cti_reg(pidr2, CORESIGHT_PERIPHIDR2);
coresight_cti_reg(pidr3, CORESIGHT_PERIPHIDR3);
coresight_cti_reg(pidr4, CORESIGHT_PERIPHIDR4);
/* Write registers with power check only (no enable check). */
static __maybe_unused ssize_t coresight_cti_reg_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t size)
{
struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
struct cs_off_attribute *cti_attr = container_of(attr, struct cs_off_attribute, attr);
unsigned long val = 0;
if (kstrtoul(buf, 0, &val))
return -EINVAL;
pm_runtime_get_sync(dev->parent);
spin_lock(&drvdata->spinlock);
if (drvdata->config.hw_powered)
cti_write_single_reg(drvdata, cti_attr->off, val);
spin_unlock(&drvdata->spinlock);
pm_runtime_put_sync(dev->parent);
return size;
}
#define coresight_cti_reg(name, offset) \
(&((struct cs_off_attribute[]) { \
{ \
__ATTR(name, 0444, coresight_cti_reg_show, NULL), \
offset \
} \
})[0].attr.attr)
#define coresight_cti_reg_rw(name, offset) \
(&((struct cs_off_attribute[]) { \
{ \
__ATTR(name, 0644, coresight_cti_reg_show, \
coresight_cti_reg_store), \
offset \
} \
})[0].attr.attr)
#define coresight_cti_reg_wo(name, offset) \
(&((struct cs_off_attribute[]) { \
{ \
__ATTR(name, 0200, NULL, coresight_cti_reg_store), \
offset \
} \
})[0].attr.attr)
/* coresight management registers */
static struct attribute *coresight_cti_mgmt_attrs[] = { static struct attribute *coresight_cti_mgmt_attrs[] = {
&dev_attr_devaff0.attr, coresight_cti_reg(devaff0, CTIDEVAFF0),
&dev_attr_devaff1.attr, coresight_cti_reg(devaff1, CTIDEVAFF1),
&dev_attr_authstatus.attr, coresight_cti_reg(authstatus, CORESIGHT_AUTHSTATUS),
&dev_attr_devarch.attr, coresight_cti_reg(devarch, CORESIGHT_DEVARCH),
&dev_attr_devid.attr, coresight_cti_reg(devid, CORESIGHT_DEVID),
&dev_attr_devtype.attr, coresight_cti_reg(devtype, CORESIGHT_DEVTYPE),
&dev_attr_pidr0.attr, coresight_cti_reg(pidr0, CORESIGHT_PERIPHIDR0),
&dev_attr_pidr1.attr, coresight_cti_reg(pidr1, CORESIGHT_PERIPHIDR1),
&dev_attr_pidr2.attr, coresight_cti_reg(pidr2, CORESIGHT_PERIPHIDR2),
&dev_attr_pidr3.attr, coresight_cti_reg(pidr3, CORESIGHT_PERIPHIDR3),
&dev_attr_pidr4.attr, coresight_cti_reg(pidr4, CORESIGHT_PERIPHIDR4),
NULL, NULL,
}; };
...@@ -454,86 +488,11 @@ static ssize_t apppulse_store(struct device *dev, ...@@ -454,86 +488,11 @@ static ssize_t apppulse_store(struct device *dev,
} }
static DEVICE_ATTR_WO(apppulse); static DEVICE_ATTR_WO(apppulse);
coresight_cti_reg(triginstatus, CTITRIGINSTATUS);
coresight_cti_reg(trigoutstatus, CTITRIGOUTSTATUS);
coresight_cti_reg(chinstatus, CTICHINSTATUS);
coresight_cti_reg(choutstatus, CTICHOUTSTATUS);
/* /*
* Define CONFIG_CORESIGHT_CTI_INTEGRATION_REGS to enable the access to the * Define CONFIG_CORESIGHT_CTI_INTEGRATION_REGS to enable the access to the
* integration control registers. Normally only used to investigate connection * integration control registers. Normally only used to investigate connection
* data. * data.
*/ */
#ifdef CONFIG_CORESIGHT_CTI_INTEGRATION_REGS
/* macro to access RW registers with power check only (no enable check). */
#define coresight_cti_reg_rw(name, offset) \
static ssize_t name##_show(struct device *dev, \
struct device_attribute *attr, char *buf) \
{ \
struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); \
u32 val = 0; \
pm_runtime_get_sync(dev->parent); \
spin_lock(&drvdata->spinlock); \
if (drvdata->config.hw_powered) \
val = readl_relaxed(drvdata->base + offset); \
spin_unlock(&drvdata->spinlock); \
pm_runtime_put_sync(dev->parent); \
return sprintf(buf, "0x%x\n", val); \
} \
\
static ssize_t name##_store(struct device *dev, \
struct device_attribute *attr, \
const char *buf, size_t size) \
{ \
struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); \
unsigned long val = 0; \
if (kstrtoul(buf, 0, &val)) \
return -EINVAL; \
\
pm_runtime_get_sync(dev->parent); \
spin_lock(&drvdata->spinlock); \
if (drvdata->config.hw_powered) \
cti_write_single_reg(drvdata, offset, val); \
spin_unlock(&drvdata->spinlock); \
pm_runtime_put_sync(dev->parent); \
return size; \
} \
static DEVICE_ATTR_RW(name)
/* macro to access WO registers with power check only (no enable check). */
#define coresight_cti_reg_wo(name, offset) \
static ssize_t name##_store(struct device *dev, \
struct device_attribute *attr, \
const char *buf, size_t size) \
{ \
struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); \
unsigned long val = 0; \
if (kstrtoul(buf, 0, &val)) \
return -EINVAL; \
\
pm_runtime_get_sync(dev->parent); \
spin_lock(&drvdata->spinlock); \
if (drvdata->config.hw_powered) \
cti_write_single_reg(drvdata, offset, val); \
spin_unlock(&drvdata->spinlock); \
pm_runtime_put_sync(dev->parent); \
return size; \
} \
static DEVICE_ATTR_WO(name)
coresight_cti_reg_rw(itchout, ITCHOUT);
coresight_cti_reg_rw(ittrigout, ITTRIGOUT);
coresight_cti_reg_rw(itctrl, CORESIGHT_ITCTRL);
coresight_cti_reg_wo(itchinack, ITCHINACK);
coresight_cti_reg_wo(ittriginack, ITTRIGINACK);
coresight_cti_reg(ittrigin, ITTRIGIN);
coresight_cti_reg(itchin, ITCHIN);
coresight_cti_reg(itchoutack, ITCHOUTACK);
coresight_cti_reg(ittrigoutack, ITTRIGOUTACK);
#endif /* CORESIGHT_CTI_INTEGRATION_REGS */
static struct attribute *coresight_cti_regs_attrs[] = { static struct attribute *coresight_cti_regs_attrs[] = {
&dev_attr_inout_sel.attr, &dev_attr_inout_sel.attr,
&dev_attr_inen.attr, &dev_attr_inen.attr,
...@@ -544,20 +503,20 @@ static struct attribute *coresight_cti_regs_attrs[] = { ...@@ -544,20 +503,20 @@ static struct attribute *coresight_cti_regs_attrs[] = {
&dev_attr_appset.attr, &dev_attr_appset.attr,
&dev_attr_appclear.attr, &dev_attr_appclear.attr,
&dev_attr_apppulse.attr, &dev_attr_apppulse.attr,
&dev_attr_triginstatus.attr, coresight_cti_reg(triginstatus, CTITRIGINSTATUS),
&dev_attr_trigoutstatus.attr, coresight_cti_reg(trigoutstatus, CTITRIGOUTSTATUS),
&dev_attr_chinstatus.attr, coresight_cti_reg(chinstatus, CTICHINSTATUS),
&dev_attr_choutstatus.attr, coresight_cti_reg(choutstatus, CTICHOUTSTATUS),
#ifdef CONFIG_CORESIGHT_CTI_INTEGRATION_REGS #ifdef CONFIG_CORESIGHT_CTI_INTEGRATION_REGS
&dev_attr_itctrl.attr, coresight_cti_reg_rw(itctrl, CORESIGHT_ITCTRL),
&dev_attr_ittrigin.attr, coresight_cti_reg(ittrigin, ITTRIGIN),
&dev_attr_itchin.attr, coresight_cti_reg(itchin, ITCHIN),
&dev_attr_ittrigout.attr, coresight_cti_reg_rw(ittrigout, ITTRIGOUT),
&dev_attr_itchout.attr, coresight_cti_reg_rw(itchout, ITCHOUT),
&dev_attr_itchoutack.attr, coresight_cti_reg(itchoutack, ITCHOUTACK),
&dev_attr_ittrigoutack.attr, coresight_cti_reg(ittrigoutack, ITTRIGOUTACK),
&dev_attr_ittriginack.attr, coresight_cti_reg_wo(ittriginack, ITTRIGINACK),
&dev_attr_itchinack.attr, coresight_cti_reg_wo(itchinack, ITCHINACK),
#endif #endif
NULL, NULL,
}; };
......
...@@ -655,27 +655,15 @@ static const struct file_operations etb_fops = { ...@@ -655,27 +655,15 @@ static const struct file_operations etb_fops = {
.llseek = no_llseek, .llseek = no_llseek,
}; };
#define coresight_etb10_reg(name, offset) \
coresight_simple_reg32(struct etb_drvdata, name, offset)
coresight_etb10_reg(rdp, ETB_RAM_DEPTH_REG);
coresight_etb10_reg(sts, ETB_STATUS_REG);
coresight_etb10_reg(rrp, ETB_RAM_READ_POINTER);
coresight_etb10_reg(rwp, ETB_RAM_WRITE_POINTER);
coresight_etb10_reg(trg, ETB_TRG);
coresight_etb10_reg(ctl, ETB_CTL_REG);
coresight_etb10_reg(ffsr, ETB_FFSR);
coresight_etb10_reg(ffcr, ETB_FFCR);
static struct attribute *coresight_etb_mgmt_attrs[] = { static struct attribute *coresight_etb_mgmt_attrs[] = {
&dev_attr_rdp.attr, coresight_simple_reg32(rdp, ETB_RAM_DEPTH_REG),
&dev_attr_sts.attr, coresight_simple_reg32(sts, ETB_STATUS_REG),
&dev_attr_rrp.attr, coresight_simple_reg32(rrp, ETB_RAM_READ_POINTER),
&dev_attr_rwp.attr, coresight_simple_reg32(rwp, ETB_RAM_WRITE_POINTER),
&dev_attr_trg.attr, coresight_simple_reg32(trg, ETB_TRG),
&dev_attr_ctl.attr, coresight_simple_reg32(ctl, ETB_CTL_REG),
&dev_attr_ffsr.attr, coresight_simple_reg32(ffsr, ETB_FFSR),
&dev_attr_ffcr.attr, coresight_simple_reg32(ffcr, ETB_FFCR),
NULL, NULL,
}; };
......
...@@ -1252,31 +1252,17 @@ static struct attribute *coresight_etm_attrs[] = { ...@@ -1252,31 +1252,17 @@ static struct attribute *coresight_etm_attrs[] = {
NULL, NULL,
}; };
#define coresight_etm3x_reg(name, offset) \
coresight_simple_reg32(struct etm_drvdata, name, offset)
coresight_etm3x_reg(etmccr, ETMCCR);
coresight_etm3x_reg(etmccer, ETMCCER);
coresight_etm3x_reg(etmscr, ETMSCR);
coresight_etm3x_reg(etmidr, ETMIDR);
coresight_etm3x_reg(etmcr, ETMCR);
coresight_etm3x_reg(etmtraceidr, ETMTRACEIDR);
coresight_etm3x_reg(etmteevr, ETMTEEVR);
coresight_etm3x_reg(etmtssvr, ETMTSSCR);
coresight_etm3x_reg(etmtecr1, ETMTECR1);
coresight_etm3x_reg(etmtecr2, ETMTECR2);
static struct attribute *coresight_etm_mgmt_attrs[] = { static struct attribute *coresight_etm_mgmt_attrs[] = {
&dev_attr_etmccr.attr, coresight_simple_reg32(etmccr, ETMCCR),
&dev_attr_etmccer.attr, coresight_simple_reg32(etmccer, ETMCCER),
&dev_attr_etmscr.attr, coresight_simple_reg32(etmscr, ETMSCR),
&dev_attr_etmidr.attr, coresight_simple_reg32(etmidr, ETMIDR),
&dev_attr_etmcr.attr, coresight_simple_reg32(etmcr, ETMCR),
&dev_attr_etmtraceidr.attr, coresight_simple_reg32(etmtraceidr, ETMTRACEIDR),
&dev_attr_etmteevr.attr, coresight_simple_reg32(etmteevr, ETMTEEVR),
&dev_attr_etmtssvr.attr, coresight_simple_reg32(etmtssvr, ETMTSSCR),
&dev_attr_etmtecr1.attr, coresight_simple_reg32(etmtecr1, ETMTECR1),
&dev_attr_etmtecr2.attr, coresight_simple_reg32(etmtecr2, ETMTECR2),
NULL, NULL,
}; };
......
...@@ -2306,6 +2306,34 @@ static ssize_t cpu_show(struct device *dev, ...@@ -2306,6 +2306,34 @@ static ssize_t cpu_show(struct device *dev,
} }
static DEVICE_ATTR_RO(cpu); static DEVICE_ATTR_RO(cpu);
static ssize_t ts_source_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
int val;
struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
if (!drvdata->trfcr) {
val = -1;
goto out;
}
switch (drvdata->trfcr & TRFCR_ELx_TS_MASK) {
case TRFCR_ELx_TS_VIRTUAL:
case TRFCR_ELx_TS_GUEST_PHYSICAL:
case TRFCR_ELx_TS_PHYSICAL:
val = FIELD_GET(TRFCR_ELx_TS_MASK, drvdata->trfcr);
break;
default:
val = -1;
break;
}
out:
return sysfs_emit(buf, "%d\n", val);
}
static DEVICE_ATTR_RO(ts_source);
static struct attribute *coresight_etmv4_attrs[] = { static struct attribute *coresight_etmv4_attrs[] = {
&dev_attr_nr_pe_cmp.attr, &dev_attr_nr_pe_cmp.attr,
&dev_attr_nr_addr_cmp.attr, &dev_attr_nr_addr_cmp.attr,
...@@ -2360,6 +2388,7 @@ static struct attribute *coresight_etmv4_attrs[] = { ...@@ -2360,6 +2388,7 @@ static struct attribute *coresight_etmv4_attrs[] = {
&dev_attr_vmid_val.attr, &dev_attr_vmid_val.attr,
&dev_attr_vmid_masks.attr, &dev_attr_vmid_masks.attr,
&dev_attr_cpu.attr, &dev_attr_cpu.attr,
&dev_attr_ts_source.attr,
NULL, NULL,
}; };
......
...@@ -39,32 +39,37 @@ ...@@ -39,32 +39,37 @@
#define ETM_MODE_EXCL_KERN BIT(30) #define ETM_MODE_EXCL_KERN BIT(30)
#define ETM_MODE_EXCL_USER BIT(31) #define ETM_MODE_EXCL_USER BIT(31)
struct cs_pair_attribute {
struct device_attribute attr;
u32 lo_off;
u32 hi_off;
};
struct cs_off_attribute {
struct device_attribute attr;
u32 off;
};
typedef u32 (*coresight_read_fn)(const struct device *, u32 offset); extern ssize_t coresight_simple_show32(struct device *_dev,
#define __coresight_simple_func(type, func, name, lo_off, hi_off) \ struct device_attribute *attr, char *buf);
static ssize_t name##_show(struct device *_dev, \ extern ssize_t coresight_simple_show_pair(struct device *_dev,
struct device_attribute *attr, char *buf) \ struct device_attribute *attr, char *buf);
{ \
type *drvdata = dev_get_drvdata(_dev->parent); \ #define coresight_simple_reg32(name, offset) \
coresight_read_fn fn = func; \ (&((struct cs_off_attribute[]) { \
u64 val; \ { \
pm_runtime_get_sync(_dev->parent); \ __ATTR(name, 0444, coresight_simple_show32, NULL), \
if (fn) \ offset \
val = (u64)fn(_dev->parent, lo_off); \ } \
else \ })[0].attr.attr)
val = coresight_read_reg_pair(drvdata->base, \
lo_off, hi_off); \ #define coresight_simple_reg64(name, lo_off, hi_off) \
pm_runtime_put_sync(_dev->parent); \ (&((struct cs_pair_attribute[]) { \
return scnprintf(buf, PAGE_SIZE, "0x%llx\n", val); \ { \
} \ __ATTR(name, 0444, coresight_simple_show_pair, NULL), \
static DEVICE_ATTR_RO(name) lo_off, hi_off \
} \
#define coresight_simple_func(type, func, name, offset) \ })[0].attr.attr)
__coresight_simple_func(type, func, name, offset, -1)
#define coresight_simple_reg32(type, name, offset) \
__coresight_simple_func(type, NULL, name, offset, -1)
#define coresight_simple_reg64(type, name, lo_off, hi_off) \
__coresight_simple_func(type, NULL, name, lo_off, hi_off)
extern const u32 coresight_barrier_pkt[4]; extern const u32 coresight_barrier_pkt[4];
#define CORESIGHT_BARRIER_PKT_SIZE (sizeof(coresight_barrier_pkt)) #define CORESIGHT_BARRIER_PKT_SIZE (sizeof(coresight_barrier_pkt))
...@@ -127,25 +132,6 @@ static inline void CS_UNLOCK(void __iomem *addr) ...@@ -127,25 +132,6 @@ static inline void CS_UNLOCK(void __iomem *addr)
} while (0); } while (0);
} }
static inline u64
coresight_read_reg_pair(void __iomem *addr, s32 lo_offset, s32 hi_offset)
{
u64 val;
val = readl_relaxed(addr + lo_offset);
val |= (hi_offset < 0) ? 0 :
(u64)readl_relaxed(addr + hi_offset) << 32;
return val;
}
static inline void coresight_write_reg_pair(void __iomem *addr, u64 val,
s32 lo_offset, s32 hi_offset)
{
writel_relaxed((u32)val, addr + lo_offset);
if (hi_offset >= 0)
writel_relaxed((u32)(val >> 32), addr + hi_offset);
}
void coresight_disable_path(struct list_head *path); void coresight_disable_path(struct list_head *path);
int coresight_enable_path(struct list_head *path, u32 mode, void *sink_data); int coresight_enable_path(struct list_head *path, u32 mode, void *sink_data);
struct coresight_device *coresight_get_sink(struct list_head *path); struct coresight_device *coresight_get_sink(struct list_head *path);
......
...@@ -196,15 +196,9 @@ static const struct coresight_ops replicator_cs_ops = { ...@@ -196,15 +196,9 @@ static const struct coresight_ops replicator_cs_ops = {
.link_ops = &replicator_link_ops, .link_ops = &replicator_link_ops,
}; };
#define coresight_replicator_reg(name, offset) \
coresight_simple_reg32(struct replicator_drvdata, name, offset)
coresight_replicator_reg(idfilter0, REPLICATOR_IDFILTER0);
coresight_replicator_reg(idfilter1, REPLICATOR_IDFILTER1);
static struct attribute *replicator_mgmt_attrs[] = { static struct attribute *replicator_mgmt_attrs[] = {
&dev_attr_idfilter0.attr, coresight_simple_reg32(idfilter0, REPLICATOR_IDFILTER0),
&dev_attr_idfilter1.attr, coresight_simple_reg32(idfilter1, REPLICATOR_IDFILTER1),
NULL, NULL,
}; };
......
...@@ -634,22 +634,6 @@ static ssize_t traceid_store(struct device *dev, ...@@ -634,22 +634,6 @@ static ssize_t traceid_store(struct device *dev,
} }
static DEVICE_ATTR_RW(traceid); static DEVICE_ATTR_RW(traceid);
#define coresight_stm_reg(name, offset) \
coresight_simple_reg32(struct stm_drvdata, name, offset)
coresight_stm_reg(tcsr, STMTCSR);
coresight_stm_reg(tsfreqr, STMTSFREQR);
coresight_stm_reg(syncr, STMSYNCR);
coresight_stm_reg(sper, STMSPER);
coresight_stm_reg(spter, STMSPTER);
coresight_stm_reg(privmaskr, STMPRIVMASKR);
coresight_stm_reg(spscr, STMSPSCR);
coresight_stm_reg(spmscr, STMSPMSCR);
coresight_stm_reg(spfeat1r, STMSPFEAT1R);
coresight_stm_reg(spfeat2r, STMSPFEAT2R);
coresight_stm_reg(spfeat3r, STMSPFEAT3R);
coresight_stm_reg(devid, CORESIGHT_DEVID);
static struct attribute *coresight_stm_attrs[] = { static struct attribute *coresight_stm_attrs[] = {
&dev_attr_hwevent_enable.attr, &dev_attr_hwevent_enable.attr,
&dev_attr_hwevent_select.attr, &dev_attr_hwevent_select.attr,
...@@ -660,18 +644,18 @@ static struct attribute *coresight_stm_attrs[] = { ...@@ -660,18 +644,18 @@ static struct attribute *coresight_stm_attrs[] = {
}; };
static struct attribute *coresight_stm_mgmt_attrs[] = { static struct attribute *coresight_stm_mgmt_attrs[] = {
&dev_attr_tcsr.attr, coresight_simple_reg32(tcsr, STMTCSR),
&dev_attr_tsfreqr.attr, coresight_simple_reg32(tsfreqr, STMTSFREQR),
&dev_attr_syncr.attr, coresight_simple_reg32(syncr, STMSYNCR),
&dev_attr_sper.attr, coresight_simple_reg32(sper, STMSPER),
&dev_attr_spter.attr, coresight_simple_reg32(spter, STMSPTER),
&dev_attr_privmaskr.attr, coresight_simple_reg32(privmaskr, STMPRIVMASKR),
&dev_attr_spscr.attr, coresight_simple_reg32(spscr, STMSPSCR),
&dev_attr_spmscr.attr, coresight_simple_reg32(spmscr, STMSPMSCR),
&dev_attr_spfeat1r.attr, coresight_simple_reg32(spfeat1r, STMSPFEAT1R),
&dev_attr_spfeat2r.attr, coresight_simple_reg32(spfeat2r, STMSPFEAT2R),
&dev_attr_spfeat3r.attr, coresight_simple_reg32(spfeat3r, STMSPFEAT3R),
&dev_attr_devid.attr, coresight_simple_reg32(devid, CORESIGHT_DEVID),
NULL, NULL,
}; };
......
...@@ -251,41 +251,21 @@ static enum tmc_mem_intf_width tmc_get_memwidth(u32 devid) ...@@ -251,41 +251,21 @@ static enum tmc_mem_intf_width tmc_get_memwidth(u32 devid)
return memwidth; return memwidth;
} }
#define coresight_tmc_reg(name, offset) \
coresight_simple_reg32(struct tmc_drvdata, name, offset)
#define coresight_tmc_reg64(name, lo_off, hi_off) \
coresight_simple_reg64(struct tmc_drvdata, name, lo_off, hi_off)
coresight_tmc_reg(rsz, TMC_RSZ);
coresight_tmc_reg(sts, TMC_STS);
coresight_tmc_reg(trg, TMC_TRG);
coresight_tmc_reg(ctl, TMC_CTL);
coresight_tmc_reg(ffsr, TMC_FFSR);
coresight_tmc_reg(ffcr, TMC_FFCR);
coresight_tmc_reg(mode, TMC_MODE);
coresight_tmc_reg(pscr, TMC_PSCR);
coresight_tmc_reg(axictl, TMC_AXICTL);
coresight_tmc_reg(authstatus, TMC_AUTHSTATUS);
coresight_tmc_reg(devid, CORESIGHT_DEVID);
coresight_tmc_reg64(rrp, TMC_RRP, TMC_RRPHI);
coresight_tmc_reg64(rwp, TMC_RWP, TMC_RWPHI);
coresight_tmc_reg64(dba, TMC_DBALO, TMC_DBAHI);
static struct attribute *coresight_tmc_mgmt_attrs[] = { static struct attribute *coresight_tmc_mgmt_attrs[] = {
&dev_attr_rsz.attr, coresight_simple_reg32(rsz, TMC_RSZ),
&dev_attr_sts.attr, coresight_simple_reg32(sts, TMC_STS),
&dev_attr_rrp.attr, coresight_simple_reg64(rrp, TMC_RRP, TMC_RRPHI),
&dev_attr_rwp.attr, coresight_simple_reg64(rwp, TMC_RWP, TMC_RWPHI),
&dev_attr_trg.attr, coresight_simple_reg32(trg, TMC_TRG),
&dev_attr_ctl.attr, coresight_simple_reg32(ctl, TMC_CTL),
&dev_attr_ffsr.attr, coresight_simple_reg32(ffsr, TMC_FFSR),
&dev_attr_ffcr.attr, coresight_simple_reg32(ffcr, TMC_FFCR),
&dev_attr_mode.attr, coresight_simple_reg32(mode, TMC_MODE),
&dev_attr_pscr.attr, coresight_simple_reg32(pscr, TMC_PSCR),
&dev_attr_devid.attr, coresight_simple_reg32(devid, CORESIGHT_DEVID),
&dev_attr_dba.attr, coresight_simple_reg64(dba, TMC_DBALO, TMC_DBAHI),
&dev_attr_axictl.attr, coresight_simple_reg32(axictl, TMC_AXICTL),
&dev_attr_authstatus.attr, coresight_simple_reg32(authstatus, TMC_AUTHSTATUS),
NULL, NULL,
}; };
......
...@@ -282,12 +282,12 @@ ssize_t tmc_etr_get_sysfs_trace(struct tmc_drvdata *drvdata, ...@@ -282,12 +282,12 @@ ssize_t tmc_etr_get_sysfs_trace(struct tmc_drvdata *drvdata,
static inline u64 \ static inline u64 \
tmc_read_##name(struct tmc_drvdata *drvdata) \ tmc_read_##name(struct tmc_drvdata *drvdata) \
{ \ { \
return coresight_read_reg_pair(drvdata->base, lo_off, hi_off); \ return csdev_access_relaxed_read_pair(&drvdata->csdev->access, lo_off, hi_off); \
} \ } \
static inline void \ static inline void \
tmc_write_##name(struct tmc_drvdata *drvdata, u64 val) \ tmc_write_##name(struct tmc_drvdata *drvdata, u64 val) \
{ \ { \
coresight_write_reg_pair(drvdata->base, val, lo_off, hi_off); \ csdev_access_relaxed_write_pair(&drvdata->csdev->access, val, lo_off, hi_off); \
} }
TMC_REG_PAIR(rrp, TMC_RRP, TMC_RRPHI) TMC_REG_PAIR(rrp, TMC_RRP, TMC_RRPHI)
......
# SPDX-License-Identifier: GPL-2.0-only
config HISI_PTT
tristate "HiSilicon PCIe Tune and Trace Device"
depends on ARM64 || (COMPILE_TEST && 64BIT)
depends on PCI && HAS_DMA && HAS_IOMEM && PERF_EVENTS
help
HiSilicon PCIe Tune and Trace device exists as a PCIe RCiEP
device, and it provides support for PCIe traffic tuning and
tracing TLP headers to the memory.
This driver can also be built as a module. If so, the module
will be called hisi_ptt.
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_HISI_PTT) += hisi_ptt.o
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Driver for HiSilicon PCIe tune and trace device
*
* Copyright (c) 2022 HiSilicon Technologies Co., Ltd.
* Author: Yicong Yang <yangyicong@hisilicon.com>
*/
#ifndef _HISI_PTT_H
#define _HISI_PTT_H
#include <linux/bits.h>
#include <linux/cpumask.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/pci.h>
#include <linux/perf_event.h>
#include <linux/spinlock.h>
#include <linux/types.h>
#define DRV_NAME "hisi_ptt"
/*
* The definition of the device registers and register fields.
*/
#define HISI_PTT_TUNING_CTRL 0x0000
#define HISI_PTT_TUNING_CTRL_CODE GENMASK(15, 0)
#define HISI_PTT_TUNING_CTRL_SUB GENMASK(23, 16)
#define HISI_PTT_TUNING_DATA 0x0004
#define HISI_PTT_TUNING_DATA_VAL_MASK GENMASK(15, 0)
#define HISI_PTT_TRACE_ADDR_SIZE 0x0800
#define HISI_PTT_TRACE_ADDR_BASE_LO_0 0x0810
#define HISI_PTT_TRACE_ADDR_BASE_HI_0 0x0814
#define HISI_PTT_TRACE_ADDR_STRIDE 0x8
#define HISI_PTT_TRACE_CTRL 0x0850
#define HISI_PTT_TRACE_CTRL_EN BIT(0)
#define HISI_PTT_TRACE_CTRL_RST BIT(1)
#define HISI_PTT_TRACE_CTRL_RXTX_SEL GENMASK(3, 2)
#define HISI_PTT_TRACE_CTRL_TYPE_SEL GENMASK(7, 4)
#define HISI_PTT_TRACE_CTRL_DATA_FORMAT BIT(14)
#define HISI_PTT_TRACE_CTRL_FILTER_MODE BIT(15)
#define HISI_PTT_TRACE_CTRL_TARGET_SEL GENMASK(31, 16)
#define HISI_PTT_TRACE_INT_STAT 0x0890
#define HISI_PTT_TRACE_INT_STAT_MASK GENMASK(3, 0)
#define HISI_PTT_TRACE_INT_MASK 0x0894
#define HISI_PTT_TUNING_INT_STAT 0x0898
#define HISI_PTT_TUNING_INT_STAT_MASK BIT(0)
#define HISI_PTT_TRACE_WR_STS 0x08a0
#define HISI_PTT_TRACE_WR_STS_WRITE GENMASK(27, 0)
#define HISI_PTT_TRACE_WR_STS_BUFFER GENMASK(29, 28)
#define HISI_PTT_TRACE_STS 0x08b0
#define HISI_PTT_TRACE_IDLE BIT(0)
#define HISI_PTT_DEVICE_RANGE 0x0fe0
#define HISI_PTT_DEVICE_RANGE_UPPER GENMASK(31, 16)
#define HISI_PTT_DEVICE_RANGE_LOWER GENMASK(15, 0)
#define HISI_PTT_LOCATION 0x0fe8
#define HISI_PTT_CORE_ID GENMASK(15, 0)
#define HISI_PTT_SICL_ID GENMASK(31, 16)
/* Parameters of PTT trace DMA part. */
#define HISI_PTT_TRACE_DMA_IRQ 0
#define HISI_PTT_TRACE_BUF_CNT 4
#define HISI_PTT_TRACE_BUF_SIZE SZ_4M
#define HISI_PTT_TRACE_TOTAL_BUF_SIZE (HISI_PTT_TRACE_BUF_SIZE * \
HISI_PTT_TRACE_BUF_CNT)
/* Wait time for hardware DMA to reset */
#define HISI_PTT_RESET_TIMEOUT_US 10UL
#define HISI_PTT_RESET_POLL_INTERVAL_US 1UL
/* Poll timeout and interval for waiting hardware work to finish */
#define HISI_PTT_WAIT_TUNE_TIMEOUT_US 1000000UL
#define HISI_PTT_WAIT_TRACE_TIMEOUT_US 100UL
#define HISI_PTT_WAIT_POLL_INTERVAL_US 10UL
#define HISI_PCIE_CORE_PORT_ID(devfn) ((PCI_SLOT(devfn) & 0x7) << 1)
/* Definition of the PMU configs */
#define HISI_PTT_PMU_FILTER_IS_PORT BIT(19)
#define HISI_PTT_PMU_FILTER_VAL_MASK GENMASK(15, 0)
#define HISI_PTT_PMU_DIRECTION_MASK GENMASK(23, 20)
#define HISI_PTT_PMU_TYPE_MASK GENMASK(31, 24)
#define HISI_PTT_PMU_FORMAT_MASK GENMASK(35, 32)
/**
* struct hisi_ptt_tune_desc - Describe tune event for PTT tune
* @hisi_ptt: PTT device this tune event belongs to
* @name: name of this event
* @event_code: code of the event
*/
struct hisi_ptt_tune_desc {
struct hisi_ptt *hisi_ptt;
const char *name;
u32 event_code;
};
/**
* struct hisi_ptt_dma_buffer - Describe a single trace buffer of PTT trace.
* The detail of the data format is described
* in the documentation of PTT device.
* @dma: DMA address of this buffer visible to the device
* @addr: virtual address of this buffer visible to the cpu
*/
struct hisi_ptt_dma_buffer {
dma_addr_t dma;
void *addr;
};
/**
* struct hisi_ptt_trace_ctrl - Control and status of PTT trace
* @trace_buf: array of the trace buffers for holding the trace data.
* the length will be HISI_PTT_TRACE_BUF_CNT.
* @handle: perf output handle of current trace session
* @buf_index: the index of current using trace buffer
* @on_cpu: current tracing cpu
* @started: current trace status, true for started
* @is_port: whether we're tracing root port or not
* @direction: direction of the TLP headers to trace
* @filter: filter value for tracing the TLP headers
* @format: format of the TLP headers to trace
* @type: type of the TLP headers to trace
*/
struct hisi_ptt_trace_ctrl {
struct hisi_ptt_dma_buffer *trace_buf;
struct perf_output_handle handle;
u32 buf_index;
int on_cpu;
bool started;
bool is_port;
u32 direction:2;
u32 filter:16;
u32 format:1;
u32 type:4;
};
/**
* struct hisi_ptt_filter_desc - Descriptor of the PTT trace filter
* @list: entry of this descriptor in the filter list
* @is_port: the PCI device of the filter is a Root Port or not
* @devid: the PCI device's devid of the filter
*/
struct hisi_ptt_filter_desc {
struct list_head list;
bool is_port;
u16 devid;
};
/**
* struct hisi_ptt_pmu_buf - Descriptor of the AUX buffer of PTT trace
* @length: size of the AUX buffer
* @nr_pages: number of pages of the AUX buffer
* @base: start address of AUX buffer
* @pos: position in the AUX buffer to commit traced data
*/
struct hisi_ptt_pmu_buf {
size_t length;
int nr_pages;
void *base;
long pos;
};
/**
* struct hisi_ptt - Per PTT device data
* @trace_ctrl: the control information of PTT trace
* @hotplug_node: node for register cpu hotplug event
* @hisi_ptt_pmu: the pum device of trace
* @iobase: base IO address of the device
* @pdev: pci_dev of this PTT device
* @tune_lock: lock to serialize the tune process
* @pmu_lock: lock to serialize the perf process
* @upper_bdf: the upper BDF range of the PCI devices managed by this PTT device
* @lower_bdf: the lower BDF range of the PCI devices managed by this PTT device
* @port_filters: the filter list of root ports
* @req_filters: the filter list of requester ID
* @port_mask: port mask of the managed root ports
*/
struct hisi_ptt {
struct hisi_ptt_trace_ctrl trace_ctrl;
struct hlist_node hotplug_node;
struct pmu hisi_ptt_pmu;
void __iomem *iobase;
struct pci_dev *pdev;
struct mutex tune_lock;
spinlock_t pmu_lock;
u32 upper_bdf;
u32 lower_bdf;
/*
* The trace TLP headers can either be filtered by certain
* root port, or by the requester ID. Organize the filters
* by @port_filters and @req_filters here. The mask of all
* the valid ports is also cached for doing sanity check
* of user input.
*/
struct list_head port_filters;
struct list_head req_filters;
u16 port_mask;
};
#define to_hisi_ptt(pmu) container_of(pmu, struct hisi_ptt, hisi_ptt_pmu)
#endif /* _HISI_PTT_H */
...@@ -2817,6 +2817,26 @@ static int arm_smmu_dev_disable_feature(struct device *dev, ...@@ -2817,6 +2817,26 @@ static int arm_smmu_dev_disable_feature(struct device *dev,
} }
} }
/*
* HiSilicon PCIe tune and trace device can be used to trace TLP headers on the
* PCIe link and save the data to memory by DMA. The hardware is restricted to
* use identity mapping only.
*/
#define IS_HISI_PTT_DEVICE(pdev) ((pdev)->vendor == PCI_VENDOR_ID_HUAWEI && \
(pdev)->device == 0xa12e)
static int arm_smmu_def_domain_type(struct device *dev)
{
if (dev_is_pci(dev)) {
struct pci_dev *pdev = to_pci_dev(dev);
if (IS_HISI_PTT_DEVICE(pdev))
return IOMMU_DOMAIN_IDENTITY;
}
return 0;
}
static struct iommu_ops arm_smmu_ops = { static struct iommu_ops arm_smmu_ops = {
.capable = arm_smmu_capable, .capable = arm_smmu_capable,
.domain_alloc = arm_smmu_domain_alloc, .domain_alloc = arm_smmu_domain_alloc,
...@@ -2831,6 +2851,7 @@ static struct iommu_ops arm_smmu_ops = { ...@@ -2831,6 +2851,7 @@ static struct iommu_ops arm_smmu_ops = {
.sva_unbind = arm_smmu_sva_unbind, .sva_unbind = arm_smmu_sva_unbind,
.sva_get_pasid = arm_smmu_sva_get_pasid, .sva_get_pasid = arm_smmu_sva_get_pasid,
.page_response = arm_smmu_page_response, .page_response = arm_smmu_page_response,
.def_domain_type = arm_smmu_def_domain_type,
.pgsize_bitmap = -1UL, /* Restricted during device attach */ .pgsize_bitmap = -1UL, /* Restricted during device attach */
.owner = THIS_MODULE, .owner = THIS_MODULE,
.default_domain_ops = &(const struct iommu_domain_ops) { .default_domain_ops = &(const struct iommu_domain_ops) {
......
...@@ -372,6 +372,29 @@ static inline u32 csdev_access_relaxed_read32(struct csdev_access *csa, ...@@ -372,6 +372,29 @@ static inline u32 csdev_access_relaxed_read32(struct csdev_access *csa,
return csa->read(offset, true, false); return csa->read(offset, true, false);
} }
static inline u64 csdev_access_relaxed_read_pair(struct csdev_access *csa,
u32 lo_offset, u32 hi_offset)
{
if (likely(csa->io_mem)) {
return readl_relaxed(csa->base + lo_offset) |
((u64)readl_relaxed(csa->base + hi_offset) << 32);
}
return csa->read(lo_offset, true, false) | (csa->read(hi_offset, true, false) << 32);
}
static inline void csdev_access_relaxed_write_pair(struct csdev_access *csa, u64 val,
u32 lo_offset, u32 hi_offset)
{
if (likely(csa->io_mem)) {
writel_relaxed((u32)val, csa->base + lo_offset);
writel_relaxed((u32)(val >> 32), csa->base + hi_offset);
} else {
csa->write((u32)val, lo_offset, true, false);
csa->write((u32)(val >> 32), hi_offset, true, false);
}
}
static inline u32 csdev_access_read32(struct csdev_access *csa, u32 offset) static inline u32 csdev_access_read32(struct csdev_access *csa, u32 offset)
{ {
if (likely(csa->io_mem)) if (likely(csa->io_mem))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment