All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman@ti.com>
To: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Cc: linux-omap@vger.kernel.org, tony@atomide.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3 13/13] gpio/omap: fix incorrect update to context.irqenable1
Date: Mon, 12 Mar 2012 15:09:54 -0700	[thread overview]
Message-ID: <87haxtwjwt.fsf@ti.com> (raw)
In-Reply-To: <1331118963-26364-14-git-send-email-tarun.kanti@ti.com> (Tarun Kanti DebBarma's message of "Wed, 7 Mar 2012 16:46:03 +0530")

Tarun Kanti DebBarma <tarun.kanti@ti.com> writes:

> In _enable_gpio_irqbank() when bank->regs->set_irqenable is valid,
> gpio_mask can be directly set by writing to set_irqenable register
> without overwriting current value. 

Ouch.  Nice catch.

> In order to ensure the same is
> stored in context.irqenable1, we must read from regs->irqenable
> instead of overwriting it with gpio_mask.
> The overwriting makes sense only in the second case where irqenable
> is explicitly read and updated with new gpio_mask before writing it
> back. However, for consistency reading regs->irqenable into the
> bank->context.irqenable1 takes care of both the scenarios.

...takes care of both scenarios, but adds and extra duplicate read for
the second.

Instead, how about just move the context update into each side of the
if/else?  untested patch below to show what I mean.

Kevin


diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 752ae9b..f8b7099 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -442,6 +442,7 @@ static void _enable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
 	if (bank->regs->set_irqenable) {
 		reg += bank->regs->set_irqenable;
 		l = gpio_mask;
+		bank->context.irqenable1 |= gpio_mask;
 	} else {
 		reg += bank->regs->irqenable;
 		l = __raw_readl(reg);
@@ -449,10 +450,10 @@ static void _enable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
 			l &= ~gpio_mask;
 		else
 			l |= gpio_mask;
+		bank->context.irqenable1 = l;
 	}
 
 	__raw_writel(l, reg);
-	bank->context.irqenable1 = l;
 }
 
 static void _disable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
@@ -463,6 +464,7 @@ static void _disable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
 	if (bank->regs->clr_irqenable) {
 		reg += bank->regs->clr_irqenable;
 		l = gpio_mask;
+		bank->context.irqenable1 &= ~gpio_mask;
 	} else {
 		reg += bank->regs->irqenable;
 		l = __raw_readl(reg);
@@ -470,10 +472,10 @@ static void _disable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
 			l |= gpio_mask;
 		else
 			l &= ~gpio_mask;
+		bank->context.irqenable1 = l;
 	}
 
 	__raw_writel(l, reg);
-	bank->context.irqenable1 = l;
 }
 
 static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int enable)


WARNING: multiple messages have this Message-ID (diff)
From: khilman@ti.com (Kevin Hilman)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 13/13] gpio/omap: fix incorrect update to context.irqenable1
Date: Mon, 12 Mar 2012 15:09:54 -0700	[thread overview]
Message-ID: <87haxtwjwt.fsf@ti.com> (raw)
In-Reply-To: <1331118963-26364-14-git-send-email-tarun.kanti@ti.com> (Tarun Kanti DebBarma's message of "Wed, 7 Mar 2012 16:46:03 +0530")

Tarun Kanti DebBarma <tarun.kanti@ti.com> writes:

> In _enable_gpio_irqbank() when bank->regs->set_irqenable is valid,
> gpio_mask can be directly set by writing to set_irqenable register
> without overwriting current value. 

Ouch.  Nice catch.

> In order to ensure the same is
> stored in context.irqenable1, we must read from regs->irqenable
> instead of overwriting it with gpio_mask.
> The overwriting makes sense only in the second case where irqenable
> is explicitly read and updated with new gpio_mask before writing it
> back. However, for consistency reading regs->irqenable into the
> bank->context.irqenable1 takes care of both the scenarios.

...takes care of both scenarios, but adds and extra duplicate read for
the second.

Instead, how about just move the context update into each side of the
if/else?  untested patch below to show what I mean.

Kevin


diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 752ae9b..f8b7099 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -442,6 +442,7 @@ static void _enable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
 	if (bank->regs->set_irqenable) {
 		reg += bank->regs->set_irqenable;
 		l = gpio_mask;
+		bank->context.irqenable1 |= gpio_mask;
 	} else {
 		reg += bank->regs->irqenable;
 		l = __raw_readl(reg);
@@ -449,10 +450,10 @@ static void _enable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
 			l &= ~gpio_mask;
 		else
 			l |= gpio_mask;
+		bank->context.irqenable1 = l;
 	}
 
 	__raw_writel(l, reg);
-	bank->context.irqenable1 = l;
 }
 
 static void _disable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
@@ -463,6 +464,7 @@ static void _disable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
 	if (bank->regs->clr_irqenable) {
 		reg += bank->regs->clr_irqenable;
 		l = gpio_mask;
+		bank->context.irqenable1 &= ~gpio_mask;
 	} else {
 		reg += bank->regs->irqenable;
 		l = __raw_readl(reg);
@@ -470,10 +472,10 @@ static void _disable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
 			l |= gpio_mask;
 		else
 			l &= ~gpio_mask;
+		bank->context.irqenable1 = l;
 	}
 
 	__raw_writel(l, reg);
-	bank->context.irqenable1 = l;
 }
 
 static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int enable)

  parent reply	other threads:[~2012-03-12 22:09 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-07 11:15 [PATCH v3 00/13] gpio/omap: Some more driver cleanup and fixes Tarun Kanti DebBarma
2012-03-07 11:15 ` Tarun Kanti DebBarma
2012-03-07 11:15 ` [PATCH v3 01/13] gpio/omap: remove saved_fallingdetect, saved_risingdetect fields Tarun Kanti DebBarma
2012-03-07 11:15   ` Tarun Kanti DebBarma
2012-03-07 11:15 ` [PATCH v3 02/13] gpio/omap: fix wakeup_en register update in _set_gpio_wakeup() Tarun Kanti DebBarma
2012-03-07 11:15   ` Tarun Kanti DebBarma
2012-03-07 11:59   ` Santosh Shilimkar
2012-03-07 11:59     ` Santosh Shilimkar
2012-03-07 11:15 ` [PATCH v3 03/13] gpio/omap: remove suspend_wakeup field from struct gpio_bank Tarun Kanti DebBarma
2012-03-07 11:15   ` Tarun Kanti DebBarma
2012-03-07 11:15 ` [PATCH v3 04/13] gpio/omap: remove saved_wakeup " Tarun Kanti DebBarma
2012-03-07 11:15   ` Tarun Kanti DebBarma
2012-03-07 11:15 ` [PATCH v3 05/13] gpio/omap: get rid of retrigger variable in gpio_irq_handler Tarun Kanti DebBarma
2012-03-07 11:15   ` Tarun Kanti DebBarma
2012-03-09  8:46   ` DebBarma, Tarun Kanti
2012-03-09  8:46     ` DebBarma, Tarun Kanti
2012-03-12 18:53     ` Kevin Hilman
2012-03-12 18:53       ` Kevin Hilman
2012-03-12 18:52   ` Kevin Hilman
2012-03-12 18:52     ` Kevin Hilman
2012-03-07 11:15 ` [PATCH v3 06/13] gpio/omap: fix trigger type to unsigned Tarun Kanti DebBarma
2012-03-07 11:15   ` Tarun Kanti DebBarma
2012-03-07 11:15 ` [PATCH v3 07/13] gpio/omap: fix _set_gpio_irqenable implementation Tarun Kanti DebBarma
2012-03-07 11:15   ` Tarun Kanti DebBarma
2012-03-07 11:15 ` [PATCH v3 08/13] gpio/omap: remove redundant decoding of gpio offset Tarun Kanti DebBarma
2012-03-07 11:15   ` Tarun Kanti DebBarma
2012-03-07 12:00   ` Santosh Shilimkar
2012-03-07 12:00     ` Santosh Shilimkar
2012-03-07 11:15 ` [PATCH v3 09/13] gpio/omap: remove suspend/resume callbacks Tarun Kanti DebBarma
2012-03-07 11:15   ` Tarun Kanti DebBarma
2012-03-07 12:01   ` Santosh Shilimkar
2012-03-07 12:01     ` Santosh Shilimkar
2012-03-07 11:16 ` [PATCH v3 10/13] gpio/omap: fix missing dataout context save in _set_gpio_dataout_reg Tarun Kanti DebBarma
2012-03-07 11:16   ` Tarun Kanti DebBarma
2012-03-07 12:03   ` Santosh Shilimkar
2012-03-07 12:03     ` Santosh Shilimkar
2012-03-08  3:34     ` DebBarma, Tarun Kanti
2012-03-08  3:34       ` DebBarma, Tarun Kanti
2012-03-07 11:16 ` [PATCH v3 11/13] gpio/omap: fix dataout register overwrite in _set_gpio_dataout_* Tarun Kanti DebBarma
2012-03-07 11:16   ` Tarun Kanti DebBarma
2012-03-07 12:04   ` Santosh Shilimkar
2012-03-07 12:04     ` Santosh Shilimkar
2012-03-12 21:54   ` Kevin Hilman
2012-03-12 21:54     ` Kevin Hilman
2012-03-13  6:03     ` DebBarma, Tarun Kanti
2012-03-13  6:03       ` DebBarma, Tarun Kanti
2012-03-13  6:33       ` DebBarma, Tarun Kanti
2012-03-13  6:33         ` DebBarma, Tarun Kanti
2012-03-13  6:52         ` DebBarma, Tarun Kanti
2012-03-13  6:52           ` DebBarma, Tarun Kanti
2012-03-13 16:27           ` Kevin Hilman
2012-03-13 16:27             ` Kevin Hilman
2012-03-14  1:53             ` DebBarma, Tarun Kanti
2012-03-14  1:53               ` DebBarma, Tarun Kanti
2012-03-07 11:16 ` [PATCH v3 12/13] gpio/omap: fix incorrect context restore logic in omap_gpio_runtime_resume Tarun Kanti DebBarma
2012-03-07 11:16   ` Tarun Kanti DebBarma
2012-03-07 12:07   ` Santosh Shilimkar
2012-03-07 12:07     ` Santosh Shilimkar
2012-03-08  3:58     ` DebBarma, Tarun Kanti
2012-03-08  3:58       ` DebBarma, Tarun Kanti
2012-03-08  7:19       ` Shilimkar, Santosh
2012-03-08  7:19         ` Shilimkar, Santosh
2012-03-09  9:25         ` DebBarma, Tarun Kanti
2012-03-09  9:25           ` DebBarma, Tarun Kanti
2012-03-07 11:16 ` [PATCH v3 13/13] gpio/omap: fix incorrect update to context.irqenable1 Tarun Kanti DebBarma
2012-03-07 11:16   ` Tarun Kanti DebBarma
2012-03-07 12:09   ` Santosh Shilimkar
2012-03-07 12:09     ` Santosh Shilimkar
2012-03-12 22:09   ` Kevin Hilman [this message]
2012-03-12 22:09     ` Kevin Hilman
2012-03-13  5:31     ` DebBarma, Tarun Kanti
2012-03-13  5:31       ` DebBarma, Tarun Kanti
2012-03-12 18:54 ` [PATCH v3 00/13] gpio/omap: Some more driver cleanup and fixes Kevin Hilman
2012-03-12 18:54   ` Kevin Hilman
2012-03-12 19:53   ` DebBarma, Tarun Kanti
2012-03-12 19:53     ` DebBarma, Tarun Kanti
2012-03-12 20:08     ` DebBarma, Tarun Kanti
2012-03-12 20:08       ` DebBarma, Tarun Kanti
2012-03-12 20:27       ` DebBarma, Tarun Kanti
2012-03-12 20:27         ` DebBarma, Tarun Kanti
2012-03-12 22:17         ` Kevin Hilman
2012-03-12 22:17           ` Kevin Hilman
2012-03-12 22:28         ` Kevin Hilman
2012-03-12 22:28           ` Kevin Hilman
2012-03-13  3:57           ` Grant Likely
2012-03-13  3:57             ` Grant Likely
2012-03-13  4:35             ` DebBarma, Tarun Kanti
2012-03-13  4:35               ` DebBarma, Tarun Kanti

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=87haxtwjwt.fsf@ti.com \
    --to=khilman@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --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.