ACPI: NFIT: Install Notify() handler before getting NFIT table
authorXiang Chen <chenxiang66@hisilicon.com>
Thu, 19 Oct 2023 13:01:21 +0000 (21:01 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sun, 22 Oct 2023 10:47:43 +0000 (12:47 +0200)
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.

Install the handler 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>
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/nfit/core.c

index f96bf32cd3687599573b7d2c60a1fe64b4340452..7d88db451cfbfe17c5f8196fa90c5af3d5cc594e 100644 (file)
@@ -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);
+       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);
-       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)