RE: [PATCH v6 5/8] EDAC/ghes: Make ghes_edac a proper module to remove the dependency on ghes

From: Justin He
Date: Thu Sep 22 2022 - 04:26:40 EST


Hi Borislav

> -----Original Message-----
> From: Borislav Petkov <bp@xxxxxxxxx>
> Sent: Wednesday, September 21, 2022 1:22 AM
> To: Justin He <Justin.He@xxxxxxx>
> Cc: Len Brown <lenb@xxxxxxxxxx>; James Morse <James.Morse@xxxxxxx>;
> Tony Luck <tony.luck@xxxxxxxxx>; Mauro Carvalho Chehab
> <mchehab@xxxxxxxxxx>; Robert Richter <rric@xxxxxxxxxx>; Robert Moore
> <robert.moore@xxxxxxxxx>; Qiuxu Zhuo <qiuxu.zhuo@xxxxxxxxx>; Yazen
> Ghannam <yazen.ghannam@xxxxxxx>; Jan Luebbe <jlu@xxxxxxxxxxxxxx>;
> Khuong Dinh <khuong@xxxxxxxxxxxxxxxxxxxxxx>; Kani Toshi
> <toshi.kani@xxxxxxx>; Ard Biesheuvel <ardb@xxxxxxxxxx>;
> linux-acpi@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx;
> linux-edac@xxxxxxxxxxxxxxx; devel@xxxxxxxxxx; Rafael J . Wysocki
> <rafael@xxxxxxxxxx>; Shuai Xue <xueshuai@xxxxxxxxxxxxxxxxx>; Jarkko
> Sakkinen <jarkko@xxxxxxxxxx>; linux-efi@xxxxxxxxxxxxxxx; nd <nd@xxxxxxx>
> Subject: Re: [PATCH v6 5/8] EDAC/ghes: Make ghes_edac a proper module to
> remove the dependency on ghes
>
> On Mon, Sep 12, 2022 at 02:40:02PM +0000, Jia He wrote:
> > Commit dc4e8c07e9e2 ("ACPI: APEI: explicit init of HEST and GHES in
> > apci_init()") introduced a bug that ghes_edac_register() would be
> > invoked before edac_init(). Because at that time, the bus "edac"
> > hadn't been even registered, this created sysfs /devices/mc0 instead
> > of
> > /sys/devices/system/edac/mc/mc0 on an Ampere eMag server.
> >
> > To remove the dependency of ghes_edac on ghes, make it a proper
> > module. Use a list to save the probing devices in ghes_probe(), and
> > defer the
> > ghes_edac_register() to module_init() of the new ghes_edac module by
> > iterating over the devices list.
> >
> > The ghes_edac_force_enable check is not needed in
> > ghes_edac_unregister() since it has been checked in ghes_edac_init().
> >
> > Co-developed-by: Borislav Petkov <bp@xxxxxxxxx>
> > Signed-off-by: Borislav Petkov <bp@xxxxxxxxx>
> > Signed-off-by: Jia He <justin.he@xxxxxxx>
> > Fixes: dc4e8c07e9e2 ("ACPI: APEI: explicit init of HEST and GHES in
> > apci_init()")
> > Cc: Shuai Xue <xueshuai@xxxxxxxxxxxxxxxxx>
> > Acked-by: Toshi Kani <toshi.kani@xxxxxxx>
> > ---
> > drivers/acpi/apei/ghes.c | 22 +++++++++++++--
> > drivers/edac/Kconfig | 4 +--
> > drivers/edac/ghes_edac.c | 59
> +++++++++++++++++++++++-----------------
> > include/acpi/ghes.h | 24 ++++------------
> > 4 files changed, 62 insertions(+), 47 deletions(-)
>
> So those last three patches look unnecessarily complex. You don't need to
> export ghes_edac_force_enable and you don't need that
> ghes_edac_preferred() thing.
>
> IOW, I'd like to see the below split into two patches:
>
> 1. Add ghes_get_devices() to ghes.c along with moving the
> ghes_edac_force_enable param to ghes.c
>
> 2. Add init() and exit() module functions and fixup Kconfig
>
> There's no need for ghes_present - ghes.c has either registered devices or
> not.
>

If there is no ghes_present flag.
What if ghes.disable is passed to kernel boot parameter and then ghes_edac is
loaded by modprobe?
Thus, ghes_edac can be loaded even if ghes is disabled. (ghes_dev list is null)

The ghes_present is to avoid this case.

What do u think of it?

--
Cheers,
Justin (Jia He)