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

Justin He
2022-09-22T08:26:37Z

Hi Borislav

> -----Original Message-----
> From: Borislav Petkov <bp@alien8.de>
> Sent: Wednesday, September 21, 2022 1:22 AM
> To: Justin He <Justin.He@arm.com>
> Cc: Len Brown <lenb@kernel.org>; James Morse <James.Morse@arm.com>;
> Tony Luck <tony.luck@intel.com>; Mauro Carvalho Chehab
> <mchehab@kernel.org>; Robert Richter <rric@kernel.org>; Robert Moore
> <robert.moore@intel.com>; Qiuxu Zhuo <qiuxu.zhuo@intel.com>; Yazen
> Ghannam <yazen.ghannam@amd.com>; Jan Luebbe <jlu@pengutronix.de>;
> Khuong Dinh <khuong@os.amperecomputing.com>; Kani Toshi
> <toshi.kani@hpe.com>; Ard Biesheuvel <ardb@kernel.org>;
> linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org;
> linux-edac@vger.kernel.org; devel@acpica.org; Rafael J . Wysocki
> <rafael@kernel.org>; Shuai Xue <xueshuai@linux.alibaba.com>; Jarkko
> Sakkinen <jarkko@kernel.org>; linux-efi@vger.kernel.org; nd <nd@arm.com>
> 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@alien8.de>
> > Signed-off-by: Borislav Petkov <bp@alien8.de>
> > Signed-off-by: Jia He <justin.he@arm.com>
> > Fixes: dc4e8c07e9e2 ("ACPI: APEI: explicit init of HEST and GHES in
> > apci_init()")
> > Cc: Shuai Xue <xueshuai@linux.alibaba.com>
> > Acked-by: Toshi Kani <toshi.kani@hpe.com>
> > ---
> > 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)