On Thu, 6 Sep 2012 16:26:06 +0300 Felipe Balbi <balbi@xxxxxx> wrote: > Hi, > > On Thu, Sep 06, 2012 at 05:02:45PM +1000, NeilBrown wrote: > > On Thu, 6 Sep 2012 11:18:09 +0530 "Shilimkar, Santosh" > > <santosh.shilimkar@xxxxxx> wrote: > > > > > On Thu, Sep 6, 2012 at 8:35 AM, NeilBrown <neilb@xxxxxxx> wrote: > > > > On Mon, 3 Sep 2012 22:59:06 -0700 "Shilimkar, Santosh" > > > > <santosh.shilimkar@xxxxxx> wrote: > > > > > >> After thinking bit more on this, the problem seems to be coming > > > >> mainly because the gpio device is runtime suspended bit early than > > > >> it should be. Similar issue seen with i2c driver as well. The i2c issue > > > >> was discussed with Rafael at LPC last week. The idea is to move > > > >> the pm_runtime_enable/disable() calls entirely up to the > > > >> _late/_early stage of device suspend/resume. > > > >> Will update this thread once I have further update. > > > > > > > > This won't be late enough. IRQCHIP_MASK_ON_SUSPEND takes effect after all > > > > the _late callbacks have been called. > > > > I, too, spoke to Rafael about this in San Diego. He seemed to agree with me > > > > that the interrupt needs to be masked in the ->suspend callback. any later > > > > is too late. > > > > > > > Thanks for information about your discussion. Will wait for the patch then. > > > > > > Regards > > > santosh > > > > I already sent a patch - that is what started this thread :-) > > > > I include it below. > > You said "The patch doesn't seems to be correct" but didn't expand on why. > > Do you still think it is not correct? I wouldn't be surprised if there is > > some case that it doesn't handle quite right, but it seems right to me. > > > > Thanks, > > NeilBrown > > > > > > From: NeilBrown <neilb@xxxxxxx> > > Subject: [PATCH] OMAP GPIO - don't wake from suspend unless requested. > > > > Current kernel will wake from suspend on an event on any active > > GPIO even if enable_irq_wake() wasn't called. > > > > There are two reasons that the hardware wake-enable bit should be set: > > > > 1/ while non-suspended the CPU might go into a deep sleep (off_mode) > > in which the wake-enable bit is needed for an interrupt to be > > recognised. > > 2/ while suspended the GPIO interrupt should wake from suspend if and > > only if irq_wake as been enabled. > > > > The code currently doesn't keep these two reasons separate so they get > > confused and sometimes the wakeup flags is set incorrectly. > > > > This patch reverts: > > commit 9c4ed9e6c01e7a8bd9079da8267e1f03cb4761fc > > gpio/omap: remove suspend/resume callbacks > > and > > commit 0aa2727399c0b78225021413022c164cb99fbc5e > > gpio/omap: remove suspend_wakeup field from struct gpio_bank > > > > and makes some minor changes so that we have separate flags for "GPIO > > should wake from deep idle" and "GPIO should wake from suspend". > > > > With this patch, the GPIO from my touch screen doesn't wake my device > > any more, which is what I want. > > > > Cc: Kevin Hilman <khilman@xxxxxx> > > Cc: Tony Lindgren <tony@xxxxxxxxxxx> > > Cc: Santosh Shilimkar <santosh.shilimkar@xxxxxx> > > Cc: Cousson Benoit <b-cousson@xxxxxx> > > Cc: Grant Likely <grant.likely@xxxxxxxxxxxx> > > Cc: Tarun Kanti DebBarma <tarun.kanti@xxxxxx> > > Cc: Felipe Balbi <balbi@xxxxxx> > > Cc: Govindraj.R <govindraj.raja@xxxxxx> > > > > Signed-off-by: NeilBrown <neilb@xxxxxxx> > > > > diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c > > index 4fbc208..fdbad70 100644 > > --- a/drivers/gpio/gpio-omap.c > > +++ b/drivers/gpio/gpio-omap.c > > @@ -57,6 +57,7 @@ struct gpio_bank { > > u16 irq; > > int irq_base; > > struct irq_domain *domain; > > + u32 suspend_wakeup; > > u32 non_wakeup_gpios; > > u32 enabled_non_wakeup_gpios; > > struct gpio_regs context; > > @@ -522,11 +523,12 @@ static int _set_gpio_wakeup(struct gpio_bank *bank, int gpio, int enable) > > > > spin_lock_irqsave(&bank->lock, flags); > > if (enable) > > - bank->context.wake_en |= gpio_bit; > > + bank->suspend_wakeup |= gpio_bit; > > else > > - bank->context.wake_en &= ~gpio_bit; > > + bank->suspend_wakeup &= ~gpio_bit; > > > > - __raw_writel(bank->context.wake_en, bank->base + bank->regs->wkup_en); > > + if (!bank->loses_context) > > + __raw_writel(bank->suspend_wakeup, bank->base + bank->regs->wkup_en); > > spin_unlock_irqrestore(&bank->lock, flags); > > > > return 0; > > @@ -1157,6 +1159,51 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev) > > #ifdef CONFIG_ARCH_OMAP2PLUS > > > > #if defined(CONFIG_PM_RUNTIME) > > + > > +#if defined(CONFIG_PM_SLEEP) > > +static int omap_gpio_suspend(struct device *dev) > > +{ > > + struct platform_device *pdev = to_platform_device(dev); > > + struct gpio_bank *bank = platform_get_drvdata(pdev); > > + void __iomem *base = bank->base; > > + unsigned long flags; > > + > > + if (!bank->mod_usage || !bank->loses_context) > > + return 0; > > + > > + if (!bank->regs->wkup_en || !bank->context.wake_en) > > + return 0; > > + > > + spin_lock_irqsave(&bank->lock, flags); > > shouldn't you be using _noirq methods instead ? Then this would become a > normal spin_lock()/spin_unlock(). > I don't think it is appropriate to move functionality between the different suspend call-backs just because it seems to make the code easier. Each callback has a purpose and we should stick to that purpose. The 'suspend' callback should transition the device to a quiescent state, and I think that includes ensuring that unwanted interrupts won't fire. 'suspend_late' should almost always be the same as runtime_suspend - it should power-off the device. 'suspend_noirq' ... doesn't seem to have a clear role any more since the introduction of suspend_late. Hopefully everything will transition over and suspend_noirq can disappear. More pragmatically: By the time we get to suspend_noirq, I think the iclk will have been turned off and so it is too late to try to clear the wkup flags. Thanks, NeilBrown
Attachment:
signature.asc
Description: PGP signature