public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Ben Cheatham <Benjamin.Cheatham@amd.com>
To: <dan.j.williams@intel.com>, <dave@stogolabs.net>,
	<jonathan.cameron@huawei.com>, <dave.jiang@intel.com>,
	<alison.schofield@intel.com>, <vishal.l.verma@intel.com>,
	<ira.weiny@intel.com>, <rafael@kernel.org>
Cc: <linux-cxl@vger.kernel.org>, <linux-acpi@vger.kernel.org>,
	<benjamin.cheatham@amd.com>
Subject: [PATCH v8 2/5] ACPI, APEI, EINJ: Add wrapper __init function
Date: Wed, 13 Dec 2023 16:36:59 -0600	[thread overview]
Message-ID: <20231213223702.543419-3-Benjamin.Cheatham@amd.com> (raw)
In-Reply-To: <20231213223702.543419-1-Benjamin.Cheatham@amd.com>

The CXL core module should be able to load regardless of whether the
EINJ module initializes correctly. Instead of porting the EINJ module to
a library module, add a wrapper __init function around einj_init() to
pin the EINJ module even if it does not initialize correctly. This
should be fine since the EINJ module is only ever unloaded manually.

One note: since the CXL core will be calling into the EINJ module
directly, even though it may not have initialized, all CXL helper
functions *have* to check if the EINJ module is initialized before
doing any work.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Ben Cheatham <Benjamin.Cheatham@amd.com>
---
 drivers/acpi/apei/einj.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
index 013eb621dc92..26a887d2a5cd 100644
--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -615,6 +615,8 @@ static int available_error_type_show(struct seq_file *m, void *v)
 
 DEFINE_SHOW_ATTRIBUTE(available_error_type);
 
+static bool einj_initialized;
+
 static int error_type_get(void *data, u64 *val)
 {
 	*val = error_type;
@@ -684,7 +686,7 @@ static int einj_check_table(struct acpi_table_einj *einj_tab)
 	return 0;
 }
 
-static int __init einj_init(void)
+static int __init __einj_init(void)
 {
 	int rc;
 	acpi_status status;
@@ -782,10 +784,31 @@ static int __init einj_init(void)
 	return rc;
 }
 
+static int __init einj_init(void)
+{
+	int rc = __einj_init();
+
+	einj_initialized = (rc == 0);
+
+	/*
+	 * CXL needs to be able to link and call its EINJ helpers
+	 * regardless of whether the EINJ table is present and initialized
+	 * correctly. CXL helpers check @einj_initialized before
+	 * doing any work.
+	 */
+	if (IS_ENABLED(CONFIG_CXL_EINJ))
+		return 0;
+
+	return rc;
+}
+
 static void __exit einj_exit(void)
 {
 	struct apei_exec_context ctx;
 
+	if (!einj_initialized)
+		return;
+
 	if (einj_param) {
 		acpi_size size = (acpi5) ?
 			sizeof(struct set_error_type_with_address) :
-- 
2.34.1


  parent reply	other threads:[~2023-12-13 22:37 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-13 22:36 [PATCH v8 0/5] CXL, ACPI, APEI, EINJ: Update EINJ for CXL error types Ben Cheatham
2023-12-13 22:36 ` [PATCH v8 1/5] cxl, ACPI, APEI, EINJ: Add CXL_EINJ Kconfig option Ben Cheatham
2023-12-18 23:48   ` Dan Williams
2024-01-10 20:31     ` Ben Cheatham
2023-12-13 22:36 ` Ben Cheatham [this message]
2023-12-18 23:59   ` [PATCH v8 2/5] ACPI, APEI, EINJ: Add wrapper __init function Dan Williams
2023-12-19 15:39     ` Jonathan Cameron
2023-12-19 20:48       ` Dan Williams
2023-12-20 14:37         ` Ben Cheatham
2023-12-20 23:51           ` Dan Williams
2023-12-20 14:33       ` Ben Cheatham
2023-12-13 22:37 ` [PATCH v8 3/5] ACPI: Add CXL protocol error defines Ben Cheatham
2023-12-19  5:09   ` Dan Williams
2023-12-13 22:37 ` [PATCH v8 4/5] cxl/core, EINJ: Add CXL debugfs files and EINJ functions Ben Cheatham
2023-12-19  4:47   ` Dan Williams
2024-01-10 20:31     ` Ben Cheatham
2024-01-10 22:10       ` Dan Williams
2024-01-10 22:17         ` Ben Cheatham
2023-12-13 22:37 ` [PATCH v8 5/5] EINJ, Documentation: Update EINJ kernel doc Ben Cheatham

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=20231213223702.543419-3-Benjamin.Cheatham@amd.com \
    --to=benjamin.cheatham@amd.com \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stogolabs.net \
    --cc=ira.weiny@intel.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=vishal.l.verma@intel.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