diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c index 4e4460411ec50..4a4acb13586a3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c @@ -2850,7 +2850,7 @@ static int amdgpu_bad_page_notifier(struct notifier_block *nb, * and error occurred in DramECC (Extended error code = 0) then only * process the error, else bail out. */ - if (!m || !((smca_get_bank_type(m->extcpu, m->bank) == SMCA_UMC_V2) && + if (!m || !((kcl_smca_get_bank_type(m->extcpu, m->bank) == SMCA_UMC_V2) && (XEC(m->status, 0x3f) == 0x0))) return NOTIFY_DONE; diff --git a/drivers/gpu/drm/amd/amdkcl/kcl_mce_amd.c b/drivers/gpu/drm/amd/amdkcl/kcl_mce_amd.c index 30e62d94fbead..bd90d447713f5 100644 --- a/drivers/gpu/drm/amd/amdkcl/kcl_mce_amd.c +++ b/drivers/gpu/drm/amd/amdkcl/kcl_mce_amd.c @@ -12,10 +12,19 @@ #ifdef CONFIG_X86_MCE_AMD #include -#ifndef HAVE_SMCA_GET_BANK_TYPE +#if defined(HAVE_SMCA_GET_BANK_TYPE_WITH_TWO_ARGUMENTS) +enum smca_bank_types kcl_smca_get_bank_type(unsigned int cpu, unsigned int bank) +{ + return smca_get_bank_type(cpu, bank); +} +#elif defined(HAVE_SMCA_GET_BANK_TYPE_WITH_ONE_ARGUMENT) +enum smca_bank_types kcl_smca_get_bank_type(unsigned int cpu, unsigned int bank) +{ + return smca_get_bank_type(bank); +} /* Copied from v5.15-rc2-452-gf38ce910d8df:arch/x86/kernel/cpu/mce/amd.c and modified for KCL */ -#ifdef HAVE_SMCA_BANK_STRUCT +#elif defined(HAVE_STRUCT_SMCA_BANK) enum smca_bank_types smca_get_bank_type(unsigned int bank) { struct smca_bank *b; @@ -29,14 +38,24 @@ enum smca_bank_types smca_get_bank_type(unsigned int bank) return b->hwid->bank_type; } +enum smca_bank_types kcl_smca_get_bank_type(unsigned int cpu, unsigned int bank) +{ + return smca_get_bank_type(bank); +} + #else int smca_get_bank_type(unsigned int bank) { pr_warn_once("smca_get_bank_type is not supported\n"); return 0; } -#endif /* HAVE_SMCA_BANK_STRUCT */ -EXPORT_SYMBOL_GPL(smca_get_bank_type); -#endif /* HAVE_SMCA_GET_BANK_TYPE */ + +int kcl_smca_get_bank_type(unsigned int cpu, unsigned int bank) +{ + return smca_get_bank_type(bank); +} + +#endif +EXPORT_SYMBOL_GPL(kcl_smca_get_bank_type); #endif /* CONFIG_X86_MCE_AMD */ diff --git a/drivers/gpu/drm/amd/dkms/config/config.h b/drivers/gpu/drm/amd/dkms/config/config.h index 58cffa4328dd7..27adf49531822 100644 --- a/drivers/gpu/drm/amd/dkms/config/config.h +++ b/drivers/gpu/drm/amd/dkms/config/config.h @@ -1092,8 +1092,11 @@ /* whether si_mem_available() is available */ #define HAVE_SI_MEM_AVAILABLE 1 -/* smca_get_bank_type() is available */ -#define HAVE_SMCA_GET_BANK_TYPE 1 +/* smca_get_bank_type(x) is available */ +/* #undef HAVE_SMCA_GET_BANK_TYPE_WITH_ONE_ARGUMENT */ + +/* whether smca_get_bank_type(x, x) is available */ +#define HAVE_SMCA_GET_BANK_TYPE_WITH_TWO_ARGUMENTS 1 /* is_smca_umc_v2() is available */ /* #undef HAVE_SMCA_UMC_V2 */ diff --git a/drivers/gpu/drm/amd/dkms/m4/smca_get_bank_type.m4 b/drivers/gpu/drm/amd/dkms/m4/smca_get_bank_type.m4 index 2ed1eef7d5149..4dbfe78524f84 100644 --- a/drivers/gpu/drm/amd/dkms/m4/smca_get_bank_type.m4 +++ b/drivers/gpu/drm/amd/dkms/m4/smca_get_bank_type.m4 @@ -1,27 +1,49 @@ dnl # -dnl # -dnl # v5.15-rc2-452-gf38ce910d8df x86/MCE/AMD: Export smca_get_bank_type symbol +dnl # v5.16-rc1-22-g91f75eb481cf x86/MCE/AMD, EDAC/mce_amd: Support non-uniform MCA bank type enumeration dnl # AC_DEFUN([AC_AMDGPU_SMCA_GET_BANK_TYPE], [ AC_KERNEL_DO_BACKGROUND([ - AC_KERNEL_CHECK_SYMBOL_EXPORT([smca_get_bank_type], - [arch/x86/kernel/cpu/mce/amd.c], [ - AC_DEFINE(HAVE_SMCA_GET_BANK_TYPE, 1, - [smca_get_bank_type() is available]) - ], [ - dnl # + AC_KERNEL_TRY_COMPILE([ + #include + #include + ],[ + unsigned int a = 0, b = 0; + enum smca_bank_types bank_type; + bank_type = smca_get_bank_type(a, b); + ],[ + AC_DEFINE(HAVE_SMCA_GET_BANK_TYPE_WITH_TWO_ARGUMENTS, 1, + [whether smca_get_bank_type(x, x) is available]) + ],[ dnl # - dnl # v4.9-rc4-4-g79349f529ab1 x86/RAS: Simplify SMCA bank descriptor struct + dnl # v5.15-rc2-452-gf38ce910d8df x86/MCE/AMD: Export smca_get_bank_type symbol dnl # AC_KERNEL_TRY_COMPILE([ + #include #include - ], [ - struct smca_bank *b = NULL; - b->id = 0; - ], [ - AC_DEFINE(HAVE_STRUCT_SMCA_BANK, 1, - [struct smca_bank is available]) + ],[ + unsigned int a = 0; + enum smca_bank_types bank_type; + bank_type = smca_get_bank_type(a); + ],[ + AC_DEFINE(HAVE_SMCA_GET_BANK_TYPE_WITH_ONE_ARGUMENT, 1, + [smca_get_bank_type(x) is available]) + ],[ + dnl # + dnl # v4.9-rc4-4-g79349f529ab1 x86/RAS: Simplify SMCA bank descriptor struct + dnl # + AC_KERNEL_TRY_COMPILE([ + #include + #include + ],[ + struct smca_bank *b = NULL; + b->id = 0; + ], [ + AC_DEFINE(HAVE_STRUCT_SMCA_BANK, 1, + [struct smca_bank is available]) + ]) + ]) ]) + ]) ]) diff --git a/include/kcl/kcl_mce.h b/include/kcl/kcl_mce.h index 80625b60944b7..fd6098c99a240 100644 --- a/include/kcl/kcl_mce.h +++ b/include/kcl/kcl_mce.h @@ -11,12 +11,10 @@ #define XEC(x, mask) (((x) >> 16) & mask) #endif -#if !defined(HAVE_SMCA_GET_BANK_TYPE) -#ifdef HAVE_SMCA_BANK_STRUCT -enum smca_bank_types smca_get_bank_type(unsigned int bank); +#if defined(HAVE_SMCA_GET_BANK_TYPE_WITH_TWO_ARGUMENTS) || defined(HAVE_SMCA_GET_BANK_TYPE_WITH_ONE_ARGUMENT) || defined(HAVE_STRUCT_SMCA_BANK) +enum smca_bank_types kcl_smca_get_bank_type(unsigned int cpu, unsigned int bank); #else -int smca_get_bank_type(unsigned int bank); -#endif +int kcl_smca_get_bank_type(unsigned int cpu, unsigned int bank); #endif #ifndef HAVE_MCE_PRIO_UC