Re: [PATCH] ACPI: dock: Retry probing battery docks after hotplug
From: Rafael J. Wysocki (Intel)
Date: Mon Oct 12 2026 - 14:01:40 EST
On Sat, Oct 3, 2026 at 6:40 PM Vibhor Goel <vibhor1102@xxxxxxxxx> wrote:
>
> On a ThinkPad T480 booted with the removable battery absent, reinserting
> that battery can leave BAT1 missing from /sys/class/power_supply even
> after firmware sends an ACPI add notification.
>
> The battery dock platform device already exists, but its driver did not
> bind while the battery was absent. During hotplug, acpi_bus_scan()
> updates the ACPI device and attempts to attach it on the ACPI bus.
> acpi_create_platform_device() does not create another platform device
> because the existing physical node is still associated with the ACPI
> device. Consequently, the existing platform device remains unbound.
>
> Retry probing the battery dock platform device after hotplug_dock_devices()
> has refreshed the ACPI state. Restrict this to battery docks. If the
> platform device is already bound, device_initial_probe() leaves that
> binding in place.
>
> Signed-off-by: Vibhor Goel <vibhor1102@xxxxxxxxx>
> ---
> Tested on a dual-battery ThinkPad T480 with an aftermarket external pack.
>
> On Fedora 7.2.8-200.fc44.x86_64, tracing showed the firmware add
> notification, a successful ACPI rescan, and no attachment attempt for the
> existing dock.0 platform device. A subsequent manual bind registered BAT1.
>
> On patched upstream v7.2.8, booting with BAT1 absent and then triggering a
> firmware add notification automatically called device_initial_probe(),
> bound acpi-battery and registered BAT1. UPower detected the battery too.
> Removal and reinsertion after binding also worked, without a second driver
> probe. Both captures completed without trace-buffer loss.
>
> Physical reinsertion initially produced no add notification on this pack;
> toggling charger mains while leaving the battery untouched triggered one.
> This patch addresses Linux handling after that notification. The initial
> notification behavior is outside its scope.
>
> The baseline and patched kernels differ in configuration and Fedora
> patches. The traces identify the missing attachment operation and show the
> new call resolving it; this was not a same-source unpatched comparison.
>
> Built the kernel and all 221 configured modules, booted with Secure Boot
> enabled, and tested on the physical laptop. The patch was developed with
> AI assistance and reviewed and tested by me.
>
> drivers/acpi/dock.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
> index d7f3a8912..748df19d9 100644
> --- a/drivers/acpi/dock.c
> +++ b/drivers/acpi/dock.c
> @@ -445,6 +445,14 @@ int dock_notify(struct acpi_device *adev, u32 event)
> break;
> }
> hotplug_dock_devices(ds, event);
> + /*
> + * The dock platform device already exists when an empty battery
> + * bay becomes occupied, but its driver may not have bound while
> + * the battery was absent. Retry after the ACPI scan updates its
> + * status, since the scan only attaches the ACPI device.
> + */
> + if (ds->flags & DOCK_IS_BAT)
> + device_initial_probe(&ds->dock_device->dev);
> complete_dock(ds);
> dock_event(ds, event, DOCK_EVENT);
> acpi_evaluate_lck(ds->handle, 1);
> --
Applied as 7.4 material, thanks!