linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: Jerome Brunet <jbrunet@baylibre.com>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	Marc Zyngier <marc.zyngier@arm.com>,
	"open list:ARM/Amlogic Meson..."
	<linux-amlogic@lists.infradead.org>,
	Kevin Hilman <khilman@baylibre.com>,
	Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] gpio: about the need to manage irq mapping dynamically.
Date: Sun, 2 Jul 2017 17:01:11 +0200	[thread overview]
Message-ID: <CACRpkdbcKGu7n3qRZegHvkXLXpRo4XTO3rUs7K61+cmyKrwa9w@mail.gmail.com> (raw)
In-Reply-To: <f8495533-b53f-8999-9320-38f18ca7691b@ti.com>

On Fri, Jun 30, 2017 at 9:54 PM, Grygorii Strashko
<grygorii.strashko@ti.com> wrote:
> On 06/29/2017 09:16 AM, Linus Walleij wrote:
>> On Tue, Jun 27, 2017 at 10:43 PM, Grygorii Strashko
>> <grygorii.strashko@ti.com> wrote:
>>
>>> And my opinion is still the same here - It should be perfectly valid to create
>>> mappings from gpio_to_irq() to handle properly orthogonality of gpiochip and
>>> gpio-irqchip functionality and satisfy SPARSE_IRQ goal (allocate Linux virq and
>>> irq descriptors on demand).
>>
>> You are right.
>>
>> I would rather say: GPIO drivers that have a 1-to-1 mapping between GPIO
>> lines and IRQs should not do it, they should map up them all at probe().
>>
>
> Sry, can't completely agree here :( There could be 300 (or even thousands)
> of gpios and only dozen of them will be used as GPIO IRQ, so statical mapping will
> just waste system resources. So, better not define such kind of restrictions -
> it seems platform/system specific.

If there could, yeah.

But the majority of the worlds systems use a hardcoded value of 512 GPIOs.

See include/asm-generic/gpio.h:

#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

The only arch that overrides this is ARM, which has CONFIG_ARCH_NR_GPIO:

# 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 1024 if ARCH_BRCMSTB || ARCH_SHMOBILE || ARCH_TEGRA || \
                ARCH_ZYNQ
        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.

So actually, noone use more than 1024 GPIOs.

For each GPIO a descriptor of 16 bytes is allocated. So in worst case 16KiB.

Also this is an upper cap: it just means the nax we have on any platform is 1024
statically allocated GPIO descriptors, not that they all get mapped to IRQs.
That happens on a per-gpiochip basis.

But every irq descriptor is pretty big (somewhere around 64+ bytes), so you have
a point.

If every GPIO allocates an IRQ descriptor, it may add up to as much as 64KiB
on a machine with 1024 GPIOs.

Yours,
Linus Walleij

  reply	other threads:[~2017-07-02 15:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-15 16:20 [RFC] gpio: about the need to manage irq mapping dynamically Jerome Brunet
2017-06-20  8:39 ` Linus Walleij
2017-06-20 10:26   ` Jerome Brunet
2017-06-20 16:37     ` Linus Walleij
2017-06-20 17:23       ` Jerome Brunet
2017-06-21 20:50         ` Linus Walleij
2017-06-22 14:25           ` Jerome Brunet
2017-06-27 17:49             ` Grygorii Strashko
2017-06-27 18:25               ` Jerome Brunet
2017-06-27 20:43                 ` Grygorii Strashko
2017-06-29 14:16                   ` Linus Walleij
2017-06-30 19:54                     ` Grygorii Strashko
2017-07-02 15:01                       ` Linus Walleij [this message]
2017-06-29 14:14                 ` Linus Walleij
2017-06-29 14:57                   ` Jerome Brunet
2017-06-29 16:53                     ` Marc Zyngier
2017-06-29 18:33                       ` Jerome Brunet
2017-06-29 22:16                     ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACRpkdbcKGu7n3qRZegHvkXLXpRo4XTO3rUs7K61+cmyKrwa9w@mail.gmail.com \
    --to=linus.walleij@linaro.org \
    --cc=grygorii.strashko@ti.com \
    --cc=jbrunet@baylibre.com \
    --cc=khilman@baylibre.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.zyngier@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).