On Wed, Apr 27, 2011 at 11:11 AM, Yinghai Lu <yinghai@xxxxxxxxxx> wrote: > On 04/27/2011 08:07 AM, Bjorn Helgaas wrote: >> On Wed, Apr 27, 2011 at 1:38 AM, Ram Pai <linuxram@xxxxxxxxxx> wrote: >>> On Tue, Apr 26, 2011 at 05:25:00PM -0600, Bjorn Helgaas wrote: >>>> I'm uneasy about release_child_resources(). This patch doesn't add >>>> it, but it does add another use of it. >>>> >>>> What makes it safe for us to blindly release child resources? If we >>>> start with something like this: >>>> >>>> f2500000-f25fffff : PCI Bus 0000:0d >>>> f2500000-f25000ff : 0000:0d:00.0 >>>> f2500000-f25000ff : mmc0 >>>> >>>> and we call release_child_resources() on the top-level bridge window >>>> (f2500000-f25fffff), I think we will also release the 0000:0d:00.0 and >>>> mmc resources. This might not be a problem at boot-time, when the >>>> driver won't have claimed the device yet, but often we want to shuffle >>>> resources to make a hot-plugged device work, and then we do have to >>>> worry about other drivers. >>>> >>>> It seems like we need to check whether a driver is bound to a device, >>>> and if so, leave its resources alone. I didn't see anything like >>>> that, but maybe I missed it. >>> >>> But pci_assign_unassigned_resources() is called only during boot-time, >>> before any resources are assigned to any drivers. right? >> >> That's true today, but I expect it will be false soon. The problem of >> assigning resources and finding that we need to rearrange things is >> really the same, whether it occurs at boot-time or at hot-add time. I >> think we ought to use the same strategy either way. >> >> I think we're building on a faulty foundation, and I'd rather fix it >> now before we build more things on top of it. > > pciehp hotplug path is calling pci_assign_unassigned_bridge_resources() instead. > it only update the bridge itself and will not go up. 1) Why does only pciehp call pci_assign_unassigned_bridge_resources()? Is there something special about pciehp that means it needs that call, while none of the other hotplug drivers do? I would have thought they should all have similar _configure_device() functions. We have a whole list of functions including pciehp_configure_device cpci_configure_slot cpqhp_configure_device shpchp_configure_device ibm_configure_device cb_alloc sgi_hotplug enable_slot acpiphp enable_device that are disturbingly similar, yet different in the particulars. I suspect that there should be a lot of unification here. 2) As you say, pciehp_configure_device() calls pci_assign_unassigned_bridge_resources(), which ultimately calls release_child_resources(). But you didn't answer my question: how do we know it's safe to release child resources under the bridge? Do we know somehow that there are no drivers bound to devices below the bridge? Are we assuming that there's only one device (the newly hot-added one) below the bridge? Is that true for all potential callers of pci_assign_unassigned_bridge_resources()? 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