All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Danilo Krummrich" <dakr@kernel.org>
Cc: ojeda@kernel.org, "Alexandre Courbot" <acourbot@nvidia.com>,
	dri-devel@lists.freedesktop.org,
	"Danilo Krummrich" <dakr@kernel.org>
Subject: Re: [PATCH 3/4] samples: rust_dma: separate driver type from driver data
Date: Sun, 30 Aug 2026 19:57:39 +0000	[thread overview]
Message-ID: <20260830195739.6E4F61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260830193824.471089-4-dakr@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] Missing generic lifetime parameter on Generic Associated Type (GAT) `Self::Data`.
- [Low] Type mismatch between `&pci::Device<Core<'_>>` and `&pci::Device<Bound>` in struct field initialization.
--

commit e990389a909f2dd12217de05acd654c0fd95ac40
Author: Danilo Krummrich <dakr@kernel.org>

samples: rust_dma: separate driver type from driver data

This commit splits the DmaSampleDriver into a driver type and a separate
DmaSampleData struct for device private data. It updates the associated Data
type to carry a lifetime bound, preparing for future changes to
dma::Coherent.

> diff --git a/samples/rust/rust_dma.rs b/samples/rust/rust_dma.rs
> index bd60034ded23a..0fac9d4ae566e 100644
> --- a/samples/rust/rust_dma.rs
> +++ b/samples/rust/rust_dma.rs
[ ... ]
> @@ -67,13 +71,13 @@ unsafe impl kernel::transmute::FromBytes for MyStruct {}
>  
>  impl pci::Driver for DmaSampleDriver {
>      type IdInfo = ();
> -    type Data<'bound> = Self;
> +    type Data<'bound> = DmaSampleData<'bound>;
>      const ID_TABLE: pci::IdTable<Self::IdInfo> = &PCI_TABLE;
>  
>      fn probe<'bound>(
>          pdev: &'bound pci::Device<Core<'_>>,
>          _info: Option<&'bound Self::IdInfo>,
> -    ) -> impl PinInit<Self, Error> + 'bound {
> +    ) -> impl PinInit<Self::Data<'bound>, Error> + 'bound {
>          pin_init::pin_init_scope(move || {
>              dev_info!(pdev, "Probe DMA test driver.\n");
>  
> @@ -94,8 +98,8 @@ fn probe<'bound>(
>  
>              let sgt = SGTable::new(pdev.as_ref(), pages, DataDirection::ToDevice, GFP_KERNEL);
>  
> -            Ok(try_pin_init!(Self {
> -                pdev: pdev.into(),
> +            Ok(try_pin_init!(Self::Data {

[Severity: Low]
Does this code build without explicitly providing the lifetime parameter
for the Generic Associated Type (GAT)? 

Rust typically requires explicit generic parameters for GATs used in paths,
so using Self::Data here might trigger a missing generics build error.

> +                pdev,

[Severity: Low]
Is there a type mismatch during the struct initialization here?

The probe() function receives pdev as &'bound pci::Device<Core<'_>>, but
the DmaSampleData struct definition expects &'bound pci::Device<Bound>:

struct DmaSampleData<'bound> {
    pdev: &'bound pci::Device<Bound>,
    ...
}

Since implicit Deref coercions do not apply to struct field initializations,
this direct assignment could cause a compilation failure.

>                  ca,
>                  sgt <- sgt,
>              }))

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260830193824.471089-1-dakr@kernel.org?part=3

  reply	other threads:[~2026-08-30 19:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-30 19:37 [PATCH 0/4] rust: dma: tie DMA allocations to the device's bound lifetime Danilo Krummrich
2026-08-30 19:37 ` [PATCH 1/4] rust: debugfs: drop 'static bound from ScopedDir file creation methods Danilo Krummrich
2026-08-30 19:53   ` sashiko-bot
2026-09-03 13:12   ` Gary Guo
2026-09-03 15:07     ` Danilo Krummrich
2026-09-03 15:16       ` Gary Guo
2026-08-30 19:37 ` [PATCH 2/4] rust: dma: tie CoherentHandle to the device's bound lifetime Danilo Krummrich
2026-09-03 13:12   ` Gary Guo
2026-08-30 19:37 ` [PATCH 3/4] samples: rust_dma: separate driver type from driver data Danilo Krummrich
2026-08-30 19:57   ` sashiko-bot [this message]
2026-09-03 13:13   ` Gary Guo
2026-08-30 19:37 ` [PATCH 4/4] rust: dma: tie Coherent and CoherentBox to the device's bound lifetime Danilo Krummrich
2026-08-30 19:47   ` sashiko-bot
2026-09-03 13:20   ` Gary Guo
2026-09-03 15:22     ` Danilo Krummrich
2026-09-03 15:42       ` Gary Guo
2026-09-06 15:37 ` [PATCH 0/4] rust: dma: tie DMA allocations " Danilo Krummrich
2026-09-07 21:06   ` Danilo Krummrich

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=20260830195739.6E4F61F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ojeda@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.