From: Linus Walleij <linus.walleij@linaro.org>
To: Romain Izard <romain.izard.pro@gmail.com>,
Linux GPIO List <linux-gpio@vger.kernel.org>,
Linux ARM <linux-arm-kernel@lists.infradead.org>,
Linus Walleij <linus.walleij@linaro.org>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Russell King <linux@armlinux.org.uk>
Subject: Re: GPIOs not correctly exported via sysfs on ATSAMA5D2
Date: Fri, 28 Feb 2020 14:36:11 +0100 [thread overview]
Message-ID: <CACRpkdYKemE6+OkWOWqOAqzaVEDNE9id+P_XRFaNzWs8N6c7mw@mail.gmail.com> (raw)
In-Reply-To: <20200228123910.hbf2bnk3w2dbishr@M43218.corp.atmel.com>
On Fri, Feb 28, 2020 at 1:39 PM Ludovic Desroches
<ludovic.desroches@microchip.com> wrote:
> The AT91 PIO4 pinctrl driver doesn't implement gpio_request_enable()
> contrary to the AT91 PIO pinctrl driver. If we implement it, then you
> would be able to change the pin muxing and configuration from the sysfs.
> The issue is nothing prevent you do this and so to possibly break a
> device.
>
> There is the strict pinmux_ops property which prevents from this
> situation. The side effect is that we must not declare a pinmux/conf for
> a GPIO so all the DT files have to been updated. That's not a big deal,
> the problem is, at that time, the GPIO subsystem didn't allow to set the
> bias for instance. It may have changed but not sure it covers all the
> possible configurations we have from the pinmuxing subsystem.
Yes and Russell also points very clearly to the root of the problem:
- Some pin multiplexers are non-strict meaning a line can be used
for say GPIO and something else (such as SDIO) at the same time.
Usually this is an observation from electronics, such that the GPIO
input register will always report the logical state on the line whether
it is in "gpio mode" or something else, making it possible to snoop
the line, or, as in the I2C case, it is perfectly fine to, without glitches,
pull the line out of other use cases and into the GPIO realm and do
GPIO things such as bus recovery actively driving the line despite
it being connected in the mux to SDIO or I2C at the same time.
- At the same time some system designers and driver authors are
driven by the ambition to create a system that is simple, has no
exceptions and has a clear separation of concerns, making it
impossible for the user - even a kernel developer or real savvy
hacker playing around with the deprecated sysfs ABI - to shoot
themselves in the foot. These are ambitious and admirable people
that want to protect their users and make it easy to do the right
thing. So they sort everything out and flag their pin multiplexers
as "strict", allowing only one use case at the time: this device is
either I2C or SDIO.
Personally I am not flagging any of my drivers strict because I'm
just a pragmatist and don't use the system architect type of reasoning
much in what I do. But it is admittedly a matter of taste. The flag
"strict" tells you something about the driver author's values and
ambition.
If we get to cases where the user is getting hurt by the strictness
rather than enjoying the protection it provides, such as being unable
to do I2C recovery, it may be reasonable to drop the strict setting
and just fail the ambition to separate the concerns, as clearly the
system architecture wasn't perfect in the first place, and trying to
be strict in the mux is going to be a bit like polishing dirt.
This case however looks a bit like tinkering, bring-up and hacking,
and as such it might be expected that the user hack around a bit
and recompile the kernel and device tree etc?
Yours,
Linus Walleij
next prev parent reply other threads:[~2020-02-28 13:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-28 10:58 GPIOs not correctly exported via sysfs on ATSAMA5D2 Romain Izard
2020-02-28 12:39 ` Ludovic Desroches
2020-02-28 12:46 ` Russell King - ARM Linux admin
2020-02-28 13:36 ` Linus Walleij [this message]
2020-03-02 8:47 ` Uwe Kleine-König
2020-03-02 8:39 ` Uwe Kleine-König
2020-03-02 9:36 ` Russell King - ARM Linux admin
2020-03-02 16:34 ` Linus Walleij
2020-03-02 16:44 ` Russell King - ARM Linux admin
2020-03-02 21:30 ` Uwe Kleine-König
2020-03-03 13:10 ` 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=CACRpkdYKemE6+OkWOWqOAqzaVEDNE9id+P_XRFaNzWs8N6c7mw@mail.gmail.com \
--to=linus.walleij@linaro.org \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=nicolas.ferre@microchip.com \
--cc=romain.izard.pro@gmail.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).