From: Dan Williams <dan.j.williams@intel.com>
To: Ben Cheatham <Benjamin.Cheatham@amd.com>,
<dan.j.williams@intel.com>, <jonathan.cameron@huawei.com>,
<rafael@kernel.org>, <james.morse@arm.com>, <tony.luck@intel.com>,
<bp@alien8.de>
Cc: <dave@stogolabs.net>, <dave.jiang@intel.com>,
<alison.schofield@intel.com>, <vishal.l.verma@intel.com>,
<ira.weiny@intel.com>, <linux-cxl@vger.kernel.org>,
<linux-acpi@vger.kernel.org>, <benjamin.cheatham@amd.com>
Subject: RE: [PATCH v13 1/4] EINJ: Migrate to a platform driver
Date: Tue, 20 Feb 2024 22:18:49 -0800 [thread overview]
Message-ID: <65d595c990661_5e9bf294d@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <20240220221146.399209-2-Benjamin.Cheatham@amd.com>
Ben Cheatham wrote:
> Change the EINJ module to install a platform device/driver on module
> init and move the module init() and exit() functions to driver probe and
> remove. This change allows the EINJ module to load regardless of whether
> setting up EINJ succeeds, which allows dependent modules to still load
> (i.e. the CXL core).
>
> Since EINJ may no longer be initialized when the module loads, any
> functions that are called from dependent/external modules should check
> the einj_initialized variable before calling any EINJ functions.
>
> Signed-off-by: Ben Cheatham <Benjamin.Cheatham@amd.com>
> ---
> drivers/acpi/apei/einj.c | 46 +++++++++++++++++++++++++++++++++++++---
> 1 file changed, 43 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
> index 89fb9331c611..6ea323b9d8ef 100644
> --- a/drivers/acpi/apei/einj.c
> +++ b/drivers/acpi/apei/einj.c
> @@ -21,6 +21,7 @@
> #include <linux/nmi.h>
> #include <linux/delay.h>
> #include <linux/mm.h>
> +#include <linux/platform_device.h>
> #include <asm/unaligned.h>
>
> #include "apei-internal.h"
> @@ -137,6 +138,11 @@ static struct apei_exec_ins_type einj_ins_type[] = {
> */
> static DEFINE_MUTEX(einj_mutex);
>
> +/*
> + * Exported APIs use this flag to exit early if einj_probe() failed.
> + */
> +static bool einj_initialized __ro_after_init;
> +
> static void *einj_param;
>
> static void einj_exec_ctx_init(struct apei_exec_context *ctx)
> @@ -703,7 +709,7 @@ static int einj_check_table(struct acpi_table_einj *einj_tab)
> return 0;
> }
>
> -static int __init einj_init(void)
> +static int __init einj_probe(struct platform_device *pdev)
> {
> int rc;
> acpi_status status;
> @@ -717,7 +723,7 @@ static int __init einj_init(void)
> status = acpi_get_table(ACPI_SIG_EINJ, 0,
> (struct acpi_table_header **)&einj_tab);
> if (status == AE_NOT_FOUND) {
> - pr_warn("EINJ table not found.\n");
> + pr_info("EINJ table not found.\n");
Per comment on cover letter this should be pr_debug() to hide it given
that this module is no longer only loaded manually.
> return -ENODEV;
> } else if (ACPI_FAILURE(status)) {
> pr_err("Failed to get EINJ table: %s\n",
> @@ -805,7 +811,7 @@ static int __init einj_init(void)
> return rc;
> }
>
> -static void __exit einj_exit(void)
> +static void __exit einj_remove(struct platform_device *pdev)
> {
> struct apei_exec_context ctx;
>
> @@ -826,6 +832,40 @@ static void __exit einj_exit(void)
> acpi_put_table((struct acpi_table_header *)einj_tab);
> }
>
> +static struct platform_device *einj_dev;
> +struct platform_driver einj_driver = {
This can be static.
> + .remove_new = einj_remove,
> + .driver = {
> + .name = "acpi-einj",
> + },
> +};
> +
> +static int __init einj_init(void)
> +{
> + struct platform_device_info einj_dev_info = {
> + .name = "acpi-einj",
> + .id = -1,
> + };
> + int rc;
> +
> + einj_dev = platform_device_register_full(&einj_dev_info);
> + if (IS_ERR_OR_NULL(einj_dev))
Given that platform_device_register_full() never returns NULL, this
should be IS_ERR().
> + return PTR_ERR(einj_dev);
> +
> + rc = platform_driver_probe(&einj_driver, einj_probe);
> + einj_initialized = rc == 0;
> +
> + return 0;
> +}
> +
> +static void __exit einj_exit(void)
> +{
> + if (einj_initialized)
> + platform_driver_unregister(&einj_driver);
> +
> + platform_device_del(einj_dev);
> +}
> +
> module_init(einj_init);
> module_exit(einj_exit);
>
> --
> 2.34.1
>
next prev parent reply other threads:[~2024-02-21 6:18 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-20 22:11 [PATCH v13 0/4] cxl, EINJ: Update EINJ for CXL error types Ben Cheatham
2024-02-20 22:11 ` [PATCH v13 1/4] EINJ: Migrate to a platform driver Ben Cheatham
2024-02-21 6:18 ` Dan Williams [this message]
2024-02-21 20:27 ` Ben Cheatham
2024-02-20 22:11 ` [PATCH v13 2/4] EINJ: Add CXL error type support Ben Cheatham
2024-02-21 17:43 ` Dan Williams
2024-02-21 20:27 ` Ben Cheatham
2024-02-21 20:34 ` Ben Cheatham
2024-02-21 20:41 ` Dan Williams
2024-02-21 21:00 ` Ben Cheatham
2024-02-21 22:05 ` Dan Williams
2024-02-23 1:13 ` Davidlohr Bueso
2024-02-23 15:33 ` Ben Cheatham
2024-02-22 7:49 ` kernel test robot
2024-02-20 22:11 ` [PATCH v13 3/4] cxl/core: Add CXL EINJ debugfs files Ben Cheatham
2024-02-21 17:48 ` Dan Williams
2024-02-21 20:27 ` Ben Cheatham
2024-02-20 22:11 ` [PATCH v13 4/4] EINJ, Documentation: Update EINJ kernel doc Ben Cheatham
2024-02-21 20:27 ` Dan Williams
2024-02-20 23:04 ` [PATCH v13 0/4] cxl, EINJ: Update EINJ for CXL error types Dan Williams
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=65d595c990661_5e9bf294d@dwillia2-xfh.jf.intel.com.notmuch \
--to=dan.j.williams@intel.com \
--cc=Benjamin.Cheatham@amd.com \
--cc=alison.schofield@intel.com \
--cc=bp@alien8.de \
--cc=dave.jiang@intel.com \
--cc=dave@stogolabs.net \
--cc=ira.weiny@intel.com \
--cc=james.morse@arm.com \
--cc=jonathan.cameron@huawei.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=tony.luck@intel.com \
--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