lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <9bcfe1f204013708c7ea0fb4c1392004ad34c3ac.camel@alliedtelesis.co.nz>
Date: Tue, 28 Jan 2025 03:43:40 +0000
From: Mark Tomlinson <Mark.Tomlinson@...iedtelesis.co.nz>
To: "andy.shevchenko@...il.com" <andy.shevchenko@...il.com>,
	"lakabd.work@...il.com" <lakabd.work@...il.com>
CC: "linux-gpio@...r.kernel.org" <linux-gpio@...r.kernel.org>,
	"abderrahim.lakbir@...ia.fr" <abderrahim.lakbir@...ia.fr>, "brgl@...ev.pl"
	<brgl@...ev.pl>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>, "linus.walleij@...aro.org"
	<linus.walleij@...aro.org>
Subject: Re: [PATCH] gpio: pca953x: Improve interrupt support

On Mon, 2025-01-27 at 09:47 +0200, Andy Shevchenko wrote:
> On Tue, Jan 21, 2025 at 12:12 PM lakabd <lakabd.work@...il.com> wrote:
> > Le mar. 14 janv. 2025 à 16:44, work work <lakabd.work@...il.com> a
> > écrit :
> > > Le mar. 14 janv. 2025 à 10:37, Andy Shevchenko
> > > <andy.shevchenko@...il.com> a écrit :
> > > > On Tue, Jan 14, 2025 at 12:03 AM lakabd <lakabd.work@...il.com>
> > > > wrote:
> 
> ....
> 
> > > > > +                             /* Store irq_mask for later use
> > > > > when checking pending IRQs */
> > > > > +                             bitmap_or(chip-
> > > > > >unmasked_interrupts, chip->unmasked_interrupts, chip->irq_mask,
> > > > > gc->ngpio);
> > > > 
> > > > This solution has a flaw. Where is any code that clears this new
> > > > bitmap? The code starts with 0 (obviously) and step by step it gets
> > > > saturated to all-1s.
> > > 
> > > Yes indeed, and actually the new bitmap is not necessary at all
> > > because what we need does already exist which is chip->irq_mask (I
> > > noticed it just now!).
> > > chip->irq_mask is updated whenever a pin is masked or unmasked via
> > > pca953x_irq_mask() and pca953x_irq_unmask().
> > > 
> > > The solution should look like this:
> > > 
> > > diff --git a/gpio-pca953x.c b/gpio-pca953x.c
> > > index 272febc..29e8c20 100644
> > > --- a/gpio-pca953x.c
> > > +++ b/gpio-pca953x.c
> > > @@ -842,11 +842,6 @@ static bool pca953x_irq_pending(struct
> > > pca953x_chip *chip, unsigned long *pendin
> > >   int ret;
> > > 
> > >   if (chip->driver_data & PCA_PCAL) {
> > > - /* Read the current interrupt status from the device */
> > > - ret = pca953x_read_regs(chip, PCAL953X_INT_STAT, trigger);
> > > - if (ret)
> > > - return false;
> > > -
> > >   /* Check latched inputs and clear interrupt status */
> > >   ret = pca953x_read_regs(chip, chip->regs->input, cur_stat);
> > >   if (ret)
> > > @@ -855,7 +850,7 @@ static bool pca953x_irq_pending(struct
> > > pca953x_chip *chip, unsigned long *pendin
> > >   /* Apply filter for rising/falling edge selection */
> > >   bitmap_replace(new_stat, chip->irq_trig_fall, chip->irq_trig_raise,
> > > cur_stat, gc->ngpio);
> > > 
> > > - bitmap_and(pending, new_stat, trigger, gc->ngpio);
> > > + bitmap_and(pending, new_stat, chip->irq_mask, gc->ngpio);
> > > 
> > >   return !bitmap_empty(pending, gc->ngpio);>
> 
> > >   }
> > 
> > Hi Andy, do you have any other suggestions regarding the proposed fix ?
> 
> Currently I'm reading the datasheet to understand how the chip
> actually works. I'll come back to you soon.
> 
> Nevertheless, I would like to hear from Mark if your patch fixes the
> issue. Preliminary I can say that it looks like we need slightly
> different and more complex logic there.

This patch will not miss interrupts, but I believe will trigger false
interrupts, as an input will behave more like a level triggered interrupt
if other inputs are triggering interrupts on the device. I would prefer
that we just remove the special PCA_PCAL block in this function, which
was my simple solution.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ