diff mbox series

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

Message ID 20210623192002.3671647-7-yazen.ghannam@amd.com (mailing list archive)
State New, archived
Headers show
Series AMD MCA Address Translation Updates | expand

Commit Message

Yazen Ghannam June 23, 2021, 7:19 p.m. UTC
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@amd.com>
---
Link:
https://lkml.kernel.org/r/20210507190140.18854-3-Yazen.Ghannam@amd.com

v1->v2:
* New in v2.

 drivers/edac/amd64_edac.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Borislav Petkov June 30, 2021, 5:19 p.m. UTC | #1
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@amd.com>
> ---
> Link:
> https://lkml.kernel.org/r/20210507190140.18854-3-Yazen.Ghannam@amd.com
> 
> 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.
Yazen Ghannam July 8, 2021, 7:55 p.m. UTC | #2
On Wed, Jun 30, 2021 at 07:19:45PM +0200, Borislav Petkov wrote:
> On Wed, Jun 23, 2021 at 07:19:37PM +0000, Yazen Ghannam wrote:

...

> >  
> > +	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.
>

Good point. We can set this in per_family_init().

Thanks,
Yazen
diff mbox series

Patch

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;