From: "Luka Gejak" <luka.gejak@linux.dev>
To: "Hans de Goede" <johannes.goede@oss.qualcomm.com>,
"Ulf Hansson" <ulfh@kernel.org>
Cc: "Hans de Goede" <johannes.goede@oss.qualcomm.com>,
"Aaron Lu" <aaron.lu@intel.com>,
linux-mmc@vger.kernel.org, linux-acpi@vger.kernel.org
Subject: Re: [PATCH] mmc: sdio: Set acpi_device.power.flags.ignore_parent flag on sdio_func companion
Date: Sun, 18 Oct 2026 12:00:45 +0000 [thread overview]
Message-ID: <8ac7b295da3af2836e88faeb2b464f6ca80932d1@linux.dev> (raw)
In-Reply-To: <20261017160448.77436-1-johannes.goede@oss.qualcomm.com>
Hi Hans,
October 17, 2026 at 6:04 PM, "Hans de Goede" <johannes.goede@oss.qualcomm.com> wrote:
>
> Many MMC host drivers call pm_suspend_ignore_children() which allows
> to keep MMC cards and SDIO-functions on while the host is suspended.
>
> For SDIO functions which are in the ACPI power-domain this causes a race
> where the host may end up runtime-suspended before the driver for a SDIO
> function loads and probes it. When the probe() looses this race this causes
> the pm_runtime_get_sync() in sdio_bus_probe() to fail in the ACPI pm-domain
> code with e.g. the following error:
>
> ACPI: \_SB_.SDHB.WLAN: Cannot transition to D0 for parent in D3hot
>
> Busses using pm_suspend_ignore_children() for their children should set
> acpi_device.power.flags.ignore_parent on the ACPI companion device of
> their children to avoid this.
>
> This is safe todo because drivers for sdio_func devices should always
> call sdio_claim_host() before doing any IO and that runtime-resumes
> the host.
>
> Add the missing setting of the acpi_device.power.flags.ignore_parent flag
> to fix probing of SDIO functions sometimes failing on ACPI systems with
> the error mentioned above.
>
> Also add a sdio_acpi_clear_handle() function to undo this, since the ACPI
> companion device wills stay around after removing the sdio_func device. To
> make sdio_acpi_clear_handle() the proper inverse of sdio_acpi_set_handle()
> also make it actually clear the companion pointer on the sdio_func device.
> Technically this clearing is not really necessary since the sdio_func
> device will go away shortly afterwards anyways.
>
> Closes: https://github.com/MocLG/rtw/issues/2/
> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
> ---
[...]
+
> +static void sdio_acpi_clear_handle(struct sdio_func *func)
> +{
> + struct acpi_device *adev;
> +
> + adev = ACPI_COMPANION(&func->dev);
> + if (adev) {
> + adev->power.flags.ignore_parent = false;
> + ACPI_COMPANION_SET(&func->dev, NULL);
> + }
> }
> #else
> static inline void sdio_acpi_set_handle(struct sdio_func *func) {}
> +static inline void sdio_acpi_clear_handle(struct sdio_func *func) {}
> #endif
>
> static void sdio_set_of_node(struct sdio_func *func)
[...]
> @@ -414,6 +432,8 @@ int sdio_add_func(struct sdio_func *func)
> */
> void sdio_remove_func(struct sdio_func *func)
> {
> + sdio_acpi_clear_handle(func);
> +
> if (sdio_func_present(func))
> device_del(&func->dev);
>
I am not an expert on this topic, but clearing the companion here
before device_del(), looks wrong to me. As far as I understand
device_add() binds this device with acpi_bind_one() and that takes
a reference on both the companion and the device. The unbinding is
done in device_del() via acpi_device_notify_remove(), which returns
early when the companion is NULL, so does acpi_unbind_one()
never run and the physical_node entry, the sysfs links and the
references from acpi_bind_one() all stay behind and does that also
mean that sdio_release_func() never runs, causing the sdio_func and
its card reference to leak on every removal?
Also it seems to me that the stale entry stays first in the physical
node list, so the next card init would fail
acpi_device_is_first_physical_node() and would gets no ACPI PM domain
at all. Therefore the flag set here would then do nothing.
Would it be enough to only clear ignore_parent in sdio_acpi_clear_handle()
and let device_del() clear the companion?
Take this review with a grain of salt as I am not an expert on this
topic as I previously said.
Best regards,
Luka Gejak
next prev parent reply other threads:[~2026-10-18 12:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-17 16:04 [PATCH] mmc: sdio: Set acpi_device.power.flags.ignore_parent flag on sdio_func companion Hans de Goede
2026-10-17 16:06 ` Hans de Goede
2026-10-18 12:00 ` Luka Gejak [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-10-17 15:59 Hans de Goede
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=8ac7b295da3af2836e88faeb2b464f6ca80932d1@linux.dev \
--to=luka.gejak@linux.dev \
--cc=aaron.lu@intel.com \
--cc=johannes.goede@oss.qualcomm.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=ulfh@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.