From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
To: Pierre Gondois <pierre.gondois@arm.com>
Cc: linux-kernel@vger.kernel.org, James Morse <james.morse@arm.com>,
Mark Brown <broonie@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Len Brown <lenb@kernel.org>, Tony Luck <tony.luck@intel.com>,
Borislav Petkov <bp@alien8.de>, Hanjun Guo <guohanjun@huawei.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Shuai Xue <xueshuai@linux.alibaba.com>,
Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>,
Pawel Chmielewski <pawel.chmielewski@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
"Fabio M. De Francesco" <fabio.m.de.francesco@linux.intel.com>,
Breno Leitao <leitao@debian.org>,
Terry Bowman <terry.bowman@amd.com>,
Dan Williams <djbw@kernel.org>, Ard Biesheuvel <ardb@kernel.org>,
Morduan Zang <zhangdandan@uniontech.com>,
linux-acpi@vger.kernel.org, linux-edac@vger.kernel.org,
acpica-devel@lists.linux.dev
Subject: Re: [PATCH v2 4/6] EDAC/ghes: Extract error report initialization
Date: Tue, 20 Oct 2026 10:09:37 -0700 [thread overview]
Message-ID: <20261020100937.00000d06@oss.qualcomm.com> (raw)
In-Reply-To: <20261019203915.2019037-5-pierre.gondois@arm.com>
On Mon, 19 Oct 2026 22:38:43 +0200
Pierre Gondois <pierre.gondois@arm.com> wrote:
> Extract a ghes_edac_init_error() function to prepare for
> Memory Error Section 2 support (and re-usage).
>
> Also use a guard in the caller ghes_edac_report_mem_error()
> function for code simplification.
>
> Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
> ---
> drivers/edac/ghes_edac.c | 66 +++++++++++++++++++++-------------------
> 1 file changed, 35 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c
> index d80c88818691..b90150c67f4b 100644
> --- a/drivers/edac/ghes_edac.c
> +++ b/drivers/edac/ghes_edac.c
> @@ -267,37 +267,14 @@ static int print_mem_error_other_detail(const struct cper_sec_mem_err *mem, char
> return n;
> }
>
> -static int ghes_edac_report_mem_error(struct notifier_block *nb,
> - unsigned long val, void *data)
> +/* Caller must hold ghes_lock. */
> +static struct edac_raw_error_desc *
> +ghes_edac_init_error(struct ghes_pvt *pvt, unsigned long sev)
Slightly unusual to have an init function that doesn't directly take the thing
being initialized. I'd pass it in. The clearly of pvt->msg and pvt->other_detail
is also a bit of a surprise for a function that claims to be initializing something
else so I'd do those outside of the helper.
Or maybe rename helper to something like
ghes_edac_fill_error_from_pvt()
Not sure that really conveys the modification of pvt data hidden in here though.
Perhaps this refactor was a bad suggestion from me and better to just duplicate
the code. What do ACPI maintainers think?
> {
> - struct cper_sec_mem_err *mem_err = (struct cper_sec_mem_err *)data;
> - struct cper_mem_err_compact cmem;
> - struct edac_raw_error_desc *e;
> - struct mem_ctl_info *mci;
> - unsigned long sev = val;
> - struct ghes_pvt *pvt;
> - unsigned long flags;
> - char *p;
> -
> - /*
> - * We can do the locking below because GHES defers error processing
> - * from NMI to IRQ context. Whenever that changes, we'd at least
> - * know.
> - */
> - if (WARN_ON_ONCE(in_nmi()))
> - return NOTIFY_OK;
> -
> - spin_lock_irqsave(&ghes_lock, flags);
> -
> - pvt = ghes_pvt;
> - if (!pvt)
> - goto unlock;
> -
> - mci = pvt->mci;
> - e = &mci->error_desc;
> + struct edac_raw_error_desc *e = &pvt->mci->error_desc;
>
> /* Cleans the error report buffer */
> - memset(e, 0, sizeof (*e));
> + memset(e, 0, sizeof(*e));
> e->error_count = 1;
> e->grain = 1;
> e->msg = pvt->msg;
> @@ -323,6 +300,36 @@ static int ghes_edac_report_mem_error(struct notifier_block *nb,
> e->type = HW_EVENT_ERR_INFO;
> }
>
> + return e;
> +}
> +
> +static int ghes_edac_report_mem_error(struct notifier_block *nb,
> + unsigned long val, void *data)
> +{
> + struct cper_sec_mem_err *mem_err = (struct cper_sec_mem_err *)data;
> + struct cper_mem_err_compact cmem;
> + struct edac_raw_error_desc *e;
> + struct mem_ctl_info *mci;
> + struct ghes_pvt *pvt;
> + char *p;
> +
> + /*
> + * We can do the locking below because GHES defers error processing
> + * from NMI to IRQ context. Whenever that changes, we'd at least
> + * know.
> + */
> + if (WARN_ON_ONCE(in_nmi()))
> + return NOTIFY_OK;
> +
> + guard(spinlock_irqsave)(&ghes_lock);
> +
> + pvt = ghes_pvt;
> + if (!pvt)
> + return NOTIFY_OK;
> +
> + mci = pvt->mci;
> + e = ghes_edac_init_error(pvt, val);
> +
> edac_dbg(1, "error validation_bits: 0x%08llx\n",
> (long long)mem_err->validation_bits);
>
> @@ -375,9 +382,6 @@ static int ghes_edac_report_mem_error(struct notifier_block *nb,
>
> edac_raw_mc_handle_error(e);
>
> -unlock:
> - spin_unlock_irqrestore(&ghes_lock, flags);
> -
> return NOTIFY_OK;
> }
>
next prev parent reply other threads:[~2026-10-20 17:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 20:38 [PATCH v2 0/6] CPER: Add Memory Error Section 2 support Pierre Gondois
2026-10-19 20:38 ` [PATCH v2 1/6] cper: use BIT_ULL() for processor and memory validation bits Pierre Gondois
2026-10-19 20:38 ` [PATCH v2 2/6] cper: add Memory Error Section 2 structures Pierre Gondois
2026-10-19 20:38 ` [PATCH v2 3/6] cper: add helpers to handle Memory Error Section 2 Pierre Gondois
2026-10-19 20:38 ` [PATCH v2 4/6] EDAC/ghes: Extract error report initialization Pierre Gondois
2026-10-20 17:09 ` Jonathan Cameron [this message]
2026-10-19 20:38 ` [PATCH v2 5/6] ACPI: APEI: add separate Memory Error Section 2 handlers Pierre Gondois
2026-10-20 17:17 ` Jonathan Cameron
2026-10-19 20:38 ` [PATCH v2 6/6] ACPI: extlog: add Memory Error Section 2 trace event Pierre Gondois
2026-10-20 17:10 ` [PATCH v2 0/6] CPER: Add Memory Error Section 2 support Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261020100937.00000d06@oss.qualcomm.com \
--to=jonathan.cameron@oss.qualcomm.com \
--cc=acpica-devel@lists.linux.dev \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=broonie@kernel.org \
--cc=dave.jiang@intel.com \
--cc=djbw@kernel.org \
--cc=fabio.m.de.francesco@linux.intel.com \
--cc=guohanjun@huawei.com \
--cc=james.morse@arm.com \
--cc=leitao@debian.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maciej.wieczor-retman@intel.com \
--cc=mchehab@kernel.org \
--cc=pawel.chmielewski@intel.com \
--cc=pierre.gondois@arm.com \
--cc=rafael@kernel.org \
--cc=terry.bowman@amd.com \
--cc=tony.luck@intel.com \
--cc=xueshuai@linux.alibaba.com \
--cc=zhangdandan@uniontech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox