NVDIMM Device and Persistent Memory development
 help / color / mirror / Atom feed
From: chenxiang <chenxiang66@hisilicon.com>
To: <michal.wilczynski@intel.com>, <rafael@kernel.org>
Cc: <linuxarm@huawei.com>, <linux-acpi@vger.kernel.org>,
	<nvdimm@lists.linux.dev>, Xiang Chen <chenxiang66@hisilicon.com>
Subject: [PATCH] Install Notify() handler before getting NFIT table
Date: Thu, 19 Oct 2023 21:01:21 +0800	[thread overview]
Message-ID: <1697720481-150095-1-git-send-email-chenxiang66@hisilicon.com> (raw)

From: Xiang Chen <chenxiang66@hisilicon.com>

If there is no NFIT at startup, it will return 0 immediately in function 
acpi_nfit_add() and will not install Notify() handler. If hotplugging 
a nvdimm device later, it will not be identified as there is no Notify() 
handler.
So move handler installing before getting NFI table in function 
acpi_nfit_add() to avoid above issue.

Fixes: dcca12ab62a2 ("ACPI: NFIT: Install Notify() handler directly")
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
 drivers/acpi/nfit/core.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 3826f49..9923855 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -3339,6 +3339,16 @@ static int acpi_nfit_add(struct acpi_device *adev)
 	acpi_size sz;
 	int rc = 0;
 
+	rc = acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
+					     acpi_nfit_notify, adev);
+	if (rc)
+		return rc;
+
+	rc = devm_add_action_or_reset(dev, acpi_nfit_remove_notify_handler,
+					adev);
+	if (rc)
+		return rc;
+
 	status = acpi_get_table(ACPI_SIG_NFIT, 0, &tbl);
 	if (ACPI_FAILURE(status)) {
 		/* The NVDIMM root device allows OS to trigger enumeration of
@@ -3386,17 +3396,7 @@ static int acpi_nfit_add(struct acpi_device *adev)
 	if (rc)
 		return rc;
 
-	rc = devm_add_action_or_reset(dev, acpi_nfit_shutdown, acpi_desc);
-	if (rc)
-		return rc;
-
-	rc = acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
-					     acpi_nfit_notify, adev);
-	if (rc)
-		return rc;
-
-	return devm_add_action_or_reset(dev, acpi_nfit_remove_notify_handler,
-					adev);
+	return devm_add_action_or_reset(dev, acpi_nfit_shutdown, acpi_desc);
 }
 
 static void acpi_nfit_update_notify(struct device *dev, acpi_handle handle)
-- 
2.8.1


             reply	other threads:[~2023-10-19 12:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-19 13:01 chenxiang [this message]
2023-10-19 15:43 ` [PATCH] Install Notify() handler before getting NFIT table Rafael J. Wysocki
2023-10-20 20:26   ` Ira Weiny
2023-10-22 10:53     ` Rafael J. Wysocki

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=1697720481-150095-1-git-send-email-chenxiang66@hisilicon.com \
    --to=chenxiang66@hisilicon.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=michal.wilczynski@intel.com \
    --cc=nvdimm@lists.linux.dev \
    --cc=rafael@kernel.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).