Re: [PATCH 1/7] PCI: Make sriov work with hotplug remove

From: Linus Torvalds
Date: Mon Jan 23 2012 - 14:34:48 EST


On Mon, Jan 23, 2012 at 10:45 AM, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> Why isn't this magically true in this case? If some *other* random
> entry than the one that is being iterated over can magically be
> removed, then the whole thing is just pure and utter crap, and no
> amount of list maintenance can ever fix it.
>
> So explain.

Ahh. I finally understand what's going on. The virtual device attached
to a physical device can go away, and it's on the same damn list.

That's broken. Virtual devices set up by a physical device should be
*children* of the physical device, not "siblings". But that's
apparently not what the broken virtual PCI layer does.

So I think that there are two possible solutions:

(a) fix the virtual devices that are attached to physical devices to
really be children of the physical device, with the physical device as
a "bridge" to that virtual bus.

I think this is the correct solution from any sane standpoint (now the
topology of the device tree actually matches the logical
relationship), which is why I think this is the RightThing(tm) to do.
And it should automatically fix this insane issue where removing a
device from a bus can remove *multiple* devices from the same list.

(b) if that isn't an option, and the virtual devices make a mess, at
least don't make the code uglier, just do something like:

while (!list_empty(&bus->devices)) {
struct pci_dev *dev = list_first_entry(struct pci_dev, bus_list);

pci_stop_bus_device(dev);
}

which at least isn't butt ugly. Add a large comment about how
pci_stop_bus_device() can remove multiple devices due to the virtual
devices having been done badly.

Who is in charge of the whole 'is_virtfn' mess? How realistic is it to
fix that crud?

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/