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:   Wed, 17 Aug 2022 19:46:30 +0200
From:   Arnd Bergmann <arnd@...db.de>
To:     Christophe Leroy <christophe.leroy@...roup.eu>
Cc:     Linus Walleij <linus.walleij@...aro.org>,
        Bartosz Golaszewski <brgl@...ev.pl>,
        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>, Arnd Bergmann <arnd@...db.de>,
        "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 Tue, Aug 9, 2022 at 12:40 PM Christophe Leroy
<christophe.leroy@...roup.eu> wrote:
>
> At the time being, the default maximum number of GPIOs is set to 512
> and can only get customised via an architecture specific
> CONFIG_ARCH_NR_GPIO.
>
> The maximum number of GPIOs might be dependent on the number of
> interface boards and is somewhat independent of architecture.
>
> Allow the user to select that maximum number outside of any
> architecture configuration. To enable that, re-define a
> core CONFIG_ARCH_NR_GPIO for architectures which don't already
> define one. Guard it with a new hidden CONFIG_ARCH_HAS_NR_GPIO.
>
> Only two architectures will need CONFIG_ARCH_HAS_NR_GPIO: x86 and arm.
>
> On arm, do like x86 and set 512 as the default instead of 0, that
> allows simplifying the logic in asm-generic/gpio.h
>
> Signed-off-by: Christophe Leroy <christophe.leroy@...roup.eu>
> ---
>  Documentation/driver-api/gpio/legacy.rst |  2 +-
>  arch/arm/Kconfig                         |  3 ++-
>  arch/arm/include/asm/gpio.h              |  1 -
>  arch/x86/Kconfig                         |  1 +
>  drivers/gpio/Kconfig                     | 14 ++++++++++++++
>  include/asm-generic/gpio.h               |  6 ------
>  6 files changed, 18 insertions(+), 9 deletions(-)
>
> diff --git a/Documentation/driver-api/gpio/legacy.rst b/Documentation/driver-api/gpio/legacy.rst
> index 9b12eeb89170..566b06a584cf 100644
> --- a/Documentation/driver-api/gpio/legacy.rst
> +++ b/Documentation/driver-api/gpio/legacy.rst
> @@ -558,7 +558,7 @@ Platform Support
>  To force-enable this framework, a platform's Kconfig will "select" GPIOLIB,
>  else it is up to the user to configure support for GPIO.
>
> -It may also provide a custom value for ARCH_NR_GPIOS, so that it better
> +It may also provide a custom value for CONFIG_ARCH_NR_GPIO, so that it better
>  reflects the number of GPIOs in actual use on that platform, without
>  wasting static table space.  (It should count both built-in/SoC GPIOs and
>  also ones on GPIO expanders.
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 53e6a1da9af5..e55b6560fe4f 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -14,6 +14,7 @@ config ARM
>         select ARCH_HAS_KCOV
>         select ARCH_HAS_MEMBARRIER_SYNC_CORE
>         select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
> +       select ARCH_HAS_NR_GPIO
>         select ARCH_HAS_PTE_SPECIAL if ARM_LPAE
>         select ARCH_HAS_PHYS_TO_DMA
>         select ARCH_HAS_SETUP_DMA_OPS
> @@ -1243,7 +1244,7 @@ config ARCH_NR_GPIO
>         default 352 if ARCH_VT8500
>         default 288 if ARCH_ROCKCHIP
>         default 264 if MACH_H4700
> -       default 0
> +       default 512

This list should be kept sorted, otherwise you still get e.g. the '264' default
value. If you have a GPIO extender that provides hardcoded GPIO
numbers on your machine, there should be a configuration option for
that driver.

Which driver is it that needs extra hardcoded GPIO numbers for you?
Have you tried converting it to use GPIO descriptors so you don't
need the number assignment?

        Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ