Skip to contentSkip to conversation

rust: pci: require Send for Driver trait implementers

PATCH In review Danilo Krummrich 3 participants 7 messages Mar 19, 2025

Subsystems (4)
lore
Share & tools
lore

Danilo Krummrich

author maintainer
#0 lore raw

PATCH 1/2 rust: pci: require Send for Driver trait implementers

The instance of Self, returned and created by Driver::probe() is dropped in the bus' remove() callback.

Request implementers of the Driver trait to implement Send, since the remove() callback is not guaranteed to run from the same thread as probe().

Fixes 1bd8b6b2c5d3 ("rust: pci: add basic PCI device / driver abstractions")
---
 rust/kernel/pci.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
rust/kernel/pci.rs +1 -1
index 0d09ae34a64d..22a32172b108 100644
@@ -222,7 +222,7 @@ macro_rules! pci_device_table {
 ///```
 /// Drivers must implement this trait in order to get a PCI driver registered. Please refer to the
 /// `Adapter` documentation for an example.
-pub trait Driver {
+pub trait Driver: Send {
     /// The type holding information about each device id supported by the driver.
     ///
     /// TODO: Use associated_type_defaults once stabilized:
Signature · 1 line
2.48.1
author maintainer
#1 lore raw

PATCH 2/2 rust: platform: require Send for Driver trait implementers

The instance of Self, returned and created by Driver::probe() is dropped in the bus' remove() callback.

Request implementers of the Driver trait to implement Send, since the remove() callback is not guaranteed to run from the same thread as probe().

Fixes 683a63befc73 ("rust: platform: add basic platform device / driver abstractions")
---
 rust/kernel/platform.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
rust/kernel/platform.rs +1 -1
index 2811ca53d8b6..e37531bae8e9 100644
@@ -149,7 +149,7 @@ macro_rules! module_platform_driver {
 ///     }
 /// }
 ///```
-pub trait Driver {
+pub trait Driver: Send {
     /// The type holding driver private data about each device id supported by the driver.
     ///
     /// TODO: Use associated_type_defaults once stabilized:
Signature · 1 line
2.48.1
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] rust: platform: require Send for Driver trait implementers

Quoted 11 lines · Danilo Krummrich

The instance of Self, returned and created by Driver::probe() is dropped in the bus' remove() callback.

Request implementers of the Driver trait to implement Send, since the remove() callback is not guaranteed to run from the same thread as probe().

Fixes 683a63befc73 ("rust: platform: add basic platform device / driver abstractions")

Good catch Alice!

---
Cheers,
Benno

Quoted 17 lines
---
 rust/kernel/platform.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
rust/kernel/platform.rs +1 -1
index 2811ca53d8b6..e37531bae8e9 100644
@@ -149,7 +149,7 @@ macro_rules! module_platform_driver {
 ///     }
 /// }
 ///```
-pub trait Driver {
+pub trait Driver: Send {
     /// The type holding driver private data about each device id supported by the driver.
     ///
     /// TODO: Use associated_type_defaults once stabilized:
Reviewed-by on v1 1/2
#3 lore raw
In reply to Danilo Krummrich
Quoted 11 lines · Danilo Krummrich

The instance of Self, returned and created by Driver::probe() is dropped in the bus' remove() callback.

Request implementers of the Driver trait to implement Send, since the remove() callback is not guaranteed to run from the same thread as probe().

Fixes 1bd8b6b2c5d3 ("rust: pci: add basic PCI device / driver abstractions")

---
Cheers,
Benno

Quoted 17 lines
---
 rust/kernel/pci.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
rust/kernel/pci.rs +1 -1
index 0d09ae34a64d..22a32172b108 100644
@@ -222,7 +222,7 @@ macro_rules! pci_device_table {
 ///```
 /// Drivers must implement this trait in order to get a PCI driver registered. Please refer to the
 /// `Adapter` documentation for an example.
-pub trait Driver {
+pub trait Driver: Send {
     /// The type holding information about each device id supported by the driver.
     ///
     /// TODO: Use associated_type_defaults once stabilized:
maintainer
#4 lore raw
In reply to Danilo Krummrich
Quoted 7 lines · Danilo Krummrich

The instance of Self, returned and created by Driver::probe() is dropped in the bus' remove() callback.

Request implementers of the Driver trait to implement Send, since the remove() callback is not guaranteed to run from the same thread as probe().

Quoted 7 lines
Fixes 1bd8b6b2c5d3 ("rust: pci: add basic PCI device / driver abstractions")
---
 rust/kernel/pci.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

As there's no in-kernel users of these, any objection for me to take them for 6.15-rc1, or should they go now to Linus for 6.14-final?

thanks,

greg k-h

author maintainer
#5 lore raw
Quoted 16 lines · Greg KH
Quoted 7 lines · Danilo Krummrich

The instance of Self, returned and created by Driver::probe() is dropped in the bus' remove() callback.

Request implementers of the Driver trait to implement Send, since the remove() callback is not guaranteed to run from the same thread as probe().

Quoted 7 lines
Fixes 1bd8b6b2c5d3 ("rust: pci: add basic PCI device / driver abstractions")
---
 rust/kernel/pci.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 2 lines

As there's no in-kernel users of these, any objection for me to take them for 6.15-rc1, or should they go now to Linus for 6.14-final?

I think it's fine to take them for 6.15-rc1 only.

--

Note that, while those patches can be taken "as is" to stable trees, they require

rust: platform: impl Send + Sync for platform::Device
rust: pci: impl Send + Sync for pci::Device

as well, if

	7b948a2af6b5 ("rust: pci: fix unrestricted &mut pci::Device")
	4d320e30ee04 ("rust: platform: fix unrestricted &mut platform::Device")

are in the same tree.

maintainer
#6 lore raw
Quoted 30 lines · Danilo Krummrich
Quoted 16 lines · Greg KH
Quoted 7 lines · Danilo Krummrich

The instance of Self, returned and created by Driver::probe() is dropped in the bus' remove() callback.

Request implementers of the Driver trait to implement Send, since the remove() callback is not guaranteed to run from the same thread as probe().

Quoted 7 lines
Fixes 1bd8b6b2c5d3 ("rust: pci: add basic PCI device / driver abstractions")
---
 rust/kernel/pci.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 2 lines

As there's no in-kernel users of these, any objection for me to take them for 6.15-rc1, or should they go now to Linus for 6.14-final?

I think it's fine to take them for 6.15-rc1 only.

--

Note that, while those patches can be taken "as is" to stable trees, they require

rust: platform: impl Send + Sync for platform::Device
rust: pci: impl Send + Sync for pci::Device

Quoted 6 lines

as well, if

	7b948a2af6b5 ("rust: pci: fix unrestricted &mut pci::Device")
	4d320e30ee04 ("rust: platform: fix unrestricted &mut platform::Device")

are in the same tree.

Cool, I'll deal with that in a few weeks when -rc1 is out, thanks for the warning.

greg k-h