perf/smmuv3: fix crash when platdata not specified
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): CGME20200712165509epcas5p29e66777a4e0115420b9104ba5aa83f57@epcas5p2.samsung.com
cover Add DT support for arm_smmuv3_pmu driver
Currently, only those platforms using ACPI can enable arm_smmuv3_pmu driver. This patchset adds support for enabling arm_smmuv3_pmu driver on platforms which do not enable ACPI and instead rely on DT.
Ajay Kumar (4):
perf/smmuv3: Remove dependency on CONFIG_ACPI
Documentation: perf: Add documentation for arm-smmu-v3-pmcg perf/smmuv3: add device tree support
perf/smmuv3: fix crash when platdata not specified
.../bindings/perf/arm-smmu-v3-pmcg.txt | 21 +++++++++++++++++++ drivers/perf/Kconfig | 2 +- drivers/perf/arm_smmuv3_pmu.c | 11 ++++++++-- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/perf/arm-smmu-v3-pmcg.txt
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/4 perf/smmuv3: Remove dependency on CONFIG_ACPI
This patch removes CONFIG_ACPI dependency for arm_smmuv3_pmu driver so that we can build it on platforms which don't enable ACPI.
--- drivers/perf/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/Kconfig +1 -1
@@ -55,7 +55,7 @@ config ARM_PMU_ACPI config ARM_SMMU_V3_PMU tristate "ARM SMMUv3 Performance Monitors Extension" - depends on ARM64 && ACPI && ARM_SMMU_V3 + depends on ARM64 && ARM_SMMU_V3 help Provides support for the ARM SMMUv3 Performance Monitor Counter Groups (PMCG), which provide monitoring of transactions passing
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 2/4 Documentation: perf: Add documentation for arm-smmu-v3-pmcg
In reply to Ajay KumarThis patch adds devicetree binding for perf/arm_smmuv3_pmu driver.
--- .../bindings/perf/arm-smmu-v3-pmcg.txt | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Documentation/devicetree/bindings/perf/arm-smmu-v3-pmcg.txt
Documentation/devicetree/bindings/perf/arm-smmu-v3-pmcg.txt new file +21 -0
@@ -0,0 +1,21 @@ +* ARM SMMU V3 PMCG + +Required properties: + +- compatible: should be "arm-smmu-v3-pmu" + +- reg: (standard registers property) physical address and size + of the performance counters registers block. + If Page 1 is present, specify the same. + +- interrupts: (standard interrupt property) single interrupt + generated by the SMMU PMU control block + +Example: + + pmcg@20002000 { + compatible = "arm-smmu-v3-pmu"; + reg = <0x0 0x20002000 0x0 0x1000>, + <0x0 0x20022000 0x0 0xE00>; /* Page 1 */ + interrupts = <0 181 4>; + };
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 2/4] Documentation: perf: Add documentation for arm-smmu-v3-pmcg
Quoted 3 lines · On Sun, 12 Jul 2020 22:03:39 +0530 Ajay Kumar <[email protected]> wrote:
This patch adds devicetree binding for perf/arm_smmuv3_pmu driver.
Signed-off-by Ajay Kumar <[email protected]>
New bindings want to be in yaml format.
Quoted 22 lines
--- .../bindings/perf/arm-smmu-v3-pmcg.txt | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Documentation/devicetree/bindings/perf/arm-smmu-v3-pmcg.txtDocumentation/devicetree/bindings/perf/arm-smmu-v3-pmcg.txt new file +11
-0@@ -0,0 +1,21 @@ +* ARM SMMU V3 PMCG + +Required properties: + +- compatible: should be "arm-smmu-v3-pmu" + +- reg: (standard registers property) physical address and size + of the performance counters registers block. + If Page 1 is present, specify the same. + +- interrupts: (standard interrupt property) single interrupt
Documentation/devicetree/bindings/perf/arm-smmu-v3-pmcg.txt line 21
Quoted 10 lines
Documentation/devicetree/bindings/perf/arm-smmu-v3-pmcg.txt new file +10
-0+ generated by the SMMU PMU control block + +Example: + + pmcg@20002000 { + compatible = "arm-smmu-v3-pmu"; + reg = <0x0 0x20002000 0x0 0x1000>, + <0x0 0x20022000 0x0 0xE00>; /* Page 1 */ + interrupts = <0 181 4>; + };
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 3/4 perf/smmuv3: add device tree support
In reply to Ajay KumarAdd a OF match table with compatible string to add device tree support onto arm_smmuv3_pmu driver.
--- drivers/perf/arm_smmuv3_pmu.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/perf/arm_smmuv3_pmu.c +6 -0
@@ -856,9 +856,15 @@ static void smmu_pmu_shutdown(struct platform_device *pdev)smmu_pmu_disable (&smmu_pmu->pmu); } +static const struct of_device_id arm_smmu_pmu_match[] = { + { .compatible ="arm-smmu-v3-pmu" , }, + {}, +}; +static struct platform_driver smmu_pmu_driver = { .driver = { .name ="arm-smmu-v3-pmcg" , + .of_match_table = arm_smmu_pmu_match, }, .probe = smmu_pmu_probe, .remove = smmu_pmu_remove,
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 4/4 perf/smmuv3: fix crash when platdata not specified
In reply to Ajay KumarThe arm_smmuv3_pmu driver assumes platform data is always available and exposes a possible NULL pointer deferencing at the below line.
model = *(u32 *)dev_get_platdata(smmu_pmu->dev);
This patch fixes the bug by adding a check prior to the deferencing of the platform data pointer.
--- drivers/perf/arm_smmuv3_pmu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/perf/arm_smmuv3_pmu.c +3 -2
@@ -710,9 +710,10 @@ static void smmu_pmu_reset(struct smmu_pmu *smmu_pmu)static void smmu_pmu_get_acpi_options (struct smmu_pmu *smmu_pmu) { -u32 model; +u32 model =0 ; - model = *(u32 *)dev_get_platdata (smmu_pmu->dev); +if (dev_get_platdata (smmu_pmu->dev)) + model = *(u32 *)dev_get_platdata (smmu_pmu->dev);switch (model) {case IORT_SMMU_V3_PMCG_HISI_HIP08 :
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 19 lines · On Sun, 12 Jul 2020 22:03:41 +0530 Ajay Kumar <[email protected]> wrote:
The
arm_smmuv3_pmudriver assumes platform data is always available and exposes a possible NULL pointer deferencing at the below line.model = *(u32 *)dev_get_platdata(smmu_pmu->dev);
This patch fixes the bug by adding a check prior to the deferencing of the platform data pointer.
Signed-off-by Ajay Kumar <[email protected]>--- drivers/perf/arm_smmuv3_pmu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/perf/arm_smmuv3_pmu.c +0
-0
drivers/perf/arm_smmuv3_pmu.c static void smmu_pmu_reset(struct smmu_pmu *smmu_pmu) · line 713
Quoted 5 lines
drivers/perf/arm_smmuv3_pmu.c +1
-1@@ -710,9 +710,10 @@ static void smmu_pmu_reset(struct smmu_pmu *smmu_pmu)static void smmu_pmu_get_acpi_options (struct smmu_pmu *smmu_pmu) { -u32 model; +u32 model =0 ;
Use the generic model define. Sure it's 0, but good to make it clear what the meaning of this default is.
It also seems likely you hit this because of you were using dt. If so, it seems 'odd' to be running a function explicitly mentioning acpi in it's name.
Also, should do this before introducing support that might lead to this path so as not to cause bisection problems.
Jonathan
drivers/perf/arm_smmuv3_pmu.c static void smmu_pmu_reset(struct smmu_pmu *smmu_pmu) · line 719
Quoted 7 lines
drivers/perf/arm_smmuv3_pmu.c +2
-1- model = *(u32 *)dev_get_platdata (smmu_pmu->dev); +if (dev_get_platdata (smmu_pmu->dev)) + model = *(u32 *)dev_get_platdata (smmu_pmu->dev);switch (model) {case IORT_SMMU_V3_PMCG_HISI_HIP08 :
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 19 lines · Ajay Kumar
The
arm_smmuv3_pmudriver assumes platform data is always available and exposes a possible NULL pointer deferencing at the below line.model = *(u32 *)dev_get_platdata(smmu_pmu->dev);
This patch fixes the bug by adding a check prior to the deferencing of the platform data pointer.
Signed-off-by Ajay Kumar <[email protected]>--- drivers/perf/arm_smmuv3_pmu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/perf/arm_smmuv3_pmu.c +0
-0
drivers/perf/arm_smmuv3_pmu.c static void smmu_pmu_reset(struct smmu_pmu *smmu_pmu) · line 716
Quoted 9 lines
drivers/perf/arm_smmuv3_pmu.c +3
-2@@ -710,9 +710,10 @@ static void smmu_pmu_reset(struct smmu_pmu *smmu_pmu)static void smmu_pmu_get_acpi_options (struct smmu_pmu *smmu_pmu) { -u32 model; +u32 model =0 ; - model = *(u32 *)dev_get_platdata (smmu_pmu->dev); +if (dev_get_platdata (smmu_pmu->dev)) + model = *(u32 *)dev_get_platdata (smmu_pmu->dev);
As I commented on the other series, ideally this could be something like:
if (dev->of_node) model = of_device_get_match_data(dev->of_node); else model = *(u32 *)dev_get_platdata(dev); /* from IORT */
(and lose the "acpi_" from the function name, obviously)
Robin.
drivers/perf/arm_smmuv3_pmu.c static void smmu_pmu_reset(struct smmu_pmu *smmu_pmu)
Quoted 4 lines
drivers/perf/arm_smmuv3_pmu.c +0
-0switch (model) {case IORT_SMMU_V3_PMCG_HISI_HIP08 :
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 0/4] Add DT support for arm_smmuv3_pmu driver
In reply to Ajay KumarQuoted 4 lines · Ajay Kumar
Currently, only those platforms using ACPI can enable
arm_smmuv3_pmudriver. This patchset adds support for enablingarm_smmuv3_pmudriver on platforms which do not enable ACPI and instead rely on DT.
This must be a popular topic all of a sudden, since it's barely a week since the last one!
https://lore.kernel.org/linux-arm-kernel/[email protected]/
I'm not sure whether Jay has seen my review since Alibaba's mail server apparently decided to reject the direct reply as spam, but some of what I said there applies here too. Could we please try to coordinate where we go from here so we're not all wasting time developing and reviewing multiple versions of the exact same thing?
Robin.
Quoted 7 lines
Ajay Kumar (4):
perf/smmuv3: Remove dependency onCONFIG_ACPI
Documentation: perf: Add documentation for arm-smmu-v3-pmcg perf/smmuv3: add device tree support
perf/smmuv3: fix crash when platdata not specified
Quoted 6 lines
.../bindings/perf/arm-smmu-v3-pmcg.txt | 21 +++++++++++++++++++ drivers/perf/Kconfig | 2 +- drivers/perf/arm_smmuv3_pmu.c | 11 ++++++++-- 3 files changed, 31 insertions(+), 3 deletions(-)create mode 100644
Documentation/devicetree/bindings/perf/arm-smmu-v3-pmcg.txt
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 0/4] Add DT support for arm_smmuv3_pmu driver
Quoted 10 lines · Robin Murphy
Quoted 4 lines · Ajay Kumar
Currently, only those platforms using ACPI can enable
arm_smmuv3_pmudriver. This patchset adds support for enablingarm_smmuv3_pmudriver on platforms which do not enable ACPI and instead rely on DT.This must be a popular topic all of a sudden, since it's barely a week since the last one!
JFYI, I don't have that mail (so can't reply directly), but hisi platforms which have SMMUv3 PMCG don't support DT intentionally, and there is a desire to avoid headache of HW-specific DT support there in future.
thanks
Quoted 22 lines
I'm not sure whether Jay has seen my review since Alibaba's mail server apparently decided to reject the direct reply as spam, but some of what I said there applies here too. Could we please try to coordinate where we go from here so we're not all wasting time developing and reviewing multiple versions of the exact same thing?
Robin.
Quoted 7 lines
Ajay Kumar (4):
perf/smmuv3: Remove dependency onCONFIG_ACPI
Documentation: perf: Add documentation for arm-smmu-v3-pmcg perf/smmuv3: add device tree support
perf/smmuv3: fix crash when platdata not specifiedQuoted 6 lines
.../bindings/perf/arm-smmu-v3-pmcg.txt | 21 +++++++++++++++++++ drivers/perf/Kconfig | 2 +- drivers/perf/arm_smmuv3_pmu.c | 11 ++++++++--
3 files changed, 31 insertions(+), 3 deletions(-)create mode 100644
Documentation/devicetree/bindings/perf/arm-smmu-v3-pmcg.txt
Quoted 5 lines
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
.
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 0/4] Add DT support for arm_smmuv3_pmu driver
Hi Robin and Garry,
Quoted 10 lines · John Garry
Quoted 9 lines · Robin Murphy
Quoted 4 lines · Ajay Kumar
Currently, only those platforms using ACPI can enable
arm_smmuv3_pmudriver. This patchset adds support for enablingarm_smmuv3_pmudriver on platforms which do not enable ACPI and instead rely on DT.This must be a popular topic all of a sudden, since it's barely a week since the last one!
Quoted 8 lines
JFYI, I don't have that mail (so can't reply directly), but hisi platforms which have SMMUv3 PMCG don't support DT intentionally, and there is a desire to avoid headache of HW-specific DT support there in future.
The patchset allows support for both DT and ACPI to co-exist.
Quoted 6 lines
Quoted 6 lines
I'm not sure whether Jay has seen my review since Alibaba's mail server apparently decided to reject the direct reply as spam, but some of what I said there applies here too. Could we please try to coordinate where we go from here so we're not all wasting time developing and reviewing multiple versions of the exact same thing?
Agreed. I checked Jay's patchset:
https://lore.kernel.org/linux-arm-kernel/[email protected]/
Pretty much tries to achieve the same thing. Its Jay's call now.
Quoted 28 lines
Quoted 21 lines
Robin.
Quoted 7 lines
Ajay Kumar (4):
perf/smmuv3: Remove dependency onCONFIG_ACPI
Documentation: perf: Add documentation for arm-smmu-v3-pmcg perf/smmuv3: add device tree support
perf/smmuv3: fix crash when platdata not specifiedQuoted 7 lines
.../bindings/perf/arm-smmu-v3-pmcg.txt | 21 +++++++++++++++++++ drivers/perf/Kconfig | 2 +- drivers/perf/arm_smmuv3_pmu.c | 11 ++++++++-- 3 files changed, 31 insertions(+), 3 deletions(-)create mode 100644
Documentation/devicetree/bindings/perf/arm-smmu-v3-pmcg.txtQuoted 5 lines
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
.
Quoted 5 lines
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 0/4] Add DT support for arm_smmuv3_pmu driver
In reply to John GarryQuoted 7 lines · John Garry
Quoted 6 lines · Robin Murphy
Quoted 4 lines · Ajay Kumar
Currently, only those platforms using ACPI can enable
arm_smmuv3_pmudriver. This patchset adds support for enablingarm_smmuv3_pmudriver on platforms which do not enable ACPI and instead rely on DT.
Quoted 6 lines
Quoted 4 lines
This must be a popular topic all of a sudden, since it's barely a week since the last one!
JFYI, I don't have that mail (so can't reply directly), but hisi platforms which have SMMUv3 PMCG don't support DT intentionally, and there is a desire to avoid headache of HW-specific DT support there in future.
Thanks John, I was wondering about that, since I do have a vague memory of a promise that you guys would never ask for DT support yourselves :)
Perhaps someone at Huawei can follow up directly with Alibaba about their use-case and whether there's a better way to support it upstream (if at all).
Bonus tip: If you download a "raw" link from lore and save it with a .eml extension, Thunderbird can then be convinced to open it in a manner which can be replied to.
Robin.
Quoted 31 lines
thanks
Quoted 27 lines
I'm not sure whether Jay has seen my review since Alibaba's mail server apparently decided to reject the direct reply as spam, but some of what I said there applies here too. Could we please try to coordinate where we go from here so we're not all wasting time developing and reviewing multiple versions of the exact same thing?
Robin.
Quoted 7 lines
Ajay Kumar (4):
perf/smmuv3: Remove dependency onCONFIG_ACPI
Documentation: perf: Add documentation for arm-smmu-v3-pmcg perf/smmuv3: add device tree support
perf/smmuv3: fix crash when platdata not specifiedQuoted 6 lines
.../bindings/perf/arm-smmu-v3-pmcg.txt | 21 +++++++++++++++++++ drivers/perf/Kconfig | 2 +- drivers/perf/arm_smmuv3_pmu.c | 11 ++++++++--
3 files changed, 31 insertions(+), 3 deletions(-)create mode 100644
Documentation/devicetree/bindings/perf/arm-smmu-v3-pmcg.txt_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
.
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel