aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShameer Kolothum <shameerali.kolothum.thodi@huawei.com>2019-03-26 11:17:53 -0400
committerWill Deacon <will.deacon@arm.com>2019-04-04 11:49:22 -0400
commit24062fe85860debfdae0eeaa495f27c9971ec163 (patch)
tree95df5553d96f619adbcb5728ec711a8dbf5aa1cf
parentf202cdab3b48d8c2c1846c938ea69cb8aa897699 (diff)
perf/smmuv3: Enable HiSilicon Erratum 162001800 quirk
HiSilicon erratum 162001800 describes the limitation of SMMUv3 PMCG implementation on HiSilicon Hip08 platforms. On these platforms, the PMCG event counter registers (SMMU_PMCG_EVCNTRn) are read only and as a result it is not possible to set the initial counter period value on event monitor start. To work around this, the current value of the counter is read and used for delta calculations. OEM information from ACPI header is used to identify the affected hardware platforms. Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> Reviewed-by: Hanjun Guo <hanjun.guo@linaro.org> Reviewed-by: Robin Murphy <robin.murphy@arm.com> Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> [will: update silicon-errata.txt and add reason string to acpi match] Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r--Documentation/arm64/silicon-errata.txt1
-rw-r--r--drivers/acpi/arm64/iort.c16
-rw-r--r--drivers/perf/arm_smmuv3_pmu.c48
-rw-r--r--include/linux/acpi_iort.h1
4 files changed, 58 insertions, 8 deletions
diff --git a/Documentation/arm64/silicon-errata.txt b/Documentation/arm64/silicon-errata.txt
index d1e2bb801e1b..c00efb639e46 100644
--- a/Documentation/arm64/silicon-errata.txt
+++ b/Documentation/arm64/silicon-errata.txt
@@ -77,6 +77,7 @@ stable kernels.
77| Hisilicon | Hip0{5,6,7} | #161010101 | HISILICON_ERRATUM_161010101 | 77| Hisilicon | Hip0{5,6,7} | #161010101 | HISILICON_ERRATUM_161010101 |
78| Hisilicon | Hip0{6,7} | #161010701 | N/A | 78| Hisilicon | Hip0{6,7} | #161010701 | N/A |
79| Hisilicon | Hip07 | #161600802 | HISILICON_ERRATUM_161600802 | 79| Hisilicon | Hip07 | #161600802 | HISILICON_ERRATUM_161600802 |
80| Hisilicon | Hip08 SMMU PMCG | #162001800 | N/A |
80| | | | | 81| | | | |
81| Qualcomm Tech. | Kryo/Falkor v1 | E1003 | QCOM_FALKOR_ERRATUM_1003 | 82| Qualcomm Tech. | Kryo/Falkor v1 | E1003 | QCOM_FALKOR_ERRATUM_1003 |
82| Qualcomm Tech. | Falkor v1 | E1009 | QCOM_FALKOR_ERRATUM_1009 | 83| Qualcomm Tech. | Falkor v1 | E1009 | QCOM_FALKOR_ERRATUM_1009 |
diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
index e2c9b26bbee6..2d70b349bd6c 100644
--- a/drivers/acpi/arm64/iort.c
+++ b/drivers/acpi/arm64/iort.c
@@ -1366,9 +1366,23 @@ static void __init arm_smmu_v3_pmcg_init_resources(struct resource *res,
1366 ACPI_EDGE_SENSITIVE, &res[2]); 1366 ACPI_EDGE_SENSITIVE, &res[2]);
1367} 1367}
1368 1368
1369static struct acpi_platform_list pmcg_plat_info[] __initdata = {
1370 /* HiSilicon Hip08 Platform */
1371 {"HISI ", "HIP08 ", 0, ACPI_SIG_IORT, greater_than_or_equal,
1372 "Erratum #162001800", IORT_SMMU_V3_PMCG_HISI_HIP08},
1373 { }
1374};
1375
1369static int __init arm_smmu_v3_pmcg_add_platdata(struct platform_device *pdev) 1376static int __init arm_smmu_v3_pmcg_add_platdata(struct platform_device *pdev)
1370{ 1377{
1371 u32 model = IORT_SMMU_V3_PMCG_GENERIC; 1378 u32 model;
1379 int idx;
1380
1381 idx = acpi_match_platform_list(pmcg_plat_info);
1382 if (idx >= 0)
1383 model = pmcg_plat_info[idx].data;
1384 else
1385 model = IORT_SMMU_V3_PMCG_GENERIC;
1372 1386
1373 return platform_device_add_data(pdev, &model, sizeof(model)); 1387 return platform_device_add_data(pdev, &model, sizeof(model));
1374} 1388}
diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c
index a4f4b488a2de..da71c741cb46 100644
--- a/drivers/perf/arm_smmuv3_pmu.c
+++ b/drivers/perf/arm_smmuv3_pmu.c
@@ -35,6 +35,7 @@
35 */ 35 */
36 36
37#include <linux/acpi.h> 37#include <linux/acpi.h>
38#include <linux/acpi_iort.h>
38#include <linux/bitfield.h> 39#include <linux/bitfield.h>
39#include <linux/bitops.h> 40#include <linux/bitops.h>
40#include <linux/cpuhotplug.h> 41#include <linux/cpuhotplug.h>
@@ -93,6 +94,8 @@
93 94
94#define SMMU_PMCG_PA_SHIFT 12 95#define SMMU_PMCG_PA_SHIFT 12
95 96
97#define SMMU_PMCG_EVCNTR_RDONLY BIT(0)
98
96static int cpuhp_state_num; 99static int cpuhp_state_num;
97 100
98struct smmu_pmu { 101struct smmu_pmu {
@@ -108,6 +111,7 @@ struct smmu_pmu {
108 void __iomem *reg_base; 111 void __iomem *reg_base;
109 void __iomem *reloc_base; 112 void __iomem *reloc_base;
110 u64 counter_mask; 113 u64 counter_mask;
114 u32 options;
111 bool global_filter; 115 bool global_filter;
112 u32 global_filter_span; 116 u32 global_filter_span;
113 u32 global_filter_sid; 117 u32 global_filter_sid;
@@ -222,15 +226,27 @@ static void smmu_pmu_set_period(struct smmu_pmu *smmu_pmu,
222 u32 idx = hwc->idx; 226 u32 idx = hwc->idx;
223 u64 new; 227 u64 new;
224 228
225 /* 229 if (smmu_pmu->options & SMMU_PMCG_EVCNTR_RDONLY) {
226 * We limit the max period to half the max counter value of the counter 230 /*
227 * size, so that even in the case of extreme interrupt latency the 231 * On platforms that require this quirk, if the counter starts
228 * counter will (hopefully) not wrap past its initial value. 232 * at < half_counter value and wraps, the current logic of
229 */ 233 * handling the overflow may not work. It is expected that,
230 new = smmu_pmu->counter_mask >> 1; 234 * those platforms will have full 64 counter bits implemented
235 * so that such a possibility is remote(eg: HiSilicon HIP08).
236 */
237 new = smmu_pmu_counter_get_value(smmu_pmu, idx);
238 } else {
239 /*
240 * We limit the max period to half the max counter value
241 * of the counter size, so that even in the case of extreme
242 * interrupt latency the counter will (hopefully) not wrap
243 * past its initial value.
244 */
245 new = smmu_pmu->counter_mask >> 1;
246 smmu_pmu_counter_set_value(smmu_pmu, idx, new);
247 }
231 248
232 local64_set(&hwc->prev_count, new); 249 local64_set(&hwc->prev_count, new);
233 smmu_pmu_counter_set_value(smmu_pmu, idx, new);
234} 250}
235 251
236static void smmu_pmu_set_event_filter(struct perf_event *event, 252static void smmu_pmu_set_event_filter(struct perf_event *event,
@@ -665,6 +681,22 @@ static void smmu_pmu_reset(struct smmu_pmu *smmu_pmu)
665 smmu_pmu->reloc_base + SMMU_PMCG_OVSCLR0); 681 smmu_pmu->reloc_base + SMMU_PMCG_OVSCLR0);
666} 682}
667 683
684static void smmu_pmu_get_acpi_options(struct smmu_pmu *smmu_pmu)
685{
686 u32 model;
687
688 model = *(u32 *)dev_get_platdata(smmu_pmu->dev);
689
690 switch (model) {
691 case IORT_SMMU_V3_PMCG_HISI_HIP08:
692 /* HiSilicon Erratum 162001800 */
693 smmu_pmu->options |= SMMU_PMCG_EVCNTR_RDONLY;
694 break;
695 }
696
697 dev_notice(smmu_pmu->dev, "option mask 0x%x\n", smmu_pmu->options);
698}
699
668static int smmu_pmu_probe(struct platform_device *pdev) 700static int smmu_pmu_probe(struct platform_device *pdev)
669{ 701{
670 struct smmu_pmu *smmu_pmu; 702 struct smmu_pmu *smmu_pmu;
@@ -744,6 +776,8 @@ static int smmu_pmu_probe(struct platform_device *pdev)
744 return -EINVAL; 776 return -EINVAL;
745 } 777 }
746 778
779 smmu_pmu_get_acpi_options(smmu_pmu);
780
747 /* Pick one CPU to be the preferred one to use */ 781 /* Pick one CPU to be the preferred one to use */
748 smmu_pmu->on_cpu = raw_smp_processor_id(); 782 smmu_pmu->on_cpu = raw_smp_processor_id();
749 WARN_ON(irq_set_affinity_hint(smmu_pmu->irq, 783 WARN_ON(irq_set_affinity_hint(smmu_pmu->irq,
diff --git a/include/linux/acpi_iort.h b/include/linux/acpi_iort.h
index 052ef7b9f985..723e4dfa1c14 100644
--- a/include/linux/acpi_iort.h
+++ b/include/linux/acpi_iort.h
@@ -32,6 +32,7 @@
32 * do with hardware or with IORT specification. 32 * do with hardware or with IORT specification.
33 */ 33 */
34#define IORT_SMMU_V3_PMCG_GENERIC 0x00000000 /* Generic SMMUv3 PMCG */ 34#define IORT_SMMU_V3_PMCG_GENERIC 0x00000000 /* Generic SMMUv3 PMCG */
35#define IORT_SMMU_V3_PMCG_HISI_HIP08 0x00000001 /* HiSilicon HIP08 PMCG */
35 36
36int iort_register_domain_token(int trans_id, phys_addr_t base, 37int iort_register_domain_token(int trans_id, phys_addr_t base,
37 struct fwnode_handle *fw_node); 38 struct fwnode_handle *fw_node);