Re: [PATCH v4 03/10] gpiolib: implement low-level, shared GPIO support
From: Andy Shevchenko
Date: Wed Mar 11 2026 - 16:15:41 EST
On Wed, Mar 11, 2026 at 8:38 PM Jon Hunter <jonathanh@xxxxxxxxxx> wrote:
> On 12/11/2025 13:55, Bartosz Golaszewski wrote:
...
> On Tegra234, the main gpio controller has a total of 164 GPIOs (see
> the tegra234_main_ports in drivers/gpio/gpio-tegra186.c). The GPIOs
> are assigned a index by the kernel from 0-163, but these GPIOs are
> not contiguous with respect to the device-tree specifier.
If I may ask...
Why? Is it sparse because there are pads that can't be used as GPIOs?
> For example, in device-tree, if I have a shared-gpio with the
> following specifier ...
>
> gpios = <&gpio TEGRA234_MAIN_GPIO(AF, 1) GPIO_ACTIVE_LOW>;
>
> The macro TEGRA234_MAIN_GPIO(AF, 1) evaluates to (23 * 8) + 1 = 185.
To me it sounds like a bad design of the driver for this SoC/platform.
> This is greater than 164 and this is causing the above crash because
> 'entry->offset' in gpio_device_setup_shared() is greater than
> 'gdev->ngpio' and this causes us to access invalid memory.
>
> This is what I have been able to determine so far and wanted to get
> your inputs.
--
With Best Regards,
Andy Shevchenko