* [PATCH] gpio: bcm-kona: lock IRQs when starting them @ 2013-11-19 13:17 Linus Walleij 2013-11-21 1:13 ` Markus Mayer 0 siblings, 1 reply; 6+ messages in thread From: Linus Walleij @ 2013-11-19 13:17 UTC (permalink / raw) To: linux-gpio, Markus Mayer Cc: Alexandre Courbot, Linus Walleij, Christian Daudt 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: Markus Mayer <markus.mayer@linaro.org> Cc: Christian Daudt <csd@broadcom.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- drivers/gpio/gpio-bcm-kona.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c index 72c927dc3be1..dee6d03a7959 100644 --- a/drivers/gpio/gpio-bcm-kona.c +++ b/drivers/gpio/gpio-bcm-kona.c @@ -449,12 +449,32 @@ static void bcm_kona_gpio_irq_handler(unsigned int irq, struct irq_desc *desc) chained_irq_exit(chip, desc); } +static unsigned int bcm_kona_gpio_irq_startup(struct irq_data *d) +{ + struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); + + if (gpio_lock_as_irq(&kona_gpio->gpio_chip, d->hwirq)) + dev_err(kona_gpio->gpio_chip.dev, + "unable to lock HW IRQ %lu for IRQ\n", + d->hwirq); + return 0; +} + +static void bcm_kona_gpio_irq_shutdown(struct irq_data *d) +{ + struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); + + gpio_unlock_as_irq(&kona_gpio->gpio_chip, d->hwirq); +} + static struct irq_chip bcm_gpio_irq_chip = { .name = "bcm-kona-gpio", .irq_ack = bcm_kona_gpio_irq_ack, .irq_mask = bcm_kona_gpio_irq_mask, .irq_unmask = bcm_kona_gpio_irq_unmask, .irq_set_type = bcm_kona_gpio_irq_set_type, + .irq_startup = bcm_kona_gpio_irq_startup, + .irq_shutdown = bcm_kona_gpio_irq_shutdown, }; static struct __initconst of_device_id bcm_kona_gpio_of_match[] = { -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: bcm-kona: lock IRQs when starting them 2013-11-19 13:17 [PATCH] gpio: bcm-kona: lock IRQs when starting them Linus Walleij @ 2013-11-21 1:13 ` Markus Mayer 2013-11-21 1:21 ` Markus Mayer 0 siblings, 1 reply; 6+ messages in thread From: Markus Mayer @ 2013-11-21 1:13 UTC (permalink / raw) To: Linus Walleij; +Cc: Linux GPIO List, Alexandre Courbot, Christian Daudt On 19 November 2013 05:17, Linus Walleij <linus.walleij@linaro.org> 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: Markus Mayer <markus.mayer@linaro.org> > Cc: Christian Daudt <csd@broadcom.com> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org> > --- > drivers/gpio/gpio-bcm-kona.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c > index 72c927dc3be1..dee6d03a7959 100644 > --- a/drivers/gpio/gpio-bcm-kona.c > +++ b/drivers/gpio/gpio-bcm-kona.c > @@ -449,12 +449,32 @@ static void bcm_kona_gpio_irq_handler(unsigned int irq, struct irq_desc *desc) > chained_irq_exit(chip, desc); > } > > +static unsigned int bcm_kona_gpio_irq_startup(struct irq_data *d) > +{ > + struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); > + > + if (gpio_lock_as_irq(&kona_gpio->gpio_chip, d->hwirq)) > + dev_err(kona_gpio->gpio_chip.dev, > + "unable to lock HW IRQ %lu for IRQ\n", > + d->hwirq); > + return 0; > +} > + > +static void bcm_kona_gpio_irq_shutdown(struct irq_data *d) > +{ > + struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); > + > + gpio_unlock_as_irq(&kona_gpio->gpio_chip, d->hwirq); > +} > + > static struct irq_chip bcm_gpio_irq_chip = { > .name = "bcm-kona-gpio", > .irq_ack = bcm_kona_gpio_irq_ack, > .irq_mask = bcm_kona_gpio_irq_mask, > .irq_unmask = bcm_kona_gpio_irq_unmask, > .irq_set_type = bcm_kona_gpio_irq_set_type, > + .irq_startup = bcm_kona_gpio_irq_startup, > + .irq_shutdown = bcm_kona_gpio_irq_shutdown, > }; > > static struct __initconst of_device_id bcm_kona_gpio_of_match[] = { > -- > 1.8.3.1 > I don't know yet why, but as soon as I apply that patch, the cd-gpio interrupt doesn't seem to get triggered anymore. $ grep bcm-kona-gpio /proc/interrupts 270: 0 bcm-kona-gpio 14 3f1b0000.sdio cd The counter remains at 0. If I comment-out the irq_startup & irq_shutdown assignments to temporarily disable the new code, the interrupt counter increases again when I insert/remove an SD card. Regards, -Markus -- Markus Mayer Broadcom Landing Team ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: bcm-kona: lock IRQs when starting them 2013-11-21 1:13 ` Markus Mayer @ 2013-11-21 1:21 ` Markus Mayer 2013-11-21 9:04 ` Grygorii Strashko 0 siblings, 1 reply; 6+ messages in thread From: Markus Mayer @ 2013-11-21 1:21 UTC (permalink / raw) To: Linus Walleij; +Cc: Linux GPIO List, Alexandre Courbot, Christian Daudt Fixing Christian's e-mail address. On 20 November 2013 17:13, Markus Mayer <markus.mayer@linaro.org> wrote: > On 19 November 2013 05:17, Linus Walleij <linus.walleij@linaro.org> 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: Markus Mayer <markus.mayer@linaro.org> >> Cc: Christian Daudt <csd@broadcom.com> >> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> >> --- >> drivers/gpio/gpio-bcm-kona.c | 20 ++++++++++++++++++++ >> 1 file changed, 20 insertions(+) >> >> diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c >> index 72c927dc3be1..dee6d03a7959 100644 >> --- a/drivers/gpio/gpio-bcm-kona.c >> +++ b/drivers/gpio/gpio-bcm-kona.c >> @@ -449,12 +449,32 @@ static void bcm_kona_gpio_irq_handler(unsigned int irq, struct irq_desc *desc) >> chained_irq_exit(chip, desc); >> } >> >> +static unsigned int bcm_kona_gpio_irq_startup(struct irq_data *d) >> +{ >> + struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); >> + >> + if (gpio_lock_as_irq(&kona_gpio->gpio_chip, d->hwirq)) >> + dev_err(kona_gpio->gpio_chip.dev, >> + "unable to lock HW IRQ %lu for IRQ\n", >> + d->hwirq); >> + return 0; >> +} >> + >> +static void bcm_kona_gpio_irq_shutdown(struct irq_data *d) >> +{ >> + struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); >> + >> + gpio_unlock_as_irq(&kona_gpio->gpio_chip, d->hwirq); >> +} >> + >> static struct irq_chip bcm_gpio_irq_chip = { >> .name = "bcm-kona-gpio", >> .irq_ack = bcm_kona_gpio_irq_ack, >> .irq_mask = bcm_kona_gpio_irq_mask, >> .irq_unmask = bcm_kona_gpio_irq_unmask, >> .irq_set_type = bcm_kona_gpio_irq_set_type, >> + .irq_startup = bcm_kona_gpio_irq_startup, >> + .irq_shutdown = bcm_kona_gpio_irq_shutdown, >> }; >> >> static struct __initconst of_device_id bcm_kona_gpio_of_match[] = { >> -- >> 1.8.3.1 >> > > I don't know yet why, but as soon as I apply that patch, the cd-gpio > interrupt doesn't seem to get triggered anymore. > > $ grep bcm-kona-gpio /proc/interrupts > 270: 0 bcm-kona-gpio 14 3f1b0000.sdio cd > > The counter remains at 0. If I comment-out the irq_startup & > irq_shutdown assignments to temporarily disable the new code, the > interrupt counter increases again when I insert/remove an SD card. > > Regards, > -Markus -- Markus Mayer Broadcom Landing Team ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: bcm-kona: lock IRQs when starting them 2013-11-21 1:21 ` Markus Mayer @ 2013-11-21 9:04 ` Grygorii Strashko 2013-11-21 9:50 ` Javier Martinez Canillas 0 siblings, 1 reply; 6+ messages in thread From: Grygorii Strashko @ 2013-11-21 9:04 UTC (permalink / raw) To: Markus Mayer, Linus Walleij Cc: Linux GPIO List, Alexandre Courbot, Christian Daudt On 11/21/2013 03:21 AM, Markus Mayer wrote: > Fixing Christian's e-mail address. > > On 20 November 2013 17:13, Markus Mayer <markus.mayer@linaro.org> wrote: >> On 19 November 2013 05:17, Linus Walleij <linus.walleij@linaro.org> 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: Markus Mayer <markus.mayer@linaro.org> >>> Cc: Christian Daudt <csd@broadcom.com> >>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> >>> --- >>> drivers/gpio/gpio-bcm-kona.c | 20 ++++++++++++++++++++ >>> 1 file changed, 20 insertions(+) >>> >>> diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c >>> index 72c927dc3be1..dee6d03a7959 100644 >>> --- a/drivers/gpio/gpio-bcm-kona.c >>> +++ b/drivers/gpio/gpio-bcm-kona.c >>> @@ -449,12 +449,32 @@ static void bcm_kona_gpio_irq_handler(unsigned int irq, struct irq_desc *desc) >>> chained_irq_exit(chip, desc); >>> } >>> >>> +static unsigned int bcm_kona_gpio_irq_startup(struct irq_data *d) >>> +{ >>> + struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); >>> + >>> + if (gpio_lock_as_irq(&kona_gpio->gpio_chip, d->hwirq)) >>> + dev_err(kona_gpio->gpio_chip.dev, >>> + "unable to lock HW IRQ %lu for IRQ\n", >>> + d->hwirq); >>> + return 0; >>> +} >>> + >>> +static void bcm_kona_gpio_irq_shutdown(struct irq_data *d) >>> +{ >>> + struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); >>> + >>> + gpio_unlock_as_irq(&kona_gpio->gpio_chip, d->hwirq); >>> +} >>> + >>> static struct irq_chip bcm_gpio_irq_chip = { >>> .name = "bcm-kona-gpio", >>> .irq_ack = bcm_kona_gpio_irq_ack, >>> .irq_mask = bcm_kona_gpio_irq_mask, >>> .irq_unmask = bcm_kona_gpio_irq_unmask, >>> .irq_set_type = bcm_kona_gpio_irq_set_type, >>> + .irq_startup = bcm_kona_gpio_irq_startup, >>> + .irq_shutdown = bcm_kona_gpio_irq_shutdown, >>> }; >>> >>> static struct __initconst of_device_id bcm_kona_gpio_of_match[] = { >>> -- >>> 1.8.3.1 >>> >> >> I don't know yet why, but as soon as I apply that patch, the cd-gpio >> interrupt doesn't seem to get triggered anymore. >> >> $ grep bcm-kona-gpio /proc/interrupts >> 270: 0 bcm-kona-gpio 14 3f1b0000.sdio cd >> >> The counter remains at 0. If I comment-out the irq_startup & >> irq_shutdown assignments to temporarily disable the new code, the >> interrupt counter increases again when I insert/remove an SD card. Possibly, you have the same problem as I explained here "[PATCH] gpio: lynxpoint: lock IRQs when starting them" http://comments.gmane.org/gmane.linux.kernel.gpio/1163 >> >> Regards, >> -Markus > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: bcm-kona: lock IRQs when starting them 2013-11-21 9:04 ` Grygorii Strashko @ 2013-11-21 9:50 ` Javier Martinez Canillas 2013-11-21 10:10 ` Grygorii Strashko 0 siblings, 1 reply; 6+ messages in thread From: Javier Martinez Canillas @ 2013-11-21 9:50 UTC (permalink / raw) To: Grygorii Strashko Cc: Markus Mayer, Linus Walleij, Linux GPIO List, Alexandre Courbot, Christian Daudt Hi, On Thu, Nov 21, 2013 at 10:04 AM, Grygorii Strashko <grygorii.strashko@ti.com> wrote: > On 11/21/2013 03:21 AM, Markus Mayer wrote: >> >> Fixing Christian's e-mail address. >> >> On 20 November 2013 17:13, Markus Mayer <markus.mayer@linaro.org> wrote: >>> >>> On 19 November 2013 05:17, Linus Walleij <linus.walleij@linaro.org> >>> 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: Markus Mayer <markus.mayer@linaro.org> >>>> Cc: Christian Daudt <csd@broadcom.com> >>>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> >>>> --- >>>> drivers/gpio/gpio-bcm-kona.c | 20 ++++++++++++++++++++ >>>> 1 file changed, 20 insertions(+) >>>> >>>> diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c >>>> index 72c927dc3be1..dee6d03a7959 100644 >>>> --- a/drivers/gpio/gpio-bcm-kona.c >>>> +++ b/drivers/gpio/gpio-bcm-kona.c >>>> @@ -449,12 +449,32 @@ static void bcm_kona_gpio_irq_handler(unsigned int >>>> irq, struct irq_desc *desc) >>>> chained_irq_exit(chip, desc); >>>> } >>>> >>>> +static unsigned int bcm_kona_gpio_irq_startup(struct irq_data *d) >>>> +{ >>>> + struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); >>>> + >>>> + if (gpio_lock_as_irq(&kona_gpio->gpio_chip, d->hwirq)) >>>> + dev_err(kona_gpio->gpio_chip.dev, >>>> + "unable to lock HW IRQ %lu for IRQ\n", >>>> + d->hwirq); >>>> + return 0; >>>> +} >>>> + >>>> +static void bcm_kona_gpio_irq_shutdown(struct irq_data *d) >>>> +{ >>>> + struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); >>>> + >>>> + gpio_unlock_as_irq(&kona_gpio->gpio_chip, d->hwirq); >>>> +} >>>> + >>>> static struct irq_chip bcm_gpio_irq_chip = { >>>> .name = "bcm-kona-gpio", >>>> .irq_ack = bcm_kona_gpio_irq_ack, >>>> .irq_mask = bcm_kona_gpio_irq_mask, >>>> .irq_unmask = bcm_kona_gpio_irq_unmask, >>>> .irq_set_type = bcm_kona_gpio_irq_set_type, >>>> + .irq_startup = bcm_kona_gpio_irq_startup, >>>> + .irq_shutdown = bcm_kona_gpio_irq_shutdown, >>>> }; >>>> >>>> static struct __initconst of_device_id bcm_kona_gpio_of_match[] = { >>>> -- >>>> 1.8.3.1 >>>> >>> >>> I don't know yet why, but as soon as I apply that patch, the cd-gpio >>> interrupt doesn't seem to get triggered anymore. >>> >>> $ grep bcm-kona-gpio /proc/interrupts >>> 270: 0 bcm-kona-gpio 14 3f1b0000.sdio cd >>> >>> The counter remains at 0. If I comment-out the irq_startup & >>> irq_shutdown assignments to temporarily disable the new code, the >>> interrupt counter increases again when I insert/remove an SD card. > > > Possibly, you have the same problem as I explained here > "[PATCH] gpio: lynxpoint: lock IRQs when starting them" > http://comments.gmane.org/gmane.linux.kernel.gpio/1163 > How about locking the GPIO as IRQ on the .irq_set_type function handler instead of adding a .irq_startup? That's how we did on gpio-omap driver and it works pretty well. >>> >>> Regards, >>> -Markus >> >> > Best regards, Javier ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: bcm-kona: lock IRQs when starting them 2013-11-21 9:50 ` Javier Martinez Canillas @ 2013-11-21 10:10 ` Grygorii Strashko 0 siblings, 0 replies; 6+ messages in thread From: Grygorii Strashko @ 2013-11-21 10:10 UTC (permalink / raw) To: Javier Martinez Canillas Cc: Markus Mayer, Linus Walleij, Linux GPIO List, Alexandre Courbot, Christian Daudt On 11/21/2013 11:50 AM, Javier Martinez Canillas wrote: > Hi, > > On Thu, Nov 21, 2013 at 10:04 AM, Grygorii Strashko > <grygorii.strashko@ti.com> wrote: >> On 11/21/2013 03:21 AM, Markus Mayer wrote: >>> >>> Fixing Christian's e-mail address. >>> >>> On 20 November 2013 17:13, Markus Mayer <markus.mayer@linaro.org> wrote: >>>> >>>> On 19 November 2013 05:17, Linus Walleij <linus.walleij@linaro.org> >>>> 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: Markus Mayer <markus.mayer@linaro.org> >>>>> Cc: Christian Daudt <csd@broadcom.com> >>>>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> >>>>> --- >>>>> drivers/gpio/gpio-bcm-kona.c | 20 ++++++++++++++++++++ >>>>> 1 file changed, 20 insertions(+) >>>>> >>>>> diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c >>>>> index 72c927dc3be1..dee6d03a7959 100644 >>>>> --- a/drivers/gpio/gpio-bcm-kona.c >>>>> +++ b/drivers/gpio/gpio-bcm-kona.c >>>>> @@ -449,12 +449,32 @@ static void bcm_kona_gpio_irq_handler(unsigned int >>>>> irq, struct irq_desc *desc) >>>>> chained_irq_exit(chip, desc); >>>>> } >>>>> >>>>> +static unsigned int bcm_kona_gpio_irq_startup(struct irq_data *d) >>>>> +{ >>>>> + struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); >>>>> + >>>>> + if (gpio_lock_as_irq(&kona_gpio->gpio_chip, d->hwirq)) >>>>> + dev_err(kona_gpio->gpio_chip.dev, >>>>> + "unable to lock HW IRQ %lu for IRQ\n", >>>>> + d->hwirq); >>>>> + return 0; >>>>> +} >>>>> + >>>>> +static void bcm_kona_gpio_irq_shutdown(struct irq_data *d) >>>>> +{ >>>>> + struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); >>>>> + >>>>> + gpio_unlock_as_irq(&kona_gpio->gpio_chip, d->hwirq); >>>>> +} >>>>> + >>>>> static struct irq_chip bcm_gpio_irq_chip = { >>>>> .name = "bcm-kona-gpio", >>>>> .irq_ack = bcm_kona_gpio_irq_ack, >>>>> .irq_mask = bcm_kona_gpio_irq_mask, >>>>> .irq_unmask = bcm_kona_gpio_irq_unmask, >>>>> .irq_set_type = bcm_kona_gpio_irq_set_type, >>>>> + .irq_startup = bcm_kona_gpio_irq_startup, >>>>> + .irq_shutdown = bcm_kona_gpio_irq_shutdown, >>>>> }; >>>>> >>>>> static struct __initconst of_device_id bcm_kona_gpio_of_match[] = { >>>>> -- >>>>> 1.8.3.1 >>>>> >>>> >>>> I don't know yet why, but as soon as I apply that patch, the cd-gpio >>>> interrupt doesn't seem to get triggered anymore. >>>> >>>> $ grep bcm-kona-gpio /proc/interrupts >>>> 270: 0 bcm-kona-gpio 14 3f1b0000.sdio cd >>>> >>>> The counter remains at 0. If I comment-out the irq_startup & >>>> irq_shutdown assignments to temporarily disable the new code, the >>>> interrupt counter increases again when I insert/remove an SD card. >> >> >> Possibly, you have the same problem as I explained here >> "[PATCH] gpio: lynxpoint: lock IRQs when starting them" >> http://comments.gmane.org/gmane.linux.kernel.gpio/1163 >> > > How about locking the GPIO as IRQ on the .irq_set_type function > handler instead of adding a .irq_startup? > > That's how we did on gpio-omap driver and it works pretty well. As for me - .irq_startup/.irq_shutdown are fit the best to do gpio lock, but they have to be implemented accordingly. Because .irq_startup()/.irq_shutdown() are called exactly when GPIO is requested/freed as opposed to .irq_set_type() which may be called any time and many times. Looks like, It will be enough to unmask/mask IRQ from bcm_kona_gpio_irq_startup/shutdown() for this driver. Regards, - grygorii ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-11-21 10:13 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-11-19 13:17 [PATCH] gpio: bcm-kona: lock IRQs when starting them Linus Walleij 2013-11-21 1:13 ` Markus Mayer 2013-11-21 1:21 ` Markus Mayer 2013-11-21 9:04 ` Grygorii Strashko 2013-11-21 9:50 ` Javier Martinez Canillas 2013-11-21 10:10 ` Grygorii Strashko
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).