Re: [PATCH v7] cxl/core: Create EINJ debugfs files regardless of EINJ init order

From: Dave Jiang

Date: Tue Nov 17 2026 - 17:39:10 EST




On 11/17/26 3:04 PM, Alison Schofield wrote:
> On Wed, Nov 04, 2026 at 02:12:56PM +0800, Yongxin Yang wrote:
>> The einj_types file under the CXL debugfs directory is never created when
>> cxl_core is built in. cxl_core_init() runs at subsys_initcall level, while
>> einj_init() registers EINJ at device_initcall level, so the
>> einj_cxl_is_initialized() check in cxl_core_init() always sees EINJ as not
>> up yet and the debugfs_create_file() below it is never reached.
>>
>> Change the file creation condition from EINJ being initialized to a compile
>> time check for ACPI_APEI_EINJ_CXL and return -ENODEV until EINJ is up.
>>
>> The same check also guards the inject files under every downstream port
>> directory. Gate that directory creation on CONFIG_ACPI_APEI_EINJ_CXL as
>> well, and check einj_cxl_is_initialized() in cxl_einj_inject() to reject
>> writes until EINJ is up.
>
> I believe this is changing user visible behavior.
>
> On a host with no EINJ table, einj_types and the dport einj_inject
> files now exist even though EINJ never comes up, and every read or
> write of them fails with -ENODEV. They should not be there.
>
> We last visited this here:
> 4ed7952b9e87 ("cxl/core: Fix cxl_dport debugfs EINJ entries")
> A file should only exist where injection can work.
>
> Can the built-in fix keep these files absent when EINJ never comes up?
>
> ndctl relies on the files being absent:
> - 'cxl list -v' shows "protocol_injectable": true on root ports that
> cannot inject
> - 'cxl list -B' prints "failed to read .../einj_types: No such device"
>
>
> An implementation question below...

I've removed from cxl/fixes until issues raised by Alison are addressed.

DJ

>
>>
>> Fixes: 8039804cfa73 ("cxl/core: Add CXL EINJ debugfs files")
>> Reviewed-by: Ben Cheatham <benjamin.cheatham@xxxxxxx>
>> Signed-off-by: Yongxin Yang <yangyongxin@xxxxxxxxxx>
>> ---
>> Link: https://lore.kernel.org/all/de14c4ef-e3d8-432f-9ce8-87c468d6d2ad@xxxxxxx/
>> Link: https://lore.kernel.org/all/7a22cc6a-deba-40e6-8033-97d1234420ba@xxxxxxx/
>> Link: https://lore.kernel.org/all/63e782a6-e33a-46ce-a455-5d207a60661f@xxxxxxx/
>> Link: https://lore.kernel.org/all/1a5ceda1-f039-4946-b8d7-2bc97ed48c00@xxxxxxx/
>>
>> Changes in v7:
>> - Drop the RCH mention from the third paragraph, as suggested by Ben.
>>
>> drivers/acpi/apei/einj-cxl.c | 3 +++
>> drivers/cxl/core/port.c | 7 +++++--
>> 2 files changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/acpi/apei/einj-cxl.c b/drivers/acpi/apei/einj-cxl.c
>> index e70a416ec925..22a7eb4dc75e 100644
>> --- a/drivers/acpi/apei/einj-cxl.c
>> +++ b/drivers/acpi/apei/einj-cxl.c
>> @@ -30,6 +30,9 @@ int einj_cxl_available_error_type_show(struct seq_file *m, void *v)
>> int cxl_err, rc;
>> u32 available_error_type = 0;
>>
>> + if (!einj_cxl_is_initialized())
>> + return -ENODEV;
>> +
>> rc = einj_get_available_error_type(&available_error_type, ACPI_EINJ_GET_ERROR_TYPE);
>> if (rc)
>> return rc;
>> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
>> index 625e4aa427db..a949228de936 100644
>> --- a/drivers/cxl/core/port.c
>> +++ b/drivers/cxl/core/port.c
>> @@ -806,6 +806,9 @@ static int cxl_einj_inject(void *data, u64 type)
>> {
>> struct cxl_dport *dport = data;
>>
>> + if (!einj_cxl_is_initialized())
>> + return -ENODEV;
>> +
>> if (dport->rch)
>> return einj_cxl_inject_rch_error(dport->rcrb.base, type);
>>
>> @@ -819,7 +822,7 @@ static void cxl_debugfs_create_dport_dir(struct cxl_dport *dport)
>> struct cxl_port *parent = parent_port_of(dport->port);
>> struct dentry *dir;
>>
>> - if (!einj_cxl_is_initialized())
>> + if (!IS_ENABLED(CONFIG_ACPI_APEI_EINJ_CXL))
>> return;
>>
>> /*
>> @@ -2515,7 +2518,7 @@ static __init int cxl_core_init(void)
>>
>> cxl_debugfs = debugfs_create_dir("cxl", NULL);
>>
>> - if (einj_cxl_is_initialized())
>> + if (IS_ENABLED(CONFIG_ACPI_APEI_EINJ_CXL))
>> debugfs_create_file("einj_types", 0400, cxl_debugfs, NULL,
>> &einj_cxl_available_error_type_fops);
>
> Why are the two new einj_cxl_is_initialized() checks at different
> levels?
>
> einj_cxl_available_error_type_show() checks for itself, but
> einj_cxl_inject_error() and einj_cxl_inject_rch_error() rely on their
> caller, cxl_einj_inject().
>
> Can all three helpers check, like the !CONFIG_ACPI_APEI_EINJ_CXL stubs do?
>
> -- Alison
>
>>
>> --
>> 2.25.1
>>