Date: Mon, 24 Jul 2017 14:51:28 -0700 From: Krishna Yenduri <kyenduri@brkt.com> To: John Baldwin <jhb@freebsd.org> Cc: freebsd-drivers@freebsd.org Subject: Re: ACPI mediated Hotplug? Message-ID: <D76A4571-9847-4063-9ED5-5DF133D0E6A3@brkt.com> In-Reply-To: <3585281.TQq0CdjIrL@ralph.baldwin.cx> References: <3DDBEFB3-AB51-4AD2-845D-A8B81ECB417A@brkt.com> <3585281.TQq0CdjIrL@ralph.baldwin.cx>
next in thread | previous in thread | raw e-mail | index | archive | help
> On Jul 20, 2017, at 10:19 AM, John Baldwin <jhb@freebsd.org> wrote: >=20 > 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? >>=20 >> 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. >=20 > 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]
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?D76A4571-9847-4063-9ED5-5DF133D0E6A3>