All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman@deeprootsystems.com>
To: "Shilimkar, Santosh" <santosh.shilimkar@ti.com>
Cc: NeilBrown <neilb@suse.de>, "Rafael J. Wysocki" <rjw@sisk.pl>,
	Tarun Kanti DebBarma <tarun.kanti@ti.com>,
	Tony Lindgren <tony@atomide.com>, Benoit <b-cousson@ti.com>,
	Grant Likely <grant.likely@secretlab.ca>,
	Felipe Balbi <balbi@ti.com>,
	linux-omap@vger.kernel.org, lkml <linux-kernel@vger.kernel.org>,
	Jon Hunter <jon-hunter@ti.com>
Subject: Re: [PATCH] OMAP GPIO - don't wake from suspend unless requested.
Date: Mon, 10 Sep 2012 10:57:07 -0700	[thread overview]
Message-ID: <87ipblahho.fsf@deeprootsystems.com> (raw)
In-Reply-To: <CAMQu2gwSCvw_4gVE-giD6MSzmRCNoNu4NoFBSao_dh9YnojfuA@mail.gmail.com> (Santosh Shilimkar's message of "Sat, 8 Sep 2012 13:25:03 +0530")

"Shilimkar, Santosh" <santosh.shilimkar@ti.com> writes:

> On Sat, Sep 8, 2012 at 3:07 AM, Kevin Hilman
> <khilman@deeprootsystems.com> wrote:
>> Hi Neil,
>>
>> NeilBrown <neilb@suse.de> writes:
>>
>>> On Thu, 6 Sep 2012 11:18:09 +0530 "Shilimkar, Santosh"
>>> <santosh.shilimkar@ti.com> wrote:
>>>
>>>> On Thu, Sep 6, 2012 at 8:35 AM, NeilBrown <neilb@suse.de> wrote:
>>>> > On Mon, 3 Sep 2012 22:59:06 -0700 "Shilimkar, Santosh"
>>>> > <santosh.shilimkar@ti.com> 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@suse.de>
>>> 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.
>>
>> I think the direction is right here.  We never should've separated the
>> handling of idle vs suspend wakeups.  However, I have a few
>> questions/doubts below...
>>
> I thought irq_set_wake() is suspend only wakeup functionality. In idle, the
> driver IRQs are not disabled/masked so there no need of any special
> wakeup calls for idle. More ever patch is adding the suspend hooks
> for wakeups.
>
> I have no objection on the subject patch, but the suspend wakeup
> facility is easy enough to implement for IRQCHIPS and that is
> what I was proposing it. Infact the mask on suspend patch almost
> works and it fails only because the GPIO driver is suspended earlier
> than the IRQ framework expect it to be.

That is a pretty big problem to overcome. :)

That being said, I don't see how simply using MASK_ON_SUSPEND can work
for GPIO.  AFAICT, that flag is for the whole irq_chip, not for
individual IRQs.  We really need to keep track at the bank/IRQ level, as
in the proposed patch from Neil (actually, we used to have this featur,
but I screwed up by not catching this removal when reviewing the GPIO
cleanup/reorg series.)

Because of retention/off in idle, we set *all* GPIOs with IRQ triggering
to be wakeup enabled so they will cause wakeups during idle.  During
suspend, we only want the irq_set_wake() ones to cause wakeups.

> Anyways I step back here since the proposed patch already fixes
> the issue seen. Assuming the IRQCHIP mask on suspend doesn't
> seems to work well with drivers as Neil mentioned, the $subject patch
> seems to be the right option.

OK thanks, I'll queue this up for v3.6-rc as this should qualify as a
regression.

Also, the IRQCHIP mask feature seems to have been designed for IRQ chips
without the control registers to handle this.  We have the control
registers to handle it, so I believe it's better to keep this handled in
the driver itself.

Kevin

WARNING: multiple messages have this Message-ID (diff)
From: Kevin Hilman <khilman@deeprootsystems.com>
To: "Shilimkar\, Santosh" <santosh.shilimkar@ti.com>
Cc: NeilBrown <neilb@suse.de>, "Rafael J. Wysocki" <rjw@sisk.pl>,
	Tarun Kanti DebBarma <tarun.kanti@ti.com>,
	Tony Lindgren <tony@atomide.com>, Benoit <b-cousson@ti.com>,
	Grant Likely <grant.likely@secretlab.ca>,
	Felipe Balbi <balbi@ti.com>,
	linux-omap@vger.kernel.org, lkml <linux-kernel@vger.kernel.org>,
	Jon Hunter <jon-hunter@ti.com>
Subject: Re: [PATCH] OMAP GPIO - don't wake from suspend unless requested.
Date: Mon, 10 Sep 2012 10:57:07 -0700	[thread overview]
Message-ID: <87ipblahho.fsf@deeprootsystems.com> (raw)
In-Reply-To: <CAMQu2gwSCvw_4gVE-giD6MSzmRCNoNu4NoFBSao_dh9YnojfuA@mail.gmail.com> (Santosh Shilimkar's message of "Sat, 8 Sep 2012 13:25:03 +0530")

"Shilimkar, Santosh" <santosh.shilimkar@ti.com> writes:

> On Sat, Sep 8, 2012 at 3:07 AM, Kevin Hilman
> <khilman@deeprootsystems.com> wrote:
>> Hi Neil,
>>
>> NeilBrown <neilb@suse.de> writes:
>>
>>> On Thu, 6 Sep 2012 11:18:09 +0530 "Shilimkar, Santosh"
>>> <santosh.shilimkar@ti.com> wrote:
>>>
>>>> On Thu, Sep 6, 2012 at 8:35 AM, NeilBrown <neilb@suse.de> wrote:
>>>> > On Mon, 3 Sep 2012 22:59:06 -0700 "Shilimkar, Santosh"
>>>> > <santosh.shilimkar@ti.com> 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@suse.de>
>>> 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.
>>
>> I think the direction is right here.  We never should've separated the
>> handling of idle vs suspend wakeups.  However, I have a few
>> questions/doubts below...
>>
> I thought irq_set_wake() is suspend only wakeup functionality. In idle, the
> driver IRQs are not disabled/masked so there no need of any special
> wakeup calls for idle. More ever patch is adding the suspend hooks
> for wakeups.
>
> I have no objection on the subject patch, but the suspend wakeup
> facility is easy enough to implement for IRQCHIPS and that is
> what I was proposing it. Infact the mask on suspend patch almost
> works and it fails only because the GPIO driver is suspended earlier
> than the IRQ framework expect it to be.

That is a pretty big problem to overcome. :)

That being said, I don't see how simply using MASK_ON_SUSPEND can work
for GPIO.  AFAICT, that flag is for the whole irq_chip, not for
individual IRQs.  We really need to keep track at the bank/IRQ level, as
in the proposed patch from Neil (actually, we used to have this featur,
but I screwed up by not catching this removal when reviewing the GPIO
cleanup/reorg series.)

Because of retention/off in idle, we set *all* GPIOs with IRQ triggering
to be wakeup enabled so they will cause wakeups during idle.  During
suspend, we only want the irq_set_wake() ones to cause wakeups.

> Anyways I step back here since the proposed patch already fixes
> the issue seen. Assuming the IRQCHIP mask on suspend doesn't
> seems to work well with drivers as Neil mentioned, the $subject patch
> seems to be the right option.

OK thanks, I'll queue this up for v3.6-rc as this should qualify as a
regression.

Also, the IRQCHIP mask feature seems to have been designed for IRQ chips
without the control registers to handle this.  We have the control
registers to handle it, so I believe it's better to keep this handled in
the driver itself.

Kevin


  reply	other threads:[~2012-09-10 17:57 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20120825214459.7333a376@notabene.brown>
2012-08-26  4:17 ` [PATCH] OMAP GPIO - don't wake from suspend unless requested Shilimkar, Santosh
2012-08-26 22:53   ` NeilBrown
2012-08-27  1:29     ` Shilimkar, Santosh
2012-09-04  5:59       ` Shilimkar, Santosh
2012-09-06  3:05         ` NeilBrown
2012-09-06  5:48           ` Shilimkar, Santosh
2012-09-06  7:02             ` NeilBrown
2012-09-06  7:27               ` Shilimkar, Santosh
2012-09-06  7:51                 ` NeilBrown
2012-09-06  8:43                   ` Shilimkar, Santosh
2012-09-06 13:26               ` Felipe Balbi
2012-09-10  6:58                 ` NeilBrown
2012-09-06 14:11               ` Shubhrajyoti
2012-09-07 21:37               ` Kevin Hilman
2012-09-07 21:37                 ` Kevin Hilman
2012-09-08  7:55                 ` Shilimkar, Santosh
2012-09-10 17:57                   ` Kevin Hilman [this message]
2012-09-10 17:57                     ` Kevin Hilman
2012-12-14  7:05                     ` NeilBrown
2012-12-14  9:04                       ` anish kumar
2012-12-19 22:20                       ` Grant Likely
2013-02-05 19:47                         ` Kevin Hilman
2013-02-05 19:47                           ` Kevin Hilman
2012-09-10  4:10                 ` NeilBrown
2012-09-10 18:17                   ` Kevin Hilman
2012-09-10 18:17                     ` Kevin Hilman

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=87ipblahho.fsf@deeprootsystems.com \
    --to=khilman@deeprootsystems.com \
    --cc=b-cousson@ti.com \
    --cc=balbi@ti.com \
    --cc=grant.likely@secretlab.ca \
    --cc=jon-hunter@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=rjw@sisk.pl \
    --cc=santosh.shilimkar@ti.com \
    --cc=tarun.kanti@ti.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.