linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: mazziesaccount@gmail.com, heikki.haikola@fi.rohmeurope.com,
	mikko.mutanen@fi.rohmeurope.com, Mark Brown <broonie@kernel.org>,
	Greg KH <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>,
	Linux-Renesas <linux-renesas-soc@vger.kernel.org>
Subject: Re: [PATCH v3] regmap: regmap-irq/gpio-max77620: add level-irq support
Date: Thu, 27 Dec 2018 09:56:48 +0200	[thread overview]
Message-ID: <20181227075648.GB2461@localhost.localdomain> (raw)
In-Reply-To: <20181227073531.GA2461@localhost.localdomain>

Hello All,

On Thu, Dec 27, 2018 at 09:35:31AM +0200, Matti Vaittinen wrote:
> On Wed, Dec 26, 2018 at 12:39:17PM +0100, Geert Uytterhoeven wrote:
> > Hi Matti,
> > 
> > On Tue, Dec 18, 2018 at 1:00 PM Matti Vaittinen
> > <matti.vaittinen@fi.rohmeurope.com> wrote:
> > > Add level active IRQ support to regmap-irq irqchip. Change breaks
> > > existing regmap-irq type setting. Convert the existing drivers which
> > 
> > Indeed it does.
> > 
> > > use regmap-irq with trigger type setting (gpio-max77620) to work
> > > with this new approach. So we do not magically support level-active
> > > IRQs on gpio-max77620 - but add support to the regmap-irq for chips
> > > which support them =)
> > >
> > > We do not support distinguishing situation where HW supports rising
> > > and falling edge detection but not both. Separating this would require
> > > inventing yet another flags for IRQ types.
> > >
> > > Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
> > 
> > This is now upstream as commit 1c2928e3e3212252 ("regmap:
> > regmap-irq/gpio-max77620: add level-irq support"), and breaks da9063-rtc
> > on the Renesas Koelsch board:
> > 
> >     genirq: Setting trigger mode 8 for irq 157 failed
> > (regmap_irq_set_type+0x0/0x140)
> >     da9063-rtc da9063-rtc: Failed to request ALARM IRQ 157: -524
> >     da9063-rtc: probe of da9063-rtc failed with error -524
> 
> This is strange as I do not see any type setting support code in
> drivers/mfd/da9063-irq.c. The type setting registers are neither
> specified in static const struct regmap_irq_chip da9063l_irq_chip nor
> in static const struct regmap_irq_chip da9063_irq_chip. Hence I don't
> understand how the da9063 could have been supporting IRQ type setting in
> first place.
> 
> > > ---
> > >
> > > Version 3 of this patch is intended to be functionally identical to v2.
> > > This patch is rebased on top of a tree which contains changes:
> > > "regmap: irq: handle HW using separate rising/falling edge interrupts"
> > > from Bartosz Golaszewski and the change
> > > "regmap: regmap-irq: Remove default irq type setting from core"
> > > (proposed here):
> > > https://lore.kernel.org/lkml/20181218105813.GA6957@localhost.localdomain/
> > >
> > > There should not be direct dependency to "regmap: regmap-irq: Remove
> > > default irq type setting from core" though. Patch was also tested to
> > > apply cleany on regmap-tree.
> > >
> > > Same statement regarding testing applies - gpio-max77620 are only
> > > tested to compile. All real testing would be _HIGHLY_ appreciated.
> > >
> > >  drivers/base/regmap/regmap-irq.c | 35 ++++++++++-----
> > >  drivers/gpio/gpio-max77620.c     | 96 ++++++++++++++++++++++++++--------------
> > >  include/linux/regmap.h           | 27 ++++++++---
> > >  3 files changed, 110 insertions(+), 48 deletions(-)
> > >
> > > diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
> > > index 8b216b2e2c19..31d23c9a5ae7 100644
> > > --- a/drivers/base/regmap/regmap-irq.c
> > > +++ b/drivers/base/regmap/regmap-irq.c
> > > @@ -199,7 +199,7 @@ static void regmap_irq_enable(struct irq_data *data)
> > >         const struct regmap_irq *irq_data = irq_to_regmap_irq(d, data->hwirq);
> > >         unsigned int mask, type;
> > >
> > > -       type = irq_data->type_falling_mask | irq_data->type_rising_mask;
> > > +       type = irq_data->type.type_falling_val | irq_data->type.type_rising_val;
> > >
> > >         /*
> > >          * The type_in_mask flag means that the underlying hardware uses
> > > @@ -234,27 +234,42 @@ static int regmap_irq_set_type(struct irq_data *data, unsigned int type)
> > >         struct regmap_irq_chip_data *d = irq_data_get_irq_chip_data(data);
> > >         struct regmap *map = d->map;
> > >         const struct regmap_irq *irq_data = irq_to_regmap_irq(d, data->hwirq);
> > > -       int reg = irq_data->type_reg_offset / map->reg_stride;
> > > +       int reg;
> > > +       const struct regmap_irq_type *t = &irq_data->type;
> > >
> > > -       if (!(irq_data->type_rising_mask | irq_data->type_falling_mask))
> > > -               return 0;
> > > +       if ((t->types_supported & type) != type)
> > > +               return -ENOTSUPP;
> > 
> > Given types_supported defaults to zero, I think this breaks every existing
> > setup using REGMAP_IRQ_REG().

Right. Now I see what you mean. Original code did:

	if (!(irq_data->type_rising_mask | irq_data->type_falling_mask))
		return 0;

Eg, even when the driver was not able to perform the type-setting this
failure was silently ignored, right. So doing:
       if ((t->types_supported & type) != type)
               return 0;
would be functionally equal. It feels like utterly wrong thing to do
(to me) - if driver is written to work with edge or level active
interrupts - and if the irq controller is not supporting this - then we
should warn the user. Just silently ignoring this sounds like asking for
irq storm or missed interrupts - but maybe I just don't get this =)

I'll send a patch with 
	if (!(irq_data->type_rising_mask | irq_data->type_falling_mask))
		return 0;
in order to not break existing functionality - but it feels plain wrong
to me.


> Br,
> 	Matti Vaittinen
> 
> -- 
> Matti Vaittinen
> ROHM Semiconductors
> 
> ~~~ "I don't think so," said Rene Descartes.  Just then, he vanished ~~~

-- 
Matti Vaittinen
ROHM Semiconductors

~~~ "I don't think so," said Rene Descartes.  Just then, he vanished ~~~

  reply	other threads:[~2018-12-27  7:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-18 11:59 [PATCH v3] regmap: regmap-irq/gpio-max77620: add level-irq support Matti Vaittinen
2018-12-18 15:36 ` kbuild test robot
2018-12-19  6:48   ` Matti Vaittinen
2018-12-19 17:52     ` Mark Brown
2018-12-26 11:39 ` Geert Uytterhoeven
2018-12-27  7:35   ` Matti Vaittinen
2018-12-27  7:56     ` Matti Vaittinen [this message]
2018-12-28  8:05       ` Matti Vaittinen
2018-12-31 19:11         ` Mark Brown
2019-01-02  7:42           ` Matti Vaittinen
2019-01-03 17:20             ` Charles Keepax
2019-01-04  8:02               ` Matti Vaittinen

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=20181227075648.GB2461@localhost.localdomain \
    --to=matti.vaittinen@fi.rohmeurope.com \
    --cc=broonie@kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.haikola@fi.rohmeurope.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=mazziesaccount@gmail.com \
    --cc=mikko.mutanen@fi.rohmeurope.com \
    --cc=rafael@kernel.org \
    --cc=vladimir_zapolskiy@mentor.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 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).