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]
Date:   Thu, 25 Aug 2022 15:36:58 +0200
From:   Linus Walleij <linus.walleij@...aro.org>
To:     Arnd Bergmann <arnd@...db.de>
Cc:     Alexandre Courbot <gnurou@...il.com>,
        Alexandre Courbot <acourbot@...dia.com>,
        Bartosz Golaszewski <brgl@...ev.pl>,
        Christophe Leroy <christophe.leroy@...roup.eu>,
        Jonathan Corbet <corbet@....net>,
        Russell King <linux@...linux.org.uk>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>,
        "H. Peter Anvin" <hpa@...or.com>,
        "open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
        "open list:DOCUMENTATION" <linux-doc@...r.kernel.org>,
        open list <linux-kernel@...r.kernel.org>,
        "moderated list:ARM PORT" <linux-arm-kernel@...ts.infradead.org>,
        "open list:GENERIC INCLUDE/ASM HEADER FILES" 
        <linux-arch@...r.kernel.org>
Subject: Re: [PATCH] gpio: Allow user to customise maximum number of GPIOs

On Thu, Aug 18, 2022 at 2:46 PM Arnd Bergmann <arnd@...db.de> wrote:
> On Thu, Aug 18, 2022 at 2:25 PM Linus Walleij <linus.walleij@...aro.org> wrote:

> > git grep 'base = -1' yields these suspects:
> >
> > arch/arm/common/sa1111.c:       sachip->gc.base = -1;
> > arch/arm/common/scoop.c:        devptr->gpio.base = -1;
> > arch/powerpc/platforms/52xx/mpc52xx_gpt.c:      gpt->gc.base = -1;
> > arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c: gc->base = -1;
> >
> > That's all! We could just calculate these to 512-ngpios and
> > hardcode that instead.
>
> How do the consumers find the numbers for these four?

For SA1111 the chip gets named "sa1111" and some consumers actually
use proper machine descriptions, maybe all?

arch/arm/mach-sa1100/jornada720.c:              GPIO_LOOKUP("sa1111",
0, "s0-power", GPIO_ACTIVE_HIGH),
arch/arm/mach-sa1100/jornada720.c:              GPIO_LOOKUP("sa1111",
1, "s1-power", GPIO_ACTIVE_HIGH),
(...)

For Scoop it is conditionally overridden in the code. I guess always
overridden.

For powerpc these seem to be using (old but working) device tree
lookups, so should not be an issue.

Sadly I'm not 100% sure that there are no random hard-coded
GPIO numbers referring to whatever the framework gave them
at the time the code was written :(

Another reason the base is assigned from above (usually
from 512 and downward) is that the primary SoC GPIO usually
want to be at base 0 and there is no guarantee that it will
get probed first. So hard-coded GPIO bases go from 0 -> n
and dynamically allocateed GPIO bases from n <- 512.

Then we hope they don't meet and overlap in the middle...

> > and in that case it is better to delete the use of this function
> > altogether since it can not fail.
>
> S32_MAX might be a better upper bound. That allows to
> just have no number assigned to a gpio chip. Any driver
> code calling desc_to_gpio() could then get back -1
> or a negative error code.
>
> Making the ones that are invalid today valid sounds like
> a step backwards to me if the goal is to stop using
> gpio numbers and most consumers no longer need them.

OK I get it...

Now: who wants to write this patch? :)

Christophe? Will you take a stab at it?

Yours,
Linus Walleij

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ