public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux ACPI <linux-acpi@vger.kernel.org>,
	Jonathan Cameron <jonathan.cameron@huawei.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Russell King (Oracle)" <linux@armlinux.org.uk>
Subject: [PATCH v2 5/5] ACPI: scan: Consolidate Device Check and Bus Check notification handling
Date: Mon, 26 Feb 2024 17:46:41 +0100	[thread overview]
Message-ID: <7632957.EvYhyI6sBW@kreacher> (raw)
In-Reply-To: <6021126.lOV4Wx5bFT@kreacher>

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

There is no particular reason why device object subtree rescans in
acpi_scan_device_check() and acpi_scan_device_check() should be carried
out differently, so move the rescan code into a new function called
acpi_scan_rescan_bus() and make both the functions above invoke it.

While at it, in the Device Check case, start the device object subtree
rescan mentioned above from the target device's parent, as per the
specification. [1]

Link: https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#device-object-notification-values # [1]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---

v1 -> v2:
   * New patch (split off patch [3/4] from v1).

---
 drivers/acpi/scan.c |   44 +++++++++++++++++++++++++-------------------
 1 file changed, 25 insertions(+), 19 deletions(-)

Index: linux-pm/drivers/acpi/scan.c
===================================================================
--- linux-pm.orig/drivers/acpi/scan.c
+++ linux-pm/drivers/acpi/scan.c
@@ -336,9 +336,25 @@ static int acpi_scan_hot_remove(struct a
 	return 0;
 }
 
+static int acpi_scan_rescan_bus(struct acpi_device *adev)
+{
+	struct acpi_scan_handler *handler = adev->handler;
+	int ret;
+
+	if (handler && handler->hotplug.scan_dependent)
+		ret = handler->hotplug.scan_dependent(adev);
+	else
+		ret = acpi_bus_scan(adev->handle);
+
+	if (ret)
+		dev_info(&adev->dev, "Namespace scan failure\n");
+
+	return ret;
+}
+
 static int acpi_scan_device_check(struct acpi_device *adev)
 {
-	int error;
+	struct acpi_device *parent;
 
 	acpi_scan_check_subtree(adev);
 
@@ -356,36 +372,26 @@ static int acpi_scan_device_check(struct
 		dev_dbg(&adev->dev, "Already enumerated\n");
 		return 0;
 	}
-	error = acpi_bus_scan(adev->handle);
-	if (error)
-		dev_warn(&adev->dev, "Namespace scan failure\n");
 
-	return error;
+	parent = acpi_dev_parent(adev);
+	if (!parent)
+		parent = adev;
+
+	return acpi_scan_rescan_bus(parent);
 }
 
-static int acpi_scan_bus_check(struct acpi_device *adev, void *not_used)
+static int acpi_scan_bus_check(struct acpi_device *adev)
 {
-	struct acpi_scan_handler *handler = adev->handler;
-	int error;
-
 	acpi_scan_check_subtree(adev);
 
-	if (handler && handler->hotplug.scan_dependent)
-		return handler->hotplug.scan_dependent(adev);
-
-	error = acpi_bus_scan(adev->handle);
-	if (error) {
-		dev_warn(&adev->dev, "Namespace scan failure\n");
-		return error;
-	}
-	return acpi_dev_for_each_child(adev, acpi_scan_bus_check, NULL);
+	return acpi_scan_rescan_bus(adev);
 }
 
 static int acpi_generic_hotplug_event(struct acpi_device *adev, u32 type)
 {
 	switch (type) {
 	case ACPI_NOTIFY_BUS_CHECK:
-		return acpi_scan_bus_check(adev, NULL);
+		return acpi_scan_bus_check(adev);
 	case ACPI_NOTIFY_DEVICE_CHECK:
 		return acpi_scan_device_check(adev);
 	case ACPI_NOTIFY_EJECT_REQUEST:




  parent reply	other threads:[~2024-02-26 16:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-26 16:24 [PATCH v2 0/5] ACPI: scan: Check enabled _STA bit on Bus/Device Checks Rafael J. Wysocki
2024-02-26 16:35 ` [PATCH v2 1/5] ACPI: scan: Fix device check notification handling Rafael J. Wysocki
2024-02-26 16:36 ` [PATCH v2 2/5] ACPI: scan: Relocate acpi_bus_trim_one() Rafael J. Wysocki
2024-02-26 16:49   ` Rafael J. Wysocki
2024-02-26 16:40 ` [PATCH v2 3/5] ACPI: scan: Make acpi_processor_add() check the device enabled bit Rafael J. Wysocki
2024-02-27  9:28   ` Jonathan Cameron
2024-02-27 11:13     ` Rafael J. Wysocki
2024-02-26 16:45 ` [PATCH v2 4/5] ACPI: scan: Rework Device Check and Bus Check notification handling Rafael J. Wysocki
2024-02-27  9:39   ` Jonathan Cameron
2024-02-26 16:46 ` Rafael J. Wysocki [this message]
2024-02-27  9:41   ` [PATCH v2 5/5] ACPI: scan: Consolidate " Jonathan Cameron

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=7632957.EvYhyI6sBW@kreacher \
    --to=rjw@rjwysocki.net \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mika.westerberg@linux.intel.com \
    --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