mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shawn Guo <shengchao.guo@oss.qualcomm.com>
To: Bartosz Golaszewski <brgl@kernel.org>
Cc: linux-gpio@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org, Linus Walleij <linusw@kernel.org>
Subject: Re: [PATCH v4 3/4] gpio: shared-proxy: Drive the default value when no votes are cast
Date: Wed, 28 Oct 2026 15:01:01 +0800	[thread overview]
Message-ID: <auGdrYC_mZeJft0q@QCOM-aGQu4IUr3Y> (raw)
In-Reply-To: <CAMRc=McoAYKHojJCT6yeTvsMLKDTisD3V42VH5ebRapuG-UGBg@mail.gmail.com>

On Tue, Oct 20, 2026 at 09:17:00AM -0400, Bartosz Golaszewski wrote:
> On Sat, 17 Oct 2026 06:36:04 +0200, Shawn Guo
> <shengchao.guo@oss.qualcomm.com> said:
> > A consumer that requests a shared line with GPIOD_ASIS never calls
> > direction_output(), so def_val keeps its initial value of 0. If the
> > line was left high, for instance by the bootloader, a later
> > gpiod_set_value(0) from that consumer matches def_val and the proxy
> > treats it as withdrawing a vote it never cast. It returns success
> > without writing the hardware, and the line stays high.
> >
> > The consumer has no way to tell. Its request to drive the line low is
> > silently ignored until it first votes for high and then withdraws
> > that vote.
> >
> > When the requested value is the default and no votes are
> > outstanding, write it to the hardware instead of returning early.
> > For lines configured via direction_output() this is a redundant
> > write of the value the line already has. With votes outstanding the
> > request remains a no-op, as the line must stay at the voted value.
> >
> 
> Wouldn't this only matter for a line requested as-is? We could avoid the
> redundant write if we only did it for such lines instead of for all
> unconditionally.

It also matters for a line configured via direction_output(), after
patch 2. When a proxy releases the line and restoring the default value
fails, gpio_shared_proxy_free() still drops its vote. The line is then
at the non-default value with votecnt == 0, so "no votes outstanding"
no longer implies "line is at the default" either way. The unconditional
write lets any remaining user that sets the default bring the line back.
Gating it on as-is lines would leave it stuck there.

The proxy also has no direct notion of as-is; it would need a flag in
gpio_shared_desc tracking whether def_val has ever been written to the
hardware, set and cleared in the init paths of direction_output() and
direction_input().

The write itself is cheap and rare: it only happens when a proxy that
hasn't voted sets the default while no votes are outstanding.

If you still prefer the gating, I can do that in v5 and keep the
free-failure case recoverable some other way. Otherwise I'll add the
reasoning above to the commit message.

Shawn

  reply	other threads:[~2026-10-28  7:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-17  4:36 [PATCH v4 0/4] gpio: shared-proxy: Fix line accounting Shawn Guo
2026-10-17  4:36 ` [PATCH v4 1/4] gpio: shared-proxy: Fix race between concurrent first users Shawn Guo
2026-10-20 10:06   ` Bartosz Golaszewski
2026-10-28  6:57     ` Shawn Guo
2026-10-17  4:36 ` [PATCH v4 2/4] gpio: shared-proxy: Drop the vote of a released proxy on write failure Shawn Guo
2026-10-17  4:36 ` [PATCH v4 3/4] gpio: shared-proxy: Drive the default value when no votes are cast Shawn Guo
2026-10-20 13:17   ` Bartosz Golaszewski
2026-10-28  7:01     ` Shawn Guo [this message]
2026-10-28  9:22       ` Bartosz Golaszewski
2026-10-17  4:36 ` [PATCH v4 4/4] gpio: shared-proxy: Drop the vote when switching to input Shawn Guo
2026-10-20 13:18 ` [PATCH v4 0/4] gpio: shared-proxy: Fix line accounting Bartosz Golaszewski

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=auGdrYC_mZeJft0q@QCOM-aGQu4IUr3Y \
    --to=shengchao.guo@oss.qualcomm.com \
    --cc=brgl@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.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

all inboxes | Powered by JetHome®