The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Gary Guo" <gary@garyguo.net>
Cc: "Robin Murphy" <robin.murphy@arm.com>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Abdiel Janulgue" <abdiel.janulgue@gmail.com>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Onur Özkan" <work@onurozkan.dev>,
	"John Hubbard" <jhubbard@nvidia.com>,
	"Alistair Popple" <apopple@nvidia.com>,
	"Timur Tabi" <ttabi@nvidia.com>,
	"Eliot Courtney" <ecourtney@nvidia.com>,
	"Zhi Wang" <zhiw@nvidia.com>,
	nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, driver-core@lists.linux.dev,
	rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v2 2/3] rust: dma: rename dma_handle to dma_address
Date: Thu, 13 Aug 2026 00:32:45 +0200	[thread overview]
Message-ID: <DKNBM5C0CWIL.1Y659FEPPM2G0@kernel.org> (raw)
In-Reply-To: <DKIQEJX6H5A0.1D3POLLNZB9YS@garyguo.net>

On Fri Aug 7, 2026 at 3:04 PM CEST, Gary Guo wrote:
> On Wed Aug 5, 2026 at 9:39 PM BST, Danilo Krummrich wrote:
>> On Wed Aug 5, 2026 at 1:32 PM CEST, Robin Murphy wrote:
>>> To be fair, that is sort of the intent in the C API as well, to be clear 
>>> that DMA addresses must not simply be treated as physical addresses, and 
>>> aren't necessarily address-like in general e.g. comparing two 
>>> dma_handles is pretty meaningless, since they could have different 
>>> values but still refer to the same underlying memory, or vice-versa. 
>>> Adding or subtracting offsets within the bounds of the original 
>>> allocation/mapping size is pretty much the only arithmetic that _is_ valid.
>>
>> Yes, I did suggest a dma::Range type [1] for this purpose, such that only this
>> kind arithmetic is possible to do.
>>
>> The dma::Range type should have a method returning its embedded raw value which
>> then can be used to program registers etc.
>>
>> This patch is only an intermediate step, that clarifies that intent of the
>> current usage of dma_handle() (or now dma_address()), which is not to serve as a
>> handle.
>
> I suppose with I/O projections now it's rarer that people need to operate on dma
> address directly? What do you envison as the use case for `dma::Range`?
>
> Also, I suppose we can also represent dma address ranges as `Io` views that does
> not implement any accessor methods, so projection still works on them.

Yes, that covers most cases. What about SGEntry cases and CoherentHandle?

For instance, in nova-core we currently have

	for sg_entry in sg_table.iter() {
	    let num_pages = usize::from_safe_cast(sg_entry.dma_len()).div_ceil(GSP_PAGE_SIZE);
	    for i in 0..num_pages {
	        let entry = sg_entry.dma_address()
	            + (u64::from_safe_cast(i) * u64::from_safe_cast(GSP_PAGE_SIZE));
	        dst.extend_from_slice(&entry.to_le_bytes(), GFP_KERNEL)?;
	    }
	}

which could become

	for sg_entry in sg_table.iter() {
	    sg_entry.dma_range().for_each_block(GSP_PAGE_SIZE, |addr| {
	        dst.extend_from_slice(&addr.to_le_bytes(), GFP_KERNEL)
	    })?;
	}

  reply	other threads:[~2026-08-12 22:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05  5:01 [PATCH v2 0/3] gpu: nova-core: falcon: use I/O projections for DMA transfers Alexandre Courbot
2026-08-05  5:01 ` [PATCH v2 1/3] gpu: nova-core: falcon: remove unnecessary check Alexandre Courbot
2026-08-05  7:02   ` Ethan Plant
2026-08-05  5:01 ` [PATCH v2 2/3] rust: dma: rename dma_handle to dma_address Alexandre Courbot
2026-08-05 11:32   ` Robin Murphy
2026-08-05 20:39     ` Danilo Krummrich
2026-08-07 13:04       ` Gary Guo
2026-08-12 22:32         ` Danilo Krummrich [this message]
2026-08-12 23:51           ` Gary Guo
2026-08-06 21:16   ` Danilo Krummrich
2026-08-05  5:01 ` [PATCH v2 3/3] gpu: nova-core: falcon: use I/O projection to check transfer bounds Alexandre Courbot
2026-08-06 21:25 ` [PATCH v2 0/3] gpu: nova-core: falcon: use I/O projections for DMA transfers 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=DKNBM5C0CWIL.1Y659FEPPM2G0@kernel.org \
    --to=dakr@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=abdiel.janulgue@gmail.com \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=apopple@nvidia.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=driver-core@lists.linux.dev \
    --cc=ecourtney@nvidia.com \
    --cc=gary@garyguo.net \
    --cc=jhubbard@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=nova-gpu@lists.linux.dev \
    --cc=ojeda@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=ttabi@nvidia.com \
    --cc=work@onurozkan.dev \
    --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