* [PATCH] ACPI: dock: Retry probing battery docks after hotplug
@ 2026-10-03 16:40 Vibhor Goel
0 siblings, 0 replies; only message in thread
From: Vibhor Goel @ 2026-10-03 16:40 UTC (permalink / raw)
To: rafael; +Cc: lenb, linux-acpi, linux-kernel
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@gmail.com>
---
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);
--
2.55.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-03 16:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-03 16:40 [PATCH] ACPI: dock: Retry probing battery docks after hotplug Vibhor Goel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®