linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ACPI: scan: Fix _STA getting called on devices with unmet dependencies
@ 2021-03-29 15:46 Hans de Goede
  2021-03-29 17:33 ` Rafael J. Wysocki
  2021-03-30 18:46 ` Hans de Goede
  0 siblings, 2 replies; 3+ messages in thread
From: Hans de Goede @ 2021-03-29 15:46 UTC (permalink / raw)
  To: Rafael J . Wysocki, Len Brown; +Cc: Hans de Goede, linux-acpi

Commit 71da201f38df ("ACPI: scan: Defer enumeration of devices with
_DEP lists") dropped the following 2 lines from acpi_init_device_object():

	/* Assume there are unmet deps until acpi_device_dep_initialize() runs */
	device->dep_unmet = 1;

Leaving the initial value of dep_unmet at the 0 from the kzalloc(). This
causes the acpi_bus_get_status() call in acpi_add_single_object() to
actually call _STA, even though there maybe unmet deps, leading to errors
like these:

[    0.123579] ACPI Error: No handler for Region [ECRM] (00000000ba9edc4c)
               [GenericSerialBus] (20170831/evregion-166)
[    0.123601] ACPI Error: Region GenericSerialBus (ID=9) has no handler
               (20170831/exfldio-299)
[    0.123618] ACPI Error: Method parse/execution failed
               \_SB.I2C1.BAT1._STA, AE_NOT_EXIST (20170831/psparse-550)

Fix this by re-adding the dep_unmet = 1 initialization to
acpi_init_device_object() and modifying acpi_bus_check_add() to make sure
that dep_unmet always gets setup there, overriding the initial 1 value.

This re-fixes the issue initially fixed by
commit 63347db0affa ("ACPI / scan: Use acpi_bus_get_status() to initialize
ACPI_TYPE_DEVICE devs"), which introduced the removed
"device->dep_unmet = 1;" statement.

This issue was noticed; and the fix tested on a Dell Venue 10 Pro 5055.

Fixes: 71da201f38df ("ACPI: scan: Defer enumeration of devices with _DEP lists")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/acpi/scan.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 1584c9e463bd..aca4edc8fe6b 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1647,6 +1647,8 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
 	device_initialize(&device->dev);
 	dev_set_uevent_suppress(&device->dev, true);
 	acpi_init_coherency(device);
+	/* Assume there are unmet deps to start with. */
+	device->dep_unmet = 1;
 }
 
 void acpi_device_add_finalize(struct acpi_device *device)
@@ -1957,7 +1959,13 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep,
 		return AE_CTRL_DEPTH;
 
 	acpi_scan_init_hotplug(device);
-	if (!check_dep)
+	/*
+	 * If check_dep is true at this point, the device has no dependencies,
+	 * or the creation of the device object would have been postponed above.
+	 */
+	if (check_dep)
+		device->dep_unmet = 0;
+	else
 		acpi_scan_dep_init(device);
 
 out:
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] ACPI: scan: Fix _STA getting called on devices with unmet dependencies
  2021-03-29 15:46 [PATCH v2] ACPI: scan: Fix _STA getting called on devices with unmet dependencies Hans de Goede
@ 2021-03-29 17:33 ` Rafael J. Wysocki
  2021-03-30 18:46 ` Hans de Goede
  1 sibling, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2021-03-29 17:33 UTC (permalink / raw)
  To: Hans de Goede; +Cc: Rafael J . Wysocki, Len Brown, ACPI Devel Maling List

On Mon, Mar 29, 2021 at 5:47 PM Hans de Goede <hdegoede@redhat.com> wrote:
>
> Commit 71da201f38df ("ACPI: scan: Defer enumeration of devices with
> _DEP lists") dropped the following 2 lines from acpi_init_device_object():
>
>         /* Assume there are unmet deps until acpi_device_dep_initialize() runs */
>         device->dep_unmet = 1;
>
> Leaving the initial value of dep_unmet at the 0 from the kzalloc(). This
> causes the acpi_bus_get_status() call in acpi_add_single_object() to
> actually call _STA, even though there maybe unmet deps, leading to errors
> like these:
>
> [    0.123579] ACPI Error: No handler for Region [ECRM] (00000000ba9edc4c)
>                [GenericSerialBus] (20170831/evregion-166)
> [    0.123601] ACPI Error: Region GenericSerialBus (ID=9) has no handler
>                (20170831/exfldio-299)
> [    0.123618] ACPI Error: Method parse/execution failed
>                \_SB.I2C1.BAT1._STA, AE_NOT_EXIST (20170831/psparse-550)
>
> Fix this by re-adding the dep_unmet = 1 initialization to
> acpi_init_device_object() and modifying acpi_bus_check_add() to make sure
> that dep_unmet always gets setup there, overriding the initial 1 value.
>
> This re-fixes the issue initially fixed by
> commit 63347db0affa ("ACPI / scan: Use acpi_bus_get_status() to initialize
> ACPI_TYPE_DEVICE devs"), which introduced the removed
> "device->dep_unmet = 1;" statement.
>
> This issue was noticed; and the fix tested on a Dell Venue 10 Pro 5055.
>
> Fixes: 71da201f38df ("ACPI: scan: Defer enumeration of devices with _DEP lists")
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Applied as 5.12-rc material, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] ACPI: scan: Fix _STA getting called on devices with unmet dependencies
  2021-03-29 15:46 [PATCH v2] ACPI: scan: Fix _STA getting called on devices with unmet dependencies Hans de Goede
  2021-03-29 17:33 ` Rafael J. Wysocki
@ 2021-03-30 18:46 ` Hans de Goede
  1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2021-03-30 18:46 UTC (permalink / raw)
  To: Rafael J . Wysocki, Len Brown; +Cc: linux-acpi

Hi Rafael,

On 3/29/21 5:46 PM, Hans de Goede wrote:
> Commit 71da201f38df ("ACPI: scan: Defer enumeration of devices with
> _DEP lists") dropped the following 2 lines from acpi_init_device_object():
> 
> 	/* Assume there are unmet deps until acpi_device_dep_initialize() runs */
> 	device->dep_unmet = 1;
> 
> Leaving the initial value of dep_unmet at the 0 from the kzalloc(). This
> causes the acpi_bus_get_status() call in acpi_add_single_object() to
> actually call _STA, even though there maybe unmet deps, leading to errors
> like these:
> 
> [    0.123579] ACPI Error: No handler for Region [ECRM] (00000000ba9edc4c)
>                [GenericSerialBus] (20170831/evregion-166)
> [    0.123601] ACPI Error: Region GenericSerialBus (ID=9) has no handler
>                (20170831/exfldio-299)
> [    0.123618] ACPI Error: Method parse/execution failed
>                \_SB.I2C1.BAT1._STA, AE_NOT_EXIST (20170831/psparse-550)
> 
> Fix this by re-adding the dep_unmet = 1 initialization to
> acpi_init_device_object() and modifying acpi_bus_check_add() to make sure
> that dep_unmet always gets setup there, overriding the initial 1 value.
> 
> This re-fixes the issue initially fixed by
> commit 63347db0affa ("ACPI / scan: Use acpi_bus_get_status() to initialize
> ACPI_TYPE_DEVICE devs"), which introduced the removed
> "device->dep_unmet = 1;" statement.
> 
> This issue was noticed; and the fix tested on a Dell Venue 10 Pro 5055.
> 
> Fixes: 71da201f38df ("ACPI: scan: Defer enumeration of devices with _DEP lists")
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Self-nack, sorry, I know you already merged this, but I hope you can still replace
it, as this is broken. It causes dep_unmet to never reach 0 for devices with deps
because it is missing this:

--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1910,6 +1910,8 @@ static void acpi_scan_dep_init(struct acpi_device *adev)
 {
 	struct acpi_dep_data *dep;
 
+	adev->dep_unmet = 0;
+
 	mutex_lock(&acpi_dep_list_lock);
 
 	list_for_each_entry(dep, &acpi_dep_list, node) {

So now acpi_scan_dep_init() starts with 1 dep and then adds the actual
number of deps on top.

I'll send a v3 fixing this as soon as I've tested it.

(I should have noticed the battery reporting was gone with v2, but
I only checked that the errors were gone from dmesg...)

Let me know if you want a follow-up patch fixing this instead.

Regards,

Hans







> ---
>  drivers/acpi/scan.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
> index 1584c9e463bd..aca4edc8fe6b 100644
> --- a/drivers/acpi/scan.c
> +++ b/drivers/acpi/scan.c
> @@ -1647,6 +1647,8 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
>  	device_initialize(&device->dev);
>  	dev_set_uevent_suppress(&device->dev, true);
>  	acpi_init_coherency(device);
> +	/* Assume there are unmet deps to start with. */
> +	device->dep_unmet = 1;
>  }
>  
>  void acpi_device_add_finalize(struct acpi_device *device)
> @@ -1957,7 +1959,13 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep,
>  		return AE_CTRL_DEPTH;
>  
>  	acpi_scan_init_hotplug(device);
> -	if (!check_dep)
> +	/*
> +	 * If check_dep is true at this point, the device has no dependencies,
> +	 * or the creation of the device object would have been postponed above.
> +	 */
> +	if (check_dep)
> +		device->dep_unmet = 0;
> +	else
>  		acpi_scan_dep_init(device);
>  
>  out:
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-30 18:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-29 15:46 [PATCH v2] ACPI: scan: Fix _STA getting called on devices with unmet dependencies Hans de Goede
2021-03-29 17:33 ` Rafael J. Wysocki
2021-03-30 18:46 ` Hans de Goede

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 NNTP newsgroup(s).