Re: [PATCH 04/18] EDAC/amd64: Remove PCI Function 0

From: Yazen Ghannam
Date: Thu May 12 2022 - 10:35:04 EST


On Wed, May 11, 2022 at 12:34:58PM +0200, Borislav Petkov wrote:
> On Mon, May 09, 2022 at 02:55:20PM +0000, Yazen Ghannam wrote:
> > @@ -3287,26 +3276,12 @@ static void decode_umc_error(int node_id, struct mce *m)
> > /*
> > * Use pvt->F3 which contains the F3 CPU PCI device to get the related
> > * F1 (AddrMap) and F2 (Dct) devices. Return negative value on error.
> > - * Reserve F0 on systems with a UMC.
> > */
> > static int
> > reserve_mc_sibling_devs(struct amd64_pvt *pvt, u16 pci_id1, u16 pci_id2)
> > {
> > - if (pvt->umc) {
> > - pvt->F0 = pci_get_related_function(pvt->F3->vendor, pci_id1, pvt->F3);
> > - if (!pvt->F0) {
> > - edac_dbg(1, "F0 not found, device 0x%x\n", pci_id1);
> > - return -ENODEV;
> > - }
> > -
> > - if (!pci_ctl_dev)
> > - pci_ctl_dev = &pvt->F0->dev;
> > -
> > - edac_dbg(1, "F0: %s\n", pci_name(pvt->F0));
> > - edac_dbg(1, "F3: %s\n", pci_name(pvt->F3));
> > -
> > + if (pvt->umc)
>
> I don't like the sprinkling of those checks everywhere. And
> hw_info_get() has those checks too. I think it would be cleaner if
> hw_info_get() would call a df-specific function for fam 0x17 and later
> and do the setup there cleanly:
>
> hw_info_get:
>
> if (pvt->fam >= 0x17)
> return hw_info_get_df(pvt);
>
> and so on.
>
> Btw, I completely agree with leaving the old code as it is.
>
> And I obviously like the code removal, ofc.
>
> :-)
>

Okay, will do.

Also, there are five function pointers that are created in this patchset and
called from hw_info_get(). I think those pointers can be dropped and the
helper functions called from hw_info_get(). So I think it'd be good to make
hw_info_get() into a function pointer which gets set to a functoin that calls
the right collection of legacy, modern, and GPU helper functions. How does
that sound?

Thanks!

-Yazen