Re: [PATCH v2 04/31] EDAC/amd64: Allow for DF Indirect Broadcast reads

From: Yazen Ghannam
Date: Thu Jul 08 2021 - 15:44:18 EST


On Wed, Jun 30, 2021 at 06:22:54PM +0200, Borislav Petkov wrote:
> On Wed, Jun 23, 2021 at 07:19:35PM +0000, Yazen Ghannam wrote:
> > The DF Indirect Access method allows for "Broadcast" accesses in which
> > case no specific instance is targeted. Add support using a reserved
> > instance ID of 0xFF to indicate a broadcast access. Set the FICAA
> > register appropriately.
> >
> > Signed-off-by: Yazen Ghannam <yazen.ghannam@xxxxxxx>
> > ---
> > Link:
> > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flkml.kernel.org%2Fr%2F20210507190140.18854-1-Yazen.Ghannam%40amd.com&amp;data=04%7C01%7Cyazen.ghannam%40amd.com%7C83af21ab3dcc4b529ff008d93be354cb%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637606669851041887%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=DVzJaZy8OOETbvcISwzhg7%2FP3iHjOiP%2BOgMFd8rrrQk%3D&amp;reserved=0
> >
> > v1->v2:
> > * New in v2.
> >
> > drivers/edac/amd64_edac.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
> > index b94067e3952b..d67cd8f57b94 100644
> > --- a/drivers/edac/amd64_edac.c
> > +++ b/drivers/edac/amd64_edac.c
> > @@ -1010,7 +1010,11 @@ struct df_reg {
> > *
> > * Fabric Indirect Configuration Access Data (FICAD): There are FICAD LO
> > * and FICAD HI registers but so far we only need the LO register.
> > + *
> > + * Use Instance Id 0xFF to indicate a broadcast read.
> > */
> > +
> > +#define DF_BROADCAST 0xFF
> > static int amd_df_indirect_read(u16 node, struct df_reg reg, u8 instance_id, u32 *lo)
> > {
> > struct pci_dev *F4;
> > @@ -1024,7 +1028,7 @@ static int amd_df_indirect_read(u16 node, struct df_reg reg, u8 instance_id, u32
> > if (!F4)
> > goto out;
> >
> > - ficaa = 1;
> > + ficaa = (instance_id == DF_BROADCAST) ? 0 : 1;
>
> Or, you can define two functions:
>
> df_indirect_read_broadcast()
> df_indirect_read_umc()
>
> (no need for the "amd_" prefix either - this is a static function now)
>
> which both call a low-level helper:
>
> static int __df_indirect_read(u16 node, struct df_reg reg, u8 instance_id, u32 *lo)
>
> and there you either pass the instance_id or 0xff depending on which
> outer function is calling it...
>

Yeah, I like it. I'll see what I can do.

BTW, I'm thinking to include a "tmp" or "scratch" u32 value in the
context used to hold raw register values that don't need to be saved
long term. There are a few places where a value is read and some fields
are extracted, so a few functions have a u32 tmp variable declared. What
do you think?

Thanks,
Yazen