linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpiolib: fix issue of gpio acpi handler
@ 2015-03-06 15:08 qipeng.zha
  2015-03-09 11:12 ` Mika Westerberg
  0 siblings, 1 reply; 3+ messages in thread
From: qipeng.zha @ 2015-03-06 15:08 UTC (permalink / raw)
  To: linux-gpio; +Cc: linus.walleij, mika.westerberg, qi.zheng, qipeng.zha

From: "qipeng.zha" <qipeng.zha@intel.com>

If GPIO driver use pin mapping, need to tranlate pin number
between ACPI table and GPIO driver.

This issue is found on one platform with Cherryview gpio
controller, kernel is hang when executed _PS0 method of
one ACPI device, since without this translation, it access
invalid gpiodesc array.

Verified it works again with this patch.

Signed-off-by: qipeng.zha <qipeng.zha@intel.com>
---
 drivers/gpio/gpiolib-acpi.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index c0929d9..661e272 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -551,6 +551,13 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
 		struct gpio_desc *desc;
 		bool found;
 
+		/*Translate ACPI gpio pin to offset in gpio driver*/
+		pin = acpi_gpiochip_pin_to_gpio_offset(chip, pin);
+		if (pin < 0) {
+			status = AE_BAD_PARAMETER;
+			goto out;
+		}
+
 		mutex_lock(&achip->conn_lock);
 
 		found = false;
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpiolib: fix issue of gpio acpi handler
  2015-03-06 15:08 [PATCH] gpiolib: fix issue of gpio acpi handler qipeng.zha
@ 2015-03-09 11:12 ` Mika Westerberg
  2015-03-09 11:14   ` Mika Westerberg
  0 siblings, 1 reply; 3+ messages in thread
From: Mika Westerberg @ 2015-03-09 11:12 UTC (permalink / raw)
  To: qipeng.zha; +Cc: linux-gpio, linus.walleij, qi.zheng

On Fri, Mar 06, 2015 at 11:08:38PM +0800, qipeng.zha wrote:
> From: "qipeng.zha" <qipeng.zha@intel.com>
> 
> If GPIO driver use pin mapping, need to tranlate pin number
                                          ^^^^^^^^
typo, should be "translate"

> between ACPI table and GPIO driver.
> 
> This issue is found on one platform with Cherryview gpio
> controller, kernel is hang when executed _PS0 method of
> one ACPI device, since without this translation, it access
> invalid gpiodesc array.
> 
> Verified it works again with this patch.
> 
> Signed-off-by: qipeng.zha <qipeng.zha@intel.com>
> ---
>  drivers/gpio/gpiolib-acpi.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
> index c0929d9..661e272 100644
> --- a/drivers/gpio/gpiolib-acpi.c
> +++ b/drivers/gpio/gpiolib-acpi.c
> @@ -551,6 +551,13 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
>  		struct gpio_desc *desc;
>  		bool found;
>  
> +		/*Translate ACPI gpio pin to offset in gpio driver*/

/* Comments look like this */

notice that there is space between /* and beginning of the sentence.

But this comment does not add any new information so I would just drop
it.

Otherwise this patch seems right to me.

BTW, I wonder if we need to do the same in
acpi_gpiochip_request_interrupt()?

> +		pin = acpi_gpiochip_pin_to_gpio_offset(chip, pin);
> +		if (pin < 0) {
> +			status = AE_BAD_PARAMETER;
> +			goto out;
> +		}
> +
>  		mutex_lock(&achip->conn_lock);
>  
>  		found = false;
> -- 
> 1.8.3.2

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpiolib: fix issue of gpio acpi handler
  2015-03-09 11:12 ` Mika Westerberg
@ 2015-03-09 11:14   ` Mika Westerberg
  0 siblings, 0 replies; 3+ messages in thread
From: Mika Westerberg @ 2015-03-09 11:14 UTC (permalink / raw)
  To: qipeng.zha; +Cc: linux-gpio, linus.walleij, qi.zheng

On Mon, Mar 09, 2015 at 01:12:03PM +0200, Mika Westerberg wrote:
> On Fri, Mar 06, 2015 at 11:08:38PM +0800, qipeng.zha wrote:
> > From: "qipeng.zha" <qipeng.zha@intel.com>
> > 
> > If GPIO driver use pin mapping, need to tranlate pin number
>                                           ^^^^^^^^
> typo, should be "translate"
> 
> > between ACPI table and GPIO driver.
> > 
> > This issue is found on one platform with Cherryview gpio
> > controller, kernel is hang when executed _PS0 method of
> > one ACPI device, since without this translation, it access
> > invalid gpiodesc array.
> > 
> > Verified it works again with this patch.
> > 
> > Signed-off-by: qipeng.zha <qipeng.zha@intel.com>
> > ---
> >  drivers/gpio/gpiolib-acpi.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
> > index c0929d9..661e272 100644
> > --- a/drivers/gpio/gpiolib-acpi.c
> > +++ b/drivers/gpio/gpiolib-acpi.c
> > @@ -551,6 +551,13 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
> >  		struct gpio_desc *desc;
> >  		bool found;
> >  
> > +		/*Translate ACPI gpio pin to offset in gpio driver*/
> 
> /* Comments look like this */
> 
> notice that there is space between /* and beginning of the sentence.
> 
> But this comment does not add any new information so I would just drop
> it.
> 
> Otherwise this patch seems right to me.

One more thing, though. The title of the patch should be more
descriptive. So that you get the idea what the patch is fixing when you
run "git log --oneline".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-09 11:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-06 15:08 [PATCH] gpiolib: fix issue of gpio acpi handler qipeng.zha
2015-03-09 11:12 ` Mika Westerberg
2015-03-09 11:14   ` Mika Westerberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).