> > Due to that, I've moved the call to a workqueue instance.
> 
> You can avoid using a workqueue by calling usb_hcd_poll_rh_status() at the 
> end of ehci_irq(), after the spinlock has been released.  Doing an extra 
> test of the STS_PCD bit is a lot less overhead than starting up a 
> workqueue.
> 
> Also, you don't need to clear hcd->poll_rh in the hub_status routine.  
> The core never touches that flag, so it won't get set unless ehci-hcd sets
> it.
> 
> > Insertion/removal of cards works as expected, but I'm afraid that there
> > are corner cases which this simplistic code is not handling?
> > 
> > Is it necessary to poll status during certain situations?
> 
> Not as far as I know.  Something may turn up in the future.
> 
> One thing to watch out for is that some controllers might use
> "level-triggered" rather than "edge-triggered" interrupt reporting, even
> though the spec says they shouldn't.  For such controllers it would be
> necessary to disable the STS_PCD bit when an interrupt occurs and not
> re-enable it until hcd->hub_irq_enable() is called.  However I don't know
> whether any existing controllers include this design mistake.

How about this, then:


diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 025d333..5c90bde 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -496,6 +496,9 @@ static int ehci_run (struct usb_hcd *hcd
        u32                     temp;
        u32                     hcc_params;
 
+       hcd->uses_new_polling = 1;
+       hcd->poll_rh = 0;
+
        /* EHCI spec section 4.1 */
        if ((retval = ehci_reset(ehci)) != 0) {
                ehci_mem_cleanup(ehci);
@@ -661,6 +664,8 @@ dead:
        if (bh)
                ehci_work (ehci);
        spin_unlock (&ehci->lock);
+       if (status & STS_PCD)
+               usb_hcd_poll_rh_status(hcd);
        return IRQ_HANDLED;
 }
 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to