From: Alvin Sun <alvin.sun@linux.dev>
To: Daniel Almeida <daniel.almeida@collabora.com>, sunke@kylinos.cn
Cc: rust-for-linux@vger.kernel.org, "Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
"Lyude Paul" <lyude@redhat.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 9/9] drm/tyr: add BO-related ioctls
Date: Tue, 8 Sep 2026 22:24:56 +0800 [thread overview]
Message-ID: <cbe03927-afdb-4558-9196-e57d899b8d01@linux.dev> (raw)
In-Reply-To: <FDEDAB25-FBF2-438C-9C1C-F72DC851E88C@collabora.com>
On 9/5/26 04:35, Daniel Almeida wrote:
>
>> On 1 Sep 2026, at 13:09, Ke Sun via B4 Relay <devnull+sunke.kylinos.cn@kernel.org> wrote:
>>
>> From: Alvin Sun <alvin.sun@linux.dev>
>>
>> Expose buffer creation and BO mmap offset retrieval.
>>
>> - BO_CREATE page-aligns the size and returns a handle with
>> write-combined mapping.
>> - BO_MMAP_OFFSET provides the offset for the DRM generic mmap
>> path, rejecting NO_MMAP objects and non-zero pad.
>>
>> Signed-off-by: Alvin Sun <alvin.sun@linux.dev>
> Same comment as the previous patches, please write a few
> more things here about why the changes are needed.
>
> With that addressed,
>
> Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Hi Daniel,
Thanks for the review — your comments on patches 7 and 9 (the
conditional Reviewed-bys) are addressed in v2:
https://lore.kernel.org/all/20260908-tyr-ioctls-v2-0-88bea777df67@kylinos.cn
Best regards,
Alvin
>
>> ---
>> drivers/gpu/drm/tyr/driver.rs | 2 ++
>> drivers/gpu/drm/tyr/file.rs | 70 +++++++++++++++++++++++++++++++++++++++++++
>> drivers/gpu/drm/tyr/gem.rs | 7 +++++
>> 3 files changed, 79 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
>> index b3145526ada06..fc8d11c9ba1ca 100644
>> --- a/drivers/gpu/drm/tyr/driver.rs
>> +++ b/drivers/gpu/drm/tyr/driver.rs
>> @@ -224,6 +224,8 @@ impl drm::Driver for TyrDrmDriver {
>> (PANTHOR_VM_DESTROY, drm_panthor_vm_destroy, ioctl::RENDER_ALLOW, TyrDrmFileData::vm_destroy),
>> (PANTHOR_VM_BIND, drm_panthor_vm_bind, ioctl::RENDER_ALLOW, TyrDrmFileData::vm_bind),
>> (PANTHOR_VM_GET_STATE, drm_panthor_vm_get_state, ioctl::RENDER_ALLOW, TyrDrmFileData::vm_get_state),
>> + (PANTHOR_BO_CREATE, drm_panthor_bo_create, ioctl::RENDER_ALLOW, TyrDrmFileData::bo_create),
>> + (PANTHOR_BO_MMAP_OFFSET, drm_panthor_bo_mmap_offset, ioctl::RENDER_ALLOW, TyrDrmFileData::bo_mmap_offset),
>> }
>> }
>>
>> diff --git a/drivers/gpu/drm/tyr/file.rs b/drivers/gpu/drm/tyr/file.rs
>> index 157bc40e1cac4..16abf2968299c 100644
>> --- a/drivers/gpu/drm/tyr/file.rs
>> +++ b/drivers/gpu/drm/tyr/file.rs
>> @@ -252,6 +252,76 @@ pub(crate) fn vm_get_state(
>> Ok(0)
>> })
>> }
>> +
>> + pub(crate) fn bo_create(
>> + ddev: &TyrDrmDevice<Registered>,
>> + _reg_data: &TyrDrmRegistrationData<'_>,
>> + bocreate: &mut uapi::drm_panthor_bo_create,
>> + file: &TyrDrmFile,
>> + ) -> Result<u32> {
>> + if bocreate.size == 0
>> + || bocreate.pad != 0
>> + || bocreate.flags & !uapi::drm_panthor_bo_flags_DRM_PANTHOR_BO_NO_MMAP != 0
>> + || bocreate.exclusive_vm_id != 0
>> + {
>> + dev_err!(
>> + ddev.as_ref(),
>> + "Invalid BO_CREATE params: size={}, pad={}, flags={:#x}, exclusive_vm_id={}\n",
>> + bocreate.size,
>> + bocreate.pad,
>> + bocreate.flags,
>> + bocreate.exclusive_vm_id
>> + );
>> + return Err(EINVAL);
>> + }
>> +
>> + let size = usize::try_from(bocreate.size).map_err(|_| {
>> + dev_err!(
>> + ddev.as_ref(),
>> + "BO_CREATE size {:#x} too large\n",
>> + bocreate.size
>> + );
>> + EINVAL
>> + })?;
>> + let bo = crate::gem::new_object(ddev, size, bocreate.flags)?;
>> + bocreate.handle = bo.create_handle(file)?;
>> + bocreate.size = bo.size() as u64;
>> +
>> + Ok(0)
>> + }
>> +
>> + pub(crate) fn bo_mmap_offset(
>> + ddev: &TyrDrmDevice<Registered>,
>> + _reg_data: &TyrDrmRegistrationData<'_>,
>> + bommap: &mut uapi::drm_panthor_bo_mmap_offset,
>> + file: &TyrDrmFile,
>> + ) -> Result<u32> {
>> + if bommap.pad != 0 {
>> + dev_err!(
>> + ddev.as_ref(),
>> + "BO mmap offset pad not zero: {}\n",
>> + bommap.pad
>> + );
>> + return Err(EINVAL);
>> + }
>> +
>> + let bo = crate::gem::lookup_handle(file, bommap.handle).inspect_err(|_| {
>> + dev_err!(ddev.as_ref(), "Invalid BO mmap handle: {}\n", bommap.handle);
>> + })?;
>> + if bo.create_flags() & uapi::drm_panthor_bo_flags_DRM_PANTHOR_BO_NO_MMAP != 0 {
>> + dev_err!(ddev.as_ref(), "BO mmap offset on NO_MMAP object\n");
>> + return Err(EPERM);
>> + }
>> + bommap.offset = bo.create_mmap_offset().inspect_err(|_| {
>> + dev_err!(
>> + ddev.as_ref(),
>> + "Failed to create mmap offset for handle {}\n",
>> + bommap.handle
>> + );
>> + })?;
>> +
>> + Ok(0)
>> + }
>> }
>>
>> fn vm_bind_exec_op(vm: &Vm<'_>, file: &TyrDrmFile, op: &VmBindOp) -> Result {
>> diff --git a/drivers/gpu/drm/tyr/gem.rs b/drivers/gpu/drm/tyr/gem.rs
>> index d9ddcb287f52b..f404139f54f32 100644
>> --- a/drivers/gpu/drm/tyr/gem.rs
>> +++ b/drivers/gpu/drm/tyr/gem.rs
>> @@ -38,6 +38,13 @@ pub(crate) struct BoData {
>> flags: u32,
>> }
>>
>> +impl BoData {
>> + /// Returns the flags the BO was created with.
>> + pub(crate) fn create_flags(&self) -> u32 {
> I would prefer flags() instead of create_flags(), which reads a bit more like a constructor.
>
>> + self.flags
>> + }
>> +}
>> +
>> /// Provides a way to pass arguments when creating BoData
>> /// as required by the gem::DriverObject trait.
>> pub(crate) struct BoCreateArgs {
>>
>> --
>> 2.43.0
>>
>>
>>
next prev parent reply other threads:[~2026-09-08 14:25 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 16:08 [PATCH 0/9] drm/tyr: add VM and BO ioctl support Ke Sun via B4 Relay
2026-09-01 16:09 ` [PATCH 1/9] rust: sizes: add SZ_4G constant Ke Sun via B4 Relay
2026-09-02 12:57 ` Daniel Almeida
2026-09-06 12:47 ` Gary Guo
2026-09-01 16:09 ` [PATCH 2/9] rust: mm: add `task_size` helper Ke Sun via B4 Relay
2026-09-03 13:09 ` Daniel Almeida
2026-09-01 16:09 ` [PATCH 3/9] rust: sync: arc: relax `ForeignOwnable` for `Arc<T>` Ke Sun via B4 Relay
2026-09-03 13:12 ` Daniel Almeida
2026-09-06 12:47 ` Gary Guo
2026-09-01 16:09 ` [PATCH 4/9] drm/tyr: add per-file VM pool Ke Sun via B4 Relay
2026-09-03 17:51 ` Daniel Almeida
2026-09-01 16:09 ` [PATCH 5/9] drm/tyr: add user and MCU VM specifications Ke Sun via B4 Relay
2026-09-03 18:10 ` Daniel Almeida
2026-09-01 16:09 ` [PATCH 6/9] drm/tyr: add BO creation and lookup helpers Ke Sun via B4 Relay
2026-09-03 22:06 ` Daniel Almeida
2026-09-01 16:09 ` [PATCH 7/9] drm/tyr: refactor new_dummy_object to use new_object Ke Sun via B4 Relay
2026-09-03 22:16 ` Daniel Almeida
2026-09-01 16:09 ` [PATCH 8/9] drm/tyr: add VM-related ioctls Ke Sun via B4 Relay
2026-09-04 18:44 ` Daniel Almeida
2026-09-01 16:09 ` [PATCH 9/9] drm/tyr: add BO-related ioctls Ke Sun via B4 Relay
2026-09-04 20:35 ` Daniel Almeida
2026-09-08 14:24 ` Alvin Sun [this message]
2026-09-02 0:14 ` [PATCH 0/9] drm/tyr: add VM and BO ioctl support Deborah Brouwer
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=cbe03927-afdb-4558-9196-e57d899b8d01@linux.dev \
--to=alvin.sun@linux.dev \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=lossin@kernel.org \
--cc=lyude@redhat.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=sunke@kylinos.cn \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®