[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <63b3c26a-be33-6ef3-7feb-ff7997fbc752@csgroup.eu>
Date: Fri, 2 Sep 2022 15:22:20 +0000
From: Christophe Leroy <christophe.leroy@...roup.eu>
To: Andy Shevchenko <andy.shevchenko@...il.com>
CC: Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>,
Geert Uytterhoeven <geert+renesas@...der.be>,
Keerthy <j-keerthy@...com>, Russell King <linux@...linux.org.uk>,
Arnd Bergmann <arnd@...db.de>,
Jonathan Corbet <corbet@....net>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"H. Peter Anvin" <hpa@...or.com>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>,
Davide Ciminaghi <ciminaghi@...dd.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
"open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
linux-arm Mailing List <linux-arm-kernel@...ts.infradead.org>,
Linux-Arch <linux-arch@...r.kernel.org>,
Linux Documentation List <linux-doc@...r.kernel.org>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>
Subject: Re: [PATCH v2 5/9] gpiolib: Get rid of ARCH_NR_GPIOS
Le 02/09/2022 à 16:58, Andy Shevchenko a écrit :
> On Fri, Sep 2, 2022 at 4:57 PM Christophe Leroy
> <christophe.leroy@...roup.eu> wrote:
>>
>> Since commit 14e85c0e69d5 ("gpio: remove gpio_descs global array")
>> there is no limitation on the number of GPIOs that can be allocated
>> in the system since the allocation is fully dynamic.
>>
>> ARCH_NR_GPIOS is today only used in order to provide downwards
>> gpiobase allocation from that value, while static allocation is
>> performed upwards from 0. However that has the disadvantage of
>> limiting the number of GPIOs that can be registered in the system.
>>
>> To overcome this limitation without requiring each and every
>> platform to provide its 'best-guess' maximum number, rework the
>> allocation to allocate upwards, allowing approx 2 millions of
>> GPIOs.
>>
>> In order to still allow static allocation for legacy drivers, define
>> GPIO_DYNAMIC_BASE with the value 512 as the start for dynamic
>> allocation. The 512 value is chosen because it is the end of
>> the current default range so all current static allocations are
>> expected to be below that value. Of course that's just a rough
>> estimate based on the default value, but assuming static
>> allocations come first, even if there are more static allocations
>> it should fit under the 512 value.
>>
>> In the future, it is expected that all static allocations go away
>> and then dynamic allocation will be patched to start at 0.
>
> Eventually we have to get rid of gpio_is_valid() completely...
> But this is another story.
> Reviewed-by: Andy Shevchenko <andy.shevchenko@...il.com>
Yes that could be done as a follow-up.
There are about 300 call sites.
Should simply replace gpio_is_valid(gpio) by gpio >= 0. And then verify
that the check is really required. But needs to check signness of gpio
at every place.
First look seems already promissing:
int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
{
struct gpio_desc *desc;
int err;
desc = gpio_to_desc(gpio);
/* Compatibility: assume unavailable "valid" GPIOs will appear later */
if (!desc && gpio_is_valid(gpio))
return -EPROBE_DEFER;
Powered by blists - more mailing lists