linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Danilo Krummrich <dakr@kernel.org>
To: Benno Lossin <benno.lossin@proton.me>
Cc: gregkh@linuxfoundation.org, rafael@kernel.org,
	bhelgaas@google.com, kwilczynski@kernel.org, zhiw@nvidia.com,
	cjia@nvidia.com, jhubbard@nvidia.com, bskeggs@nvidia.com,
	acurrid@nvidia.com, joelagnelf@nvidia.com, ttabi@nvidia.com,
	acourbot@nvidia.com, ojeda@kernel.org, alex.gaynor@gmail.com,
	boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com,
	a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu,
	linux-pci@vger.kernel.org, rust-for-linux@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] samples: rust: pci: take advantage of Devres::access_with()
Date: Sat, 26 Apr 2025 23:26:36 +0200	[thread overview]
Message-ID: <aA1PjHrG4yT7XpCI@pollux> (raw)
In-Reply-To: <D9GUSVZY3ZT7.O3RTG4N0ZIK0@proton.me>

On Sat, Apr 26, 2025 at 08:30:39PM +0000, Benno Lossin wrote:
> On Sat Apr 26, 2025 at 3:30 PM CEST, Danilo Krummrich wrote:
> > For the I/O operations executed from the probe() method, take advantage
> > of Devres::access_with(), avoiding the atomic check and RCU read lock
> > required otherwise entirely.
> >
> > Signed-off-by: Danilo Krummrich <dakr@kernel.org>
> > ---
> >  samples/rust/rust_driver_pci.rs | 12 ++++++------
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/samples/rust/rust_driver_pci.rs b/samples/rust/rust_driver_pci.rs
> > index 9ce3a7323a16..3e1569e5096e 100644
> > --- a/samples/rust/rust_driver_pci.rs
> > +++ b/samples/rust/rust_driver_pci.rs
> > @@ -83,12 +83,12 @@ fn probe(pdev: &pci::Device<Core>, info: &Self::IdInfo) -> Result<Pin<KBox<Self>
> >              GFP_KERNEL,
> >          )?;
> >  
> > -        let res = drvdata
> > -            .bar
> > -            .try_access_with(|b| Self::testdev(info, b))
> > -            .ok_or(ENXIO)??;
> > -
> > -        dev_info!(pdev.as_ref(), "pci-testdev data-match count: {}\n", res);
> > +        let bar = drvdata.bar.access_with(pdev.as_ref())?;
> 
> Since this code might inspire other code, I don't think that we should
> return `EINVAL` here (bubbled up from `access_with`). Not sure what the
> correct thing here would be though...

I can't think of any other error code that would match better, EINVAL seems to
be the correct thing. Maybe one could argue for ENODEV, but I still think EINVAL
fits better.

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

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-26 13:30 [PATCH 0/3] Devres optimization with bound devices Danilo Krummrich
2025-04-26 13:30 ` [PATCH 1/3] rust: revocable: implement Revocable::access() Danilo Krummrich
2025-04-26 16:44   ` Christian Schrefl
2025-04-26 16:54     ` Boqun Feng
2025-04-26 17:01       ` Danilo Krummrich
2025-04-26 17:09         ` Christian Schrefl
2025-04-26 17:19         ` Boqun Feng
2025-04-26 17:03       ` Christian Schrefl
2025-04-26 20:16         ` Benno Lossin
2025-04-26 20:24   ` Benno Lossin
2025-04-26 21:18     ` Danilo Krummrich
2025-04-26 13:30 ` [PATCH 2/3] rust: devres: implement Devres::access_with() Danilo Krummrich
2025-04-26 16:53   ` Christian Schrefl
2025-04-26 17:08     ` Danilo Krummrich
2025-04-26 17:18       ` Christian Schrefl
2025-04-26 20:18         ` Benno Lossin
2025-04-27 13:15   ` Alexandre Courbot
2025-04-27 14:17     ` Danilo Krummrich
2025-04-26 13:30 ` [PATCH 3/3] samples: rust: pci: take advantage of Devres::access_with() Danilo Krummrich
2025-04-26 20:30   ` Benno Lossin
2025-04-26 21:26     ` Danilo Krummrich [this message]
2025-04-27  8:56       ` Benno Lossin
2025-04-27 10:20         ` Danilo Krummrich
2025-04-27 17:05           ` Benno Lossin
2025-04-26 17:09 ` [PATCH 0/3] Devres optimization with bound devices Boqun Feng
2025-04-26 17:14   ` Danilo Krummrich
2025-04-26 17:17     ` Boqun Feng

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=aA1PjHrG4yT7XpCI@pollux \
    --to=dakr@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=acurrid@nvidia.com \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=benno.lossin@proton.me \
    --cc=bhelgaas@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=bskeggs@nvidia.com \
    --cc=cjia@nvidia.com \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jhubbard@nvidia.com \
    --cc=joelagnelf@nvidia.com \
    --cc=kwilczynski@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rafael@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    --cc=ttabi@nvidia.com \
    --cc=zhiw@nvidia.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).