Re: [PATCH v2 07/31] EDAC/amd64: Define functions for DramOffset
From: Borislav Petkov
Date: Wed Jun 30 2021 - 13:27:14 EST
On Wed, Jun 23, 2021 at 07:19:38PM +0000, Yazen Ghannam wrote:
> Add helper functions to read the DramOffset register and to remove the
> offset from the calculated address.
>
> The helper functions will be expanded in future DF versions.
>
> Rename the "base" variable to "map_num" to indicate that this is the
> address map number. An address map is defined with a base and limit
> value. The map_num variable is used to select the proper base and limit
> registers to use for the address translation.
>
> Signed-off-by: Yazen Ghannam <yazen.ghannam@xxxxxxx>
> ---
> Link:
> https://lkml.kernel.org/r/20210507190140.18854-4-Yazen.Ghannam@xxxxxxx
>
> v1->v2:
> * Moved from arch/x86 to EDAC.
> * Add function to data_fabric_ops.
>
> drivers/edac/amd64_edac.c | 57 +++++++++++++++++++++++++++++----------
> 1 file changed, 43 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
> index f769353ef7e4..389f0621e885 100644
> --- a/drivers/edac/amd64_edac.c
> +++ b/drivers/edac/amd64_edac.c
> @@ -1079,16 +1079,26 @@ static struct df_reg df_regs[] = {
> [SYS_FAB_ID_MASK] = {1, 0x208},
> };
>
> +/* Use "reg_" prefix for raw register values. */
> struct addr_ctx {
> u64 ret_addr;
> + u32 reg_dram_offset;
> u16 nid;
> u8 inst_id;
> + u8 map_num;
> };
>
> struct data_fabric_ops {
> + u64 (*get_hi_addr_offset)(struct addr_ctx *ctx);
> };
>
> +static u64 get_hi_addr_offset_df2(struct addr_ctx *ctx)
> +{
> + return (ctx->reg_dram_offset & GENMASK_ULL(31, 20)) << 8;
> +}
> +
> struct data_fabric_ops df2_ops = {
Those "df2" ops are for UMC v2?
> + .get_hi_addr_offset = &get_hi_addr_offset_df2,
^
No need for the "&".
Also, if you define a member ->get_hi_addr_offset in df2_ops, then you
need to define that member in *every* df_ops structure you have so that
there's no NULL pointers.
I guess that's coming...
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette