driver inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/9840 ---------------------------------------------------------------------- Add workaround for hisi mbm 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> --- arch/x86/include/asm/resctrl.h | 2 ++ drivers/platform/mpam/mpam_devices.c | 47 ++++++++++----------------- drivers/platform/mpam/mpam_internal.h | 1 + drivers/platform/mpam/mpam_resctrl.c | 9 +++++ fs/resctrl/rdtgroup.c | 6 ++-- include/linux/arm_mpam.h | 2 +- 6 files changed, 34 insertions(+), 33 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 089742970cc1..6aa970e4beba 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -81,6 +81,8 @@ static inline void resctrl_arch_disable_mon(void) static_branch_dec_cpuslocked(&rdt_enable_key); } +static inline bool resctrl_arch_would_mbm_overflow(struct rdt_resource *r) { return true; } + /* * __resctrl_sched_in() - Writes the task's CLOSid/RMID to IA32_PQR_MSR * diff --git a/drivers/platform/mpam/mpam_devices.c b/drivers/platform/mpam/mpam_devices.c index d1686290ac35..8d0eb6d5a8ed 100644 --- a/drivers/platform/mpam/mpam_devices.c +++ b/drivers/platform/mpam/mpam_devices.c @@ -93,22 +93,6 @@ static DECLARE_WORK(mpam_broken_work, &mpam_disable); */ LIST_HEAD(mpam_classes); -static const struct midr_range hip12_cpus[] = { - MIDR_ALL_VERSIONS(MIDR_HISI_HIP12), - { /* sentinel */ } -}; - -static const struct midr_range hip13_cpus[] = { - MIDR_ALL_VERSIONS(MIDR_HISI_HIP13), - { /* sentinel */ } -}; - -static const struct midr_range hisi_cpus[] = { - MIDR_ALL_VERSIONS(MIDR_HISI_HIP12), - MIDR_ALL_VERSIONS(MIDR_HISI_HIP13), - { /* sentinel */ } -}; - /* Values for the HISI workaround */ #define HIP09_ACPI_PLAT { "HISI ", "HIP09 ", 0, ACPI_SIG_MPAM, all_versions } #define HIP09A_ACPI_PLAT { "HISI ", "HIP09A ", 0, ACPI_SIG_MPAM, all_versions } @@ -735,6 +719,22 @@ static const struct mpam_quirk mpam_quirks[] = { {} }, .workaround = HISI_EXPAND_LLC_GRAN, }, + { + .iidr_mask = MPAM_IIDR_MATCH_ONE, + .plat = (struct acpi_platform_list[]) { + /* Non-HiSilicon CPUs and HIP13 need overflow handling */ + HIP09_ACPI_PLAT, + HIP09A_ACPI_PLAT, + HIP10_ACPI_PLAT, + HIP10A_ACPI_PLAT, + HIP10B_ACPI_PLAT, + HIP10C_ACPI_PLAT, + HIP10D_ACPI_PLAT, + HIP12_ACPI_PLAT, + HIP12B_ACPI_PLAT, + {} }, + .workaround = HISI_SKIP_MBM_OVERFLOW, + }, { NULL } /* Sentinel */ }; @@ -1162,16 +1162,6 @@ static u64 mpam_msmon_overflow_val(struct mpam_msc_ris *ris) return GENMASK_ULL(30, 0) << ris->props.mbwu_scale; } -bool resctrl_arch_would_mbm_overflow(void) -{ - /* Non-HiSilicon CPUs and HIP13 need overflow handling */ - if (read_cpuid_implementor() != ARM_CPU_IMP_HISI) - return true; - - /* HIP13 is the exception among HiSilicon CPUs */ - return is_midr_in_range_list(hip13_cpus); -} - static bool mpam_ris_has_nrdy_bit(struct mpam_msc_ris *ris) { if (ris->comp->class->type == MPAM_CLASS_MEMORY) @@ -1311,9 +1301,8 @@ static void __ris_msmon_read(void *arg) * instead the scaled count of bytes transferred since the monitor * was last reset in the latest version (DDI0598D_b). */ - if (ris->comp->class->type == MPAM_CLASS_MEMORY) { - if (!resctrl_arch_would_mbm_overflow()) - break; + if (mpam_has_quirk(HISI_SKIP_MBM_OVERFLOW, msc)) { + break; } /* Add any pre-overflow value to the mbwu_state->val */ diff --git a/drivers/platform/mpam/mpam_internal.h b/drivers/platform/mpam/mpam_internal.h index 63e2b5c9a66f..023bf0240ce1 100644 --- a/drivers/platform/mpam/mpam_internal.h +++ b/drivers/platform/mpam/mpam_internal.h @@ -158,6 +158,7 @@ enum mpam_device_quirks { HISI_SHRINK_MIN_CBM, HISI_CSU_WORKAROUND, HISI_EXPAND_LLC_GRAN, + HISI_SKIP_MBM_OVERFLOW, MPAM_QUIRK_LAST }; diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index df9cc2201d24..938d3606209f 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -553,6 +553,15 @@ static bool mpam_skip_check_l2_overflow(struct mpam_component *comp, return ret; } +bool resctrl_arch_would_mbm_overflow(struct rdt_resource *r) +{ + struct mpam_resctrl_res *res; + + res = container_of(r, struct mpam_resctrl_res, resctrl_res); + + return !mpam_has_quirk(HISI_SKIP_MBM_OVERFLOW, res->class); +} + int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain *d, u32 closid, u32 rmid, enum resctrl_event_id eventid, u64 *val, void *arch_mon_ctx) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 58b070f76bb4..499848055cad 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2692,7 +2692,7 @@ void resctrl_setup_dom_overflow(struct rdt_resource *r) struct rdt_domain *d; if (resctrl_arch_is_mbm_enabled(r->rid) && - resctrl_arch_would_mbm_overflow()) { + resctrl_arch_would_mbm_overflow(r)) { list_for_each_entry(d, &r->domains, list) mbm_setup_overflow_handler(d, MBM_OVERFLOW_INTERVAL, RESCTRL_PICK_ANY_CPU); @@ -4148,7 +4148,7 @@ int resctrl_online_domain(struct rdt_resource *r, struct rdt_domain *d) if (err) goto out_unlock; - if (resctrl_arch_is_mbm_enabled(r->rid) && resctrl_arch_would_mbm_overflow()) { + if (resctrl_arch_is_mbm_enabled(r->rid) && resctrl_arch_would_mbm_overflow(r)) { INIT_DELAYED_WORK(&d->mbm_over, mbm_handle_overflow); mbm_setup_overflow_handler(d, MBM_OVERFLOW_INTERVAL, RESCTRL_PICK_ANY_CPU); @@ -4199,7 +4199,7 @@ void resctrl_setup_dom_overflow_exclude_cpu(struct rdt_resource *r, if (resctrl_arch_is_mbm_enabled(r->rid) && exclude_cpu == d->mbm_work_cpu && - resctrl_arch_would_mbm_overflow()) { + resctrl_arch_would_mbm_overflow(r)) { mutex_unlock(&rdtgroup_mutex); cancel_delayed_work_sync(&d->mbm_over); mutex_lock(&rdtgroup_mutex); diff --git a/include/linux/arm_mpam.h b/include/linux/arm_mpam.h index 25c62a42bd2c..7487b28a792c 100644 --- a/include/linux/arm_mpam.h +++ b/include/linux/arm_mpam.h @@ -69,7 +69,6 @@ bool resctrl_arch_is_mbm_core_enabled(void); bool resctrl_arch_is_mbm_local_enabled(void); bool resctrl_arch_is_mbm_total_enabled(void); bool resctrl_arch_is_mbm_enabled(enum resctrl_res_level rid); -bool resctrl_arch_would_mbm_overflow(void); /* reset cached configurations, then all devices */ void resctrl_arch_reset_resources(void); @@ -104,6 +103,7 @@ void resctrl_arch_rmid_idx_decode(u32 idx, u32 *closid, u32 *rmid); u32 resctrl_arch_system_num_rmid_idx(void); struct rdt_resource; +bool resctrl_arch_would_mbm_overflow(struct rdt_resource *r); void *resctrl_arch_mon_ctx_alloc(struct rdt_resource *r, int evtid); void resctrl_arch_mon_ctx_free(struct rdt_resource *r, int evtid, void *ctx); -- 2.33.0