Re: [PATCH v2 06/31] EDAC/amd64: Define Data Fabric operations

From: Borislav Petkov
Date: Wed Jun 30 2021 - 13:19:49 EST


On Wed, Jun 23, 2021 at 07:19:37PM +0000, Yazen Ghannam wrote:
> Define a stub to hold operations for different Data Fabric versions.
> This will be filled in following patches.
>
> Define a function to set the appropriate operations. Use a return code
> because future updates have checks that may fail.
>
> Signed-off-by: Yazen Ghannam <yazen.ghannam@xxxxxxx>
> ---
> Link:
> https://lkml.kernel.org/r/20210507190140.18854-3-Yazen.Ghannam@xxxxxxx
>
> v1->v2:
> * New in v2.
>
> drivers/edac/amd64_edac.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
> index 62eca188458f..f769353ef7e4 100644
> --- a/drivers/edac/amd64_edac.c
> +++ b/drivers/edac/amd64_edac.c
> @@ -1085,6 +1085,21 @@ struct addr_ctx {
> u8 inst_id;
> };
>
> +struct data_fabric_ops {
> +};
> +
> +struct data_fabric_ops df2_ops = {
> +};
> +
> +struct data_fabric_ops *df_ops;
> +
> +static int set_df_ops(struct addr_ctx *ctx)
> +{
> + df_ops = &df2_ops;
> +
> + return 0;
> +}
> +
> static int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr)
> {
> u64 dram_base_addr, dram_limit_addr, dram_hole_base;
> @@ -1110,6 +1125,9 @@ static int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr
> ctx.nid = nid;
> ctx.inst_id = umc;
>
> + if (set_df_ops(&ctx))
> + return -EINVAL;
> +
> if (amd_df_indirect_read(nid, df_regs[DRAM_OFFSET], umc, &tmp))
> goto out_err;
>
> --

Why?

You can simply assign to df_ops as this is all driver-static data.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette