From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Chris Packham <Chris.Packham@alliedtelesis.co.nz>
Cc: Kent Gibson <warthog618@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>,
"brgl@bgdev.pl" <brgl@bgdev.pl>,
"johan@kernel.org" <johan@kernel.org>,
"maz@kernel.org" <maz@kernel.org>,
Ben Brown <Ben.Brown@alliedtelesis.co.nz>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] gpiolib: Avoid side effects in gpio_is_visible()
Date: Wed, 17 May 2023 11:54:58 +0300 [thread overview]
Message-ID: <CAHp75VfSnb2DWX8iMZ7BiSnrEquZdbzvTD+bcHk_Oc_rh7ectw@mail.gmail.com> (raw)
In-Reply-To: <a61415db-fa3f-2fce-9c21-08d8dd026960@alliedtelesis.co.nz>
On Wed, May 17, 2023 at 2:50 AM Chris Packham
<Chris.Packham@alliedtelesis.co.nz> wrote:
> On 17/05/23 10:47, Kent Gibson wrote:
...
> The first is a userspace driver for a Power Over Ethernet Controller+PSE
> chipset (I'll refer to this as an MCU since the thing we talk to is
> really a micro controller with a vendor supplied firmware on it that
> does most of the PoE stuff). Communication to the MCU is based around
> commands sent via i2c. But there are a few extra GPIOs that are used to
> reset the MCU as well as provide a mechanism for quickly dropping power
> on certain events (e.g. if the temperature monitoring detects a problem).
Why does the MCU have no in-kernel driver?
> We do have a small kernel module that grabs the GPIOs based on the
> device tree and exports them with a known names (e.g. "poe-reset",
> "poe-dis") that the userspace driver can use.
So, besides that you repeat gpio-aggregator functionality, you already
have a "proxy" driver in the kernel. What prevents you from doing more
in-kernel?
> Back when that code was
> written we did consider not exporting the GPIOs and instead having some
> other sysfs/ioctl interface into this kernel module but that seemed more
> work than just calling gpiod_export() for little gain. This is where
> adding the gpio-names property in our .dts would allow libgpiod to do
> something similar.
>
> Having the GPIOs in sysfs is also convenient as we can have a systemd
> ExecStopPost script that can drop power and/or reset the MCU if our
> application crashes.
I'm a bit lost. What your app is doing and how that is related to the
(userspace) drivers?
> I'm not sure if the GPIO chardev interface deals
> with releasing the GPIO lines if the process that requested them exits
> abnormally (I assume it does) and obviously our ExecStopPost script
> would need updating to use some of the libgpiod applications to do what
> it currently does with a simple 'echo 1 >.../poe-reset'
>
> The second application is a userspace driver for a L3 network switch
> (actually two of them for different silicon vendors). Again this needs
> to deal with resets for PHYs connected to the switch that the kernel has
> no visibility of as well as the GPIOs for the SFP cages. Again we have a
> slightly less simple kernel module that grabs all these GPIOs and
> exports them with known names. This time there are considerably more of
> these GPIOs (our largest system currently has 96 SFP+ ports with 4 GPIOs
> per port) so we're much more reliant on being able to do things like
> `for x in port*tx-dis; do echo 1 >$x; done`
Hmm... Have you talked to the net subsystem guys? I know that there is
a lot going on around SFP cage enumeration for some of the modules
(Marvell?) and perhaps they can advise something different.
> I'm sure both of these applications could be re-written around libgpiod
> but that would incur a significant amount of regression testing on
> existing platforms. And I still consider dealing with GPIO chips an
> extra headache that the applications don't need (particularly with the
> sheer number of them the SFP case).
It seems to me that having no in-kernel driver for your stuff is the
main point of all headache here. But I might be mistaken.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2023-05-17 8:55 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-12 4:28 [PATCH] gpiolib: Avoid side effects in gpio_is_visible() Chris Packham
2023-05-12 7:24 ` Johan Hovold
2023-05-14 21:57 ` Chris Packham
2023-05-15 6:43 ` andy.shevchenko
2023-05-15 21:01 ` Chris Packham
2023-05-12 7:56 ` Linus Walleij
2023-05-14 22:27 ` Chris Packham
2023-05-16 13:57 ` Linus Walleij
2023-05-16 22:19 ` Chris Packham
2023-05-16 22:47 ` Kent Gibson
2023-05-16 23:50 ` Chris Packham
2023-05-17 0:47 ` Kent Gibson
2023-05-17 1:05 ` Kent Gibson
2023-05-17 1:07 ` Chris Packham
2023-05-17 1:21 ` Kent Gibson
2023-05-17 8:54 ` Andy Shevchenko [this message]
2023-05-17 9:10 ` Kent Gibson
2023-05-17 21:30 ` Chris Packham
2023-05-23 16:38 ` andy.shevchenko
2023-05-23 21:17 ` Chris Packham
2023-05-24 5:41 ` Kent Gibson
2023-05-24 23:53 ` using libgpiod to replace sysfs ABI (was Re: [PATCH] gpiolib: Avoid side effects in gpio_is_visible()) Chris Packham
2023-05-25 1:19 ` Kent Gibson
2023-05-25 9:13 ` Andy Shevchenko
2023-05-25 14:35 ` Bartosz Golaszewski
2023-05-26 12:46 ` [PATCH] gpiolib: Avoid side effects in gpio_is_visible() Bartosz Golaszewski
2023-05-28 21:04 ` Chris Packham
2023-05-29 9:19 ` Linus Walleij
2023-05-29 15:07 ` Andrew Lunn
2023-05-29 9:07 ` Linus Walleij
2023-05-29 22:00 ` Chris Packham
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=CAHp75VfSnb2DWX8iMZ7BiSnrEquZdbzvTD+bcHk_Oc_rh7ectw@mail.gmail.com \
--to=andy.shevchenko@gmail.com \
--cc=Ben.Brown@alliedtelesis.co.nz \
--cc=Chris.Packham@alliedtelesis.co.nz \
--cc=brgl@bgdev.pl \
--cc=johan@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=warthog618@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).