Re: device_unregister() for PCI host bridge removal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 26, 2013 at 3:41 PM, Yinghai Lu <yinghai@xxxxxxxxxx> wrote:
> On Fri, Apr 26, 2013 at 2:25 PM, Bjorn Helgaas <bhelgaas@xxxxxxxxxx> wrote:
>> I'm trying to figure out where we call device_unregister() when
>> removing a PCI host bridge.  I see the device_register() in the
>> following path:
>>
>>     acpi_pci_root_add
>>       pci_acpi_scan_root
>>         pci_create_root_bus
>>           bridge = pci_alloc_host_bridge
>>           bridge->dev.release = pci_release_bus_bridge_dev
>>           device_register(&bridge->dev)
>>         pci_set_host_bridge_release(..., release_pci_root_info, ...)
>>
>> But I don't see any device_unregister() in the remove path:
>>
>>     acpi_pci_root_remove
>>       pci_remove_root_bus
>>         put_device(&host_bridge->dev)
>>
>>     pci_release_bus_bridge_dev
>>       bridge->release_fn        # e.g., release_pci_root_info
>>         release_pci_root_info
>>           __release_pci_root_info
>>             release_resource
>>             free_pci_root_info_res
>>             teardown_mcfg_map
>>
>> What am I missing?
>
> pci_stop_root_bus
>          /* stop the host bridge */
>         device_del(&host_bridge->dev);

Hmm...  OK, thanks for the pointer.  So we don't actually call
device_unregister() itself, but since device_unregister() consists of
nothing more than "device_del(dev); put_device(dev);" I guess we're
doing the equivalent in two pieces:

    acpi_pci_root_remove
      pci_stop_root_bus
        device_del(&host_bridge->dev)
      pci_remove_root_bus
        put_device(&host_bridge->dev)

This seems unnecessarily difficult to analyze.  It would be better if
we had symmetric device_register()/device_unregister() paths, or if
that can't be done, symmetric device_add()/device_del() paths.

Don't bother to generate a quick patch to just replace
device_register() with explicit calls to device_initialize() and
device_add(), though.  Maybe someday we can clean up that and more.
Anyway, thanks for fixing my confusion.

Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux