This patch sereis implements basic generic device / driver Rust abstractions,
as well as some basic PCI abstractions.
This patch series is sent in the context of [1], and the corresponding patch
series [2], which contains some basic DRM Rust abstractions and a stub
implementation of the Nova GPU driver.
Nova is intended to be developed upstream, starting out with just a stub driver
to lift some initial required infrastructure upstream. A more detailed
explanation can be found in [1].
Some patches, which implement the generic device / driver Rust abstractions have
been sent a couple of weeks ago already [3]. For those patches the following
changes have been made since then:
- remove RawDevice::name()
- remove rust helper for dev_name() and dev_get_drvdata()
- use AlwaysRefCounted for struct Device
- drop trait RawDevice entirely in favor of AsRef and provide
Device::from_raw(), Device::as_raw() and Device::as_ref() instead
- implement RevocableGuard
- device::Data, remove resources and replace it with a Devres abstraction
- implement Devres abstraction for resources
As mentioned above, a driver serving as example on how these abstractions are
used within a (DRM) driver can be found in [2].
Additionally, the device / driver bits can also be found in [3], all
abstractions required for Nova in [4] and Nova in [5].
[1] https://lore.kernel.org/dri-devel/Zfsj0_tb-0-tNrJy@cassiopeiae/T/#u
[2] https://lore.kernel.org/dri-devel/[email protected]/
[3] https://github.com/Rust-for-Linux/linux/tree/staging/rust-device
[4] https://github.com/Rust-for-Linux/linux/tree/staging/dev
[5] https://gitlab.freedesktop.org/drm/nova/-/tree/nova-next
Danilo Krummrich (2):
rust: add abstraction for struct device
rust: add devres abstraction
FUJITA Tomonori (1):
rust: add basic PCI driver abstractions
Philipp Stanner (2):
rust: add basic abstractions for iomem operations
rust: PCI: add BAR request and ioremap
Wedson Almeida Filho (6):
rust: add driver abstraction
rust: add rcu abstraction
rust: add revocable mutex
rust: add revocable objects
rust: add device::Data
rust: add `dev_*` print macros.
rust/bindings/bindings_helper.h | 1 +
rust/helpers.c | 145 ++++++++++
rust/kernel/device.rs | 498 ++++++++++++++++++++++++++++++++
rust/kernel/devres.rs | 151 ++++++++++
rust/kernel/driver.rs | 492 +++++++++++++++++++++++++++++++
rust/kernel/iomem.rs | 135 +++++++++
rust/kernel/lib.rs | 10 +-
rust/kernel/pci.rs | 449 ++++++++++++++++++++++++++++
rust/kernel/prelude.rs | 2 +
rust/kernel/revocable.rs | 441 ++++++++++++++++++++++++++++
rust/kernel/sync.rs | 3 +
rust/kernel/sync/rcu.rs | 52 ++++
rust/kernel/sync/revocable.rs | 148 ++++++++++
rust/macros/module.rs | 2 +-
samples/rust/rust_minimal.rs | 2 +-
samples/rust/rust_print.rs | 2 +-
16 files changed, 2529 insertions(+), 4 deletions(-)
create mode 100644 rust/kernel/device.rs
create mode 100644 rust/kernel/devres.rs
create mode 100644 rust/kernel/driver.rs
create mode 100644 rust/kernel/iomem.rs
create mode 100644 rust/kernel/pci.rs
create mode 100644 rust/kernel/revocable.rs
create mode 100644 rust/kernel/sync/rcu.rs
create mode 100644 rust/kernel/sync/revocable.rs
base-commit: 97ab3e8eec0ce79d9e265e6c9e4c480492180409
--
2.45.1
On Mon, May 20, 2024 at 07:25:37PM +0200, Danilo Krummrich wrote:
> This patch sereis implements basic generic device / driver Rust abstractions,
> as well as some basic PCI abstractions.
>
> This patch series is sent in the context of [1], and the corresponding patch
> series [2], which contains some basic DRM Rust abstractions and a stub
> implementation of the Nova GPU driver.
>
> Nova is intended to be developed upstream, starting out with just a stub driver
> to lift some initial required infrastructure upstream. A more detailed
> explanation can be found in [1].
>
> Some patches, which implement the generic device / driver Rust abstractions have
> been sent a couple of weeks ago already [3]. For those patches the following
> changes have been made since then:
>
> - remove RawDevice::name()
> - remove rust helper for dev_name() and dev_get_drvdata()
> - use AlwaysRefCounted for struct Device
> - drop trait RawDevice entirely in favor of AsRef and provide
> Device::from_raw(), Device::as_raw() and Device::as_ref() instead
> - implement RevocableGuard
> - device::Data, remove resources and replace it with a Devres abstraction
> - implement Devres abstraction for resources
>
> As mentioned above, a driver serving as example on how these abstractions are
> used within a (DRM) driver can be found in [2].
>
> Additionally, the device / driver bits can also be found in [3], all
> abstractions required for Nova in [4] and Nova in [5].
>
> [1] https://lore.kernel.org/dri-devel/Zfsj0_tb-0-tNrJy@cassiopeiae/T/#u
> [2] https://lore.kernel.org/dri-devel/[email protected]/
> [3] https://github.com/Rust-for-Linux/linux/tree/staging/rust-device
> [4] https://github.com/Rust-for-Linux/linux/tree/staging/dev
> [5] https://gitlab.freedesktop.org/drm/nova/-/tree/nova-next
>
> Danilo Krummrich (2):
> rust: add abstraction for struct device
> rust: add devres abstraction
>
> FUJITA Tomonori (1):
> rust: add basic PCI driver abstractions
>
> Philipp Stanner (2):
> rust: add basic abstractions for iomem operations
> rust: PCI: add BAR request and ioremap
>
> Wedson Almeida Filho (6):
> rust: add driver abstraction
> rust: add rcu abstraction
> rust: add revocable mutex
> rust: add revocable objects
> rust: add device::Data
> rust: add `dev_*` print macros.
No list of the changes made since the last time this was submitted?
No versioning of this submission?
Why not?
thanks,
greg k-h
On Mon, May 20, 2024 at 08:14:57PM +0200, Greg KH wrote:
> On Mon, May 20, 2024 at 07:25:37PM +0200, Danilo Krummrich wrote:
> > This patch sereis implements basic generic device / driver Rust abstractions,
> > as well as some basic PCI abstractions.
> >
> > This patch series is sent in the context of [1], and the corresponding patch
> > series [2], which contains some basic DRM Rust abstractions and a stub
> > implementation of the Nova GPU driver.
> >
> > Nova is intended to be developed upstream, starting out with just a stub driver
> > to lift some initial required infrastructure upstream. A more detailed
> > explanation can be found in [1].
> >
> > Some patches, which implement the generic device / driver Rust abstractions have
> > been sent a couple of weeks ago already [3]. For those patches the following
> > changes have been made since then:
> >
> > - remove RawDevice::name()
> > - remove rust helper for dev_name() and dev_get_drvdata()
> > - use AlwaysRefCounted for struct Device
> > - drop trait RawDevice entirely in favor of AsRef and provide
> > Device::from_raw(), Device::as_raw() and Device::as_ref() instead
> > - implement RevocableGuard
> > - device::Data, remove resources and replace it with a Devres abstraction
> > - implement Devres abstraction for resources
Ah, here's the difference from the last time, sorry, it wasn't obvious.
Still nothing about proper handling and use of 'remove' in the context
of all of this, that's something you really really really need to get
right if you want to attempt to have a driver in rust interact with the
driver core properly.
thanks,
greg k-h
On Mon, May 20, 2024 at 08:16:19PM +0200, Greg KH wrote:
> On Mon, May 20, 2024 at 08:14:57PM +0200, Greg KH wrote:
> > On Mon, May 20, 2024 at 07:25:37PM +0200, Danilo Krummrich wrote:
> > > This patch sereis implements basic generic device / driver Rust abstractions,
> > > as well as some basic PCI abstractions.
> > >
> > > This patch series is sent in the context of [1], and the corresponding patch
> > > series [2], which contains some basic DRM Rust abstractions and a stub
> > > implementation of the Nova GPU driver.
> > >
> > > Nova is intended to be developed upstream, starting out with just a stub driver
> > > to lift some initial required infrastructure upstream. A more detailed
> > > explanation can be found in [1].
> > >
> > > Some patches, which implement the generic device / driver Rust abstractions have
> > > been sent a couple of weeks ago already [3]. For those patches the following
> > > changes have been made since then:
> > >
> > > - remove RawDevice::name()
> > > - remove rust helper for dev_name() and dev_get_drvdata()
> > > - use AlwaysRefCounted for struct Device
> > > - drop trait RawDevice entirely in favor of AsRef and provide
> > > Device::from_raw(), Device::as_raw() and Device::as_ref() instead
> > > - implement RevocableGuard
> > > - device::Data, remove resources and replace it with a Devres abstraction
> > > - implement Devres abstraction for resources
>
> Ah, here's the difference from the last time, sorry, it wasn't obvious.
>
> Still nothing about proper handling and use of 'remove' in the context
> of all of this, that's something you really really really need to get
> right if you want to attempt to have a driver in rust interact with the
> driver core properly.
We were right in the middle of discussing about the correct wording when I sent
those patches the first time. There were some replies from my side, e.g. [1] and
another reply from Wedson [2] about this, which you did not want to reply to any
more.
I'm not saying I insist on not changing those comments up, but first we have to
agree on how we want them to be rephrased, especially since from the
discussions so far I got the impression that we might talk a bit past each
other.
Hence, I'd propose to just continue the discussion, where we need to.
[1] https://lore.kernel.org/rust-for-linux/ZgNCo4Hvs-EjDNGT@pollux/
[2] https://lore.kernel.org/rust-for-linux/CANeycqrdBVJhAiGZdv2NSnz2SUCuDC=04D_JiTF6vfs8iLvjrA@mail.gmail.com/
>
> thanks,
>
> greg k-h
>
On Mon, May 20, 2024 at 09:50:01PM +0200, Danilo Krummrich wrote:
> On Mon, May 20, 2024 at 08:16:19PM +0200, Greg KH wrote:
> > On Mon, May 20, 2024 at 08:14:57PM +0200, Greg KH wrote:
> > > On Mon, May 20, 2024 at 07:25:37PM +0200, Danilo Krummrich wrote:
> > > > This patch sereis implements basic generic device / driver Rust abstractions,
> > > > as well as some basic PCI abstractions.
> > > >
> > > > This patch series is sent in the context of [1], and the corresponding patch
> > > > series [2], which contains some basic DRM Rust abstractions and a stub
> > > > implementation of the Nova GPU driver.
> > > >
> > > > Nova is intended to be developed upstream, starting out with just a stub driver
> > > > to lift some initial required infrastructure upstream. A more detailed
> > > > explanation can be found in [1].
> > > >
> > > > Some patches, which implement the generic device / driver Rust abstractions have
> > > > been sent a couple of weeks ago already [3]. For those patches the following
> > > > changes have been made since then:
> > > >
> > > > - remove RawDevice::name()
> > > > - remove rust helper for dev_name() and dev_get_drvdata()
> > > > - use AlwaysRefCounted for struct Device
> > > > - drop trait RawDevice entirely in favor of AsRef and provide
> > > > Device::from_raw(), Device::as_raw() and Device::as_ref() instead
> > > > - implement RevocableGuard
> > > > - device::Data, remove resources and replace it with a Devres abstraction
> > > > - implement Devres abstraction for resources
> >
> > Ah, here's the difference from the last time, sorry, it wasn't obvious.
> >
> > Still nothing about proper handling and use of 'remove' in the context
> > of all of this, that's something you really really really need to get
> > right if you want to attempt to have a driver in rust interact with the
> > driver core properly.
>
> We were right in the middle of discussing about the correct wording when I sent
> those patches the first time. There were some replies from my side, e.g. [1] and
> another reply from Wedson [2] about this, which you did not want to reply to any
> more.
>
> I'm not saying I insist on not changing those comments up, but first we have to
> agree on how we want them to be rephrased, especially since from the
> discussions so far I got the impression that we might talk a bit past each
> other.
>
> Hence, I'd propose to just continue the discussion, where we need to.
See my responses in this thread, let's continue this there.
thanks,
greg k-h