mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alison Schofield <alison.schofield@intel.com>
To: Yongxin Yang <yangyongxin@kylinos.cn>
Cc: Davidlohr Bueso <dave@stgolabs.net>,
	Jonathan Cameron <jic23@kernel.org>,
	Dave Jiang <dave.jiang@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Ira Weiny <iweiny@kernel.org>, Dan Williams <djbw@kernel.org>,
	"Rafael J . Wysocki" <rafael@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>,
	"Len Brown" <lenb@kernel.org>, Li Ming <ming.li@zohomail.com>,
	Robert Richter <rrichter@amd.com>,
	Ben Cheatham <benjamin.cheatham@amd.com>,
	<linux-cxl@vger.kernel.org>, <linux-acpi@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v7] cxl/core: Create EINJ debugfs files regardless of EINJ init order
Date: Tue, 17 Nov 2026 14:04:30 -0800	[thread overview]
Message-ID: <avzPbtCq9CedwCZt@aschofie-mobl2.lan> (raw)
In-Reply-To: <20261104061256.1449275-1-yangyongxin@kylinos.cn>

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...

> 
> Fixes: 8039804cfa73 ("cxl/core: Add CXL EINJ debugfs files")
> Reviewed-by: Ben Cheatham <benjamin.cheatham@amd.com>
> Signed-off-by: Yongxin Yang <yangyongxin@kylinos.cn>
> ---
> Link: https://lore.kernel.org/all/de14c4ef-e3d8-432f-9ce8-87c468d6d2ad@amd.com/
> Link: https://lore.kernel.org/all/7a22cc6a-deba-40e6-8033-97d1234420ba@amd.com/
> Link: https://lore.kernel.org/all/63e782a6-e33a-46ce-a455-5d207a60661f@amd.com/
> Link: https://lore.kernel.org/all/1a5ceda1-f039-4946-b8d7-2bc97ed48c00@amd.com/
> 
> 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
> 

  parent reply	other threads:[~2026-11-17 22:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02  3:24 [PATCH v5] cxl/core: Create einj_types " Yongxin Yang
2026-11-02 21:32 ` Cheatham, Benjamin
2026-11-03  5:36 ` [PATCH v6] cxl/core: Create EINJ debugfs files " Yongxin Yang
2026-11-03 21:31   ` Cheatham, Benjamin
2026-11-04  6:12     ` [PATCH v7] " Yongxin Yang
2026-11-16  2:33       ` Yongxin Yang
2026-11-16 22:27       ` Dave Jiang
2026-11-17 22:04       ` Alison Schofield [this message]
2026-11-17 22:38         ` Dave Jiang
2026-11-18  1:23           ` Yongxin Yang

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=avzPbtCq9CedwCZt@aschofie-mobl2.lan \
    --to=alison.schofield@intel.com \
    --cc=benjamin.cheatham@amd.com \
    --cc=bp@alien8.de \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=djbw@kernel.org \
    --cc=guohanjun@huawei.com \
    --cc=iweiny@kernel.org \
    --cc=jic23@kernel.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=ming.li@zohomail.com \
    --cc=rafael@kernel.org \
    --cc=rrichter@amd.com \
    --cc=tony.luck@intel.com \
    --cc=vishal.l.verma@intel.com \
    --cc=xueshuai@linux.alibaba.com \
    --cc=yangyongxin@kylinos.cn \
    /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

all inboxes | Powered by JetHome®