On Mon, Jul 25, 2022 at 06:35:27PM +0100, Marc Zyngier wrote: [...] > > That is precisely the way I've been testing it and everything appears > > to be tore down as it should. > > > > And a PCI driver that has been unbound should have released its > > resources, or that's a driver bug. Right? > > But that's the thing: you can easily remove part of the infrastructure > without the endpoint driver even noticing. It may not happen in your > particular case if removing the RC driver will also nuke the endpoints > in the process, but I can't see this is an absolute guarantee. The > crash pointed to by an earlier email is symptomatic of it. > > > And for the OF INTx case you mentioned earlier, aren't those mapped by > > PCI core and could in theory be released by core as well? > > Potentially, though I haven't tried to follow the life cycle of those. > The whole thing is pretty fragile, and this sort of resource is rarely > expected to be removed... This made me notice that we don't undo the actions (ie bridge->map_irq()) executed in pci_assign_irq() in pci_device_remove(); I don't think this can be right and that's already a candidate for a fix. It is not necessarily related to this thread topic, though I believe, in an _ideal_ world, removing a bridge should guarantee that all the downstream devices (ie drivers) had a chance of freeing/disposing the resources they allocated. This in theory; I totally understand Marc's point of view here and we should make up our mind about what we want to do on host bridge removal policy - this will take me more time to get to the bottom of it. Lorenzo