Linux CXL
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Dan Williams <dan.j.williams@intel.com>,
	rafael.j.wysocki@intel.com, linux-cxl@vger.kernel.org,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Sudeep Holla <sudeep.holla@arm.com>,
	Ben Cheatham <Benjamin.Cheatham@amd.com>
Subject: Re: [PATCH 3/3] ACPI: APEI: EINJ: Do not fail einj_init() on faux_device_create() failure
Date: Mon, 9 Jun 2025 12:42:53 +0200	[thread overview]
Message-ID: <2025060954-district-breeder-2c3e@gregkh> (raw)
In-Reply-To: <20250609111758.0000258d@huawei.com>

On Mon, Jun 09, 2025 at 11:17:58AM +0100, Jonathan Cameron wrote:
> On Fri, 6 Jun 2025 20:32:28 -0700
> Dan Williams <dan.j.williams@intel.com> wrote:
> 
> > CXL has a symbol dependency on einj_core.ko, so if einj_init() fails then
> > cxl_core.ko fails to load. Prior to the faux_device_create() conversion,
> > einj_probe() failures were tracked by the einj_initialized flag without
> > failing einj_init().
> > 
> > Revert to that behavior and always succeed einj_init() given there is no
> > way, and no pressing need, to discern faux device-create vs device-probe
> > failures.
> > 
> > This situation arose because CXL knows proper kernel named objects to
> > trigger errors against, but acpi-einj knows how to perform the error
> > injection. The injection mechanism is shared with non-CXL use cases. The
> > result is CXL now has a module dependency on einj-core.ko, and init/probe
> > failures are handled at runtime.
> > 
> > Fixes: 6cb9441bfe8d ("ACPI: APEI: EINJ: Transition to the faux device interface")
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Cc: Sudeep Holla <sudeep.holla@arm.com>
> > Cc: Ben Cheatham <Benjamin.Cheatham@amd.com>
> > Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> > ---
> >  drivers/acpi/apei/einj-core.c | 9 +++------
> >  1 file changed, 3 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
> > index fea11a35eea3..9b041415a9d0 100644
> > --- a/drivers/acpi/apei/einj-core.c
> > +++ b/drivers/acpi/apei/einj-core.c
> > @@ -883,19 +883,16 @@ static int __init einj_init(void)
> >  	}
> >  
> >  	einj_dev = faux_device_create("acpi-einj", NULL, &einj_device_ops);
> > -	if (!einj_dev)
> > -		return -ENODEV;
> >  
> > -	einj_initialized = true;
> > +	if (einj_dev)
> > +		einj_initialized = true;
> >  
> >  	return 0;
> >  }
> >  
> >  static void __exit einj_exit(void)
> >  {
> > -	if (einj_initialized)
> > -		faux_device_destroy(einj_dev);
> > -
> > +	faux_device_destroy(einj_dev);
> 
> Hi Dan,
> 
> Thi bit is sort of fine though not really related, because
> faux_device_destroy() checks
> 
> void faux_device_destroy(struct faux_device *faux_dev)
> {
> 	struct device *dev = &faux_dev->dev;
> 
> 	if (!faux_dev)
> 		return;
> 
> Though that check is after a dereference of faux_dev
> which doesn't look right to me.  Might be fine because
> of how the kernel is built (I can't remember where we ended
> up on topic of compilers making undefined behavior based
> optimizations).  Still not that nice from a logical point of view!

I think this is fine as we just put "0 + offset of dev" into dev, and
didn't do anything with that (i.e. no actual read of that memory
location happened).  The compiler shouldn't be doing anything that could
happen after the return before we check for a valid pointer here, right?

thanks,

greg k-h

  reply	other threads:[~2025-06-09 10:43 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-07  3:32 [PATCH 0/3] CXL: ACPI: faux: Fix cxl_core.ko module load regression Dan Williams
2025-06-07  3:32 ` [PATCH 1/3] driver core: faux: Suppress bind attributes Dan Williams
2025-06-09 10:19   ` Jonathan Cameron
2025-06-07  3:32 ` [PATCH 2/3] driver core: faux: Quiet probe failures Dan Williams
2025-06-09 10:19   ` Jonathan Cameron
2025-06-07  3:32 ` [PATCH 3/3] ACPI: APEI: EINJ: Do not fail einj_init() on faux_device_create() failure Dan Williams
2025-06-09 10:17   ` Jonathan Cameron
2025-06-09 10:42     ` Greg KH [this message]
2025-06-09 16:05       ` Jonathan Cameron
2025-06-10 17:22         ` Dan Williams
2025-06-09 13:28   ` Cheatham, Benjamin
2025-06-09 13:39 ` [PATCH 0/3] CXL: ACPI: faux: Fix cxl_core.ko module load regression Sudeep Holla
2025-06-09 15:04 ` Dave Jiang
2025-06-09 18:58   ` Rafael J. Wysocki
2025-06-10 10:12     ` Greg KH
2025-06-10 17:24       ` Rafael J. Wysocki

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=2025060954-district-breeder-2c3e@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=Benjamin.Cheatham@amd.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rafael@kernel.org \
    --cc=sudeep.holla@arm.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