All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Kevin Hilman <khilman@ti.com>,
	Tarun Kanti DebBarma <tarun.kanti@ti.com>,
	Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Tony Lindgren <tony@atomide.com>,
	"Cousson, Benoit" <b-cousson@ti.com>
Subject: Re: [PATCH 8/8] gpio/omap: fix missing check in *_runtime_suspend()
Date: Thu, 17 May 2012 17:27:55 -0600	[thread overview]
Message-ID: <20120517232755.EF4383E062C@localhost> (raw)
In-Reply-To: <87y5oqtpnw.fsf@ti.com>

On Thu, 17 May 2012 15:21:07 -0700, Kevin Hilman <khilman@ti.com> wrote:
> Tarun, Santosh,
> 
> Tarun Kanti DebBarma <tarun.kanti@ti.com> writes:
> 
> > We do checking for bank->enabled_non_wakeup_gpios in order
> > to skip redundant operations. Somehow, the check got missed
> > while doing the cleanup series.
> >
> > Just to make sure that we do context restore correctly in
> > *_runtime_resume(), the bank->workaround_enabled check is
> > moved after context restore. Otherwise, it would prevent
> > context restore when bank->enabled_non_wakeup_gpios is 0.
> >
> > Cc: Kevin Hilman <khilman@ti.com>
> > Cc: Tony Lindgren <tony@atomide.com>
> > Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
> > Cc: Cousson, Benoit <b-cousson@ti.com>
> > Cc: Grant Likely <grant.likely@secretlab.ca>
> > Signed-off-by: Tarun Kanti DebBarma <tarun.kanti@ti.com>
> 
> I just noticed that this patch has caused some strange problems, notably
> with the GPIO IRQ used by smsc911x NIC (Overo, Zoom3, 2430SDP, etc. etc.)
> 
> The patch itself is OK, but it has exposed a bug in other parts of the
> context restore path that was previously hidden.
> 
> We seem to have been finding lots of GPIO bugs by just testing the
> network chips with GPIO IRQs.  Can I suggest that a platform with a GPIO
> IRQ NIC be added to the test platforms you're using? 
> 
> > ---
> >  drivers/gpio/gpio-omap.c |   13 ++++++++-----
> >  1 files changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> > index d238f84..59a4af1 100644
> > --- a/drivers/gpio/gpio-omap.c
> > +++ b/drivers/gpio/gpio-omap.c
> > @@ -1160,6 +1160,9 @@ static int omap_gpio_runtime_suspend(struct device *dev)
> >  
> >  	spin_lock_irqsave(&bank->lock, flags);
> >  
> > +	if (!bank->enabled_non_wakeup_gpios)
> > +		goto update_gpio_context_count;
> > +
> >  	/*
> >  	 * Only edges can generate a wakeup event to the PRCM.
> >  	 *
> > @@ -1235,11 +1238,6 @@ static int omap_gpio_runtime_resume(struct device *dev)
> >  	__raw_writel(bank->context.risingdetect,
> >  		     bank->base + bank->regs->risingdetect);
> >  
> > -	if (!bank->workaround_enabled) {
> > -		spin_unlock_irqrestore(&bank->lock, flags);
> > -		return 0;
> > -	}
> > -
> 
> My moving this below, you exposed some buggy code that can now get
> executed in non-OFF mode, wherease before $SUBJECT patch, it would never
> be exectued in non-OFF mode.
> 
> >  	if (bank->get_context_loss_count) {
> >  		context_lost_cnt_after =
> >  			bank->get_context_loss_count(bank->dev);
> 
> ...right below this line, we have:
> 
> 		if (context_lost_cnt_after != bank->context_loss_count ||
> 						!context_lost_cnt_after) {
> 			omap_gpio_restore_context(bank);
> 
> While we've never hit off-mode, context_lost_cnt_after will always be
> zero.  However, becasue of the !context_lost_cnt_after check there, we
> will *always* restore the bank context, even though context has never
> been lost.
> 
> I have no idea why that !context_lost_cnt_after check is there, but
> clearly it is wrong.  Now that you moved the 'workraound_enabled' check
> below this section, as long as off-mode is disabled, the some GPIO
> context will be restored here on *every* runtime PM transition.
> 
> The patch below fixes the problem.
> 
> Grant, after Tarun/Santosh have a chance to review/ack this, can you
> still get this in for 3.5?  If not, getting it into -rc should be fine.

Yes.  Do you have any other omap patches?  Do you want to send me a
pull req?

g.

> > Kevin
> 
> 
> From 83874df8e0dd78a3609f5ba81d608df7217fd212 Mon Sep 17 00:00:00 2001
> From: Kevin Hilman <khilman@ti.com>
> Date: Thu, 17 May 2012 14:52:56 -0700
> Subject: [PATCH] gpio/omap: fix broken context restore for non-OFF mode
>  transitions
> 
> The fix in commit 1b12870 (gpio/omap: fix missing check in
> *_runtime_suspend()) exposed another bug in the context restore path.
> 
> Currently, the per-bank context restore happens whenever the context
> loss count is different in runtime suspend and runtime resume *and*
> whenever the per-bank contex_loss_count == 0:
> 
> 	if (context_lost_cnt_after != bank->context_loss_count ||
> 					!context_lost_cnt_after) {
> 		omap_gpio_restore_context(bank);
> 
> Restoring context when the context_lost_cnt_after == 0 is clearly
> wrong, since this will be true until the first off-mode transition
> (which could be never, if off-mode is never enabled.)  This check
> causes the context to be restored on *every* runtime PM transition.
> 
> Before commit 1b12870 (gpio/omap: fix missing check in
> *_runtime_suspend()), this code was never executed in non-OFF mode, so
> there were never spurious context restores happening.  After that
> change though, spurious context restores could happen.
> 
> To fix, simply remove the !context_lost_cnt_after check. It is not
> needed.
> 
> This bug was found when noticing that the smc911x NIC on 3530/Overo
> was not working, and git bisect tracked it down to this patch.  It
> seems that the spurious context restore was causing the smsc911x to
> not be properly probed on this platform.
> 
> Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>
> Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Signed-off-by: Kevin Hilman <khilman@ti.com>
> ---
>  drivers/gpio/gpio-omap.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index 9b71f04..b570a6a 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -1238,8 +1238,7 @@ static int omap_gpio_runtime_resume(struct device *dev)
>  	if (bank->get_context_loss_count) {
>  		context_lost_cnt_after =
>  			bank->get_context_loss_count(bank->dev);
> -		if (context_lost_cnt_after != bank->context_loss_count ||
> -						!context_lost_cnt_after) {
> +		if (context_lost_cnt_after != bank->context_loss_count) {
>  			omap_gpio_restore_context(bank);
>  		} else {
>  			spin_unlock_irqrestore(&bank->lock, flags);
> -- 
> 1.7.9.2
> 

-- 
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.

WARNING: multiple messages have this Message-ID (diff)
From: grant.likely@secretlab.ca (Grant Likely)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 8/8] gpio/omap: fix missing check in *_runtime_suspend()
Date: Thu, 17 May 2012 17:27:55 -0600	[thread overview]
Message-ID: <20120517232755.EF4383E062C@localhost> (raw)
In-Reply-To: <87y5oqtpnw.fsf@ti.com>

On Thu, 17 May 2012 15:21:07 -0700, Kevin Hilman <khilman@ti.com> wrote:
> Tarun, Santosh,
> 
> Tarun Kanti DebBarma <tarun.kanti@ti.com> writes:
> 
> > We do checking for bank->enabled_non_wakeup_gpios in order
> > to skip redundant operations. Somehow, the check got missed
> > while doing the cleanup series.
> >
> > Just to make sure that we do context restore correctly in
> > *_runtime_resume(), the bank->workaround_enabled check is
> > moved after context restore. Otherwise, it would prevent
> > context restore when bank->enabled_non_wakeup_gpios is 0.
> >
> > Cc: Kevin Hilman <khilman@ti.com>
> > Cc: Tony Lindgren <tony@atomide.com>
> > Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
> > Cc: Cousson, Benoit <b-cousson@ti.com>
> > Cc: Grant Likely <grant.likely@secretlab.ca>
> > Signed-off-by: Tarun Kanti DebBarma <tarun.kanti@ti.com>
> 
> I just noticed that this patch has caused some strange problems, notably
> with the GPIO IRQ used by smsc911x NIC (Overo, Zoom3, 2430SDP, etc. etc.)
> 
> The patch itself is OK, but it has exposed a bug in other parts of the
> context restore path that was previously hidden.
> 
> We seem to have been finding lots of GPIO bugs by just testing the
> network chips with GPIO IRQs.  Can I suggest that a platform with a GPIO
> IRQ NIC be added to the test platforms you're using? 
> 
> > ---
> >  drivers/gpio/gpio-omap.c |   13 ++++++++-----
> >  1 files changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> > index d238f84..59a4af1 100644
> > --- a/drivers/gpio/gpio-omap.c
> > +++ b/drivers/gpio/gpio-omap.c
> > @@ -1160,6 +1160,9 @@ static int omap_gpio_runtime_suspend(struct device *dev)
> >  
> >  	spin_lock_irqsave(&bank->lock, flags);
> >  
> > +	if (!bank->enabled_non_wakeup_gpios)
> > +		goto update_gpio_context_count;
> > +
> >  	/*
> >  	 * Only edges can generate a wakeup event to the PRCM.
> >  	 *
> > @@ -1235,11 +1238,6 @@ static int omap_gpio_runtime_resume(struct device *dev)
> >  	__raw_writel(bank->context.risingdetect,
> >  		     bank->base + bank->regs->risingdetect);
> >  
> > -	if (!bank->workaround_enabled) {
> > -		spin_unlock_irqrestore(&bank->lock, flags);
> > -		return 0;
> > -	}
> > -
> 
> My moving this below, you exposed some buggy code that can now get
> executed in non-OFF mode, wherease before $SUBJECT patch, it would never
> be exectued in non-OFF mode.
> 
> >  	if (bank->get_context_loss_count) {
> >  		context_lost_cnt_after =
> >  			bank->get_context_loss_count(bank->dev);
> 
> ...right below this line, we have:
> 
> 		if (context_lost_cnt_after != bank->context_loss_count ||
> 						!context_lost_cnt_after) {
> 			omap_gpio_restore_context(bank);
> 
> While we've never hit off-mode, context_lost_cnt_after will always be
> zero.  However, becasue of the !context_lost_cnt_after check there, we
> will *always* restore the bank context, even though context has never
> been lost.
> 
> I have no idea why that !context_lost_cnt_after check is there, but
> clearly it is wrong.  Now that you moved the 'workraound_enabled' check
> below this section, as long as off-mode is disabled, the some GPIO
> context will be restored here on *every* runtime PM transition.
> 
> The patch below fixes the problem.
> 
> Grant, after Tarun/Santosh have a chance to review/ack this, can you
> still get this in for 3.5?  If not, getting it into -rc should be fine.

Yes.  Do you have any other omap patches?  Do you want to send me a
pull req?

g.

> > Kevin
> 
> 
> From 83874df8e0dd78a3609f5ba81d608df7217fd212 Mon Sep 17 00:00:00 2001
> From: Kevin Hilman <khilman@ti.com>
> Date: Thu, 17 May 2012 14:52:56 -0700
> Subject: [PATCH] gpio/omap: fix broken context restore for non-OFF mode
>  transitions
> 
> The fix in commit 1b12870 (gpio/omap: fix missing check in
> *_runtime_suspend()) exposed another bug in the context restore path.
> 
> Currently, the per-bank context restore happens whenever the context
> loss count is different in runtime suspend and runtime resume *and*
> whenever the per-bank contex_loss_count == 0:
> 
> 	if (context_lost_cnt_after != bank->context_loss_count ||
> 					!context_lost_cnt_after) {
> 		omap_gpio_restore_context(bank);
> 
> Restoring context when the context_lost_cnt_after == 0 is clearly
> wrong, since this will be true until the first off-mode transition
> (which could be never, if off-mode is never enabled.)  This check
> causes the context to be restored on *every* runtime PM transition.
> 
> Before commit 1b12870 (gpio/omap: fix missing check in
> *_runtime_suspend()), this code was never executed in non-OFF mode, so
> there were never spurious context restores happening.  After that
> change though, spurious context restores could happen.
> 
> To fix, simply remove the !context_lost_cnt_after check. It is not
> needed.
> 
> This bug was found when noticing that the smc911x NIC on 3530/Overo
> was not working, and git bisect tracked it down to this patch.  It
> seems that the spurious context restore was causing the smsc911x to
> not be properly probed on this platform.
> 
> Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>
> Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Signed-off-by: Kevin Hilman <khilman@ti.com>
> ---
>  drivers/gpio/gpio-omap.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index 9b71f04..b570a6a 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -1238,8 +1238,7 @@ static int omap_gpio_runtime_resume(struct device *dev)
>  	if (bank->get_context_loss_count) {
>  		context_lost_cnt_after =
>  			bank->get_context_loss_count(bank->dev);
> -		if (context_lost_cnt_after != bank->context_loss_count ||
> -						!context_lost_cnt_after) {
> +		if (context_lost_cnt_after != bank->context_loss_count) {
>  			omap_gpio_restore_context(bank);
>  		} else {
>  			spin_unlock_irqrestore(&bank->lock, flags);
> -- 
> 1.7.9.2
> 

-- 
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.

  parent reply	other threads:[~2012-05-17 23:27 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-27 14:13 [PATCH 0/8] gpio/omap: remaining cleanups and fix Tarun Kanti DebBarma
2012-04-27 14:13 ` Tarun Kanti DebBarma
2012-04-27 14:13 ` [PATCH 1/8] gpio/omap: remove virtual_irq_start variable Tarun Kanti DebBarma
2012-04-27 14:13   ` Tarun Kanti DebBarma
2012-05-03 11:13   ` Santosh Shilimkar
2012-05-03 11:13     ` Santosh Shilimkar
2012-04-27 14:13 ` [PATCH 2/8] gpio/omap: remove saved_fallingdetect, saved_risingdetect Tarun Kanti DebBarma
2012-04-27 14:13   ` Tarun Kanti DebBarma
2012-04-27 14:13 ` [PATCH 3/8] gpio/omap: remove suspend_wakeup field from struct gpio_bank Tarun Kanti DebBarma
2012-04-27 14:13   ` Tarun Kanti DebBarma
2012-04-27 14:13 ` [PATCH 4/8] gpio/omap: remove saved_wakeup " Tarun Kanti DebBarma
2012-04-27 14:13   ` Tarun Kanti DebBarma
2012-04-27 14:13 ` [PATCH 5/8] gpio/omap: remove retrigger variable in gpio_irq_handler Tarun Kanti DebBarma
2012-04-27 14:13   ` Tarun Kanti DebBarma
2012-04-27 14:13 ` [PATCH 6/8] gpio/omap: remove suspend/resume callbacks Tarun Kanti DebBarma
2012-04-27 14:13   ` Tarun Kanti DebBarma
2012-04-27 14:13 ` [PATCH 7/8] gpio/omap: remove cpu_is_omapxxxx() checks from *_runtime_resume() Tarun Kanti DebBarma
2012-04-27 14:13   ` Tarun Kanti DebBarma
2012-05-03 11:15   ` Santosh Shilimkar
2012-05-03 11:15     ` Santosh Shilimkar
2012-04-27 14:13 ` [PATCH 8/8] gpio/omap: fix missing check in *_runtime_suspend() Tarun Kanti DebBarma
2012-04-27 14:13   ` Tarun Kanti DebBarma
2012-05-03 11:16   ` Santosh Shilimkar
2012-05-03 11:16     ` Santosh Shilimkar
2012-05-17 22:21   ` Kevin Hilman
2012-05-17 22:21     ` Kevin Hilman
2012-05-17 23:12     ` Tony Lindgren
2012-05-17 23:12       ` Tony Lindgren
2012-05-17 23:56       ` Kevin Hilman
2012-05-17 23:56         ` Kevin Hilman
2012-05-18  0:10         ` Tony Lindgren
2012-05-18  0:10           ` Tony Lindgren
2012-05-18  4:48         ` DebBarma, Tarun Kanti
2012-05-18  4:48           ` DebBarma, Tarun Kanti
2012-05-18  6:22         ` Shilimkar, Santosh
2012-05-18  6:22           ` Shilimkar, Santosh
2012-05-17 23:27     ` Grant Likely [this message]
2012-05-17 23:27       ` Grant Likely
2012-05-18 14:03       ` Kevin Hilman
2012-05-18 14:03         ` Kevin Hilman
2012-05-18  5:12     ` DebBarma, Tarun Kanti
2012-05-18  5:12       ` DebBarma, Tarun Kanti
2012-05-18  8:46     ` DebBarma, Tarun Kanti
2012-05-18  8:46       ` DebBarma, Tarun Kanti
2012-04-27 19:07 ` [PATCH 0/8] gpio/omap: remaining cleanups and fix Grant Likely
2012-04-27 19:07   ` Grant Likely
2012-04-27 21:57   ` Kevin Hilman
2012-04-27 21:57     ` Kevin Hilman
2012-04-27 22:05     ` Grant Likely
2012-04-27 22:05       ` Grant Likely
2012-05-03 11:17 ` Santosh Shilimkar
2012-05-03 11:17   ` Santosh Shilimkar
2012-05-10  6:38 ` Raja, Govindraj
2012-05-10  6:38   ` Raja, Govindraj
2012-05-10 22:13   ` Kevin Hilman
2012-05-10 22:13     ` 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=20120517232755.EF4383E062C@localhost \
    --to=grant.likely@secretlab.ca \
    --cc=b-cousson@ti.com \
    --cc=khilman@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --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.