From: "Maíra Canal" <mcanal@igalia.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
Miguel Ojeda <ojeda@kernel.org>,
Alex Gaynor <alex.gaynor@gmail.com>,
Wedson Almeida Filho <wedsonaf@gmail.com>,
Boqun Feng <boqun.feng@gmail.com>, Gary Guo <gary@garyguo.net>,
Asahi Lina <lina@asahilina.net>,
Faith Ekstrand <faith.ekstrand@collabora.com>
Cc: "Melissa Wen" <mwen@igalia.com>,
"Maíra Canal" <mcanal@igalia.com>,
dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org
Subject: [RFC PATCH 0/9] Rust version of the VGEM driver
Date: Fri, 17 Mar 2023 09:12:04 -0300 [thread overview]
Message-ID: <20230317121213.93991-1-mcanal@igalia.com> (raw)
This is my first take on using the DRM Rust abstractions [1] to convert a DRM
driver, written originally in C, to Rust. This patchset consists of a conversion
of the vgem driver to a DRM Rust driver. This new driver has the exactly same
functionalities of the original C driver, but takes advantages of all the Rust
features.
These patches are based primarily on the Rust DRM abstractions [1], sent as a
RFC to the mailing list last week. Also, it depends on some Device abstractions
[2] and on the Timer abstraction [3] developed by Boqun Feng.
This patchset introduces some changes to the DRM abstractions proposed in [1]
and also introduces a new abstraction to DMA reservation. Finally, introduces a
fully functional vgem driver written in Rust.
* Patch #1: Introduces a safe abstraction to the DMA Reservation.
* Patch #2 - #5: Introduces some increments to the DRM abstractions, adding
methods and exposing attributes.
* Patch #6: Makes an adaptation to the UAPI, in order to be interpreted by bindgen.
* Patch #7 - #8: Introduces the vgem driver.
* Patch #9: Makes it possible to use the kernel::declare_drm_ioctls! macro.
The driver was tested with IGT, using the tests `vgem_basic`, `vgem_slow` and
`dmabuf_sync_file`. Also, I incremented some invalid tests to `vgem_basic` [4]
to assure the proper error handling of the driver.
A branch with all the dependencies and ready for compilation is available at
[5].
Note that patch #8 is necessary to deal with the current
kernel::declare_drm_ioctls! macro. Currently, the macro
kernel::declare_drm_ioctls! considers that the IOCTLs are in the right order and
there are no gaps, which is not true for vgem. The vgem IOCTLs starts at 0x01,
so there is a gap for IOCTL 0x00. To bypass this problem I'm currently using a
dummy IOCTL as IOCTL 0x00, but this solution should be temporary. I would love
to hear suggestions on how to address this problem.
Any suggestions and SAFETY reviews are welcomed!
[1] https://lore.kernel.org/dri-devel/20230307-rust-drm-v1-0-917ff5bc80a8@asahilina.net/T/
[2] https://github.com/Rust-for-Linux/linux/pull/982
[3] https://github.com/fbq/linux-rust/commit/c31a2a3ce7420b43bda2c6f1b43227baf0d13661
[4] https://patchwork.freedesktop.org/series/114912/
[5] https://github.com/mairacanal/linux/tree/vgem/wip-dma
Best Regards,
- Maíra Canal
Maíra Canal (9):
rust: dma_resv: add DMA Reservation abstraction
rust: drm: gem: add method to return DmaResv from GEMObject
rust: dma_fence: add method to return an indication if the fence is signaled
rust: dma_fence: expose the fence's seqno publically
rust: drm: gem: shmem: set map_wc on gem_create_object callback
drm/vgem: move IOCTLs numbers to enum
drm/rustgem: implement a Rust version of VGEM
drm/rustgem: implement timeout to prevent hangs
drm/rustgem: create dummy IOCTL with number 0x00
drivers/gpu/drm/Kconfig | 11 +++
drivers/gpu/drm/Makefile | 1 +
drivers/gpu/drm/rustgem/Makefile | 3 +
drivers/gpu/drm/rustgem/fence.rs | 83 ++++++++++++++++++
drivers/gpu/drm/rustgem/file.rs | 143 +++++++++++++++++++++++++++++++
drivers/gpu/drm/rustgem/gem.rs | 31 +++++++
drivers/gpu/drm/rustgem/vgem.rs | 105 +++++++++++++++++++++++
include/uapi/drm/vgem_drm.h | 11 ++-
rust/bindings/bindings_helper.h | 2 +
rust/helpers.c | 25 ++++++
rust/kernel/dma_fence.rs | 12 +++
rust/kernel/dma_resv.rs | 75 ++++++++++++++++
rust/kernel/drm/gem/mod.rs | 7 ++
rust/kernel/drm/gem/shmem.rs | 5 ++
rust/kernel/lib.rs | 1 +
15 files changed, 513 insertions(+), 2 deletions(-)
create mode 100644 drivers/gpu/drm/rustgem/Makefile
create mode 100644 drivers/gpu/drm/rustgem/fence.rs
create mode 100644 drivers/gpu/drm/rustgem/file.rs
create mode 100644 drivers/gpu/drm/rustgem/gem.rs
create mode 100644 drivers/gpu/drm/rustgem/vgem.rs
create mode 100644 rust/kernel/dma_resv.rs
--
2.39.2
next reply other threads:[~2023-03-17 12:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-17 12:12 Maíra Canal [this message]
2023-03-17 12:12 ` [RFC PATCH 1/9] rust: dma_resv: add DMA Reservation abstraction Maíra Canal
2023-03-17 12:12 ` [RFC PATCH 2/9] rust: drm: gem: add method to return DmaResv from GEMObject Maíra Canal
2023-03-22 19:45 ` Björn Roy Baron
2023-03-22 19:57 ` Björn Roy Baron
2023-03-17 12:12 ` [RFC PATCH 3/9] rust: dma_fence: add method to return an indication if the fence is signaled Maíra Canal
2023-03-17 12:12 ` [RFC PATCH 4/9] rust: dma_fence: expose the fence's seqno publically Maíra Canal
2023-03-17 12:12 ` [RFC PATCH 5/9] rust: drm: gem: shmem: set map_wc on gem_create_object callback Maíra Canal
2023-03-17 12:12 ` [RFC PATCH 6/9] drm/vgem: move IOCTLs numbers to enum Maíra Canal
2023-03-17 12:12 ` [RFC PATCH 7/9] drm/rustgem: implement a Rust version of VGEM Maíra Canal
2023-03-17 12:12 ` [RFC PATCH 8/9] drm/rustgem: implement timeout to prevent hangs Maíra Canal
2023-03-17 12:12 ` [RFC PATCH 9/9] drm/rustgem: create dummy IOCTL with number 0x00 Maíra Canal
2023-04-13 9:08 ` Daniel Vetter
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=20230317121213.93991-1-mcanal@igalia.com \
--to=mcanal@igalia.com \
--cc=airlied@gmail.com \
--cc=alex.gaynor@gmail.com \
--cc=boqun.feng@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=faith.ekstrand@collabora.com \
--cc=gary@garyguo.net \
--cc=lina@asahilina.net \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=mwen@igalia.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tzimmermann@suse.de \
--cc=wedsonaf@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;
as well as URLs for NNTP newsgroup(s).