driver inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/9840 ---------------------------------------------------------------------- Add workaround for hisi pmg_max When a specific device cannot be identified through the IIDR. Signed-off-by: Yifan Wu <wuyifan50@huawei.com> Signed-off-by: Hongye Lin <linhongye@h-partners.com> --- drivers/platform/mpam/mpam_devices.c | 27 ++++++++++++++++++--------- drivers/platform/mpam/mpam_internal.h | 1 + 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/platform/mpam/mpam_devices.c b/drivers/platform/mpam/mpam_devices.c index 39dd2826a7b3..217155f612e3 100644 --- a/drivers/platform/mpam/mpam_devices.c +++ b/drivers/platform/mpam/mpam_devices.c @@ -109,6 +109,11 @@ static const struct midr_range hisi_cpus[] = { { /* sentinel */ } }; +/* Values for the HISI workaround */ +#define HIP12_ACPI_PLAT { "HISI ", "HIP12 ", 0, ACPI_SIG_MPAM, all_versions } +#define HIP12B_ACPI_PLAT { "HISI ", "HIP12B ", 0, ACPI_SIG_MPAM, all_versions } +#define HIP13_ACPI_PLAT { "HISI ", "HIP13 ", 0, ACPI_SIG_MPAM, all_versions } + static u32 __mpam_read_reg(struct mpam_msc *msc, u16 reg) { WARN_ON_ONCE(reg + sizeof(u32) > msc->mapped_hwpage_sz); @@ -615,6 +620,15 @@ static struct mpam_msc_ris *mpam_get_or_create_ris(struct mpam_msc *msc, } static const struct mpam_quirk mpam_quirks[] = { + { + .iidr_mask = MPAM_IIDR_MATCH_ONE, + .plat = (struct acpi_platform_list[]) { + HIP12_ACPI_PLAT, + HIP12B_ACPI_PLAT, + HIP13_ACPI_PLAT, + {} }, + .workaround = HISI_SHRINK_PMG_MAX, + }, { NULL } /* Sentinel */ }; @@ -817,14 +831,6 @@ static void mpam_ris_hw_probe(struct mpam_msc_ris *ris) } } -static int mpam_pmg_max_workaround(u64 idr) -{ - if (is_midr_in_range_list(hisi_cpus)) - return 0; - - return FIELD_GET(MPAMF_IDR_PMG_MAX, idr); -} - static int mpam_msc_hw_probe(struct mpam_msc *msc) { u64 idr; @@ -853,7 +859,10 @@ static int mpam_msc_hw_probe(struct mpam_msc *msc) /* Use these values so partid/pmg always starts with a valid value */ msc->partid_max = FIELD_GET(MPAMF_IDR_PARTID_MAX, idr); - msc->pmg_max = mpam_pmg_max_workaround(idr); + msc->pmg_max = FIELD_GET(MPAMF_IDR_PMG_MAX, idr); + + if (mpam_has_quirk(HISI_SHRINK_PMG_MAX, msc)) + msc->pmg_max = 0; for (ris_idx = 0; ris_idx <= msc->ris_max; ris_idx++) { spin_lock(&msc->part_sel_lock); diff --git a/drivers/platform/mpam/mpam_internal.h b/drivers/platform/mpam/mpam_internal.h index f70ad200beb9..acce68708de2 100644 --- a/drivers/platform/mpam/mpam_internal.h +++ b/drivers/platform/mpam/mpam_internal.h @@ -148,6 +148,7 @@ static inline void mpam_clear_feature(enum mpam_device_features feat, /* Workaround bits for msc->quirks */ enum mpam_device_quirks { + HISI_SHRINK_PMG_MAX, MPAM_QUIRK_LAST }; -- 2.33.0