Linux-GPIO Archive mirror
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Vincent Fazio <vfazio@gmail.com>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [question] Does gpiod_set_value have a "guarantee"?
Date: Tue, 16 Apr 2024 23:02:22 +0200	[thread overview]
Message-ID: <CAMRc=Mfxq3rLGT6A1HrRaKT2jtf9Ah7Gj3tUwAGzhUv=Lpg4mA@mail.gmail.com> (raw)
In-Reply-To: <CAOrEah4J2U6eoyJrUar62y48GsiR8NahJpodkv-V80RRQxQJrQ@mail.gmail.com>

On Mon, Mar 18, 2024 at 6:13 PM Vincent Fazio <vfazio@gmail.com> wrote:
>
> Is there any implicit or expected guarantee that after having returned from
> gpiod_set_value that the GPIO will reflect the new value externally?
>

No, this is driver-specific behavior.

> Some drivers that leverage GPIO to emulate buses, like i2c-gpio, may be relying
> on this to be true in order to make a "stable" clock.
>

Well, they shouldn't rely on it because it's not enforced unless the
underlying driver enforces it.

> I was glancing at https://github.com/raspberrypi/linux/issues/5554 where
> someone ran into an issue and it looks like, at least on the RPi 4 platform,
> that there may need to be some "flush" mechanism to guarantee that a GPIO has
> been written out.
>
> If it's the responsibility of gpio_chip->set to do this, then I'm guessing the
> pinctrl driver may need to be updated, but that does incur a performance hit
> for every GPIO write.
>
> If it's up to the bus emulator to do this, short of sampling the pin, should
> there be some API or mechanism to assist with flushing writes out? Is there
> already a mechanism to do this?
>

That's an interesting use case. We could extend both the in-kernel and
user-space API for this quite easily. We could add a new flag to
gpiod_get() like GPIOD_SYNC or similar and maybe provide a callback
for GPIO drivers for flushing the state? Then do the same with
user-space request flags.

In any case, I don't think we can make it entirely generic.

Bart

      reply	other threads:[~2024-04-16 21:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-18 17:12 [question] Does gpiod_set_value have a "guarantee"? Vincent Fazio
2024-04-16 21:02 ` Bartosz Golaszewski [this message]

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='CAMRc=Mfxq3rLGT6A1HrRaKT2jtf9Ah7Gj3tUwAGzhUv=Lpg4mA@mail.gmail.com' \
    --to=brgl@bgdev.pl \
    --cc=linux-gpio@vger.kernel.org \
    --cc=vfazio@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 read-only IMAP folder(s) and NNTP newsgroup(s).