From: Jonas Jelonek <jelonek.jonas@gmail.com>
To: Peter Rosin <peda@axentia.se>,
Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Geert Uytterhoeven <geert+renesas@glider.be>
Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] gpio: add gpio-line-mux driver
Date: Mon, 27 Oct 2025 09:26:34 +0100 [thread overview]
Message-ID: <a7b6b606-4b2c-4dcf-bd79-23711dd97b71@gmail.com> (raw)
In-Reply-To: <bad968a4-37e6-655e-711f-c647becbba5a@axentia.se>
Hi Peter,
On 27.10.25 08:51, Peter Rosin wrote:
>> +static int gpio_lmux_gpio_get(struct gpio_chip *gc, unsigned int offset)
>> +{
>> + struct gpio_lmux *glm = (struct gpio_lmux *)gpiochip_get_data(gc);
>> + int ret;
>> +
>> + if (offset > gc->ngpio)
>> + return -EINVAL;
>> +
>> + guard(gpio_lmux)(glm);
>> +
>> + ret = mux_control_select(glm->mux, glm->gpio_mux_states[offset]);
> Consider using mux_control_select_delay() here, with some suitable
> delay, to allow the mux to settle before reading the gpio line.
Thanks, will fix this.
> This .set implementation is completely broken. It you want to
> set a gpio to outout high/low, you presumably want the gpio to
> stay that way for at least some period of time, while whatever
> else happens that relies on the gpio to be in that state. But in
> this case only the mux select/deselect is protecting that gpio
> state, which is bound to be inadequate for anything real.
>
> Sure, you can probably build something trivial and see that the
> gpio can be manipulated, but the second something else touches
> the mux, the intended state of an output gpio line is
> (potentially) clobbered.
>
> I notice that in your target application, the sfp driver, all
> uses of gpios via the mux are inputs. Input is a much easier
> problem. At least as long as you do not require IRQ, if you
> need IRQs you face similar problems where the mux needs to be
> locked in its position for whatever period of time you can
> expect IRQs.
Yes, that why I left IRQs out here, but somehow I didn't properly
transfer that I have similar issues with output functionality.
>
> TL;DR, this .set implementation needs to be removed, there is
> simply no reasonable way to implement a muxed gpio .set in a
> pure software driver. You need some hardware to preserve the
> state if/when the mux is manipulated.
I see, thanks for pointing it out! I'll drop this in the next iteration
then and make this driver input-only.
> Cheers,
> Peter
>
Best,
Jonas
next prev parent reply other threads:[~2025-10-27 8:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-26 23:17 [PATCH v2 0/2] add gpio-line-mux Jonas Jelonek
2025-10-26 23:17 ` [PATCH v2 1/2] dt-bindings: gpio: add gpio-line-mux controller Jonas Jelonek
2025-10-27 11:39 ` Rob Herring (Arm)
2025-10-27 11:47 ` Jonas Jelonek
2025-10-27 13:32 ` Rob Herring
2025-10-26 23:17 ` [PATCH v2 2/2] gpio: add gpio-line-mux driver Jonas Jelonek
2025-10-27 7:51 ` Peter Rosin
2025-10-27 8:26 ` Jonas Jelonek [this message]
2025-10-28 9:45 ` Thomas Richard
2025-10-28 10:09 ` Peter Rosin
2025-10-28 10:22 ` Thomas Richard
2025-11-04 14:57 ` Jonas Jelonek
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=a7b6b606-4b2c-4dcf-bd79-23711dd97b71@gmail.com \
--to=jelonek.jonas@gmail.com \
--cc=brgl@bgdev.pl \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=krzk+dt@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peda@axentia.se \
--cc=robh@kernel.org \
/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).