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
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 |
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
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}
drivers/perf/arm_smmuv3_pmu.c+41−7
@@ -35,6 +35,7 @@ · 34 unmodified lines
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 @@ · 52 unmodified lines
93 94
94#define SMMU_PMCG_PA_SHIFT 1295#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 { · 9 unmodified lines
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, · 108 unmodified lines
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 counter230 /*
227 * size, so that even in the case of extreme interrupt latency the231 * 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) · 428 unmodified lines
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) · 73 unmodified lines
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,
include/linux/acpi_iort.h+1−0
@@ -32,6 +32,7 @@ · 31 unmodified lines
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);

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