CXL: ACPI: faux: Fix cxl_core.ko module load regression
Subsystems (3)
cover CXL: ACPI: faux: Fix cxl_core.ko module load regression
git bisect flags:
6cb9441bfe8d ("ACPI: APEI: EINJ: Transition to the faux device interface")
...as the reason basic CXL unit tests are failing on latest mainline. In addition to the fix to einj-core.c, this also needs some updates to faux_device to make it behave more like platform_driver_probe(). Details in the individual patches.
Dan Williams (3):
driver core: faux: Suppress bind attributes
driver core: faux: Quiet probe failures
ACPI: APEI: EINJ: Do not fail einj_init() on faux_device_create()
failure
drivers/acpi/apei/einj-core.c | 9 +++------ drivers/base/faux.c | 3 ++- 2 files changed, 5 insertions(+), 7 deletions(-)
base-commit: a9dfb7db96f7bc1f30feae673aab7fdbfbc94e9c
Signature · 1 line
2.49.0
PATCH 1/3 driver core: faux: Suppress bind attributes
faux_device_create() is almost a suitable candidate to replace platform_driver_probe() if not for the fact that faux_device_create() supports dynamic attach/detach of the driver.
Drop the bind attributes with the expectation that simple faux devices can always assume that the device is permanently bound at create, and only unbound at 'destroy'.
The acpi-einj driver depends on static bind.
--- drivers/base/faux.c | 1 + 1 file changed, 1 insertion(+)
drivers/base/faux.c +1 -0
@@ -86,6 +86,7 @@ static struct device_driver faux_driver = { .name = "faux_driver", .bus = &faux_bus_type, .probe_type = PROBE_FORCE_SYNCHRONOUS, + .suppress_bind_attrs = true, };static void faux_device_release (struct device *dev)
Signature · 1 line
2.49.0
Re: [PATCH 1/3] driver core: faux: Suppress bind attributes
Quoted 8 lines · On Fri, 6 Jun 2025 20:32:26 -0700 Dan Williams <[email protected]> wrote:
faux_device_create()is almost a suitable candidate to replaceplatform_driver_probe()if not for the fact thatfaux_device_create()supports dynamic attach/detach of the driver.Drop the bind attributes with the expectation that simple faux devices can always assume that the device is permanently bound at create, and only unbound at 'destroy'.
Quoted 7 lines
The acpi-einj driver depends on static bind.
Fixes 6cb9441bfe8d ("ACPI: APEI: EINJ: Transition to the faux device interface")Cc Greg Kroah-Hartman <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Danilo Krummrich <[email protected]>Signed-off-by Dan Williams <[email protected]>
Seems like a fair assumption that these should never be used so we might as well hide the.
Quoted 16 lines
--- drivers/base/faux.c | 1 + 1 file changed, 1 insertion(+)drivers/base/faux.c +1
-0@@ -86,6 +86,7 @@ static struct device_driver faux_driver = { .name = "faux_driver", .bus = &faux_bus_type, .probe_type = PROBE_FORCE_SYNCHRONOUS, + .suppress_bind_attrs = true, };static void faux_device_release (struct device *dev)
PATCH 2/3 driver core: faux: Quiet probe failures
In reply to Dan WilliamsThe acpi-einj conversion to faux_device_create() leads to a noisy error message when the error injection facility is disabled. Quiet the error as CXL error injection via ACPI expects the module to stay loaded even if the error injection facility is disabled.
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.
--- drivers/base/faux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/faux.c +1 -1
@@ -170,7 +170,7 @@ struct faux_device *faux_device_create_with_groups(const char *name,* successful is almost impossible to determine by the caller. */ if (!dev->driver) { -dev_err (dev,"probe did not succeed, tearing down the device\n" ); +dev_dbg (dev,"probe did not succeed, tearing down the device\n" );faux_device_destroy (faux_dev); faux_dev =NULL ; }
Signature · 1 line
2.49.0
Re: [PATCH 2/3] driver core: faux: Quiet probe failures
Quoted 11 lines · On Fri, 6 Jun 2025 20:32:27 -0700 Dan Williams <[email protected]> wrote:
The acpi-einj conversion to
faux_device_create()leads to a noisy error message when the error injection facility is disabled. Quiet the error as CXL error injection via ACPI expects the module to stay loaded even if the error injection facility is disabled.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.
Quoted 5 lines
Fixes 6cb9441bfe8d ("ACPI: APEI: EINJ: Transition to the faux device interface")Cc Greg Kroah-Hartman <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Danilo Krummrich <[email protected]>Signed-off-by Dan Williams <[email protected]>
I guess this is fair enough.
Quoted 17 lines
--- drivers/base/faux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/base/faux.c +1
-1@@ -170,7 +170,7 @@ struct faux_device *faux_device_create_with_groups(const char *name,* successful is almost impossible to determine by the caller. */ if (!dev->driver) { -dev_err (dev,"probe did not succeed, tearing down the device\n" ); +dev_dbg (dev,"probe did not succeed, tearing down the device\n" );faux_device_destroy (faux_dev); faux_dev =NULL ; }
PATCH 3/3 ACPI: APEI: EINJ: Do not fail einj_init() on faux_device_create() failure
In reply to Dan WilliamsCXL 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.
--- drivers/acpi/apei/einj-core.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/acpi/apei/einj-core.c +3 -6
@@ -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); }module_init (einj_init);
Signature · 1 line
2.49.0
Re: [PATCH 3/3] ACPI: APEI: EINJ: Do not fail einj_init() on faux_device_create() failure
Quoted 39 lines · On Fri, 6 Jun 2025 20:32:28 -0700 Dan Williams <[email protected]> wrote:
CXL has a symbol dependency on einj_core.ko, so if
einj_init()fails then cxl_core.ko fails to load. Prior to thefaux_device_create()conversion,einj_probe()failures were tracked by theeinj_initializedflag without failingeinj_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 <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Sudeep Holla <[email protected]>Cc Ben Cheatham <[email protected]>Signed-off-by Dan Williams <[email protected]>--- drivers/acpi/apei/einj-core.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)drivers/acpi/apei/einj-core.c +2
-3@@ -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;
drivers/acpi/apei/einj-core.c static int __init einj_init(void) · line 895
Quoted 10 lines
drivers/acpi/apei/einj-core.c +1
-3return 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!
Quoted 3 lines
drivers/acpi/apei/einj-core.c +0
-0}module_init (einj_init);
Greg KH
maintainerRe: [PATCH 3/3] ACPI: APEI: EINJ: Do not fail einj_init() on faux_device_create() failure
Quoted 65 lines · Jonathan Cameron
Quoted 39 lines · On Fri, 6 Jun 2025 20:32:28 -0700 Dan Williams <[email protected]> wrote:
CXL has a symbol dependency on einj_core.ko, so if
einj_init()fails then cxl_core.ko fails to load. Prior to thefaux_device_create()conversion,einj_probe()failures were tracked by theeinj_initializedflag without failingeinj_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 <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Sudeep Holla <[email protected]>Cc Ben Cheatham <[email protected]>Signed-off-by Dan Williams <[email protected]>--- drivers/acpi/apei/einj-core.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)drivers/acpi/apei/einj-core.c +2
-3@@ -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;drivers/acpi/apei/einj-core.c static int __init einj_init(void) · line 895
Quoted 10 lines
drivers/acpi/apei/einj-core.c +1
-3return 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()checksvoid
faux_device_destroy(struct faux_device *faux_dev){ struct device *dev = &faux_dev->dev; if (!faux_dev) return;
Quoted 5 lines
Though that check is after a dereference of
faux_devwhich 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
Re: [PATCH 3/3] ACPI: APEI: EINJ: Do not fail einj_init() on faux_device_create() failure
Quoted 72 lines · On Mon, 9 Jun 2025 12:42:53 +0200 Greg KH <[email protected]> wrote:
Quoted 65 lines · Jonathan Cameron
Quoted 39 lines · On Fri, 6 Jun 2025 20:32:28 -0700 Dan Williams <[email protected]> wrote:
CXL has a symbol dependency on einj_core.ko, so if
einj_init()fails then cxl_core.ko fails to load. Prior to thefaux_device_create()conversion,einj_probe()failures were tracked by theeinj_initializedflag without failingeinj_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 <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Sudeep Holla <[email protected]>Cc Ben Cheatham <[email protected]>Signed-off-by Dan Williams <[email protected]>--- drivers/acpi/apei/einj-core.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)drivers/acpi/apei/einj-core.c +2
-3@@ -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;drivers/acpi/apei/einj-core.c static int __init einj_init(void) · line 895
Quoted 10 lines
drivers/acpi/apei/einj-core.c +1
-3return 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()checksvoid
faux_device_destroy(struct faux_device *faux_dev){ struct device *dev = &faux_dev->dev; if (!faux_dev) return;Quoted 5 lines
Though that check is after a dereference of
faux_devwhich 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!
Quoted 4 lines
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?
Hmm. I did some digging. Seems that was debated 10 years ago without a huge amount of clarity on the answer beyond all sane people telling compiler folk not to use this in optimizations :)
Comes down to whether any dereference of NULL is UB whether or not the compiler can just do a simple offset calculation.
Anyhow, whilst fine, it's still a little ugly to my eyes :(
Jonathan
Quoted 5 lines
thanks,
greg k-h
Re: [PATCH 3/3] ACPI: APEI: EINJ: Do not fail einj_init() on faux_device_create() failure
Jonathan Cameron wrote:
[..]
Quoted 8 lines
Hmm. I did some digging. Seems that was debated 10 years ago without a huge amount of clarity on the answer beyond all sane people telling compiler folk not to use this in optimizations :)
Comes down to whether any dereference of NULL is UB whether or not the compiler can just do a simple offset calculation.
Anyhow, whilst fine, it's still a little ugly to my eyes :(
I recall we had this conversation with Dan Carpenter on a smatch patch and resolved that while it looks "interesting" it does no harm.
For this patch I am not motivated to spin it because even if the the compiler took advantage of the NULL check to drop UB work, that would only mean dropping the assignment.
Otherwise, this conversion lines up with the intent of both einj_initialized and faux_device_destroy() whereby faux_device_destroy() is already prepared for the case where faux_device_create() fails.
Re: [PATCH 3/3] ACPI: APEI: EINJ: Do not fail einj_init() on faux_device_create() failure
In reply to Dan WilliamsQuoted 15 lines · Dan Williams
CXL has a symbol dependency on einj_core.ko, so if
einj_init()fails then cxl_core.ko fails to load. Prior to thefaux_device_create()conversion,einj_probe()failures were tracked by theeinj_initializedflag without failingeinj_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.
Quoted 7 lines
Fixes 6cb9441bfe8d ("ACPI: APEI: EINJ: Transition to the faux device interface")Cc Greg Kroah-Hartman <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Sudeep Holla <[email protected]>Cc Ben Cheatham <[email protected]>Signed-off-by Dan Williams <[email protected]>---
Thanks for sending this out!
Quoted 9 lines · Dan Williams
git bisect flags:
6cb9441bfe8d("ACPI: APEI: EINJ: Transition to the faux device interface")...as the reason basic CXL unit tests are failing on latest mainline. In addition to the fix to
einj-core.c, this also needs some updates tofaux_deviceto make it behave more likeplatform_driver_probe(). Details in the individual patches.
Thanks for not only reporting the issue with the commit above but also solving it and posting patches.
They all look good to me.
Signature · 2 lines
Regards, Sudeep
Quoted 9 lines · Dan Williams
git bisect flags:
6cb9441bfe8d("ACPI: APEI: EINJ: Transition to the faux device interface")...as the reason basic CXL unit tests are failing on latest mainline. In addition to the fix to
einj-core.c, this also needs some updates tofaux_deviceto make it behave more likeplatform_driver_probe(). Details in the individual patches.
Quoted 5 lines
Dan Williams (3):
driver core: faux: Suppress bind attributes
driver core: faux: Quiet probe failures
ACPI: APEI: EINJ: Do not faileinj_init()onfaux_device_create()
failure
LGTM
Quoted 7 lines
drivers/acpi/apei/einj-core.c | 9 +++------ drivers/base/faux.c | 3 ++- 2 files changed, 5 insertions(+), 7 deletions(-)base-commit:
a9dfb7db96f7bc1f30feae673aab7fdbfbc94e9c
Rafael J. Wysocki
maintainerQuoted 13 lines · Dave Jiang
Quoted 9 lines · Dan Williams
git bisect flags:
6cb9441bfe8d("ACPI: APEI: EINJ: Transition to the faux device interface")...as the reason basic CXL unit tests are failing on latest mainline. In addition to the fix to
einj-core.c, this also needs some updates tofaux_deviceto make it behave more likeplatform_driver_probe(). Details in the individual patches.
Quoted 13 lines
Quoted 5 lines
Dan Williams (3):
driver core: faux: Suppress bind attributes
driver core: faux: Quiet probe failures
ACPI: APEI: EINJ: Do not faileinj_init()onfaux_device_create()
failureLGTM
Reviewed-by Dave Jiang <[email protected]>Quoted 4 lines
drivers/acpi/apei/einj-core.c | 9 +++------ drivers/base/faux.c | 3 ++- 2 files changed, 5 insertions(+), 7 deletions(-)
Greg, I think it's better if I route this through the ACPI tree as the issue being fixed was introduced through it.
Any concerns regarding this?
Quoted 24 lines · Rafael J. Wysocki
Quoted 23 lines · Dave Jiang
Quoted 9 lines · Dan Williams
git bisect flags:
6cb9441bfe8d("ACPI: APEI: EINJ: Transition to the faux device interface")...as the reason basic CXL unit tests are failing on latest mainline. In addition to the fix to
einj-core.c, this also needs some updates tofaux_deviceto make it behave more likeplatform_driver_probe(). Details in the individual patches.Quoted 5 lines
Dan Williams (3):
driver core: faux: Suppress bind attributes
driver core: faux: Quiet probe failures
ACPI: APEI: EINJ: Do not faileinj_init()onfaux_device_create()
failureLGTM
Reviewed-by Dave Jiang <[email protected]>Quoted 1 line
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
drivers/acpi/apei/einj-core.c | 9 +++------ drivers/base/faux.c | 3 ++- 2 files changed, 5 insertions(+), 7 deletions(-)Greg, I think it's better if I route this through the ACPI tree as the issue being fixed was introduced through it.
Any concerns regarding this?
None from me!
Rafael J. Wysocki
maintainerQuoted 30 lines · Greg KH
Quoted 28 lines · Rafael J. Wysocki
Quoted 26 lines · Dave Jiang
Quoted 9 lines · Dan Williams
git bisect flags:
6cb9441bfe8d("ACPI: APEI: EINJ: Transition to the faux device interface")...as the reason basic CXL unit tests are failing on latest mainline. In addition to the fix to
einj-core.c, this also needs some updates tofaux_deviceto make it behave more likeplatform_driver_probe(). Details in the individual patches.Quoted 5 lines
Dan Williams (3):
driver core: faux: Suppress bind attributes
driver core: faux: Quiet probe failures
ACPI: APEI: EINJ: Do not faileinj_init()onfaux_device_create()
failureLGTM
Reviewed-by Dave Jiang <[email protected]>Quoted 4 lines
drivers/acpi/apei/einj-core.c | 9 +++------ drivers/base/faux.c | 3 ++- 2 files changed, 5 insertions(+), 7 deletions(-)
Quoted 8 lines
Quoted 4 lines
Greg, I think it's better if I route this through the ACPI tree as the issue being fixed was introduced through it.
Any concerns regarding this?
None from me!
So applied as 6.16-rc material.
Thank you!