Linux-ACPI Archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Hans de Goede <hdegoede@redhat.com>
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
	Len Brown <lenb@kernel.org>,
	linux-acpi@vger.kernel.org
Subject: Re: [PATCH] ACPI: scan: Do not increase dep_unmet for already met dependencies
Date: Mon, 8 Apr 2024 16:48:46 +0200	[thread overview]
Message-ID: <CAJZ5v0iApfHiCJ-_9eLE9yuZa8RD3vQ+5aBZjpFpnzMS4+TbvQ@mail.gmail.com> (raw)
In-Reply-To: <20240406114052.4884-1-hdegoede@redhat.com>

On Sat, Apr 6, 2024 at 1:43 PM Hans de Goede <hdegoede@redhat.com> wrote:
>
> On the Toshiba Encore WT10-A tablet the BATC battery ACPI device depends
> on 3 other devices:
>
>             Name (_DEP, Package (0x03)  // _DEP: Dependencies
>             {
>                 I2C1,
>                 GPO2,
>                 GPO0
>             })
>
> acpi_scan_check_dep() adds all 3 of these to the acpi_dep_list and then
> before an acpi_device is created for the BATC handle (and thus before
> acpi_scan_dep_init() runs) acpi_scan_clear_dep() gets called for both
> GPIO depenencies, with free_when_met not set for the dependencies.
>
> Since there is no adev for BATC yet, there also is no dep_unmet to
> decrement. The only result of acpi_scan_clear_dep() in this case is
> dep->met getting set.
>
> Soon after acpi_scan_clear_dep() has been called for the GPIO dependencies
> the acpi_device gets created for the BATC handle and acpi_scan_dep_init()
> runs, this sees 3 dependencies on the acpi_dep_list and initializes
> unmet_dep to 3. Later when the dependency for I2C1 is met unmet_dep
> becomes 2, but since the 2 GPIO deps where already met it never becomes 0
> causing battery monitoring to not work.
>
> Fix this by modifying acpi_scan_dep_init() to not increase dep_met for
> dependencies which have already been marked as being met.
>
> Fixes: 3ba12d8de3fa ("ACPI: scan: Reduce overhead related to devices with dependencies")
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/acpi/scan.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
> index 7c157bf92695..d1464324de95 100644
> --- a/drivers/acpi/scan.c
> +++ b/drivers/acpi/scan.c
> @@ -1843,7 +1843,8 @@ static void acpi_scan_dep_init(struct acpi_device *adev)
>                         if (dep->honor_dep)
>                                 adev->flags.honor_deps = 1;
>
> -                       adev->dep_unmet++;
> +                       if (!dep->met)
> +                               adev->dep_unmet++;

Nice catch!

>                 }
>         }
>  }
> --

Applied as 6.9-rc material, thanks!

      reply	other threads:[~2024-04-08 14:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-06 11:40 [PATCH] ACPI: scan: Do not increase dep_unmet for already met dependencies Hans de Goede
2024-04-08 14:48 ` Rafael J. Wysocki [this message]

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=CAJZ5v0iApfHiCJ-_9eLE9yuZa8RD3vQ+5aBZjpFpnzMS4+TbvQ@mail.gmail.com \
    --to=rafael@kernel.org \
    --cc=hdegoede@redhat.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.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).