Re: [RFC 10/22] usb: Make core allocate resources per PCI-device.

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

 



On Wed, 5 Jan 2011, Sarah Sharp wrote:

> I think I'm hearing you want some of the shared_hcd references to go
> away, with the eventual goal of perhaps getting rid of the pointer out
> of the usb_hcd entirely.  I agree that dead code like the SAW_IRQ flag
> and the check_root_hub_suspended() code should go away, but I don't
> think we can get rid of shared_hcd entirely.

Yeah, that's what I'd like.  Since you still feel you need it, go ahead
and redo the RFC using the other changes we discussed and keep the
shared_hcd pointer.  Afterward we can go through and figure out how to
eliminate it (or even whether it _should_ be eliminated).

> You've addressed the use cases in the suspend and resume path, but
> there's still an issue with the allocation and freeing.  If you agree
> that the shared roothub allocation should go in the PCI core because of
> the shared resource visibility issue,

Refresh my memory: What is the shared resource visibility issue?  It's
probably sitting in an old email message somewhere, but so many of them
have gone by that I can't put my finger on it.

>  then the PCI core needs to also
> deallocate the shared_hcd.  How do you propose to do that when the USB
> PCI core doesn't have a reference to the non-primary usb_hcd?
> usb_hcd_pci_remove() needs to have a pointer to call usb_put_hcd() with.
> 
> Also, in digging around the deallocation path, I found another design
> decision I made based on shared_hcd being a part of usb_hcd.  Right now,
> the shared_hcd pointer is acting like a reference count on the bandwidth
> mutex:

...

> If the USB core has no notion of whether a shared roothub is allocated
> (which you seem to be advocating for by making the xHCI driver call into
> usb_hcd_pci_probe() and then allocating the shared_hcd), then the USB
> core has no idea when to deallocate shared resources.

That's simple.  You allocate the primary hcd first (along with all the
necessary resources) in the usual way by calling usb_hcd_pci_probe, and
then you add the secondary hcd, letting it share the primary's
resources (usb_add_shared_hcd).  When it's time for the driver to be
unloaded, you deallocate the secondary hcd (usb_remove_shared_hcd)  
leaving the shared resources intact, and then you deallocate the
primary hcd by calling usb_hcd_pci_remove normally.  In other words, 
you reverse the actions taken during the original registration.

This also handles the problem of the bandwidth mutex; it gets treated
like all the other shared resources.  hcd_release can simply do:

	if (primary_hcd(hcd))
		kfree(hcd->bandwidth_mutex);

Alan Stern

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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux