Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Francesco Dolcini <francesco@dolcini.it>
Cc: "João Paulo Gonçalves" <jpaulo.silvagoncalves@gmail.com>,
	nattan <nattanferreira58@gmail.com>,
	lucasantonio.santos@usp.br, linux-iio@vger.kernel.org
Subject: Re: [PATCH] iio: adc: ti-ads1119: Prevent concurrent access during
Date: Mon, 21 Apr 2025 14:23:59 +0100	[thread overview]
Message-ID: <20250421142359.11fb483f@jic23-huawei> (raw)
In-Reply-To: <20250420211706.GB5621@francesco-nb>

On Sun, 20 Apr 2025 23:17:06 +0200
Francesco Dolcini <francesco@dolcini.it> wrote:

> On Sun, Apr 20, 2025 at 01:07:28PM -0300, João Paulo Gonçalves wrote:
> > > Use iio_device_claim_direct() to protect register access via debugfs
> > > from conflicting with buffered capture modes. This prevents data
> > > corruption and ensures correct device operation when users access
> > > registers while streaming data.
> > >   
> > 
> > but debugfs is meant to be used during development/integration,
> > where this probably is not an issue.  
> 
> Is even worth doing any such a change? I assume Jonathan will have an
> opinion on what's the expectation for an IIO driver.
> 
> Nattan, can you explain why you need such a change? What is the use
> case?
> 
> Francesco

For debug access it 'depends'....

Some cases are easy reasons to add this protection
1) Accesses can't happen at all because to talk to the device and read
   registers etc requires some mode change (e.g. recent drivers that
   can only access config registers when the bus is operating in particular
   modes, or where we have to use a slower SPI bus rate).
2) There are register banks involved. So a single write can leave the
   driver talking to the wrong registers...
3) Driver uses multipart reads / writes (similar to register banks)
   In most cases this is a device specific thing and should use a local
   lock to serialize accesses.  On occasion that is too complex to make
   work with debug so we restrict debugfs access in general.

Other cases are less obvious.
1) Bus traffic in general might slow down a transfer and break things
   because of timing. I.e. missed samples.  That can happen for all sorts
   of reasons anyway so should only be a momentary problem.
2) They might changes settings.

These less obvious things are a case of thinking it's a debug
access. We tend to not prevent actual deliberate state changes as that's
someone shooting them selves in the foot and they get what they deserve.

So what is the case we are protecting against here?  The description
definitely needs more information to justify this patch.

Jonathan

> 


  reply	other threads:[~2025-04-21 13:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-19 23:23 [PATCH] iio: adc: ti-ads1119: Prevent concurrent access during nattan
2025-04-20 16:07 ` João Paulo Gonçalves
2025-04-20 21:17   ` Francesco Dolcini
2025-04-21 13:23     ` Jonathan Cameron [this message]
2025-04-21 14:42       ` Marcelo Schmitt
2025-04-25  8:10         ` Jonathan Cameron
2025-04-22 18:04     ` Nattan Ferreira
2025-04-25  8:14       ` Jonathan Cameron

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=20250421142359.11fb483f@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=francesco@dolcini.it \
    --cc=jpaulo.silvagoncalves@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=lucasantonio.santos@usp.br \
    --cc=nattanferreira58@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