Skip to content

Commit

Permalink
drm/amdkcl: Test whether smca_get_bank_type() has two arguments
Browse files Browse the repository at this point in the history
It's caused by 91f75eb
"x86/MCE/AMD, EDAC/mce_amd: Support non-uniform MCA bank type enumeration"

Signed-off-by: Asher Song <Asher.Song@amd.com>
Reviewed-by: Leslie Shi <Yuliang.Shi@amd.com>
(cherry picked from commit 1ad3ae0)

Change-Id: If23944476229e6b7a4c48f8855cef7c05d70ef4b
  • Loading branch information
Asher Song authored and Alexandru Tudor committed Sep 19, 2022
1 parent 802e978 commit 93cd6ba
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 28 deletions.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
29 changes: 24 additions & 5 deletions drivers/gpu/drm/amd/amdkcl/kcl_mce_amd.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,19 @@
#ifdef CONFIG_X86_MCE_AMD
#include <asm/mce.h>

#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;
Expand All @@ -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 */
7 changes: 5 additions & 2 deletions drivers/gpu/drm/amd/dkms/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
52 changes: 37 additions & 15 deletions drivers/gpu/drm/amd/dkms/m4/smca_get_bank_type.m4
Original file line number Diff line number Diff line change
@@ -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 <linux/limits.h>
#include <asm/mce.h>
],[
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 <linux/limits.h>
#include <asm/mce.h>
], [
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 <linux/limits.h>
#include <asm/mce.h>
],[
struct smca_bank *b = NULL;
b->id = 0;
], [
AC_DEFINE(HAVE_STRUCT_SMCA_BANK, 1,
[struct smca_bank is available])
])
])
])
])
])
8 changes: 3 additions & 5 deletions include/kcl/kcl_mce.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 93cd6ba

Please sign in to comment.