Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp980817rwe; Wed, 31 Aug 2022 14:49:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR4H8jS5KfjzsVRfp/Qv2kEZr7HibuBc24utV1hXyBSp5ck1T8OBXxXJG6a9hKWrYikKWHKf X-Received: by 2002:a05:6402:35c7:b0:448:95be:380 with SMTP id z7-20020a05640235c700b0044895be0380mr11953613edc.393.1661982540674; Wed, 31 Aug 2022 14:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661982540; cv=none; d=google.com; s=arc-20160816; b=U95sUfLBKnAQqGfJB7AzOlHwUMfW1iMr/qDdA5cLVG0RwrMIyEdE1CGZTN2ZI4VhSF FAOYSrqHYpTYbpLQx1PGCwitEwdL1ZpwX5xeekSpIzF2YQIarIak0yV8yRoc9/y5hKlD 9m5nRIR8/h7E2HOu9Dhb0jn8ev8SHLTxKDT5kXSF1VV/Hnb0DQRDrZhmoXMigWQQYUS/ v0sU9BQgwmRI05gGKUYvJRTs2POYBPUW2UMLr3pL0mSV5iIifCYjWCc0KjoteEl9neeS 997NotyWeSEsI5HqE0BUYJWvRZL5xgR2EAxGOcI8cT7OgKZY+vywLhlSZWiLBvmxmqMI VyFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:subject:cc:to:from :date:references:in-reply-to:message-id:mime-version:user-agent :feedback-id:dkim-signature:dkim-signature; bh=LkVDm3Qz7FBWMo01mEWdMxKemZ7sFp7vGUA7k+sq3MA=; b=fQ4A0s3TYRh1uFGEYIbM1Et2dAJeHMIFeek24yc4F3+uE2oU+gPWGBCv/N+kkD6zfO WXSSpRIxk4OlMllRAnZHYYrxDh3cqF/PkhCgwTLPFNXykQ19CzoxiX62uZ36K6e4Zz28 /XjYWy0CaZP8cg2l/6EhrjVCL/zBsKFDl8iSwAq4hiZogs/iw6WwDTH4qfdOSdl33GFi G1G13qTEVUhLbyB2muC38Ad0zziDMPE4FG7kPOzxUw73S1HoAF2w60Jl56sZowpc0OLD eD/Vt4NNgbDiOTuBc9P7Hk9ulinpN9q1Wft6dkXWpdG2Acb8KMfw0EzW+vFOCwmps3Ho 436A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm1 header.b=PPSLbF1B; dkim=pass header.i=@messagingengine.com header.s=i56a14606.fm1 header.b=pEqlW916; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020a50cd09000000b00445fba6c607si270430edi.140.2022.08.31.14.48.34; Wed, 31 Aug 2022 14:49:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@arndb.de header.s=fm1 header.b=PPSLbF1B; dkim=pass header.i=@messagingengine.com header.s=i56a14606.fm1 header.b=pEqlW916; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231477AbiHaUzo (ORCPT + 99 others); Wed, 31 Aug 2022 16:55:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229996AbiHaUzm (ORCPT ); Wed, 31 Aug 2022 16:55:42 -0400 Received: from new4-smtp.messagingengine.com (new4-smtp.messagingengine.com [66.111.4.230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50B635E578; Wed, 31 Aug 2022 13:55:39 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id 01C535801ED; Wed, 31 Aug 2022 16:55:39 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute3.internal (MEProxy); Wed, 31 Aug 2022 16:55:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1661979338; x= 1661982938; bh=LkVDm3Qz7FBWMo01mEWdMxKemZ7sFp7vGUA7k+sq3MA=; b=P PSLbF1Bmu6kVZdMCtzufYqAOg5if+vw9BKLPIbGWrIQ4hgPAaeRcgtOu+o/dRoSa Pa/fv6PhYKOJYeqRLmIFKLULBubecQrTYf8+VkutxnfDuUnwBLGOspNW72aBXlDJ Fs365JoBxA6E7cvYOPc1vaslQfVkb2+Ay4v5/0gjTD/C7GAnLxHKsws1KKdGCkw5 uyfzVPDXihfSg4gpAQhJXbeQ5ieNsg4DlwHI38Fo6Wcaoqt61OanZcscCLlUWhfF 6+b+OmafMJyvIwCPl0OnNDsQzwVf/wiyfSEnreEPPJ3b2CnLlDL6GxIdmxr2uPqW Xx5OfjUoNGnMeMzmk+/iw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=i56a14606.fm1; t= 1661979338; x=1661982938; bh=LkVDm3Qz7FBWMo01mEWdMxKemZ7sFp7vGUA 7k+sq3MA=; b=pEqlW916ckglDDJnoXqPnSVwBkCve6yH6Atee1NZ/q+WUtMYCMp +rGaey1mod27NkBky23kgsWpqOVIarbyDR4MAgR69iglbC1jti4V1s4zQyxjcZKv iALZQ6Rque4LCQug+5KVGLxeUxVW4x47caAdYI/mLRv5Ft8sU9GJe2yUhyiGPcSm lLN90133NmKu4xcVXzHOYY434OAShlt42NagBRTaDVNb+IeStJzWqnqDN+itHBys RLNFkd6vBokjw/BePosS0n31DrPb2x4+qag6PWDnISlKJag7lDPr8foYPB2RmVaq Tg50/C8iLIj+gzCPlTTwD3JfpEm4mhWbCAQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdekiedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvvefutgfgsehtqhertderreejnecuhfhrohhmpedf tehrnhguuceuvghrghhmrghnnhdfuceorghrnhgusegrrhhnuggsrdguvgeqnecuggftrf grthhtvghrnhepgeefjeehvdelvdffieejieejiedvvdfhleeivdelveehjeelteegudek tdfgjeevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprghrnhgusegrrhhnuggsrdguvg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 0C034B60083; Wed, 31 Aug 2022 16:55:36 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-841-g7899e99a45-fm-20220811.002-g7899e99a Mime-Version: 1.0 Message-Id: <1d548a19-feec-42b9-944d-890d6dde2fb8@www.fastmail.com> In-Reply-To: <18cda49e-84f0-a806-566a-6e77705e98b3@csgroup.eu> References: <18cda49e-84f0-a806-566a-6e77705e98b3@csgroup.eu> Date: Wed, 31 Aug 2022 22:55:16 +0200 From: "Arnd Bergmann" To: "Christophe Leroy" , "Andy Shevchenko" Cc: "Linus Walleij" , "Bartosz Golaszewski" , "Geert Uytterhoeven" , Keerthy , "Russell King" , "Jonathan Corbet" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , "H. Peter Anvin" , "Catalin Marinas" , "Will Deacon" , "Linux Kernel Mailing List" , "open list:GPIO SUBSYSTEM" , "linux-arm Mailing List" , Linux-Arch , "Linux Documentation List" , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Subject: Re: [PATCH v1 4/8] gpiolib: Get rid of ARCH_NR_GPIOS Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 31, 2022, at 7:49 AM, Christophe Leroy wrote: > Le 30/08/2022 =C3=A0 22:18, Andy Shevchenko a =C3=A9crit=C2=A0: >> On Mon, Aug 29, 2022 at 7:19 PM Christophe Leroy >> 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. >>=20 >> Not sure about 256, but I understand that this can only be the best g= uess. >>=20 > > Well, it's already just a precaution. Linus W's expectation is that=20 > static ones are allocated at first, they should already be allocated=20 > when we start doing dynamic allocations so he was even thinking that w= e=20 > could have started at 0 already. > > But I can start higher if you think it is safer, maybe at 512 which is=20 > 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 =3D inf->gpio_base; // 204 arch/arm/mach-s3c/gpio-samsung.c: .base =3D S3C2410_GPM(0), // 384 arch/arm/mach-s3c/gpio-samsung.c: .base =3D S3C64XX_GPQ(0), // 197 arch/arm/mach-s3c/mach-h1940.c: .base =3D H1940_LATCH_GPIO(0), // 384 = + 22 arch/arm/mach-sa1100/simpad.c: cs3_gpio.base =3D SIMPAD_CS3_GPIO_BASE; /= / 27 + 11 arch/arm/plat-orion/gpio.c: ochip->chip.base =3D gpio_base; // 64 + 32 arch/mips/alchemy/common/gpiolib.c: .base =3D ALCHEMY_GPIO2_BASE, // = 32 + 16 arch/mips/alchemy/common/gpiolib.c: .base =3D AU1300_GPIO_BASE, // 0 += 75 arch/mips/kernel/gpio_txx9.c: txx9_gpio_chip.base =3D base; // 0 + 16 arch/mips/txx9/generic/setup.c: iocled->chip.base =3D basenum; -1 drivers/bcma/driver_gpio.c: chip->base =3D bus->num * BCMA_GPIO_MAX_PI= NS; // probably 0 drivers/gpio/gpio-adp5520.c: gc->base =3D pdata->gpio_start; // unused drivers/gpio/gpio-adp5588.c: gc->base =3D pdata->gpio_start; // unused drivers/gpio/gpio-arizona.c: arizona_gpio->gpio_chip.base =3D pdata->gp= io_base; // 197 drivers/gpio/gpio-brcmstb.c: gc->base =3D gpio_base; // 2 * 32 drivers/gpio/gpio-bt8xx.c: c->base =3D modparam_gpiobase; // from modpro= be drivers/gpio/gpio-da9052.c: gpio->gp.base =3D pdata->gpio_base; // unus= ed drivers/gpio/gpio-da9055.c: gpio->gp.base =3D pdata->gpio_base; // unus= ed drivers/gpio/gpio-davinci.c: chips->chip.base =3D pdata->no_auto_base ? = pdata->base : -1; // 0 + 144 drivers/gpio/gpio-dwapb.c: port->gc.base =3D pp->gpio_base; // from DT, = deprecated drivers/gpio/gpio-f7188x.c: .base =3D _base, \ // 10*10,= unused drivers/gpio/gpio-htc-egpio.c: chip->base =3D pdata->chip[i]= .gpio_base; // 192 + 5 * 8 drivers/gpio/gpio-ich.c: chip->base =3D modparam_gpiobase; // from modpr= obe drivers/gpio/gpio-kempld.c: chip->base =3D pdata->gpio_base; // 0 drivers/gpio/gpio-lpc32xx.c: .base =3D LPC32XX_GPO_P3_GRP, // 104 drivers/gpio/gpio-madera.c: madera_gpio->gpio_chip.base =3D pdata->gpio= _base; // -1 drivers/gpio/gpio-max730x.c: ts->chip.base =3D pdata->base; // 200 + 28= (timberdale) drivers/gpio/gpio-max732x.c: gc->base =3D gpio_start; // 192 drivers/gpio/gpio-mc33880.c: mc->chip.base =3D pdata->base; // 100 (timb= erdale) drivers/gpio/gpio-merrifield.c: priv->chip.base =3D gpio_base; // 0 + 213 drivers/gpio/gpio-mmio.c: gc->base =3D pdata->base; // 197 + 32 drivers/gpio/gpio-mockup.c: gc->base =3D base; // module parama drivers/gpio/gpio-mvebu.c: mvchip->chip.base =3D id * MVEBU_MAX_GPIO_PER= _BANK; // 4 * 32, from DT drivers/gpio/gpio-omap.c: bank->chip.base =3D OMAP_MPUIO(0); // 192 drivers/gpio/gpio-omap.c: bank->chip.base =3D gpio; // 7 * 32 drivers/gpio/gpio-palmas.c: palmas_gpio->gpio_chip.base =3D palmas_pdat= a->gpio_base; // unused drivers/gpio/gpio-pca953x.c: gc->base =3D chip->gpio_start; // ???? used= a lot drivers/gpio/gpio-pcf857x.c: gpio->chip.base =3D pdata ? pdata->gpio_b= ase : -1; // 160 drivers/gpio/gpio-rc5t583.c: rc5t583_gpio->gpio_chip.base =3D pdata->gp= io_base; // unused drivers/gpio/gpio-rockchip.c: gc->base =3D bank->pin_base; // 8 * 32 drivers/gpio/gpio-sch311x.c: block->chip.base =3D sch311x_gpio_blocks[i= ].base; // 6 * 10 drivers/gpio/gpio-sta2x11.c: gpio->base =3D gpio_base; // unused=20 drivers/gpio/gpio-timberdale.c: gc->base =3D pdata->gpio_base; // 0 + 100 drivers/gpio/gpio-tps6586x.c: tps6586x_gpio->gpio_chip.base =3D pdata->= gpio_base; // -1 drivers/gpio/gpio-tps65910.c: tps65910_gpio->gpio_chip.base =3D pdata->= gpio_base; // -1 drivers/gpio/gpio-ucb1400.c: ucb->gc.base =3D ucb->gpio_offset; // 0 drivers/gpio/gpio-wm831x.c: wm831x_gpio->gpio_chip.base =3D pdata->gpio= _base; // 197 + 64 drivers/gpio/gpio-wm8350.c: wm8350_gpio->gpio_chip.base =3D pdata->gpio= _base; // 0 drivers/gpio/gpio-wm8994.c: wm8994_gpio->gpio_chip.base =3D pdata->gpio= _base; 197 + 8 drivers/input/keyboard/adp5588-keys.c: kpad->gc.base =3D gpio_data->gpio= _start; // unused drivers/input/keyboard/adp5589-keys.c: kpad->gc.base =3D gpio_data->gpio= _start; // unused drivers/leds/leds-pca9532.c: data->gpio.base =3D pdata->gpio_base; // u= nused drivers/leds/leds-tca6507.c: tca->gpio.base =3D pdata->gpio_base; // unu= sed drivers/mfd/asic3.c: asic->gpio.base =3D pdata->gpio_base; // 300 + 100 drivers/mfd/htc-i2cpld.c: gpio_chip->base =3D plat_chip_data-= >gpio_in_base; // 192 + 16 + 8*8 drivers/mfd/sm501.c: gchip->base =3D base; // 0 drivers/mfd/tps65010.c: tps->chip.base =3D board->base; // 204 drivers/mfd/ucb1x00-core.c: ucb->gpio.base =3D pdata->gpio_base; // 27 = + 13 drivers/pinctrl/nomadik/pinctrl-nomadik.c: chip->base =3D id * NMK_GPIO_= PER_CHIP; // 9 * 32 drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c: pctrl->gpio_bank[id].gc.base= =3D args.args[1]; // 8*32, from DT drivers/pinctrl/pinctrl-at91.c: chip->base =3D alias_idx * MAX_NB_GPIO_P= ER_BANK; // 5*32 drivers/pinctrl/pinctrl-ingenic.c: jzgc->gc.base =3D bank * 32; // 6 * 3= 2, from DT drivers/pinctrl/pinctrl-mcp23s08.c: mcp->chip.base =3D base; // -1 drivers/pinctrl/pinctrl-oxnas.c: .base =3D GPIO_BANK_START(_bank), // = 2*32 drivers/pinctrl/pinctrl-pic32.c: .base =3D GPIO_BANK_START(_bank), // = 10 * 16 drivers/pinctrl/pinctrl-pistachio.c: .base =3D _pin_base, // 9 * 16 drivers/pinctrl/pinctrl-st.c: bank->gpio_chip.base =3D bank_num * ST_GPI= O_PINS_PER_BANK; // 26 * 8 drivers/pinctrl/renesas/gpio.c: gc->base =3D pfc->nr_gpio_pins; // ??? d= on't understand drivers/pinctrl/samsung/pinctrl-samsung.c: gc->base =3D bank->grange.ba= se; drivers/pinctrl/stm32/pinctrl-stm32.c: bank->gpio_chip.base =3D args.ar= gs[1]; drivers/pinctrl/stm32/pinctrl-stm32.c: bank->gpio_chip.base =3D bank_nr= * STM32_GPIO_PINS_PER_BANK; drivers/pinctrl/stm32/pinctrl-stm32.c: bank->gpio_chip.base =3D bank_nr = * STM32_GPIO_PINS_PER_BANK; drivers/pinctrl/sunxi/pinctrl-sunxi.c: pctl->chip->base =3D pctl->desc->= pin_base; sound/soc/codecs/wm5100.c: wm5100->gpio_chip.base =3D wm5100->pdata.gpi= o_base; // 197 + 8 + 6 sound/soc/codecs/wm8903.c: wm8903->gpio_chip.base =3D pdata->gpio_base;= // 197 + 8 sound/soc/codecs/wm8962.c: wm8962->gpio_chip.base =3D pdata->gpio_base;= // 197 + 8=20 sound/soc/codecs/wm8996.c: wm8996->gpio_chip.base =3D wm8996->pdata.gpi= o_base; // 197 + 8=20 Arnd