linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Andy Shevchenko <andy.shevchenko@gmail.com>,
	Andreas Kemnade <andreas@kemnade.info>
Cc: "linus.walleij@linaro.org" <linus.walleij@linaro.org>,
	"brgl@bgdev.pl" <brgl@bgdev.pl>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	": Tony Lindgren" <tony@atomide.com>,
	Aaro Koskinen <aaro.koskinen@iki.fi>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>
Subject: Re: [PATCH] gpiolib: fix allocation of mixed dynamic/static GPIOs
Date: Thu, 27 Apr 2023 10:55:57 +0000	[thread overview]
Message-ID: <d585bdd8-978a-8172-bd55-4494d25299e1@csgroup.eu> (raw)
In-Reply-To: <CAHp75VezDMZkRTRHRACtJZCW2S_1NoZL5GDK7tmA2vzjrAhOKg@mail.gmail.com>



Le 27/04/2023 à 12:46, Andy Shevchenko a écrit :
> On Thu, Apr 27, 2023 at 1:37 PM Andreas Kemnade <andreas@kemnade.info> wrote:
>>
>> On Thu, 27 Apr 2023 06:20:34 +0000
>> Christophe Leroy <christophe.leroy@csgroup.eu> wrote:
>>
>>> Le 27/04/2023 à 08:00, Andy Shevchenko a écrit :
>>>> On Thu, Apr 27, 2023 at 8:40 AM Christophe Leroy
>>>> <christophe.leroy@csgroup.eu> wrote:
>>>>>
>>>>>
>>>>>
>>>>> Le 27/04/2023 à 00:03, Andreas Kemnade a écrit :
>>>>>> [Vous ne recevez pas souvent de courriers de andreas@kemnade.info. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
>>>>>>
>>>>>> If static allocation and dynamic allocation GPIOs are present,
>>>>>> dynamic allocation pollutes the numberspace for static allocation,
>>>>>> causing static allocation to fail.
>>>>>> Enfore dynamic allocation above GPIO_DYNAMIC_BASE.
>>>>>
>>>>> Hum ....
>>>>>
>>>>> Commit 7b61212f2a07 ("gpiolib: Get rid of ARCH_NR_GPIOS") was supposed
>>>>> to enforce dynamic allocation above GPIO_DYNAMIC_BASE already.
>>>>>
>>>>> Can you describe what is going wrong exactly with the above commit ?
>>>>
>>>> Above commit only works to the first dynamic allocation, if you need
>>>> more than one with static ones present it mistakenly will give you a
>>>> base _below_ DYNAMIC_BASE.
>>>
>>> Ah right, that needs to be fixed.
>>>
>>>>
>>>> However, this change is just PoC I proposed, the conditional and
>>>> action should be slightly different to cover a corner case, when
>>>> statically allocated chip overlaps the DYNAMIC_BASE, i.e. gdev->base <
>>>> DYNAMIC_BASE, while gdev->base + gdev->ngpio >= DYNAMIC_BASE.
>>>>
>>>
>>> Yes you are right, that's gdev->base + gdev->ngpio that should be checked.
>>>
>> and that not with simple continue or base might simply stay at DYNAMIC_BASE.
>>
>> I will send a v2 of this patch with refined logic.
> 
> Actually it would be nice to integrate a warning (if we don't have it
> yet) when adding a GPIO chip with a static allocation and which will
> overlap the dynamic base. Can you add that into your v2?
> 

At the time being we have a warning for all static allocations, 
allthough their has been some discussion about reverting it, see commit 
502df79b8605 ("gpiolib: Warn on drivers still using static gpiobase 
allocation")

Christophe

  reply	other threads:[~2023-04-27 10:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-26 22:03 [PATCH] gpiolib: fix allocation of mixed dynamic/static GPIOs Andreas Kemnade
2023-04-27  5:40 ` Christophe Leroy
2023-04-27  6:00   ` Andy Shevchenko
2023-04-27  6:20     ` Christophe Leroy
2023-04-27 10:37       ` Andreas Kemnade
2023-04-27 10:46         ` Andy Shevchenko
2023-04-27 10:55           ` Christophe Leroy [this message]
2023-04-27 11:01             ` Andy Shevchenko

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=d585bdd8-978a-8172-bd55-4494d25299e1@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=aaro.koskinen@iki.fi \
    --cc=andreas@kemnade.info \
    --cc=andy.shevchenko@gmail.com \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=tony@atomide.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).