linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] gpio: pl061: lock IRQs when starting them
@ 2013-11-26 13:23 Linus Walleij
  2013-11-27  4:20 ` Baruch Siach
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2013-11-26 13:23 UTC (permalink / raw)
  To: linux-gpio
  Cc: Alexandre Courbot, Linus Walleij, Haojian Zhuang, Baruch Siach,
	Deepak Sikri

This uses the new API for tagging GPIO lines as in use by
IRQs. This enforces a few semantic checks on how the underlying
GPIO line is used.

Cc: Haojian Zhuang <haojian.zhuang@linaro.org>
Cc: Baruch Siach <baruch@tkos.co.il>
Cc: Deepak Sikri <deepak.sikri@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpio/gpio-pl061.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
index f22f7f3e2e53..1c37c97acc76 100644
--- a/drivers/gpio/gpio-pl061.c
+++ b/drivers/gpio/gpio-pl061.c
@@ -231,11 +231,33 @@ static void pl061_irq_unmask(struct irq_data *d)
 	spin_unlock(&chip->lock);
 }
 
+static unsigned int pl061_irq_startup(struct irq_data *d)
+{
+	struct pl061_gpio *chip = irq_data_get_irq_chip_data(d);
+
+	if (gpio_lock_as_irq(&chip->gc, irqd_to_hwirq(d)))
+		dev_err(chip->gc.dev,
+			"unable to lock HW IRQ %lu for IRQ\n",
+			irqd_to_hwirq(d));
+	pl061_irq_unmask(d);
+	return 0;
+}
+
+static void pl061_irq_shutdown(struct irq_data *d)
+{
+	struct pl061_gpio *chip = irq_data_get_irq_chip_data(d);
+
+	pl061_irq_mask(d);
+	gpio_unlock_as_irq(&chip->gc, irqd_to_hwirq(d));
+}
+
 static struct irq_chip pl061_irqchip = {
 	.name		= "pl061 gpio",
 	.irq_mask	= pl061_irq_mask,
 	.irq_unmask	= pl061_irq_unmask,
 	.irq_set_type	= pl061_irq_type,
+	.irq_startup	= pl061_irq_startup,
+	.irq_shutdown	= pl061_irq_shutdown,
 };
 
 static int pl061_irq_map(struct irq_domain *d, unsigned int irq,
-- 
1.8.3.1


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

* Re: [PATCH 1/3] gpio: pl061: lock IRQs when starting them
  2013-11-26 13:23 [PATCH 1/3] gpio: pl061: lock IRQs when starting them Linus Walleij
@ 2013-11-27  4:20 ` Baruch Siach
  2013-11-27  7:58   ` Linus Walleij
  0 siblings, 1 reply; 4+ messages in thread
From: Baruch Siach @ 2013-11-27  4:20 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-gpio, Alexandre Courbot, Haojian Zhuang, Deepak Sikri

Hi Linus,

On Tue, Nov 26, 2013 at 02:23:47PM +0100, Linus Walleij wrote:
> This uses the new API for tagging GPIO lines as in use by
> IRQs. This enforces a few semantic checks on how the underlying
> GPIO line is used.
> 
> Cc: Haojian Zhuang <haojian.zhuang@linaro.org>
> Cc: Baruch Siach <baruch@tkos.co.il>
> Cc: Deepak Sikri <deepak.sikri@st.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/gpio/gpio-pl061.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
> index f22f7f3e2e53..1c37c97acc76 100644
> --- a/drivers/gpio/gpio-pl061.c
> +++ b/drivers/gpio/gpio-pl061.c
> @@ -231,11 +231,33 @@ static void pl061_irq_unmask(struct irq_data *d)
>  	spin_unlock(&chip->lock);
>  }
>  
> +static unsigned int pl061_irq_startup(struct irq_data *d)
> +{
> +	struct pl061_gpio *chip = irq_data_get_irq_chip_data(d);
> +
> +	if (gpio_lock_as_irq(&chip->gc, irqd_to_hwirq(d)))
> +		dev_err(chip->gc.dev,
> +			"unable to lock HW IRQ %lu for IRQ\n",
> +			irqd_to_hwirq(d));

What is this locking good for if locking is not enforced (i.e. error out)?

baruch

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -

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

* Re: [PATCH 1/3] gpio: pl061: lock IRQs when starting them
  2013-11-27  4:20 ` Baruch Siach
@ 2013-11-27  7:58   ` Linus Walleij
  2013-11-27  8:02     ` Baruch Siach
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2013-11-27  7:58 UTC (permalink / raw)
  To: Baruch Siach
  Cc: linux-gpio@vger.kernel.org, Alexandre Courbot, Haojian Zhuang,
	Deepak Sikri

On Wed, Nov 27, 2013 at 5:20 AM, Baruch Siach <baruch@tkos.co.il> wrote:
> On Tue, Nov 26, 2013 at 02:23:47PM +0100, Linus Walleij wrote:

>> This uses the new API for tagging GPIO lines as in use by
>> IRQs. This enforces a few semantic checks on how the underlying
>> GPIO line is used.
>
> What is this locking good for if locking is not enforced (i.e. error out)?

See commit d468bf9ecaabd3bf3a6134e5a369ced82b1d1ca1

commit d468bf9ecaabd3bf3a6134e5a369ced82b1d1ca1
Author: Linus Walleij <linus.walleij@linaro.org>
Date:   Tue Sep 24 11:54:38 2013 +0200

    gpio: add API to be strict about GPIO IRQ usage

    It is currently often possible in many GPIO drivers to request
    a GPIO line to be used as IRQ after calling gpio_to_irq() and,
    as the gpiolib is not aware of this, set the same line to
    output and start driving it, with undesired side effects.

    As it is a bogus usage scenario to request a line flagged as
    output to used as IRQ, we introduce APIs to let gpiolib track
    the use of a line as IRQ, and also set this flag from the
    userspace ABI.

    The API is symmetric so that lines can also be flagged from
    .irq_enable() and unflagged from IRQ by .irq_disable().
    The debugfs file is altered so that we see if a line is
    reserved for IRQ.

    Cc: Enric Balletbo i Serra <eballetbo@gmail.com>
    Cc: Grant Likely <grant.likely@linaro.org>
    Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
    Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
    Acked-by: Alexandre Courbot <acourbot@nvidia.com>
    Reviewed-by: Stephen Warren <swarren@nvidia.com>
    Reviewed-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


Yours,
Linus Walleij

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

* Re: [PATCH 1/3] gpio: pl061: lock IRQs when starting them
  2013-11-27  7:58   ` Linus Walleij
@ 2013-11-27  8:02     ` Baruch Siach
  0 siblings, 0 replies; 4+ messages in thread
From: Baruch Siach @ 2013-11-27  8:02 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-gpio@vger.kernel.org, Alexandre Courbot, Haojian Zhuang

Hi Linus,

(removing Deepak from Cc)

On Wed, Nov 27, 2013 at 08:58:03AM +0100, Linus Walleij wrote:
> On Wed, Nov 27, 2013 at 5:20 AM, Baruch Siach <baruch@tkos.co.il> wrote:
> > On Tue, Nov 26, 2013 at 02:23:47PM +0100, Linus Walleij wrote:
> 
> >> This uses the new API for tagging GPIO lines as in use by
> >> IRQs. This enforces a few semantic checks on how the underlying
> >> GPIO line is used.
> >
> > What is this locking good for if locking is not enforced (i.e. error out)?
> 
> See commit d468bf9ecaabd3bf3a6134e5a369ced82b1d1ca1

OK, then.

Acked-by: Baruch Siach <baruch@tkos.co.il>

baruch

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -

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

end of thread, other threads:[~2013-11-27  8:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-26 13:23 [PATCH 1/3] gpio: pl061: lock IRQs when starting them Linus Walleij
2013-11-27  4:20 ` Baruch Siach
2013-11-27  7:58   ` Linus Walleij
2013-11-27  8:02     ` Baruch Siach

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).