History

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.

Shameer Kolothum committed 7 years ago

Commit 24062fe1 parent f202cda4 files · +58 −8Browse files

Unified · Split

4 files
  1. Documentation/arm64/silicon-errata.txt +1 −0
  2. drivers/acpi/arm64/iort.c +15 −1
  3. drivers/perf/arm_smmuv3_pmu.c +41 −7
  4. include/linux/acpi_iort.h +1 −0
Documentation/arm64/silicon-errata.txt+1−0
@@ -77,6 +77,7 @@ stable kernels. · 76 unmodified lines
7777 | Hisilicon | Hip0{5,6,7} | #161010101 | HISILICON_ERRATUM_161010101 |
7878 | Hisilicon | Hip0{6,7} | #161010701 | N/A |
7979 | Hisilicon | Hip07 | #161600802 | HISILICON_ERRATUM_161600802 |
80+| Hisilicon | Hip08 SMMU PMCG | #162001800 | N/A |
8081 | | | | |
8182 | Qualcomm Tech. | Kryo/Falkor v1 | E1003 | QCOM_FALKOR_ERRATUM_1003 |
8283 | Qualcomm Tech. | Falkor v1 | E1009 | QCOM_FALKOR_ERRATUM_1009 |
drivers/acpi/arm64/iort.c+15−1
@@ -1366,9 +1366,23 @@ static void __init arm_smmu_v3_pmcg_init_resources(struct resource *res, · 1365 unmodified lines
13661366 ACPI_EDGE_SENSITIVE, &res[2]);
13671367 }
13681368
1369+static 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+
13691376 static int __init arm_smmu_v3_pmcg_add_platdata(struct platform_device *pdev)
13701377 {
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;
13721386
13731387 return platform_device_add_data(pdev, &model, sizeof(model));
13741388 }
drivers/perf/arm_smmuv3_pmu.c+41−7
@@ -35,6 +35,7 @@ · 34 unmodified lines
3535 */
3636
3737 #include <linux/acpi.h>
38+#include <linux/acpi_iort.h>
3839 #include <linux/bitfield.h>
3940 #include <linux/bitops.h>
4041 #include <linux/cpuhotplug.h>
@@ -93,6 +94,8 @@ · 52 unmodified lines
9394
9495 #define SMMU_PMCG_PA_SHIFT 12
9596
97+#define SMMU_PMCG_EVCNTR_RDONLY BIT(0)
98+
9699 static int cpuhp_state_num;
97100
98101 struct smmu_pmu {
@@ -108,6 +111,7 @@ struct smmu_pmu { · 9 unmodified lines
108111 void __iomem *reg_base;
109112 void __iomem *reloc_base;
110113 u64 counter_mask;
114+ u32 options;
111115 bool global_filter;
112116 u32 global_filter_span;
113117 u32 global_filter_sid;
@@ -222,15 +226,27 @@ static void smmu_pmu_set_period(struct smmu_pmu *smmu_pmu, · 108 unmodified lines
222226 u32 idx = hwc->idx;
223227 u64 new;
224228
225− /*
226− * We limit the max period to half the max counter value of the counter
227− * size, so that even in the case of extreme interrupt latency the
228− * counter will (hopefully) not wrap past its initial value.
229− */
230− new = smmu_pmu->counter_mask >> 1;
229+ if (smmu_pmu->options & SMMU_PMCG_EVCNTR_RDONLY) {
230+ /*
231+ * On platforms that require this quirk, if the counter starts
232+ * at < half_counter value and wraps, the current logic of
233+ * handling the overflow may not work. It is expected that,
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+ }
231248
232249 local64_set(&hwc->prev_count, new);
233− smmu_pmu_counter_set_value(smmu_pmu, idx, new);
234250 }
235251
236252 static void smmu_pmu_set_event_filter(struct perf_event *event,
@@ -665,6 +681,22 @@ static void smmu_pmu_reset(struct smmu_pmu *smmu_pmu) · 428 unmodified lines
665681 smmu_pmu->reloc_base + SMMU_PMCG_OVSCLR0);
666682 }
667683
684+static 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+
668700 static int smmu_pmu_probe(struct platform_device *pdev)
669701 {
670702 struct smmu_pmu *smmu_pmu;
@@ -744,6 +776,8 @@ static int smmu_pmu_probe(struct platform_device *pdev) · 73 unmodified lines
744776 return -EINVAL;
745777 }
746778
779+ smmu_pmu_get_acpi_options(smmu_pmu);
780+
747781 /* Pick one CPU to be the preferred one to use */
748782 smmu_pmu->on_cpu = raw_smp_processor_id();
749783 WARN_ON(irq_set_affinity_hint(smmu_pmu->irq,
include/linux/acpi_iort.h+1−0
@@ -32,6 +32,7 @@ · 31 unmodified lines
3232 * do with hardware or with IORT specification.
3333 */
3434 #define IORT_SMMU_V3_PMCG_GENERIC 0x00000000 /* Generic SMMUv3 PMCG */
35+#define IORT_SMMU_V3_PMCG_HISI_HIP08 0x00000001 /* HiSilicon HIP08 PMCG */
3536
3637 int iort_register_domain_token(int trans_id, phys_addr_t base,
3738 struct fwnode_handle *fw_node);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t