Re: [PATCH v1 4/8] gpiolib: Get rid of ARCH_NR_GPIOS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 31, 2022, at 7:49 AM, Christophe Leroy wrote:
> Le 30/08/2022 à 22:18, Andy Shevchenko a écrit :
>> On Mon, Aug 29, 2022 at 7:19 PM Christophe Leroy
>> <christophe.leroy@xxxxxxxxxx> 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 256 as the start for dynamic
>>> allocation.
>> 
>> Not sure about 256, but I understand that this can only be the best guess.
>> 
>
> Well, it's already just a precaution. Linus W's expectation is that 
> static ones are allocated at first, they should already be allocated 
> when we start doing dynamic allocations so he was even thinking that we 
> could have started at 0 already.
>
> But I can start higher if you think it is safer, maybe at 512 which is 
> the default ARCH_NR_GPIOS today.

FWIW, I went through the drivers that set the base to a value other than
zero or -1, to see what they use:

arch/arm/common/scoop.c:		devptr->gpio.base = inf->gpio_base; // 204
arch/arm/mach-s3c/gpio-samsung.c:			.base	= S3C2410_GPM(0), // 384
arch/arm/mach-s3c/gpio-samsung.c:			.base	= S3C64XX_GPQ(0), // 197
arch/arm/mach-s3c/mach-h1940.c:	.base			= H1940_LATCH_GPIO(0), // 384 + 22
arch/arm/mach-sa1100/simpad.c:	cs3_gpio.base = SIMPAD_CS3_GPIO_BASE; // 27 + 11
arch/arm/plat-orion/gpio.c:	ochip->chip.base = gpio_base; // 64 + 32
arch/mips/alchemy/common/gpiolib.c:		.base			= ALCHEMY_GPIO2_BASE, // 32 + 16
arch/mips/alchemy/common/gpiolib.c:	.base			= AU1300_GPIO_BASE, // 0 + 75
arch/mips/kernel/gpio_txx9.c:	txx9_gpio_chip.base = base; // 0 + 16
arch/mips/txx9/generic/setup.c:	iocled->chip.base = basenum; -1
drivers/bcma/driver_gpio.c:		chip->base		= bus->num * BCMA_GPIO_MAX_PINS; // probably 0
drivers/gpio/gpio-adp5520.c:	gc->base = pdata->gpio_start; // unused
drivers/gpio/gpio-adp5588.c:		gc->base = pdata->gpio_start; // unused
drivers/gpio/gpio-arizona.c:		arizona_gpio->gpio_chip.base = pdata->gpio_base; // 197
drivers/gpio/gpio-brcmstb.c:		gc->base = gpio_base; // 2 * 32
drivers/gpio/gpio-bt8xx.c:	c->base = modparam_gpiobase; // from modprobe
drivers/gpio/gpio-da9052.c:		gpio->gp.base = pdata->gpio_base; // unused
drivers/gpio/gpio-da9055.c:		gpio->gp.base = pdata->gpio_base; // unused
drivers/gpio/gpio-davinci.c:	chips->chip.base = pdata->no_auto_base ? pdata->base : -1; // 0 + 144
drivers/gpio/gpio-dwapb.c:	port->gc.base = pp->gpio_base; // from DT, deprecated
drivers/gpio/gpio-f7188x.c:			.base             = _base,			\ // 10*10, unused
drivers/gpio/gpio-htc-egpio.c:		chip->base            = pdata->chip[i].gpio_base; // 192 + 5 * 8
drivers/gpio/gpio-ich.c:	chip->base = modparam_gpiobase; // from modprobe
drivers/gpio/gpio-kempld.c:		chip->base = pdata->gpio_base; // 0
drivers/gpio/gpio-lpc32xx.c:			.base			= LPC32XX_GPO_P3_GRP, // 104
drivers/gpio/gpio-madera.c:		madera_gpio->gpio_chip.base = pdata->gpio_base; // -1
drivers/gpio/gpio-max730x.c:		ts->chip.base = pdata->base; // 200 + 28 (timberdale)
drivers/gpio/gpio-max732x.c:	gc->base = gpio_start; // 192
drivers/gpio/gpio-mc33880.c:	mc->chip.base = pdata->base; // 100 (timberdale)
drivers/gpio/gpio-merrifield.c:	priv->chip.base = gpio_base; // 0 + 213
drivers/gpio/gpio-mmio.c:		gc->base = pdata->base; // 197 + 32
drivers/gpio/gpio-mockup.c:	gc->base = base; // module parama
drivers/gpio/gpio-mvebu.c:	mvchip->chip.base = id * MVEBU_MAX_GPIO_PER_BANK; // 4 * 32, from DT
drivers/gpio/gpio-omap.c:		bank->chip.base = OMAP_MPUIO(0); // 192
drivers/gpio/gpio-omap.c:		bank->chip.base = gpio; // 7 * 32
drivers/gpio/gpio-palmas.c:		palmas_gpio->gpio_chip.base = palmas_pdata->gpio_base; // unused
drivers/gpio/gpio-pca953x.c:	gc->base = chip->gpio_start; // ???? used a lot
drivers/gpio/gpio-pcf857x.c:	gpio->chip.base			= pdata ? pdata->gpio_base : -1; // 160
drivers/gpio/gpio-rc5t583.c:		rc5t583_gpio->gpio_chip.base = pdata->gpio_base;  // unused
drivers/gpio/gpio-rockchip.c:	gc->base = bank->pin_base; // 8 * 32
drivers/gpio/gpio-sch311x.c:		block->chip.base = sch311x_gpio_blocks[i].base; // 6 * 10
drivers/gpio/gpio-sta2x11.c:	gpio->base = gpio_base; // unused 
drivers/gpio/gpio-timberdale.c:	gc->base = pdata->gpio_base; // 0 + 100
drivers/gpio/gpio-tps6586x.c:		tps6586x_gpio->gpio_chip.base = pdata->gpio_base; // -1
drivers/gpio/gpio-tps65910.c:		tps65910_gpio->gpio_chip.base = pdata->gpio_base; // -1
drivers/gpio/gpio-ucb1400.c:	ucb->gc.base = ucb->gpio_offset; // 0
drivers/gpio/gpio-wm831x.c:		wm831x_gpio->gpio_chip.base = pdata->gpio_base; // 197 + 64
drivers/gpio/gpio-wm8350.c:		wm8350_gpio->gpio_chip.base = pdata->gpio_base; // 0
drivers/gpio/gpio-wm8994.c:		wm8994_gpio->gpio_chip.base = pdata->gpio_base; 197 + 8
drivers/input/keyboard/adp5588-keys.c:	kpad->gc.base = gpio_data->gpio_start; // unused
drivers/input/keyboard/adp5589-keys.c:	kpad->gc.base = gpio_data->gpio_start; // unused
drivers/leds/leds-pca9532.c:		data->gpio.base = pdata->gpio_base; // unused
drivers/leds/leds-tca6507.c:	tca->gpio.base = pdata->gpio_base; // unused
drivers/mfd/asic3.c:	asic->gpio.base = pdata->gpio_base; // 300 + 100
drivers/mfd/htc-i2cpld.c:	gpio_chip->base            = plat_chip_data->gpio_in_base; // 192 + 16 + 8*8
drivers/mfd/sm501.c:	gchip->base   = base; // 0
drivers/mfd/tps65010.c:		tps->chip.base = board->base; // 204
drivers/mfd/ucb1x00-core.c:		ucb->gpio.base = pdata->gpio_base; // 27 + 13
drivers/pinctrl/nomadik/pinctrl-nomadik.c:	chip->base = id * NMK_GPIO_PER_CHIP; // 9 * 32
drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c:		pctrl->gpio_bank[id].gc.base = args.args[1]; // 8*32, from DT
drivers/pinctrl/pinctrl-at91.c:	chip->base = alias_idx * MAX_NB_GPIO_PER_BANK; // 5*32
drivers/pinctrl/pinctrl-ingenic.c:	jzgc->gc.base = bank * 32; // 6 * 32, from DT
drivers/pinctrl/pinctrl-mcp23s08.c:	mcp->chip.base = base; // -1
drivers/pinctrl/pinctrl-oxnas.c:			.base = GPIO_BANK_START(_bank),	// 2*32
drivers/pinctrl/pinctrl-pic32.c:			.base = GPIO_BANK_START(_bank), // 10 * 16
drivers/pinctrl/pinctrl-pistachio.c:			.base = _pin_base,	// 9 * 16
drivers/pinctrl/pinctrl-st.c:	bank->gpio_chip.base = bank_num * ST_GPIO_PINS_PER_BANK; // 26 * 8
drivers/pinctrl/renesas/gpio.c:	gc->base = pfc->nr_gpio_pins; // ??? don't understand
drivers/pinctrl/samsung/pinctrl-samsung.c:		gc->base = bank->grange.base;
drivers/pinctrl/stm32/pinctrl-stm32.c:		bank->gpio_chip.base = args.args[1];
drivers/pinctrl/stm32/pinctrl-stm32.c:		bank->gpio_chip.base = bank_nr * STM32_GPIO_PINS_PER_BANK;
drivers/pinctrl/stm32/pinctrl-stm32.c:	bank->gpio_chip.base = bank_nr * STM32_GPIO_PINS_PER_BANK;
drivers/pinctrl/sunxi/pinctrl-sunxi.c:	pctl->chip->base = pctl->desc->pin_base;
sound/soc/codecs/wm5100.c:		wm5100->gpio_chip.base = wm5100->pdata.gpio_base; // 197 + 8 + 6
sound/soc/codecs/wm8903.c:		wm8903->gpio_chip.base = pdata->gpio_base; // 197 + 8
sound/soc/codecs/wm8962.c:		wm8962->gpio_chip.base = pdata->gpio_base; // 197 + 8 
sound/soc/codecs/wm8996.c:		wm8996->gpio_chip.base = wm8996->pdata.gpio_base; // 197 + 8 

     Arnd




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux