ACPI mediated Hotplug?
Krishna Yenduri
kyenduri at brkt.com
Mon Jul 24 21:51:31 UTC 2017
> On Jul 20, 2017, at 10:19 AM, John Baldwin <jhb at freebsd.org> wrote:
>
> On Monday, May 22, 2017 11:12:43 AM Krishna Yenduri wrote:
>> ...
>> Is there a way to use the ACPI framework in FreeBSD so
>> that the Hotplug happens automatically?
>>
>> DTracing shows that adding a new interface triggers calls to
>> AcpiEvSciXruptHandler and AcpiEvAsynchExecuteGpeMethod.
>> Is it safe to add a hook in to pci_rescan_method() from these
>> routines? Any pointers to the ACPI<->FreeBSD kernel interface
>> are much appreciated.
>
> It is possible to support HotPlug via ACPI, however it is a bit more involved
> than that.
Agreed. Specifically, Hotplug detach is not triggering
any ACPI calls. So, even if I modify AcpiEvSciXruptHandler () to
get auto attach to work, auto detach will not work.
> There are ACPI methods for handling hotplug that are generic to
> ACPI (not PCI specific) which on some systems handle PCI hotplug. I believe
> there is a section discussing it in the ACPI spec. More details are present in
> the "Device Insertion, Removal, and Status Objects" section of the "Device
> Configuration" section of the ACPI spec (at least as of 6.1).
Thanks! I assume Intel folks wrote the ACPI code in FreeBSD and Linux.
It looks the Linux ACPI code is enhanced to support this ACPI mediated HotPlug (*).
> You might be
> able to make this work by installing a notify handler in the ACPI PCI bus
> driver (sys/dev/acpica/acpi_pci.c) and triggering a rescan in response to
> notifications with a value of 0. Something like this perhaps (untested):
Thanks! Much appreciated.
I tried this patch (after fixing a few nits). But, it did not work.
DTracing shows that acpi_pcib_notify_handler does not get called.
Regards,
-Krishna
* I traced the ACPI calls on Linux using ebpf and it supports the above theory -
# ./trace -K pci_enable_device
PID TID COMM FUNC
5 5 kworker/u30:0 pci_enable_device
pci_enable_device+0x1 [kernel]
local_pci_probe+0x45 [kernel]
pci_device_probe+0x103 [kernel]
driver_probe_device+0x2bb [kernel]
__device_attach_driver+0x8c [kernel]
bus_for_each_drv+0x67 [kernel]
__device_attach+0xdd [kernel]
device_attach+0x10 [kernel]
pci_bus_add_device+0x4f [kernel]
pci_bus_add_devices+0x39 [kernel]
enable_slot+0x26f [kernel]
acpiphp_hotplug_notify+0x14f [kernel]
acpi_device_hotplug+0x388 [kernel]
acpi_hotplug_work_fn+0x1e [kernel]
process_one_work+0x1fc [kernel]
worker_thread+0x4b [kernel]
kthread+0x101 [kernel]
ret_from_fork+0x2c [kernel]
# ./trace -K pci_enable_device pci_disable_device
PID TID COMM FUNC
41 41 kworker/u30:1 pci_disable_device
pci_disable_device+0x1 [kernel]
pci_device_remove+0x39 [kernel]
device_release_driver_internal+0x155 [kernel]
device_release_driver+0x12 [kernel]
pci_stop_bus_device+0x8a [kernel]
pci_stop_and_remove_bus_device+0x12 [kernel]
disable_slot+0x4f [kernel]
acpiphp_disable_and_eject_slot+0x1d [kernel]
acpiphp_hotplug_notify+0x9c [kernel]
acpi_device_hotplug+0x388 [kernel]
acpi_hotplug_work_fn+0x1e [kernel]
process_one_work+0x1fc [kernel]
worker_thread+0x4b [kernel]
kthread+0x101 [kernel]
ret_from_fork+0x2c [kernel]
More information about the freebsd-drivers
mailing list