Re: [PATCH 16/23] PCI: add pci bus removal through /sys/.../pci_bus/.../remove

Yinghai Lu
2012-03-08T00:53:06Z

On Wed, Mar 7, 2012 at 4:03 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> On Tue, Mar 6, 2012 at 12:13 AM, Yinghai Lu <yinghai@kernel.org> wrote:
>> it supports both pci root bus and pci bus under pci bridge.
>>
>> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
>> Cc: Randy Dunlap <rdunlap@xenotime.net>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: linux-doc@vger.kernel.org
>> ---
>>  Documentation/ABI/testing/sysfs-bus-pci |    8 ++++++++
>>  drivers/pci/pci-sysfs.c                 |   28 ++++++++++++++++++++++++++++
>>  2 files changed, 36 insertions(+), 0 deletions(-)
>>
>> diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/testing/sysfs-bus-pci
>> index 95f0f37..22392de 100644
>> --- a/Documentation/ABI/testing/sysfs-bus-pci
>> +++ b/Documentation/ABI/testing/sysfs-bus-pci
>> @@ -92,6 +92,14 @@ Description:
>>                hot-remove the PCI device and any of its children.
>>                Depends on CONFIG_HOTPLUG.
>>
>> +What:          /sys/bus/pci/devices/.../pci_bus/.../remove
>> +Date:          March 2012
>> +Contact:       Linux PCI developers <linux-pci@vger.kernel.org>
>> +Description:
>> +               Writing a non-zero value to this attribute will
>> +               hot-remove the PCI bus and any of its children.
>
> Is this the interface we want?  It seems like the ultimate goal is to
> remove the *host bridge*, i.e., the PNP0A08 device on x86.  If that's
> the case, the logical thing seems like a
> /sys/bus/acpi/devices/PNP0A08:00/remove file.
>
> All the current "remove" attributes are for *devices*, e.g.,
> /sys/devices/pci0000:00/0000:00:03.0/remove, not for *buses*.

could add that later.

I am thinking to add some non-intrusive way to make notification work
for root-bus hot removal/add.
...

also in some case, cpu buses get scan during booting, could use that
to remove those not needed
root buses.

>
> I'm not sure it makes sense to talk about removing a "bus" and leaving
> the upstream bridge (either a host bridge or a P2P bridge).  I think
> it'd make more sense to remove the bridge itself, which would of
> course have the consequence of removing the secondary bus.

for root bus, that remove pci_host_bridge and pci root bus.

for pci bus under pci bridge, will remove that pci bus, but will still
keep that pci bridge.
that should be ok. just like some pci bridge is there, and later can
not create child bus for it.

there is one case: during test busn_alloc, i need to remove all device
on one bus, and
use setpci to change bridge bus number register. then use rescan
bridge to create new bus.

with this one, I just need to remove that bus, instead of remove
children devices one by one.

Yinghai