On Thu, 2024-03-14 at 15:18 +0200, andriy.shevchenko@xxxxxxxxxxxxxxx wrote: > On Thu, Mar 14, 2024 at 01:13:31AM +0000, Hamish Martin wrote: > > On Wed, 2024-03-13 at 13:26 +0200, Andy Shevchenko wrote: > > ... > > > Removing the setting of the handle to invalid may be the right fix > > but > > I don't feel I know the code well enough to make a decision on > > that. It > > certainly doesn't resolve things immediately - I saw ref counting > > warnings output. > > Not removing, but moving to the better place? > Can you share warnings, though? > For context here is the current call chain that leads to acpi_gpiochip_remove(): acpi_gpiochip_remove+0x32/0x1a0 gpiochip_remove+0x39/0x140 devres_release_group+0xe6/0x160 i2c_device_remove+0x2d/0x80 device_release_driver_internal+0x19a/0x200 bus_remove_device+0xbf/0x100 device_del+0x157/0x490 ? __pfx_device_match_fwnode+0x10/0x10 ? srso_return_thunk+0x5/0x5f device_unregister+0xd/0x30 i2c_acpi_notify+0x10e/0x160 notifier_call_chain+0x58/0xd0 blocking_notifier_call_chain+0x3a/0x60 acpi_device_del_work_fn+0x85/0x1d0 process_one_work+0x134/0x2f0 worker_thread+0x2f0/0x410 ? __pfx_worker_thread+0x10/0x10 kthread+0xe3/0x110 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x2f/0x50 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1b/0x30 I removed the setting of adev->handle = INVALID_ACPI_HANDLE from acpi_scan_drop_device() and shifted it to just after the call to blocking_notifier_call_chain() in acpi_device_del_work_fn(). With that it seems things progress further with the call to acpi_get_data() in acpi_gpiochip_remove() succeeding now. However, later in acpi_gpiochip_free_regions() we hit this error: pca953x i2c-PRP0001:03: Failed to remove GPIO OpRegion handler We also get these errors: ACPI Warning: Obj 00000000ba6a9600, Reference Count is already zero, cannot decrement (20230628/utdelete-422) > P.S. > I'm not an expert in ACPICA and low lever of ACPI glue layer in the > Linux > kernel, perhaps Rafael can suggest something better. > OK, thanks for your help. Hopefully Rafael can add something to the discssion. Thanks, Hamish M