From: Roger Quadros <rogerq@ti.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: <balbi@ti.com>, <tony@atomide.com>, <ruslan.bilovol@ti.com>,
<linux-usb@vger.kernel.org>, <linux-omap@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [RFC PATCH 4/6] USB: ehci-omap: Suspend the controller during bus suspend
Date: Mon, 24 Jun 2013 18:09:07 +0300 [thread overview]
Message-ID: <51C86113.1090902@ti.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1306201326100.2063-100000@iolanthe.rowland.org>
Hi Alan,
On 06/20/2013 08:33 PM, Alan Stern wrote:
> On Thu, 20 Jun 2013, Roger Quadros wrote:
>
>>> runtime_resume(dev)
>>> {
>>> ...
>>>
>>> if (omap->flags & OMAP_EHCI_IRQ_PENDING) {
>>> process_pending_irqs(omap);
>>
>> OK, thanks.
>>
>> But I'm not sure if the generic ehci_irq handler is able to
>> run in a process context. Maybe if we replace spin_lock(&ehci->lock);
>> with spin_lock_irqsave() there, it will work.
>>
>> Alan is this a doable option?
>
> ehci_irq() will work okay in process context, provided the caller
> disables interrupts.
>
> But maybe none of this will be needed after Roger redesigns the
> controller suspend to work at the right time. Or if it is, we could
> adopt a simpler alternative: the controller's resume routine could
> always call usb_hcd_resume_root_hub(). After all, about the only
> reason for doing a runtime resume of the controller is because the root
> hub needs to do something.
>
OK I've tried to handle all this in an alternate way. Now the controller suspend/resume
and runtime suspend/resume is independent of bus suspend.
The controller now runtime suspends when all devices on the bus have suspended and
the hub auto suspends. NOTE: HW_ACCESSIBLE is still set on runtime_suspend.
The challenge here is to process the interrupt in this state.
I've tried to handle this state. (i.e. interrupt while controller is runtime suspended),
by disabling the interrupt till we are ready and calling usb_hcd_resume_root_hub().
We mark a flag (HW_IRQ_DISABLED) stating that the interrupt was disabled and based on
that enable the IRQ and clear the flag in hcd_resume_work().
Do let me know what you think of this approach.
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index d53547d..8879cd2 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2136,6 +2136,11 @@ static void hcd_resume_work(struct work_struct *work)
usb_lock_device(udev);
usb_remote_wakeup(udev);
usb_unlock_device(udev);
+ if (HCD_IRQ_DISABLED(hcd)) {
+ /* Interrupt was disabled */
+ clear_bit(HCD_FLAG_IRQ_DISABLED, &hcd->flags);
+ enable_irq(hcd->irq);
+ }
}
/**
@@ -2225,6 +2230,16 @@ irqreturn_t usb_hcd_irq (int irq, void *__hcd)
if (unlikely(HCD_DEAD(hcd) || !HCD_HW_ACCESSIBLE(hcd)))
rc = IRQ_NONE;
+ else if (pm_runtime_status_suspended(hcd->self.controller)) {
+ /*
+ * We can't handle it yet so disable IRQ, make note of it
+ * and resume root hub (i.e. controller as well)
+ */
+ disable_irq_nosync(hcd->irq);
+ set_bit(HCD_FLAG_IRQ_DISABLED, &hcd->flags);
+ usb_hcd_resume_root_hub(hcd);
+ rc = IRQ_HANDLED;
+ }
else if (hcd->driver->irq(hcd) == IRQ_NONE)
rc = IRQ_NONE;
else
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index f5f5c7d..6c6287e 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -110,6 +110,7 @@ struct usb_hcd {
#define HCD_FLAG_WAKEUP_PENDING 4 /* root hub is resuming? */
#define HCD_FLAG_RH_RUNNING 5 /* root hub is running? */
#define HCD_FLAG_DEAD 6 /* controller has died? */
+#define HCD_FLAG_IRQ_DISABLED 7 /* Interrupt was disabled */
/* The flags can be tested using these macros; they are likely to
* be slightly faster than test_bit().
@@ -120,6 +121,7 @@ struct usb_hcd {
#define HCD_WAKEUP_PENDING(hcd) ((hcd)->flags & (1U << HCD_FLAG_WAKEUP_PENDING))
#define HCD_RH_RUNNING(hcd) ((hcd)->flags & (1U << HCD_FLAG_RH_RUNNING))
#define HCD_DEAD(hcd) ((hcd)->flags & (1U << HCD_FLAG_DEAD))
+#define HCD_IRQ_DISABLED(hcd) ((hcd)->flags & (1U << HCD_FLAG_IRQ_DISABLED))
/* Flags that get set only during HCD registration or removal. */
unsigned rh_registered:1;/* is root hub registered? */
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 16d7150..c5320c7 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -225,6 +225,8 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
usb_phy_set_suspend(omap->phy[i], 0);
}
+ pm_runtime_put_sync(dev);
+
return 0;
err_pm_runtime:
next prev parent reply other threads:[~2013-06-24 15:09 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-19 14:05 [RFC PATCH 0/6] Suspend USB Host controller on bus suspend Roger Quadros
2013-06-19 14:05 ` [RFC PATCH 1/6] mfd: omap-usb-host: move initialization to module_init() Roger Quadros
2013-06-20 12:07 ` Felipe Balbi
2013-06-20 12:29 ` Roger Quadros
2013-06-19 14:05 ` [RFC PATCH 2/6] mfd: omap-usb-host: Put pins in IDLE state on suspend Roger Quadros
2013-06-19 17:23 ` Kevin Hilman
2013-06-20 7:21 ` Tony Lindgren
2013-06-20 12:30 ` Roger Quadros
2013-06-19 14:05 ` [RFC PATCH 3/6] USB: ehci: allow controller drivers to override irq & bus_suspend/resume Roger Quadros
2013-06-19 14:05 ` [RFC PATCH 4/6] USB: ehci-omap: Suspend the controller during bus suspend Roger Quadros
2013-06-19 17:39 ` Kevin Hilman
2013-06-20 12:32 ` Roger Quadros
2013-06-20 12:11 ` Felipe Balbi
2013-06-20 12:35 ` Roger Quadros
2013-06-20 17:33 ` Alan Stern
2013-06-24 15:09 ` Roger Quadros [this message]
2013-06-24 19:34 ` Alan Stern
2013-06-25 13:59 ` Roger Quadros
2013-06-25 17:38 ` Alan Stern
2013-06-26 13:38 ` Roger Quadros
2013-06-27 15:40 ` Alan Stern
2013-06-28 12:20 ` Roger Quadros
2013-06-28 13:57 ` Roger Quadros
2013-06-28 19:18 ` Alan Stern
2013-07-01 8:33 ` Roger Quadros
2013-06-28 19:06 ` Alan Stern
2013-07-01 8:16 ` Roger Quadros
2013-07-01 16:24 ` Alan Stern
2013-07-01 16:49 ` Felipe Balbi
2013-07-01 21:01 ` Alan Stern
2013-07-02 8:22 ` Roger Quadros
2013-07-02 17:17 ` Alan Stern
2013-07-03 9:13 ` Roger Quadros
2013-07-03 12:57 ` Felipe Balbi
2013-07-03 13:06 ` Roger Quadros
2013-07-03 13:15 ` Felipe Balbi
2013-07-03 14:30 ` Alan Stern
2013-07-09 13:58 ` Roger Quadros
2013-06-19 14:05 ` [RFC PATCH 5/6] ARM: dts: omap3beagle-xm: Add idle state pins for USB host Roger Quadros
2013-06-19 18:42 ` Kevin Hilman
2013-06-20 11:55 ` Roger Quadros
2013-06-20 12:02 ` Roger Quadros
2013-06-20 13:02 ` Roger Quadros
2013-06-19 14:05 ` [RFC PATCH 6/6] ARM: OMAP3: Enable Hardware Save and Restore for USB Host Roger Quadros
2013-06-19 17:30 ` Sergei Shtylyov
2013-06-20 12:42 ` Roger Quadros
2013-06-19 15:23 ` [RFC PATCH 0/6] Suspend USB Host controller on bus suspend Alan Stern
2013-06-20 12:39 ` Roger Quadros
2013-06-20 17:19 ` Alan Stern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51C86113.1090902@ti.com \
--to=rogerq@ti.com \
--cc=balbi@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=ruslan.bilovol@ti.com \
--cc=stern@rowland.harvard.edu \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox