perf/smmuv3: Enable HiSilicon Erratum 162001900 quirk for HIP08/09
Subsystems (5)
PATCH 1/1 perf/smmuv3: Enable HiSilicon Erratum 162001900 quirk for HIP08/09
From: Yicong Yang <[email protected]>
Some HiSilicon SMMU PMCG suffers the erratum 162001900 that the PMU disable control sometimes fail to disable the counters. This will lead to error or inaccurate data since before we enable the counters the counter's still counting for the event used in last perf session.
This patch tries to fix this by hardening the global disable process. Before disable the PMU, writing an invalid event type (0xffff) to focibly stop the counters. Correspondingly restore each events on pmu::pmu_enable().
--- Documentation/arch/arm64/silicon-errata.rst | 3 ++ drivers/acpi/arm64/iort.c | 5 ++- drivers/perf/arm_smmuv3_pmu.c | 49 ++++++++++++++++++++- include/linux/acpi_iort.h | 1 + 4 files changed, 56 insertions(+), 2 deletions(-)
Documentation/arch/arm64/silicon-errata.rst +3 -0
@@ -195,6 +195,9 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | Hisilicon | Hip08 SMMU PMCG | #162001800 | N/A | +----------------+-----------------+-----------------+-----------------------------+ +| Hisilicon | Hip08 SMMU PMCG | #162001900 | N/A | +| | Hip09 SMMU PMCG | | | ++----------------+-----------------+-----------------+-----------------------------+ +----------------+-----------------+-----------------+-----------------------------+ | Qualcomm Tech. | Kryo/Falkor v1 | E1003 | QCOM_FALKOR_ERRATUM_1003 | +----------------+-----------------+-----------------+-----------------------------+
drivers/acpi/arm64/iort.c +4 -1
@@ -1708,7 +1708,10 @@ static void __init arm_smmu_v3_pmcg_init_resources(struct resource *res,static struct acpi_platform_list pmcg_plat_info[]__initdata = {/* HiSilicon Hip08 Platform */ {"HISI " ,"HIP08 " ,0 ,ACPI_SIG_IORT , greater_than_or_equal, -"Erratum #162001800" ,IORT_SMMU_V3_PMCG_HISI_HIP08 }, +"Erratum #162001800, Erratum #162001900" ,IORT_SMMU_V3_PMCG_HISI_HIP08 }, +/* HiSilicon Hip09 Platform */ + {"HISI " ,"HIP09 " ,0 ,ACPI_SIG_IORT , greater_than_or_equal, +"Erratum #162001900" ,IORT_SMMU_V3_PMCG_HISI_HIP09 }, { } };
drivers/perf/arm_smmuv3_pmu.c +48 -1
79 lines not on this page · raw message
include/linux/acpi_iort.h +1 -0
@@ -21,6 +21,7 @@*/ #define IORT_SMMU_V3_PMCG_GENERIC 0x00000000/* Generic SMMUv3 PMCG */ #define IORT_SMMU_V3_PMCG_HISI_HIP08 0x00000001/* HiSilicon HIP08 PMCG */ +#define IORT_SMMU_V3_PMCG_HISI_HIP09 0x00000002/* HiSilicon HIP09 PMCG */ int iort_register_domain_token (int trans_id,phys_addr_t base,struct fwnode_handle *fw_node);
Signature · 1 line
2.24.0
Will Deacon
maintainerQuoted 20 lines · Yicong Yang
drivers/perf/arm_smmuv3_pmu.c +5
-0@@ -115,6 +115,7 @@#define SMMU_PMCG_PA_SHIFT 12#define SMMU_PMCG_EVCNTR_RDONLY BIT(0) +#define SMMU_PMCG_HARDEN_DISABLE BIT(1)static int cpuhp_state_num;@@ -150,6 +151,22 @@ SMMU_PMU_EVENT_ATTR_EXTRACTOR(filter_stream_id, config1, 0, 31);SMMU_PMU_EVENT_ATTR_EXTRACTOR (filter_span, config1,32 ,32 );SMMU_PMU_EVENT_ATTR_EXTRACTOR (filter_enable, config1,33 ,33 ); +static int smmu_pmu_apply_event_filter (struct smmu_pmu *smmu_pmu, +struct perf_event *event,int idx); + +static inline void smmu_pmu_enable_quirk_hip08_09 (struct pmu *pmu)
drivers/perf/arm_smmuv3_pmu.c SMMU_PMU_EVENT_ATTR_EXTRACTOR(filter_stream_id, config1, 0, 31); · line 167
Quoted 10 lines
drivers/perf/arm_smmuv3_pmu.c +10
-0+{ +struct smmu_pmu *smmu_pmu =to_smmu_pmu (pmu); +unsigned int idx; + +for_each_set_bit (idx, smmu_pmu->used_counters, smmu_pmu->num_counters) +smmu_pmu_apply_event_filter (smmu_pmu, smmu_pmu->events[idx], idx); + +writel (SMMU_PMCG_IRQ_CTRL_IRQEN , + smmu_pmu->reg_base +SMMU_PMCG_IRQ_CTRL ); +writel (SMMU_PMCG_CR_ENABLE , smmu_pmu->reg_base +SMMU_PMCG_CR );
Can you tail-call smmu_pmu_enable() instead of duplicating it here?
Quoted 5 lines
drivers/perf/arm_smmuv3_pmu.c +5
-0+static inline void smmu_pmu_disable_quirk_hip08_09 (struct pmu *pmu) +{ +struct smmu_pmu *smmu_pmu =to_smmu_pmu (pmu); +unsigned int idx; +
drivers/perf/arm_smmuv3_pmu.c static inline void smmu_pmu_enable(struct pmu *pmu) · line 193
Quoted 10 lines
drivers/perf/arm_smmuv3_pmu.c +10
-0+/* +* The global disable of PMU sometimes fail to stop the counting. +* Harden this by writing an invalid event type to each used counter +* to forcibly stop counting. +*/ +for_each_set_bit (idx, smmu_pmu->used_counters, smmu_pmu->num_counters) +writel (0xffff , smmu_pmu->reg_base +SMMU_PMCG_EVTYPER (idx)); + +writel (0 , smmu_pmu->reg_base +SMMU_PMCG_CR ); +writel (0 , smmu_pmu->reg_base +SMMU_PMCG_IRQ_CTRL );
Same things here, but with smmu_pmu_disable()
Will
Quoted 43 lines · Will Deacon
Quoted 20 lines · Yicong Yang
drivers/perf/arm_smmuv3_pmu.c +5
-0@@ -115,6 +115,7 @@#define SMMU_PMCG_PA_SHIFT 12#define SMMU_PMCG_EVCNTR_RDONLY BIT(0) +#define SMMU_PMCG_HARDEN_DISABLE BIT(1)static int cpuhp_state_num;@@ -150,6 +151,22 @@ SMMU_PMU_EVENT_ATTR_EXTRACTOR(filter_stream_id, config1, 0, 31);SMMU_PMU_EVENT_ATTR_EXTRACTOR (filter_span, config1,32 ,32 );SMMU_PMU_EVENT_ATTR_EXTRACTOR (filter_enable, config1,33 ,33 ); +static int smmu_pmu_apply_event_filter (struct smmu_pmu *smmu_pmu, +struct perf_event *event,int idx); + +static inline void smmu_pmu_enable_quirk_hip08_09 (struct pmu *pmu)drivers/perf/arm_smmuv3_pmu.c SMMU_PMU_EVENT_ATTR_EXTRACTOR(filter_stream_id, config1, 0, 31); · line 167
Quoted 10 lines
drivers/perf/arm_smmuv3_pmu.c +10
-0+{ +struct smmu_pmu *smmu_pmu =to_smmu_pmu (pmu); +unsigned int idx; + +for_each_set_bit (idx, smmu_pmu->used_counters, smmu_pmu->num_counters) +smmu_pmu_apply_event_filter (smmu_pmu, smmu_pmu->events[idx], idx); + +writel (SMMU_PMCG_IRQ_CTRL_IRQEN , + smmu_pmu->reg_base +SMMU_PMCG_IRQ_CTRL ); +writel (SMMU_PMCG_CR_ENABLE , smmu_pmu->reg_base +SMMU_PMCG_CR );Can you tail-call
smmu_pmu_enable()instead of duplicating it here?Quoted 9 lines
drivers/perf/arm_smmuv3_pmu.c +9
-0+static inline void smmu_pmu_disable_quirk_hip08_09 (struct pmu *pmu) +{ +struct smmu_pmu *smmu_pmu =to_smmu_pmu (pmu); +unsigned int idx; + +/* +* The global disable of PMU sometimes fail to stop the counting. +* Harden this by writing an invalid event type to each used counter +* to forcibly stop counting.
Quoted 9 lines
drivers/perf/arm_smmuv3_pmu.c static inline void smmu_pmu_enable(struct pmu *pmu) · line 193
Quoted 6 lines
drivers/perf/arm_smmuv3_pmu.c +6
-0+*/ +for_each_set_bit (idx, smmu_pmu->used_counters, smmu_pmu->num_counters) +writel (0xffff , smmu_pmu->reg_base +SMMU_PMCG_EVTYPER (idx)); + +writel (0 , smmu_pmu->reg_base +SMMU_PMCG_CR ); +writel (0 , smmu_pmu->reg_base +SMMU_PMCG_IRQ_CTRL );Same things here, but with
smmu_pmu_disable()
Sure. Will tail call smmu_pmu_{enable, disable} in both case to avoid duplication. Thanks for the comments.
Thanks.
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel