gpio: Get rid of ARCH_NR_GPIOS (v2)
Subsystems (8)
v2 cover gpio: Get rid of ARCH_NR_GPIOS (v2)
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 from 512 upwards, allowing approx 2 millions of GPIOs.
In the meantime, add a warning for drivers how are still doing static allocation, so that in the future the static allocation gets removed completely and dynamic allocation can start at base 0.
Main changes in v2:
- Adding a patch to remove sta2x11 GPIO driver instead of modifying it
- Moving the base of dynamic allocation from 256 to 512 because there are drivers allocating gpios as high as 400.
Christophe Leroy (8):
gpio: aggregator: Stop using ARCH_NR_GPIOS
gpio: davinci: Stop using ARCH_NR_GPIOS
gpiolib: Warn on drivers still using static gpiobase allocation
gpiolib: Get rid of ARCH_NR_GPIOS
Documentation: gpio: Remove text about ARCH_NR_GPIOS
x86: Remove CONFIG_ARCH_NR_GPIO
arm: Remove CONFIG_ARCH_NR_GPIO
arm64: Remove CONFIG_ARCH_NR_GPIO
Davide Ciminaghi (1):
gpio: Remove sta2x11 GPIO driver
Documentation/driver-api/gpio/legacy.rst | 5 - arch/arm/Kconfig | 21 -- arch/arm/include/asm/gpio.h | 1 - arch/arm64/Kconfig | 12 - arch/x86/Kconfig | 5 - drivers/gpio/Kconfig | 8 - drivers/gpio/Makefile | 1 - drivers/gpio/gpio-aggregator.c | 7 +- drivers/gpio/gpio-davinci.c | 3 - drivers/gpio/gpio-sta2x11.c | 411 ----------------------- drivers/gpio/gpiolib.c | 13 +- include/asm-generic/gpio.h | 55 ++- 12 files changed, 33 insertions(+), 509 deletions(-) delete mode 100644 drivers/gpio/gpio-sta2x11.c
Signature · 7 lines
2.37.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 1/9 gpio: Remove sta2x11 GPIO driver
From: Davide Ciminaghi <[email protected]>
The Connext chip has 4 gpio cells looking very similar to those of the Nomadik, whose gpio/pinctrl driver (already featuring devicetree support) will be used instead of the sta2x11 specific one.
---
v2: New
--- drivers/gpio/Kconfig | 8 - drivers/gpio/Makefile | 1 - drivers/gpio/gpio-sta2x11.c | 411 ------------------------------------ 3 files changed, 420 deletions(-) delete mode 100644 drivers/gpio/gpio-sta2x11.c
drivers/gpio/Kconfig +0 -8
@@ -596,14 +596,6 @@ config GPIO_SPRD help Say yes here to support Spreadtrum GPIO device. -config GPIO_STA2X11 - bool "STA2x11/ConneXt GPIO support" - depends on MFD_STA2X11 - select GENERIC_IRQ_CHIP - help - Say yes here to support the STA2x11/ConneXt GPIO device. - The GPIO module has 128 GPIO pins with alternate functions. - config GPIO_STP_XWAY bool "XWAY STP GPIOs" depends on SOC_XWAY || COMPILE_TEST
drivers/gpio/Makefile +0 -1
@@ -140,7 +140,6 @@ obj-$(CONFIG_GPIO_SL28CPLD) += gpio-sl28cpld.o obj-$(CONFIG_GPIO_SODAVILLE) += gpio-sodaville.o obj-$(CONFIG_GPIO_SPEAR_SPICS) += gpio-spear-spics.o obj-$(CONFIG_GPIO_SPRD) += gpio-sprd.o -obj-$(CONFIG_GPIO_STA2X11) += gpio-sta2x11.o obj-$(CONFIG_GPIO_STMPE) += gpio-stmpe.o obj-$(CONFIG_GPIO_STP_XWAY) += gpio-stp-xway.o obj-$(CONFIG_GPIO_SYSCON) += gpio-syscon.o
drivers/gpio/gpio-sta2x11.c deleted +0 -411
411 lines not on this page · raw message
Signature · 7 lines
2.37.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 2/9 gpio: aggregator: Stop using ARCH_NR_GPIOS
In reply to Christophe LeroyARCH_NR_GPIOS is used locally in aggr_parse() as the maximum number of GPIOs to be aggregated together by the driver since commit ec75039d5550 ("gpio: aggregator: Use bitmap_parselist() for parsing GPIO offsets").
Don't rely on the total possible number of GPIOs in the system but define a local arbitrary macro for that, set to 512 which should be large enough as it is also the default value for ARCH_NR_GPIOS.
---
v2: Moved AGGREGATOR_MAX_GPIOS before code
--- drivers/gpio/gpio-aggregator.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpio/gpio-aggregator.c +4 -3
@@ -23,6 +23,7 @@#include <linux/spinlock.h> #include <linux/string.h> +#define AGGREGATOR_MAX_GPIOS 512/* * GPIO Aggregator sysfs interface
@@ -64,7 +65,7 @@ static int aggr_parse(struct gpio_aggregator *aggr)unsigned int i, n =0 ;int error =0 ; - bitmap =bitmap_alloc (ARCH_NR_GPIOS ,GFP_KERNEL ); + bitmap =bitmap_alloc (AGGREGATOR_MAX_GPIOS ,GFP_KERNEL );if (!bitmap)return -ENOMEM ;
@@ -84,13 +85,13 @@ static int aggr_parse(struct gpio_aggregator *aggr) }/* GPIO chip + offset(s) */ - error =bitmap_parselist (offsets, bitmap,ARCH_NR_GPIOS ); + error =bitmap_parselist (offsets, bitmap,AGGREGATOR_MAX_GPIOS );if (error) {pr_err ("Cannot parse %s: %d\n" , offsets, error); goto free_bitmap; } -for_each_set_bit (i, bitmap,ARCH_NR_GPIOS ) { +for_each_set_bit (i, bitmap,AGGREGATOR_MAX_GPIOS ) { error =aggr_add_gpio (aggr, name, i, &n);if (error) goto free_bitmap;
Signature · 7 lines
2.37.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 3/9 gpio: davinci: Stop using ARCH_NR_GPIOS
In reply to Christophe LeroySince commit 14e85c0e69d5 ("gpio: remove gpio_descs global array") there is no global limitation anymore on the number of GPIOs in the system so don't clamp the number of GPIOs with ARCH_NR_GPIOS.
--- drivers/gpio/gpio-davinci.c | 3 --- 1 file changed, 3 deletions(-)
drivers/gpio/gpio-davinci.c +0 -3
@@ -217,9 +217,6 @@ static int davinci_gpio_probe(struct platform_device *pdev)return -EINVAL ; } -if (WARN_ON (ARCH_NR_GPIOS < ngpio)) - ngpio =ARCH_NR_GPIOS ; -/* * If there are unbanked interrupts then the number of * interrupts is equal to number of gpios else all are banked so
Signature · 7 lines
2.37.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 4/9 gpiolib: Warn on drivers still using static gpiobase allocation
In reply to Christophe LeroyIn the preparation of getting completely rid of static gpiobase allocation in the future, emit a warning in drivers still doing so.
---
v2: unsplit the warning text.
--- drivers/gpio/gpiolib.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpio/gpiolib.c +3 -0
@@ -715,6 +715,9 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,* a poison instead. */ gc->base = base; + }else { +dev_warn (&gdev->dev, +"Static allocation of GPIO base is deprecated, use dynamic allocation.\n" ); } gdev->base = base;
Signature · 7 lines
2.37.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 5/9 gpiolib: Get rid of ARCH_NR_GPIOS
In reply to Christophe LeroySince 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.
---
v2: Enhanced commit description and change from 256 to 512.
--- arch/arm/include/asm/gpio.h | 1 - drivers/gpio/gpiolib.c | 10 +++---- include/asm-generic/gpio.h | 55 ++++++++++++++----------------------- 3 files changed, 26 insertions(+), 40 deletions(-)
arch/arm/include/asm/gpio.h +0 -1
@@ -2,7 +2,6 @@#ifndef _ARCH_ARM_GPIO_H#define _ARCH_ARM_GPIO_H -/* Note: this may rely upon the value of ARCH_NR_GPIOS set in mach/gpio.h */ #include <asm-generic/gpio.h> /* The trivial gpiolib dispatchers */
drivers/gpio/gpiolib.c +5 -5
@@ -183,14 +183,14 @@ EXPORT_SYMBOL_GPL(gpiod_to_chip);static int gpiochip_find_base (int ngpio) {struct gpio_device *gdev; -int base =ARCH_NR_GPIOS - ngpio; +int base =GPIO_DYNAMIC_BASE ; -list_for_each_entry_reverse (gdev, &gpio_devices, list) { +list_for_each_entry (gdev, &gpio_devices, list) {/* found a free space? */ -if (gdev->base + gdev->ngpio <= base) +if (gdev->base >= base + ngpio)break ; -/* nope, check the space right before the chip */ - base = gdev->base - ngpio; +/* nope, check the space right after the chip */ + base = gdev->base + gdev->ngpio; }if (gpio_is_valid (base)) {
include/asm-generic/gpio.h +21 -34
77 lines not on this page · raw message
Signature · 7 lines
2.37.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2 5/9] gpiolib: Get rid of ARCH_NR_GPIOS
Quoted 24 lines · Christophe Leroy
Since commit
14e85c0e69d5("gpio: removegpio_descsglobal 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_GPIOSis 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_BASEwith 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.
Quoted 2 lines
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.
Quoted 132 lines
Signed-off-by Christophe Leroy <[email protected]>---
v2: Enhanced commit description and change from 256 to 512.--- arch/arm/include/asm/gpio.h | 1 - drivers/gpio/gpiolib.c | 10 +++---- include/asm-generic/gpio.h | 55 ++++++++++++++----------------------- 3 files changed, 26 insertions(+), 40 deletions(-)arch/arm/include/asm/gpio.h +0
-1@@ -2,7 +2,6 @@#ifndef _ARCH_ARM_GPIO_H#define _ARCH_ARM_GPIO_H -/* Note: this may rely upon the value of ARCH_NR_GPIOS set in mach/gpio.h */ #include <asm-generic/gpio.h> /* The trivial gpiolib dispatchers */ drivers/gpio/gpiolib.c +5
-5@@ -183,14 +183,14 @@ EXPORT_SYMBOL_GPL(gpiod_to_chip);static int gpiochip_find_base (int ngpio) {struct gpio_device *gdev; -int base =ARCH_NR_GPIOS - ngpio; +int base =GPIO_DYNAMIC_BASE ; -list_for_each_entry_reverse (gdev, &gpio_devices, list) { +list_for_each_entry (gdev, &gpio_devices, list) {/* found a free space? */ -if (gdev->base + gdev->ngpio <= base) +if (gdev->base >= base + ngpio)break ; -/* nope, check the space right before the chip */ - base = gdev->base - ngpio; +/* nope, check the space right after the chip */ + base = gdev->base + gdev->ngpio; }if (gpio_is_valid (base)) {include/asm-generic/gpio.h +21
-35@@ -11,40 +11,18 @@#include <linux/gpio/driver.h> #include <linux/gpio/consumer.h> -/* Platforms may implement their GPIO interface with library code, +/* +* Platforms may implement their GPIO interface with library code, * at a small performance cost for non-inlined operations and some * extra memory (for code and for per-GPIO table entries). -* -* While the GPIO programming interface defines valid GPIO numbers -* to be in the range 0..MAX_INT, this library restricts them to the -* smaller range 0..ARCH_NR_GPIOS-1. -* -* ARCH_NR_GPIOS is somewhat arbitrary; it usually reflects the sum of -* builtin/SoC GPIOs plus a number of GPIOs on expanders; the latter is -* actually an estimate of a board-specific value. */ -#ifndef ARCH_NR_GPIOS -#if defined(CONFIG_ARCH_NR_GPIO ) &&CONFIG_ARCH_NR_GPIO >0 -#define ARCH_NR_GPIOS CONFIG_ARCH_NR_GPIO -#else -#define ARCH_NR_GPIOS 512 -#endif -#endif -/* -* "valid" GPIO numbers are nonnegative and may be passed to -* setup routines like gpio_request(). only some valid numbers -* can successfully be requested and used. -* -* Invalid GPIO numbers are useful for indicating no-such-GPIO in -* platform data and other tables. +* At the end we want all GPIOs to be dynamically allocated from 0. +* However, some legacy drivers still perform fixed allocation. +* Until they are all fixed, leave 0-512 space for them. */ - -static inline bool gpio_is_valid (int number) -{ -return number >=0 && number <ARCH_NR_GPIOS ; -} +#define GPIO_DYNAMIC_BASE 512struct device ;struct gpio ;@@ -140,12 +118,6 @@ static inline void gpio_unexport(unsigned gpio)#include <linux/kernel.h> -static inline bool gpio_is_valid (int number) -{ -/* only non-negative numbers are valid */ -return number >=0 ; -} -/* platforms that don't directly support access to GPIOs through I2C, SPI, * or other blocking infrastructure can use these wrappers. */ @@ -169,4 +141,19 @@ static inline void gpio_set_value_cansleep(unsigned gpio, int value)#endif /* !CONFIG_GPIOLIB */ +/* +* "valid" GPIO numbers are nonnegative and may be passed to +* setup routines like gpio_request(). only some valid numbers +* can successfully be requested and used. +* +* Invalid GPIO numbers are useful for indicating no-such-GPIO in +* platform data and other tables. +*/ + +static inline bool gpio_is_valid (int number) +{ +/* only non-negative numbers are valid */ +return number >=0 ; +} +#endif /* _ASM_GENERIC_GPIO_H */ --2.37.1
Signature · 7 lines
With Best Regards, Andy Shevchenko _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2 5/9] gpiolib: Get rid of ARCH_NR_GPIOS
Le 02/09/2022 à 16:58, Andy Shevchenko a écrit :
Quoted 26 lines
Quoted 24 lines · Christophe Leroy
Since commit
14e85c0e69d5("gpio: removegpio_descsglobal 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_GPIOSis 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_BASEwith 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.
Quoted 6 lines
Quoted 2 lines
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 <[email protected]>
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;_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 6/9 Documentation: gpio: Remove text about ARCH_NR_GPIOS
In reply to Christophe LeroyARCH_NR_GPIOS have been removed, clean up the documentation.
After this patch, the only place when ARCH_NR_GPIOS remains is in translations/zh_CN/gpio.txt and translations/zh_TW/gpio.txt. I don't have the skills to update that, anyway those two files are already out of sync as they are still mentionning ARCH_REQUIRE_GPIOLIB which was removed by commit 65053e1a7743 ("gpio: delete ARCH_[WANTS_OPTIONAL|REQUIRE]_GPIOLIB")
--- Documentation/driver-api/gpio/legacy.rst | 5 ----- 1 file changed, 5 deletions(-)
Documentation/driver-api/gpio/legacy.rst +0 -5
@@ -558,11 +558,6 @@ 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 -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. - If neither of these options are selected, the platform does not support GPIOs through GPIO-lib and the code cannot be enabled by the user.
Signature · 7 lines
2.37.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 7/9 x86: Remove CONFIG_ARCH_NR_GPIO
In reply to Christophe LeroyCONFIG_ARCH_NR_GPIO is not used anymore, remove it.
--- arch/x86/Kconfig | 5 ----- 1 file changed, 5 deletions(-)
arch/x86/Kconfig +0 -5
@@ -345,11 +345,6 @@ config ARCH_HAS_CPU_RELAX config ARCH_HIBERNATION_POSSIBLE def_bool y -config ARCH_NR_GPIO - int - default 1024 if X86_64 - default 512 - config ARCH_SUSPEND_POSSIBLE def_bool y
Signature · 7 lines
2.37.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2 7/9] x86: Remove CONFIG_ARCH_NR_GPIO
Quoted 4 lines · Christophe Leroy
CONFIG_ARCH_NR_GPIOis not used anymore, remove it.Signed-off-by Christophe Leroy <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 8/9 arm: Remove CONFIG_ARCH_NR_GPIO
In reply to Christophe LeroyCONFIG_ARCH_NR_GPIO is not used anymore, remove it.
--- arch/arm/Kconfig | 21 --------------------- 1 file changed, 21 deletions(-)
arch/arm/Kconfig +0 -21
@@ -1227,27 +1227,6 @@ config ARM_PSCI 0022A ("Power State Coordination Interface System Software on ARM processors"). -# The GPIO number here must be sorted by descending number. In case of -# a multiplatform kernel, we just want the highest value required by the -# selected platforms. -config ARCH_NR_GPIO - int - default 2048 if ARCH_INTEL_SOCFPGA - default 1024 if ARCH_BRCMSTB || ARCH_RENESAS || ARCH_TEGRA || \ - ARCH_ZYNQ || ARCH_ASPEED - default 512 if ARCH_EXYNOS || ARCH_KEYSTONE || SOC_OMAP5 || \ - SOC_DRA7XX || ARCH_S3C24XX || ARCH_S3C64XX || ARCH_S5PV210 - default 416 if ARCH_SUNXI - default 392 if ARCH_U8500 - default 352 if ARCH_VT8500 - default 288 if ARCH_ROCKCHIP - default 264 if MACH_H4700 - default 0 - help - Maximum number of GPIOs in the system. - - If unsure, leave the default value. - config HZ_FIXED int default 128 if SOC_AT91RM9200
Signature · 7 lines
2.37.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 9/9 arm64: Remove CONFIG_ARCH_NR_GPIO
In reply to Christophe LeroyCONFIG_ARCH_NR_GPIO is not used anymore, remove it.
--- arch/arm64/Kconfig | 12 ------------ 1 file changed, 12 deletions(-)
arch/arm64/Kconfig +0 -12
@@ -2110,18 +2110,6 @@ config STACKPROTECTOR_PER_TASK def_bool y depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_SYSREG -# The GPIO number here must be sorted by descending number. In case of -# a multiplatform kernel, we just want the highest value required by the -# selected platforms. -config ARCH_NR_GPIO - int - default 2048 if ARCH_APPLE - default 0 - help - Maximum number of GPIOs in the system. - - If unsure, leave the default value. - endmenu # "Kernel Features" menu "Boot options"
Signature · 7 lines
2.37.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 52 lines · Christophe Leroy
Since commit
14e85c0e69d5("gpio: removegpio_descsglobal 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_GPIOSis 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 from 512 upwards, allowing approx 2 millions of GPIOs.
In the meantime, add a warning for drivers how are still doing static allocation, so that in the future the static allocation gets removed completely and dynamic allocation can start at base 0.
Main changes in v2:
- Adding a patch to remove sta2x11 GPIO driver instead of modifying it
- Moving the base of dynamic allocation from 256 to 512 because there are drivers allocating gpios as high as 400.Christophe Leroy (8):
gpio: aggregator: Stop usingARCH_NR_GPIOS
gpio: davinci: Stop usingARCH_NR_GPIOS
gpiolib: Warn on drivers still using static gpiobase allocation
gpiolib: Get rid ofARCH_NR_GPIOS
Documentation: gpio: Remove text aboutARCH_NR_GPIOS
x86: RemoveCONFIG_ARCH_NR_GPIO
arm: RemoveCONFIG_ARCH_NR_GPIO
arm64: RemoveCONFIG_ARCH_NR_GPIODavide Ciminaghi (1):
gpio: Remove sta2x11 GPIO driverDocumentation/driver-api/gpio/legacy.rst | 5 - arch/arm/Kconfig | 21 -- arch/arm/include/asm/gpio.h | 1 - arch/arm64/Kconfig | 12 - arch/x86/Kconfig | 5 - drivers/gpio/Kconfig | 8 - drivers/gpio/Makefile | 1 - drivers/gpio/gpio-aggregator.c | 7 +- drivers/gpio/gpio-davinci.c | 3 - drivers/gpio/gpio-sta2x11.c | 411 ----------------------- drivers/gpio/gpiolib.c | 13 +- include/asm-generic/gpio.h | 55 ++- 12 files changed, 33 insertions(+), 509 deletions(-) delete mode 100644 drivers/gpio/gpio-sta2x11.c
Quoted 3 lines
--
2.37.1
I'd like to take it through the GPIO tree if we can get acks for ARM and x86?
Bart
Quoted 16 lines · Bartosz Golaszewski
Quoted 15 lines · Christophe Leroy
Documentation/driver-api/gpio/legacy.rst | 5 - arch/arm/Kconfig | 21 -- arch/arm/include/asm/gpio.h | 1 - arch/arm64/Kconfig | 12 - arch/x86/Kconfig | 5 - drivers/gpio/Kconfig | 8 - drivers/gpio/Makefile | 1 - drivers/gpio/gpio-aggregator.c | 7 +- drivers/gpio/gpio-davinci.c | 3 - drivers/gpio/gpio-sta2x11.c | 411 ----------------------- drivers/gpio/gpiolib.c | 13 +- include/asm-generic/gpio.h | 55 ++- 12 files changed, 33 insertions(+), 509 deletions(-) delete mode 100644 drivers/gpio/gpio-sta2x11.c
For the arch/arm*/Kconfig and include/asm-generic changes:
sta2x11 is an x86 driver, so not my area, but I think it would be best to kill off the entire platform rather than just its gpio driver, since everything needs to work together and it's clearly not functional at the moment.
$ git grep -l STA2X11 Documentation/admin-guide/media/pci-cardlist.rst arch/x86/Kconfig arch/x86/include/asm/sta2x11.h arch/x86/pci/Makefile arch/x86/pci/sta2x11-fixup.c drivers/ata/ahci.c drivers/gpio/Kconfig drivers/gpio/Makefile drivers/gpio/gpio-sta2x11.c drivers/i2c/busses/Kconfig drivers/media/pci/Makefile drivers/media/pci/sta2x11/Kconfig drivers/media/pci/sta2x11/Makefile drivers/media/pci/sta2x11/sta2x11_vip.c drivers/media/pci/sta2x11/sta2x11_vip.h drivers/mfd/Kconfig drivers/mfd/Makefile drivers/mfd/sta2x11-mfd.c include/linux/mfd/sta2x11-mfd.h
Removing the other sta2x11 bits (mfd, media, x86) should probably be done through the respective tree, but it would be good not to forget those.
Arnd
Quoted 1 line · Arnd Bergmann
Quoted 1 line
Quoted 1 line
drivers/gpio/gpio-sta2x11.c | 411 -----------------------
(...)
Quoted 26 lines
sta2x11 is an x86 driver, so not my area, but I think it would be best to kill off the entire platform rather than just its gpio driver, since everything needs to work together and it's clearly not functional at the moment.
$ git grep -l STA2X11 Documentation/admin-guide/media/pci-cardlist.rst arch/x86/Kconfig arch/x86/include/asm/sta2x11.h arch/x86/pci/Makefile arch/x86/pci/sta2x11-fixup.c drivers/ata/ahci.c drivers/gpio/Kconfig drivers/gpio/Makefile drivers/gpio/gpio-sta2x11.c drivers/i2c/busses/Kconfig drivers/media/pci/Makefile drivers/media/pci/sta2x11/Kconfig drivers/media/pci/sta2x11/Makefile drivers/media/pci/sta2x11/sta2x11_vip.c drivers/media/pci/sta2x11/sta2x11_vip.h drivers/mfd/Kconfig drivers/mfd/Makefile drivers/mfd/sta2x11-mfd.c include/linux/mfd/sta2x11-mfd.h
Quoted 3 lines
Removing the other sta2x11 bits (mfd, media, x86) should probably be done through the respective tree, but it would be good not to forget those.
Andy is pretty much default x86 platform device maintainer, maybe he can ACK or brief us on what he knows about the status of STA2x11?
Yours,
Linus Walleij
Andy Shevchenko
Acked-byQuoted 30 lines · Linus Walleij
Quoted 1 line · Arnd Bergmann
Quoted 1 line
Quoted 1 line
drivers/gpio/gpio-sta2x11.c | 411 -----------------------(...)
Quoted 26 lines
sta2x11 is an x86 driver, so not my area, but I think it would be best to kill off the entire platform rather than just its gpio driver, since everything needs to work together and it's clearly not functional at the moment.
$ git grep -l STA2X11 Documentation/admin-guide/media/pci-cardlist.rst arch/x86/Kconfig arch/x86/include/asm/sta2x11.h arch/x86/pci/Makefile arch/x86/pci/sta2x11-fixup.c drivers/ata/ahci.c drivers/gpio/Kconfig drivers/gpio/Makefile drivers/gpio/gpio-sta2x11.c drivers/i2c/busses/Kconfig drivers/media/pci/Makefile drivers/media/pci/sta2x11/Kconfig drivers/media/pci/sta2x11/Makefile drivers/media/pci/sta2x11/sta2x11_vip.c drivers/media/pci/sta2x11/sta2x11_vip.h drivers/mfd/Kconfig drivers/mfd/Makefile drivers/mfd/sta2x11-mfd.c include/linux/mfd/sta2x11-mfd.h
Quoted 7 lines
Quoted 3 lines
Removing the other sta2x11 bits (mfd, media, x86) should probably be done through the respective tree, but it would be good not to forget those.
Andy is pretty much default x86 platform device maintainer, maybe he can ACK or brief us on what he knows about the status of STA2x11?
Actually I have no idea about STA2x11, but in some thread I have noticed that there were people who know more on the topic and they told that removal is the right thing to do.
Not sure how it should be done practically (driver-by-driver or altogether),
for either of the variants if it helps.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Arnd Bergmann
maintainerQuoted 29 lines · Linus Walleij
Quoted 1 line · Arnd Bergmann
Quoted 1 line
Quoted 1 line
drivers/gpio/gpio-sta2x11.c | 411 -----------------------(...)
Quoted 26 lines
sta2x11 is an x86 driver, so not my area, but I think it would be best to kill off the entire platform rather than just its gpio driver, since everything needs to work together and it's clearly not functional at the moment.
$ git grep -l STA2X11 Documentation/admin-guide/media/pci-cardlist.rst arch/x86/Kconfig arch/x86/include/asm/sta2x11.h arch/x86/pci/Makefile arch/x86/pci/sta2x11-fixup.c drivers/ata/ahci.c drivers/gpio/Kconfig drivers/gpio/Makefile drivers/gpio/gpio-sta2x11.c drivers/i2c/busses/Kconfig drivers/media/pci/Makefile drivers/media/pci/sta2x11/Kconfig drivers/media/pci/sta2x11/Makefile drivers/media/pci/sta2x11/sta2x11_vip.c drivers/media/pci/sta2x11/sta2x11_vip.h drivers/mfd/Kconfig drivers/mfd/Makefile drivers/mfd/sta2x11-mfd.c include/linux/mfd/sta2x11-mfd.h
Quoted 7 lines
Quoted 3 lines
Removing the other sta2x11 bits (mfd, media, x86) should probably be done through the respective tree, but it would be good not to forget those.
Andy is pretty much default x86 platform device maintainer, maybe he can ACK or brief us on what he knows about the status of STA2x11?
I think the explanation given by Davide and Alessandro was rather detailed already:
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/
Arnd
Hi Linus,
Le 14/09/2022 à 15:03, Arnd Bergmann a écrit :
Quoted 38 lines · Linus Walleij
Quoted 29 lines · Arnd Bergmann
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/gpio/gpio-sta2x11.c | 411 -----------------------(...)
Quoted 26 lines
sta2x11 is an x86 driver, so not my area, but I think it would be best to kill off the entire platform rather than just its gpio driver, since everything needs to work together and it's clearly not functional at the moment.
$ git grep -l STA2X11 Documentation/admin-guide/media/pci-cardlist.rst arch/x86/Kconfig arch/x86/include/asm/sta2x11.h arch/x86/pci/Makefile arch/x86/pci/sta2x11-fixup.c drivers/ata/ahci.c drivers/gpio/Kconfig drivers/gpio/Makefile drivers/gpio/gpio-sta2x11.c drivers/i2c/busses/Kconfig drivers/media/pci/Makefile drivers/media/pci/sta2x11/Kconfig drivers/media/pci/sta2x11/Makefile drivers/media/pci/sta2x11/sta2x11_vip.c drivers/media/pci/sta2x11/sta2x11_vip.h drivers/mfd/Kconfig drivers/mfd/Makefile drivers/mfd/sta2x11-mfd.c include/linux/mfd/sta2x11-mfd.hQuoted 7 lines
Quoted 3 lines
Removing the other sta2x11 bits (mfd, media, x86) should probably be done through the respective tree, but it would be good not to forget those.
Andy is pretty much default x86 platform device maintainer, maybe he can ACK or brief us on what he knows about the status of STA2x11?
Quoted 6 lines
I think the explanation given by Davide and Alessandro was rather detailed already:
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/
I can't see this series in neither linus tree nor linux-next.
Following the ACK from Andy + the above explanations from Arnd, do you plan to merge this series anytime soon ?
Do you need anything more from me ?
Thanks
Christophe
Quoted 51 lines · Christophe Leroy
Hi Linus,
Quoted 38 lines · Arnd Bergmann
Quoted 29 lines · Linus Walleij
Quoted 1 line · Arnd Bergmann
Quoted 1 line
Quoted 1 line
drivers/gpio/gpio-sta2x11.c | 411 -----------------------(...)
Quoted 26 lines
sta2x11 is an x86 driver, so not my area, but I think it would be best to kill off the entire platform rather than just its gpio driver, since everything needs to work together and it's clearly not functional at the moment.
$ git grep -l STA2X11 Documentation/admin-guide/media/pci-cardlist.rst arch/x86/Kconfig arch/x86/include/asm/sta2x11.h arch/x86/pci/Makefile arch/x86/pci/sta2x11-fixup.c drivers/ata/ahci.c drivers/gpio/Kconfig drivers/gpio/Makefile drivers/gpio/gpio-sta2x11.c drivers/i2c/busses/Kconfig drivers/media/pci/Makefile drivers/media/pci/sta2x11/Kconfig drivers/media/pci/sta2x11/Makefile drivers/media/pci/sta2x11/sta2x11_vip.c drivers/media/pci/sta2x11/sta2x11_vip.h drivers/mfd/Kconfig drivers/mfd/Makefile drivers/mfd/sta2x11-mfd.c include/linux/mfd/sta2x11-mfd.hQuoted 7 lines
Quoted 3 lines
Removing the other sta2x11 bits (mfd, media, x86) should probably be done through the respective tree, but it would be good not to forget those.
Andy is pretty much default x86 platform device maintainer, maybe he can ACK or brief us on what he knows about the status of STA2x11?
Quoted 6 lines
I think the explanation given by Davide and Alessandro was rather detailed already:
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/I can't see this series in neither linus tree nor linux-next.
Quoted 7 lines
Following the ACK from Andy + the above explanations from Arnd, do you plan to merge this series anytime soon ?
Do you need anything more from me ?
Thanks
Christophe
I will take it after v6.1-rc1 is tagged.
Bart
Quoted 57 lines · Bartosz Golaszewski
Quoted 54 lines · Christophe Leroy
Hi Linus,
Quoted 38 lines · Arnd Bergmann
Quoted 29 lines · Linus Walleij
Quoted 1 line · Arnd Bergmann
Quoted 1 line
Quoted 1 line
drivers/gpio/gpio-sta2x11.c | 411 -----------------------(...)
Quoted 26 lines
sta2x11 is an x86 driver, so not my area, but I think it would be best to kill off the entire platform rather than just its gpio driver, since everything needs to work together and it's clearly not functional at the moment.
$ git grep -l STA2X11 Documentation/admin-guide/media/pci-cardlist.rst arch/x86/Kconfig arch/x86/include/asm/sta2x11.h arch/x86/pci/Makefile arch/x86/pci/sta2x11-fixup.c drivers/ata/ahci.c drivers/gpio/Kconfig drivers/gpio/Makefile drivers/gpio/gpio-sta2x11.c drivers/i2c/busses/Kconfig drivers/media/pci/Makefile drivers/media/pci/sta2x11/Kconfig drivers/media/pci/sta2x11/Makefile drivers/media/pci/sta2x11/sta2x11_vip.c drivers/media/pci/sta2x11/sta2x11_vip.h drivers/mfd/Kconfig drivers/mfd/Makefile drivers/mfd/sta2x11-mfd.c include/linux/mfd/sta2x11-mfd.hQuoted 7 lines
Quoted 3 lines
Removing the other sta2x11 bits (mfd, media, x86) should probably be done through the respective tree, but it would be good not to forget those.
Andy is pretty much default x86 platform device maintainer, maybe he can ACK or brief us on what he knows about the status of STA2x11?
Quoted 6 lines
I think the explanation given by Davide and Alessandro was rather detailed already:
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/I can't see this series in neither linus tree nor linux-next.
Following the ACK from Andy + the above explanations from Arnd, do you plan to merge this series anytime soon ?
Quoted 8 lines
Quoted 4 lines
Do you need anything more from me ?
Thanks
ChristopheI will take it after v6.1-rc1 is tagged.
Bart
Now queued.
Bart
Quoted 60 lines · Bartosz Golaszewski
Quoted 59 lines · Bartosz Golaszewski
Quoted 56 lines · Christophe Leroy
Hi Linus,
Quoted 38 lines · Arnd Bergmann
Quoted 29 lines · Linus Walleij
Quoted 1 line · Arnd Bergmann
Quoted 1 line
Quoted 1 line
drivers/gpio/gpio-sta2x11.c | 411 -----------------------(...)
Quoted 26 lines
sta2x11 is an x86 driver, so not my area, but I think it would be best to kill off the entire platform rather than just its gpio driver, since everything needs to work together and it's clearly not functional at the moment.
$ git grep -l STA2X11 Documentation/admin-guide/media/pci-cardlist.rst arch/x86/Kconfig arch/x86/include/asm/sta2x11.h arch/x86/pci/Makefile arch/x86/pci/sta2x11-fixup.c drivers/ata/ahci.c drivers/gpio/Kconfig drivers/gpio/Makefile drivers/gpio/gpio-sta2x11.c drivers/i2c/busses/Kconfig drivers/media/pci/Makefile drivers/media/pci/sta2x11/Kconfig drivers/media/pci/sta2x11/Makefile drivers/media/pci/sta2x11/sta2x11_vip.c drivers/media/pci/sta2x11/sta2x11_vip.h drivers/mfd/Kconfig drivers/mfd/Makefile drivers/mfd/sta2x11-mfd.c include/linux/mfd/sta2x11-mfd.hQuoted 7 lines
Quoted 3 lines
Removing the other sta2x11 bits (mfd, media, x86) should probably be done through the respective tree, but it would be good not to forget those.
Andy is pretty much default x86 platform device maintainer, maybe he can ACK or brief us on what he knows about the status of STA2x11?
Quoted 6 lines
I think the explanation given by Davide and Alessandro was rather detailed already:
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/I can't see this series in neither linus tree nor linux-next.
Following the ACK from Andy + the above explanations from Arnd, do you plan to merge this series anytime soon ?
Do you need anything more from me ?
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Thanks
ChristopheI will take it after v6.1-rc1 is tagged.
Bart
Now queued.
Thanks for reviewing and applying this!
Let's test it in linux-next we need wide coverage for this.
Yours,
Linus Walleij
Quoted 1 line · Linus Walleij
On Mon, Oct 17, 2022 at 11:05 AM Bartosz Golaszewski <[email protected]> wrote:
...
Quoted 1 line
Let's test it in linux-next we need wide coverage for this.
Yes, I believe the best if we can have this in the Linux Next as long as possible before going to upstream. This is good change that needs good testing coverage.
Speaking of the latter, and a bit of offtopic, I want to send a PR of cleaning up the headers in pin control subsystem as soon as possible with the same rationale underneath, i.e. testing and new drivers using a cleaned up headers..
Signature · 2 lines
With Best Regards, Andy Shevchenko