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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VdCwyJhYD9rtxf8H5mi5AfcPOhvSYx2MOqw3==3mnxoSg@mail.gmail.com>
Date: Mon, 27 Jan 2025 09:47:17 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: lakabd <lakabd.work@...il.com>
Cc: mark.tomlinson@...iedtelesis.co.nz, brgl@...ev.pl, 
	linus.walleij@...aro.org, linux-gpio@...r.kernel.org, 
	linux-kernel@...r.kernel.org, Abderrahim LAKBIR <abderrahim.lakbir@...ia.fr>
Subject: Re: [PATCH] gpio: pca953x: Improve interrupt support

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.

P.S. Sorry for the delays.

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ