linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 0/3] perf/imx_ddr: Add system PMU support
@ 2020-05-20  2:56 Joakim Zhang
  2020-05-20  2:56 ` [PATCH V2 1/3] bindings: perf: imx8_ddr: add identifier property Joakim Zhang
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Joakim Zhang @ 2020-05-20  2:56 UTC (permalink / raw)
  To: john.garry, will, mark.rutland, robh+dt, shawnguo
  Cc: devicetree, linux-imx, linux-arm-kernel, linux-kernel

The patch set adds system PMU support for i.MX8 DDR Perf.

The sysfs location for userspace to get the PMU identifier under the
directory:
	/sys/bus/event_source/devices/<PMU DEVICE>/identifier

ChangeLogs:
V1 -> V2:
	*add property in dt instead of changing compatible string.

Joakim Zhang (3):
  bindings: perf: imx8_ddr: add identifier property
  perf/imx_ddr: Add system PMU identifier for userspace
  arm64: dts: imx8/8mm/8mn/8mq: add identifier for DDR perf

 .../devicetree/bindings/perf/fsl-imx-ddr.txt  |  3 ++
 arch/arm64/boot/dts/freescale/imx8mm.dtsi     |  1 +
 arch/arm64/boot/dts/freescale/imx8mn.dtsi     |  1 +
 arch/arm64/boot/dts/freescale/imx8mq.dtsi     |  1 +
 arch/arm64/boot/dts/freescale/imx8qxp.dtsi    |  1 +
 drivers/perf/fsl_imx8_ddr_perf.c              | 29 +++++++++++++++++++
 6 files changed, 36 insertions(+)

-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH V2 1/3] bindings: perf: imx8_ddr: add identifier property
  2020-05-20  2:56 [PATCH V2 0/3] perf/imx_ddr: Add system PMU support Joakim Zhang
@ 2020-05-20  2:56 ` Joakim Zhang
  2020-05-20  2:56 ` [PATCH V2 2/3] perf/imx_ddr: Add system PMU identifier for userspace Joakim Zhang
  2020-05-20  2:56 ` [PATCH V2 3/3] arm64: dts: imx8/8mm/8mn/8mq: add identifier for DDR perf Joakim Zhang
  2 siblings, 0 replies; 5+ messages in thread
From: Joakim Zhang @ 2020-05-20  2:56 UTC (permalink / raw)
  To: john.garry, will, mark.rutland, robh+dt, shawnguo
  Cc: devicetree, linux-imx, linux-arm-kernel, linux-kernel

Add "identifier" property for DDR Perf which used to identity system pmu.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
 Documentation/devicetree/bindings/perf/fsl-imx-ddr.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/perf/fsl-imx-ddr.txt b/Documentation/devicetree/bindings/perf/fsl-imx-ddr.txt
index 7822a806ea0a..ebb9a40094c5 100644
--- a/Documentation/devicetree/bindings/perf/fsl-imx-ddr.txt
+++ b/Documentation/devicetree/bindings/perf/fsl-imx-ddr.txt
@@ -12,6 +12,8 @@ Required properties:
 - interrupts: single interrupt
 	generated by the control block
 
+- identifier: identify system pmu
+
 Example:
 
 	ddr-pmu@5c020000 {
@@ -19,4 +21,5 @@ Example:
 		reg = <0x5c020000 0x10000>;
 		interrupt-parent = <&gic>;
 		interrupts = <GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>;
+		identifier = "i.mx8mm";
 	};
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH V2 2/3] perf/imx_ddr: Add system PMU identifier for userspace
  2020-05-20  2:56 [PATCH V2 0/3] perf/imx_ddr: Add system PMU support Joakim Zhang
  2020-05-20  2:56 ` [PATCH V2 1/3] bindings: perf: imx8_ddr: add identifier property Joakim Zhang
@ 2020-05-20  2:56 ` Joakim Zhang
  2020-05-20  7:41   ` Will Deacon
  2020-05-20  2:56 ` [PATCH V2 3/3] arm64: dts: imx8/8mm/8mn/8mq: add identifier for DDR perf Joakim Zhang
  2 siblings, 1 reply; 5+ messages in thread
From: Joakim Zhang @ 2020-05-20  2:56 UTC (permalink / raw)
  To: john.garry, will, mark.rutland, robh+dt, shawnguo
  Cc: devicetree, linux-imx, linux-arm-kernel, linux-kernel

The DDR Perf for i.MX8 is a system PMU whose axi id would different from
SoC to SoC. Need expose system PMU identifier for userspace which refer
to /sys/bus/event_source/devices/<PMU DEVICE>/identifier.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
 drivers/perf/fsl_imx8_ddr_perf.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/perf/fsl_imx8_ddr_perf.c b/drivers/perf/fsl_imx8_ddr_perf.c
index 90884d14f95f..ba523a94f4d7 100644
--- a/drivers/perf/fsl_imx8_ddr_perf.c
+++ b/drivers/perf/fsl_imx8_ddr_perf.c
@@ -76,6 +76,7 @@ struct ddr_pmu {
 	unsigned int cpu;
 	struct	hlist_node node;
 	struct	device *dev;
+	const char *identifier;
 	struct perf_event *events[NUM_COUNTERS];
 	int active_events;
 	enum cpuhp_state cpuhp_state;
@@ -84,6 +85,27 @@ struct ddr_pmu {
 	int id;
 };
 
+static ssize_t ddr_perf_identifier_show(struct device *dev,
+					struct device_attribute *attr,
+					char *page)
+{
+	struct ddr_pmu *pmu = dev_get_drvdata(dev);
+
+	return sprintf(page, "%s\n", pmu->identifier);
+}
+
+static struct device_attribute ddr_perf_identifier_attr =
+	__ATTR(identifier, 0444, ddr_perf_identifier_show, NULL);
+
+static struct attribute *ddr_perf_identifier_attrs[] = {
+	&ddr_perf_identifier_attr.attr,
+	NULL,
+};
+
+static struct attribute_group ddr_perf_identifier_attr_group = {
+	.attrs = ddr_perf_identifier_attrs,
+};
+
 enum ddr_perf_filter_capabilities {
 	PERF_CAP_AXI_ID_FILTER = 0,
 	PERF_CAP_AXI_ID_FILTER_ENHANCED,
@@ -237,6 +259,7 @@ static const struct attribute_group *attr_groups[] = {
 	&ddr_perf_format_attr_group,
 	&ddr_perf_cpumask_attr_group,
 	&ddr_perf_filter_cap_attr_group,
+	&ddr_perf_identifier_attr_group,
 	NULL,
 };
 
@@ -601,6 +624,7 @@ static int ddr_perf_probe(struct platform_device *pdev)
 	struct ddr_pmu *pmu;
 	struct device_node *np;
 	void __iomem *base;
+	const char *identifier = NULL;
 	char *name;
 	int num;
 	int ret;
@@ -620,6 +644,11 @@ static int ddr_perf_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, pmu);
 
+	ret = of_property_read_string(np, "identifier", &identifier);
+	if (ret < 0)
+		dev_warn(&pdev->dev, "Failed to get identifier\n");
+	pmu->identifier = identifier;
+
 	name = devm_kasprintf(&pdev->dev, GFP_KERNEL, DDR_PERF_DEV_NAME "%d",
 			      num);
 	if (!name)
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH V2 3/3] arm64: dts: imx8/8mm/8mn/8mq: add identifier for DDR perf
  2020-05-20  2:56 [PATCH V2 0/3] perf/imx_ddr: Add system PMU support Joakim Zhang
  2020-05-20  2:56 ` [PATCH V2 1/3] bindings: perf: imx8_ddr: add identifier property Joakim Zhang
  2020-05-20  2:56 ` [PATCH V2 2/3] perf/imx_ddr: Add system PMU identifier for userspace Joakim Zhang
@ 2020-05-20  2:56 ` Joakim Zhang
  2 siblings, 0 replies; 5+ messages in thread
From: Joakim Zhang @ 2020-05-20  2:56 UTC (permalink / raw)
  To: john.garry, will, mark.rutland, robh+dt, shawnguo
  Cc: devicetree, linux-imx, linux-arm-kernel, linux-kernel

Add identifier property for DDR perf.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
 arch/arm64/boot/dts/freescale/imx8mm.dtsi  | 1 +
 arch/arm64/boot/dts/freescale/imx8mn.dtsi  | 1 +
 arch/arm64/boot/dts/freescale/imx8mq.dtsi  | 1 +
 arch/arm64/boot/dts/freescale/imx8qxp.dtsi | 1 +
 4 files changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mm.dtsi b/arch/arm64/boot/dts/freescale/imx8mm.dtsi
index 1e5e11592f7b..ee14a6ecdb93 100644
--- a/arch/arm64/boot/dts/freescale/imx8mm.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mm.dtsi
@@ -898,6 +898,7 @@
 			reg = <0x3d800000 0x400000>;
 			interrupt-parent = <&gic>;
 			interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>;
+			identifier = "i.mx8mm";
 		};
 	};
 };
diff --git a/arch/arm64/boot/dts/freescale/imx8mn.dtsi b/arch/arm64/boot/dts/freescale/imx8mn.dtsi
index a44b5438e842..b93e56ebf9a7 100644
--- a/arch/arm64/boot/dts/freescale/imx8mn.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mn.dtsi
@@ -796,6 +796,7 @@
 			compatible = "fsl,imx8mn-ddr-pmu", "fsl,imx8m-ddr-pmu";
 			reg = <0x3d800000 0x400000>;
 			interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>;
+			identifier = "i.mx8mn";
 		};
 	};
 
diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
index 6a1e83922c71..38cc93af35ac 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
@@ -1217,6 +1217,7 @@
 			reg = <0x3d800000 0x400000>;
 			interrupt-parent = <&gic>;
 			interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>;
+			identifier = "i.mx8mq";
 		};
 	};
 };
diff --git a/arch/arm64/boot/dts/freescale/imx8qxp.dtsi b/arch/arm64/boot/dts/freescale/imx8qxp.dtsi
index fb5f752b15fe..0c294b549806 100644
--- a/arch/arm64/boot/dts/freescale/imx8qxp.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8qxp.dtsi
@@ -436,6 +436,7 @@
 			compatible = "fsl,imx8-ddr-pmu";
 			reg = <0x5c020000 0x10000>;
 			interrupts = <GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>;
+			identifier = "i.mx8";
 		};
 	};
 
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH V2 2/3] perf/imx_ddr: Add system PMU identifier for userspace
  2020-05-20  2:56 ` [PATCH V2 2/3] perf/imx_ddr: Add system PMU identifier for userspace Joakim Zhang
@ 2020-05-20  7:41   ` Will Deacon
  0 siblings, 0 replies; 5+ messages in thread
From: Will Deacon @ 2020-05-20  7:41 UTC (permalink / raw)
  To: Joakim Zhang
  Cc: mark.rutland, devicetree, john.garry, linux-kernel, robh+dt,
	linux-imx, shawnguo, linux-arm-kernel

On Wed, May 20, 2020 at 10:56:18AM +0800, Joakim Zhang wrote:
> The DDR Perf for i.MX8 is a system PMU whose axi id would different from
> SoC to SoC. Need expose system PMU identifier for userspace which refer
> to /sys/bus/event_source/devices/<PMU DEVICE>/identifier.
> 
> Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
> ---
>  drivers/perf/fsl_imx8_ddr_perf.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/perf/fsl_imx8_ddr_perf.c b/drivers/perf/fsl_imx8_ddr_perf.c
> index 90884d14f95f..ba523a94f4d7 100644
> --- a/drivers/perf/fsl_imx8_ddr_perf.c
> +++ b/drivers/perf/fsl_imx8_ddr_perf.c
> @@ -76,6 +76,7 @@ struct ddr_pmu {
>  	unsigned int cpu;
>  	struct	hlist_node node;
>  	struct	device *dev;
> +	const char *identifier;
>  	struct perf_event *events[NUM_COUNTERS];
>  	int active_events;
>  	enum cpuhp_state cpuhp_state;
> @@ -84,6 +85,27 @@ struct ddr_pmu {
>  	int id;
>  };
>  
> +static ssize_t ddr_perf_identifier_show(struct device *dev,
> +					struct device_attribute *attr,
> +					char *page)
> +{
> +	struct ddr_pmu *pmu = dev_get_drvdata(dev);
> +
> +	return sprintf(page, "%s\n", pmu->identifier);
> +}
> +
> +static struct device_attribute ddr_perf_identifier_attr =
> +	__ATTR(identifier, 0444, ddr_perf_identifier_show, NULL);
> +
> +static struct attribute *ddr_perf_identifier_attrs[] = {
> +	&ddr_perf_identifier_attr.attr,
> +	NULL,
> +};
> +
> +static struct attribute_group ddr_perf_identifier_attr_group = {
> +	.attrs = ddr_perf_identifier_attrs,
> +};
> +
>  enum ddr_perf_filter_capabilities {
>  	PERF_CAP_AXI_ID_FILTER = 0,
>  	PERF_CAP_AXI_ID_FILTER_ENHANCED,
> @@ -237,6 +259,7 @@ static const struct attribute_group *attr_groups[] = {
>  	&ddr_perf_format_attr_group,
>  	&ddr_perf_cpumask_attr_group,
>  	&ddr_perf_filter_cap_attr_group,
> +	&ddr_perf_identifier_attr_group,
>  	NULL,
>  };
>  
> @@ -601,6 +624,7 @@ static int ddr_perf_probe(struct platform_device *pdev)
>  	struct ddr_pmu *pmu;
>  	struct device_node *np;
>  	void __iomem *base;
> +	const char *identifier = NULL;
>  	char *name;
>  	int num;
>  	int ret;
> @@ -620,6 +644,11 @@ static int ddr_perf_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, pmu);
>  
> +	ret = of_property_read_string(np, "identifier", &identifier);
> +	if (ret < 0)
> +		dev_warn(&pdev->dev, "Failed to get identifier\n");
> +	pmu->identifier = identifier;

I think this is exactly what Rob was objecting to when he said "yet another
way to identify the SoC from userspace". I've asked him on the other thread
as to what the best way to do this is.

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-05-20  7:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-20  2:56 [PATCH V2 0/3] perf/imx_ddr: Add system PMU support Joakim Zhang
2020-05-20  2:56 ` [PATCH V2 1/3] bindings: perf: imx8_ddr: add identifier property Joakim Zhang
2020-05-20  2:56 ` [PATCH V2 2/3] perf/imx_ddr: Add system PMU identifier for userspace Joakim Zhang
2020-05-20  7:41   ` Will Deacon
2020-05-20  2:56 ` [PATCH V2 3/3] arm64: dts: imx8/8mm/8mn/8mq: add identifier for DDR perf Joakim Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).