perf/imx_ddr: Add i.MX8QM and pmu in DB (system interconnects)
Subsystems (4)
Frank Li
maintainerv3 cover perf/imx_ddr: Add i.MX8QM and pmu in DB (system interconnects)
dts: add soc specific compatible string for imx8qm, imx8qxp, imx8dxl in db. driver:
- did some cleanup
- add support for pmu in imx8dxl DB
binding:
- add compatible string for imx8qm, imx8qxp, imx8dxl in db
---
Changes in v3:
- collect Rob's reviewed by tags
- use .is_visible() call back. so below feedback will not applied after change to .is_visible().
"Is this identifier useful given that you don't add 'ddr_perf_identifier_attrs' here:"
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- fix binding file by move imx8qm/qxp/dxl under enum
- move clock-db-ipg clock into imx8dxl.dtsi
- Fix CHECK_DTBS warning caused in v1
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Frank Li (4):
dt-bindings: perf: fsl-imx-ddr: Add compatible string for i.MX8QM, i.MX8QXP and i.MX8DXL perf/imx_ddr: Move ida_alloc() from ddr_perf_init() to ddr_perf_probe() perf/imx_ddr: Get and enable optional clks
arm64: dts: imx8qm: add ddr perf device node
Jacky Bai (1):
arm64: dts: imx8dxl-ss-ddr: Add DB (system interconnects) pmu support for i.MX8DXL
Joakim Zhang (1):
perf/imx_ddr: Add support for PMU in DB (system interconnects)
.../devicetree/bindings/perf/fsl-imx-ddr.yaml | 29 ++++++- arch/arm64/boot/dts/freescale/imx8-ss-ddr.dtsi | 2 +- arch/arm64/boot/dts/freescale/imx8dxl-ss-ddr.dtsi | 22 +++++ arch/arm64/boot/dts/freescale/imx8dxl.dtsi | 7 ++ arch/arm64/boot/dts/freescale/imx8qm-ss-ddr.dtsi | 19 +++++ arch/arm64/boot/dts/freescale/imx8qm.dtsi | 2 + drivers/perf/fsl_imx8_ddr_perf.c | 93 ++++++++++++++++++---- 7 files changed, 157 insertions(+), 17 deletions(-)
---
base-commit: c31b21db1c04ba719c3889a57873f0f7eff54670
change-id: 20251022-qm_dts-60145802537d
Best regards,
--
Frank Li <[email protected]>
Frank Li
maintainerPATCH v3 1/6 dt-bindings: perf: fsl-imx-ddr: Add compatible string for i.MX8QM, i.MX8QXP and i.MX8DXL
Add compatible string fsl,imx8qm-ddr-pmu, fsl,imx8qxp-ddr-pmu, which fallback to fsl,imx8-ddr-pmu and fsl,imx8dxl-db-pmu (for data bus fabric).
Add clocks, clock-names for fsl,imx8dxl-db-pmu and keep the same restriction for existing compatible strings.
---
changes in v2
- move fsl,imx8qm-ddr-pmu, fsl,imx8qxp-ddr-pmu under enum
--- .../devicetree/bindings/perf/fsl-imx-ddr.yaml | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/perf/fsl-imx-ddr.yaml +28 -1
@@ -14,6 +14,7 @@ properties: oneOf: - enum: - fsl,imx8-ddr-pmu + - fsl,imx8dxl-db-pmu - fsl,imx8m-ddr-pmu - fsl,imx8mq-ddr-pmu - fsl,imx8mm-ddr-pmu
@@ -28,7 +29,10 @@ properties: - fsl,imx8mp-ddr-pmu - const: fsl,imx8m-ddr-pmu - items: - - const: fsl,imx8dxl-ddr-pmu + - enum: + - fsl,imx8dxl-ddr-pmu + - fsl,imx8qm-ddr-pmu + - fsl,imx8qxp-ddr-pmu - const: fsl,imx8-ddr-pmu - items: - enum:
@@ -43,6 +47,14 @@ properties: interrupts: maxItems: 1 + clocks: + maxItems: 2 + + clock-names: + items: + - const: ipg + - const: cnt + required: - compatible - reg
@@ -50,6 +62,21 @@ required: additionalProperties: false +allOf: + - if: + properties: + compatible: + contains: + const: fsl,imx8dxl-db-pmu + then: + required: + - clocks + - clock-names + else: + properties: + clocks: false + clock-names: false + examples: - | #include <dt-bindings/interrupt-controller/arm-gic.h>
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH v3 2/6 perf/imx_ddr: Move ida_alloc() from ddr_perf_init() to ddr_perf_probe()
In reply to Frank LiMove ida_alloc() from helper ddr_perf_init() into ddr_perf_probe() to clarify why ida_free() must be called at the error path.
Add return value check for ida_alloc().
Rename label 'cpuhp_state_err' to 'idr_free' to make the code clearer, since two error paths now jump to this label.
--- drivers/perf/fsl_imx8_ddr_perf.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/perf/fsl_imx8_ddr_perf.c +12 -9
@@ -645,8 +645,8 @@ static void ddr_perf_pmu_disable(struct pmu *pmu) { } -static int ddr_perf_init (struct ddr_pmu *pmu,void __iomem *base, -struct device *dev) +static void ddr_perf_init (struct ddr_pmu *pmu,void __iomem *base, +struct device *dev) { *pmu = (struct ddr_pmu ) { .pmu = (struct pmu ) {
@@ -667,9 +667,6 @@ static int ddr_perf_init(struct ddr_pmu *pmu, void __iomem *base, .base = base, .dev = dev, }; - - pmu->id =ida_alloc (&ddr_ida,GFP_KERNEL ); -return pmu->id; }static irqreturn_t ddr_perf_irq_handler (int irq,void *p)
@@ -753,15 +750,21 @@ static int ddr_perf_probe(struct platform_device *pdev)if (!pmu)return -ENOMEM ; - num =ddr_perf_init (pmu, base, &pdev->dev); +ddr_perf_init (pmu, base, &pdev->dev);platform_set_drvdata (pdev, pmu); + num =ida_alloc (&ddr_ida,GFP_KERNEL ); +if (num <0 ) +return num; + + pmu->id = num; + name =devm_kasprintf (&pdev->dev,GFP_KERNEL ,DDR_PERF_DEV_NAME "%d" , num);if (!name) { ret = -ENOMEM ; - goto cpuhp_state_err; + goto idr_free; } pmu->devtype_data =of_device_get_match_data (&pdev->dev);
@@ -774,7 +777,7 @@ static int ddr_perf_probe(struct platform_device *pdev)if (ret <0 ) {dev_err (&pdev->dev,"cpuhp_setup_state_multi failed\n" ); - goto cpuhp_state_err; + goto idr_free; } pmu->cpuhp_state = ret;
@@ -821,7 +824,7 @@ static int ddr_perf_probe(struct platform_device *pdev)cpuhp_state_remove_instance_nocalls (pmu->cpuhp_state, &pmu->node); cpuhp_instance_err:cpuhp_remove_multi_state (pmu->cpuhp_state); -cpuhp_state_err: +idr_free:ida_free (&ddr_ida, pmu->id);dev_warn (&pdev->dev,"i.MX8 DDR Perf PMU failed (%d), disabled\n" , ret);return ret;
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH v3 3/6 perf/imx_ddr: Get and enable optional clks
In reply to Frank LiGet and enable optional clks because fsl,imx8dxl-db-pmu have two clocks.
--- drivers/perf/fsl_imx8_ddr_perf.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/perf/fsl_imx8_ddr_perf.c +7 -0
@@ -5,6 +5,7 @@*/ #include <linux/bitfield.h> +#include <linux/clk.h> #include <linux/init.h> #include <linux/interrupt.h> #include <linux/io.h>
@@ -732,10 +733,12 @@ static int ddr_perf_offline_cpu(unsigned int cpu, struct hlist_node *node)static int ddr_perf_probe (struct platform_device *pdev) { +struct clk_bulk_data *clks;struct ddr_pmu *pmu;struct device_node *np;void __iomem *base;char *name; +int nclks;int num;int ret;int irq;
@@ -754,6 +757,10 @@ static int ddr_perf_probe(struct platform_device *pdev)platform_set_drvdata (pdev, pmu); + nclks =devm_clk_bulk_get_all_enabled (&pdev->dev, &clks); +if (nclks <0 ) +return dev_err_probe (&pdev->dev, nclks,"Failure get clks\n" ); + num =ida_alloc (&ddr_ida,GFP_KERNEL );if (num <0 )return num;
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH v3 4/6 perf/imx_ddr: Add support for PMU in DB (system interconnects)
In reply to Frank LiFrom: Joakim Zhang <[email protected]>
There is a PMU in DB, which has the same function with PMU in DDR subsystem, the difference is PMU in DB only supports cycles, axid-read, axid-write events.
e.g.
perf stat -a -e imx8_db0/axid-read,axi_mask=0xMMMM,axi_id=0xDDDD,axi_port=0xPP,axi_channel=0xH/ cmd perf stat -a -e imx8_db0/axid-write,axi_mask=0xMMMM,axi_id=0xDDDD,axi_port=0xPP,axi_channel=0xH/ cmd
---
Change in v3
- use is_visible() callback to show support events
--- drivers/perf/fsl_imx8_ddr_perf.c | 67 +++++++++++++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 7 deletions(-)
drivers/perf/fsl_imx8_ddr_perf.c +60 -7
@@ -53,18 +53,27 @@#define to_ddr_pmu (p) container_of(p, struct ddr_pmu, pmu)#define DDR_PERF_DEV_NAME "imx8_ddr" +#define DB_PERF_DEV_NAME "imx8_db"#define DDR_CPUHP_CB_NAME DDR_PERF_DEV_NAME "_perf_pmu"static DEFINE_IDA (ddr_ida); +static DEFINE_IDA (db_ida);/* DDR Perf hardware feature */ #define DDR_CAP_AXI_ID_FILTER 0x1/* support AXI ID filter */ #define DDR_CAP_AXI_ID_FILTER_ENHANCED 0x3/* support enhanced AXI ID filter */ #define DDR_CAP_AXI_ID_PORT_CHANNEL_FILTER 0x4/* support AXI ID PORT CHANNEL filter */ +/* Perf type */ +enum fsl_ddr_type { +DDR_PERF_TYPE =0 ,/* ddr Perf (default) */ +DB_PERF_TYPE ,/* db Perf */ +}; +struct fsl_ddr_devtype_data {unsigned int quirks;/* quirks needed for different DDR Perf core */ const char *identifier;/* system PMU identifier for userspace */ +enum fsl_ddr_type type;/* types of Perf, ddr or db */ };static const struct fsl_ddr_devtype_data imx8_devtype_data;
@@ -98,6 +107,12 @@ static const struct fsl_ddr_devtype_data imx8dxl_devtype_data = { .identifier = "i.MX8DXL", }; +static const struct fsl_ddr_devtype_data imx8dxl_db_devtype_data = { + .quirks =DDR_CAP_AXI_ID_PORT_CHANNEL_FILTER , + .identifier ="i.MX8DXL" , + .type =DB_PERF_TYPE , +}; +static const struct of_device_id imx_ddr_pmu_dt_ids[] = { { .compatible ="fsl,imx8-ddr-pmu" , .data = &imx8_devtype_data}, { .compatible ="fsl,imx8m-ddr-pmu" , .data = &imx8m_devtype_data},
@@ -106,6 +121,7 @@ static const struct of_device_id imx_ddr_pmu_dt_ids[] = { { .compatible = "fsl,imx8mn-ddr-pmu", .data = &imx8mn_devtype_data}, { .compatible = "fsl,imx8mp-ddr-pmu", .data = &imx8mp_devtype_data}, { .compatible = "fsl,imx8dxl-ddr-pmu", .data = &imx8dxl_devtype_data}, + { .compatible = "fsl,imx8dxl-db-pmu", .data = &imx8dxl_db_devtype_data}, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, imx_ddr_pmu_dt_ids);
@@ -285,9 +301,37 @@ static struct attribute *ddr_perf_events_attrs[] = { NULL, }; +static const int ddr_perf_db_visible_event_list[] = { +EVENT_CYCLES_ID , +0x41 , +0x42 , +}; + +static umode_t ddr_perf_events_attrs_is_visible (struct kobject *kobj, +struct attribute *attr,int n) +{ +struct device *dev =kobj_to_dev (kobj); +struct ddr_pmu *pmu =dev_get_drvdata (dev); +struct perf_pmu_events_attr *pmu_attr; +unsigned int i; + + pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr.attr); + +if (pmu->devtype_data->type ==DDR_PERF_TYPE ) +return attr->mode; + +/* DB Type */ +for (i =0 ; i <ARRAY_SIZE (ddr_perf_db_visible_event_list); i++) +if (pmu_attr->id == ddr_perf_db_visible_event_list[i]) +return attr->mode; + +return 0 ; +} +static const struct attribute_group ddr_perf_events_attr_group = { .name ="events" , .attrs = ddr_perf_events_attrs, + .is_visible = ddr_perf_events_attrs_is_visible, };PMU_FORMAT_ATTR (event,"config:0-7" );
@@ -737,6 +781,7 @@ static int ddr_perf_probe(struct platform_device *pdev)struct ddr_pmu *pmu;struct device_node *np;void __iomem *base; +struct ida *ida;char *name;int nclks;int num;
@@ -761,21 +806,25 @@ static int ddr_perf_probe(struct platform_device *pdev)if (nclks <0 )return dev_err_probe (&pdev->dev, nclks,"Failure get clks\n" ); - num =ida_alloc (&ddr_ida,GFP_KERNEL ); + pmu->devtype_data =of_device_get_match_data (&pdev->dev); + + ida = pmu->devtype_data->type ==DDR_PERF_TYPE ? &ddr_ida : &db_ida; + num =ida_alloc (ida,GFP_KERNEL );if (num <0 )return num; pmu->id = num; - name =devm_kasprintf (&pdev->dev,GFP_KERNEL ,DDR_PERF_DEV_NAME "%d" , - num); +if (pmu->devtype_data->type ==DDR_PERF_TYPE ) + name =devm_kasprintf (&pdev->dev,GFP_KERNEL ,DDR_PERF_DEV_NAME "%d" , num); +else + name =devm_kasprintf (&pdev->dev,GFP_KERNEL ,DB_PERF_DEV_NAME "%d" , num); +if (!name) { ret = -ENOMEM ; goto idr_free; } - pmu->devtype_data =of_device_get_match_data (&pdev->dev); - pmu->cpu =raw_smp_processor_id (); ret = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN, DDR_CPUHP_CB_NAME,
@@ -832,7 +881,7 @@ static int ddr_perf_probe(struct platform_device *pdev) cpuhp_instance_err:cpuhp_remove_multi_state (pmu->cpuhp_state); idr_free: -ida_free (&ddr_ida, pmu->id); +ida_free (ida, pmu->id);dev_warn (&pdev->dev,"i.MX8 DDR Perf PMU failed (%d), disabled\n" , ret);return ret; }
@@ -846,7 +895,11 @@ static void ddr_perf_remove(struct platform_device *pdev)perf_pmu_unregister (&pmu->pmu); -ida_free (&ddr_ida, pmu->id); +if (pmu->devtype_data->type ==DDR_PERF_TYPE ) +ida_free (&ddr_ida, pmu->id); +else +ida_free (&db_ida, pmu->id); + }static struct platform_driver imx_ddr_pmu_driver = {
Signature · 1 line
2.34.1
Frank Li
maintainerPATCH v3 5/6 arm64: dts: imx8qm: add ddr perf device node
In reply to Frank LiAdd ddr perf monitor device node for i.MX8QM. Change imx8-ss-ddr.dtsi's compatible string to fsl,imx8qxp-ddr-pmu. i.MX8QM overwrite to fsl,imx8qm-ddr-pmu. All fallback to fsl,imx8-ddr-pmu.
--- arch/arm64/boot/dts/freescale/imx8-ss-ddr.dtsi | 2 +- arch/arm64/boot/dts/freescale/imx8qm-ss-ddr.dtsi | 19 +++++++++++++++++++ arch/arm64/boot/dts/freescale/imx8qm.dtsi | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/freescale/imx8-ss-ddr.dtsi +1 -1
@@ -11,7 +11,7 @@ ddr_subsys: bus@5c000000 { ranges = <0x5c000000 0x0 0x5c000000 0x1000000>; ddr_pmu0: ddr-pmu@5c020000 { - compatible = "fsl,imx8-ddr-pmu"; + compatible = "fsl,imx8qxp-ddr-pmu", "fsl,imx8-ddr-pmu"; reg = <0x5c020000 0x10000>; interrupts = <GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>; };
arch/arm64/boot/dts/freescale/imx8qm-ss-ddr.dtsi new file +19 -0
@@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2025 NXP + * Dong Aisheng <[email protected]> + */ + +&ddr_pmu0 { + compatible = "fsl,imx8qm-ddr-pmu", "fsl,imx8-ddr-pmu"; + interrupts = <GIC_SPI 130 IRQ_TYPE_LEVEL_HIGH>; +}; + +&ddr_subsys { + ddr_pmu1: ddr-pmu@5c120000 { + compatible = "fsl,imx8qm-ddr-pmu", "fsl,imx8-ddr-pmu"; + reg = <0x5c120000 0x10000>; + interrupt-parent = <&gic>; + interrupts = <GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>; + }; +};
arch/arm64/boot/dts/freescale/imx8qm.dtsi +2 -0
@@ -635,6 +635,7 @@ vpu_dsp: dsp@556e8000 { #include "imx8-ss-img.dtsi" #include "imx8-ss-dma.dtsi" #include "imx8-ss-conn.dtsi" + #include "imx8-ss-ddr.dtsi" #include "imx8-ss-lsio.dtsi" #include "imx8-ss-hsio.dtsi" };
@@ -647,5 +648,6 @@ vpu_dsp: dsp@556e8000 { #include "imx8qm-ss-lvds.dtsi" #include "imx8qm-ss-mipi.dtsi" #include "imx8qm-ss-hsio.dtsi" +#include "imx8qm-ss-ddr.dtsi" /delete-node/ &dsp;
Signature · 1 line
2.34.1
Shawn Guo
AppliedRe: [PATCH v3 5/6] arm64: dts: imx8qm: add ddr perf device node
Quoted 6 lines · Frank Li
Add ddr perf monitor device node for i.MX8QM. Change imx8-ss-ddr.dtsi's compatible string to fsl,imx8qxp-ddr-pmu. i.MX8QM overwrite to fsl,imx8qm-ddr-pmu. All fallback to fsl,imx8-ddr-pmu.
Signed-off-by Joakim Zhang <[email protected]>Signed-off-by Frank Li <[email protected]>
Applied, thanks!
Frank Li
maintainerPATCH v3 6/6 arm64: dts: imx8dxl-ss-ddr: Add DB (system interconnects) pmu support for i.MX8DXL
In reply to Frank LiFrom: Jacky Bai <[email protected]>
Add DB pmu related nodes. This pmu is in DB (system interconnects).
---
change in v2
- move clock-db-ipg to imx8dxl.dtsi
--- arch/arm64/boot/dts/freescale/imx8dxl-ss-ddr.dtsi | 22 ++++++++++++++++++++++ arch/arm64/boot/dts/freescale/imx8dxl.dtsi | 7 +++++++ 2 files changed, 29 insertions(+)
arch/arm64/boot/dts/freescale/imx8dxl-ss-ddr.dtsi +22 -0
@@ -7,3 +7,25 @@ &ddr_pmu0 { compatible = "fsl,imx8dxl-ddr-pmu", "fsl,imx8-ddr-pmu"; interrupts = <GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>; }; + +&ddr_subsys { + db_pmu0: db-pmu@5ca40000 { + compatible = "fsl,imx8dxl-db-pmu"; + reg = <0x5ca40000 0x10000>; + interrupt-parent = <&gic>; + interrupts = <GIC_SPI 338 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&db_pmu0_lpcg IMX_LPCG_CLK_4>, <&db_pmu0_lpcg IMX_LPCG_CLK_0>; + clock-names = "ipg", "cnt"; + }; + + db_pmu0_lpcg: clock-controller@5cae0000 { + compatible = "fsl,imx8qxp-lpcg"; + reg = <0x5cae0000 0x10000>; + #clock-cells = <1>; + clocks = <&db_ipg_clk>, <&db_ipg_clk>; + clock-indices = <IMX_LPCG_CLK_0>, <IMX_LPCG_CLK_4>; + clock-output-names = "perf_lpcg_cnt_clk", + "perf_lpcg_ipg_clk"; + power-domains = <&pd IMX_SC_R_PERF>; + }; +};
arch/arm64/boot/dts/freescale/imx8dxl.dtsi +7 -0
@@ -236,6 +236,13 @@ xtal24m: clock-xtal24m { clock-output-names = "xtal_24MHz"; }; + db_ipg_clk: clock-db-ipg { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <456000000>; + clock-output-names = "db_ipg_clk"; + }; + /* sorted in register address */ #include "imx8-ss-cm40.dtsi" #include "imx8-ss-adma.dtsi"
Signature · 1 line
2.34.1
Shawn Guo
AppliedRe: [PATCH v3 6/6] arm64: dts: imx8dxl-ss-ddr: Add DB (system interconnects) pmu support for i.MX8DXL
Quoted 6 lines · Frank Li
From: Jacky Bai <[email protected]>
Add DB pmu related nodes. This pmu is in DB (system interconnects).
Signed-off-by Jacky Bai <[email protected]>Signed-off-by Frank Li <[email protected]>
Applied, thanks!
Will Deacon
maintainerQuoted 8 lines · Frank Li
dts: add soc specific compatible string for imx8qm, imx8qxp, imx8dxl in db. driver:
- did some cleanup
- add support for pmu in imx8dxl DB
binding:
- add compatible string for imx8qm, imx8qxp, imx8dxl in db[...]
Applied driver changes to will (for-next/perf), thanks!
[1/6] dt-bindings: perf: fsl-imx-ddr: Add compatible string for i.MX8QM, i.MX8QXP and i.MX8DXL
https://git.kernel.org/will/c/de8209e55408 [2/6] perf/imx_ddr: Move ida_alloc() from ddr_perf_init() to ddr_perf_probe() https://git.kernel.org/will/c/66db99ffdfcb [3/6] perf/imx_ddr: Get and enable optional clks https://git.kernel.org/will/c/037e8cf67178 [4/6] perf/imx_ddr: Add support for PMU in DB (system interconnects) https://git.kernel.org/will/c/11abb4e87b0e
Cheers,
Signature · 5 lines
Will https://fixes.arm64.dev https://next.arm64.dev https://will.arm64.dev