rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] rust: pci: require Send for Driver trait implementers
@ 2025-03-19 14:52 Danilo Krummrich
  2025-03-19 14:52 ` [PATCH 2/2] rust: platform: " Danilo Krummrich
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Danilo Krummrich @ 2025-03-19 14:52 UTC (permalink / raw)
  To: bhelgaas, gregkh, rafael, ojeda, alex.gaynor, boqun.feng, gary,
	bjorn3_gh, benno.lossin, a.hindborg, aliceryhl, tmgross
  Cc: linux-pci, rust-for-linux, linux-kernel, 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")
Reported-by: Alice Ryhl <aliceryhl@google.com>
Closes: https://lore.kernel.org/lkml/Z9rDxOJ2V2bPjj5i@google.com/
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
---
 rust/kernel/pci.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs
index 0d09ae34a64d..22a32172b108 100644
--- a/rust/kernel/pci.rs
+++ b/rust/kernel/pci.rs
@@ -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:
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] rust: platform: require Send for Driver trait implementers
  2025-03-19 14:52 [PATCH 1/2] rust: pci: require Send for Driver trait implementers Danilo Krummrich
@ 2025-03-19 14:52 ` Danilo Krummrich
  2025-03-19 15:02   ` Benno Lossin
  2025-03-19 15:02 ` [PATCH 1/2] rust: pci: " Benno Lossin
  2025-03-19 17:03 ` Greg KH
  2 siblings, 1 reply; 7+ messages in thread
From: Danilo Krummrich @ 2025-03-19 14:52 UTC (permalink / raw)
  To: bhelgaas, gregkh, rafael, ojeda, alex.gaynor, boqun.feng, gary,
	bjorn3_gh, benno.lossin, a.hindborg, aliceryhl, tmgross
  Cc: linux-pci, rust-for-linux, linux-kernel, 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")
Reported-by: Alice Ryhl <aliceryhl@google.com>
Closes: https://lore.kernel.org/lkml/Z9rDxOJ2V2bPjj5i@google.com/
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
---
 rust/kernel/platform.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/platform.rs b/rust/kernel/platform.rs
index 2811ca53d8b6..e37531bae8e9 100644
--- a/rust/kernel/platform.rs
+++ b/rust/kernel/platform.rs
@@ -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:
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] rust: platform: require Send for Driver trait implementers
  2025-03-19 14:52 ` [PATCH 2/2] rust: platform: " Danilo Krummrich
@ 2025-03-19 15:02   ` Benno Lossin
  0 siblings, 0 replies; 7+ messages in thread
From: Benno Lossin @ 2025-03-19 15:02 UTC (permalink / raw)
  To: Danilo Krummrich, bhelgaas, gregkh, rafael, ojeda, alex.gaynor,
	boqun.feng, gary, bjorn3_gh, a.hindborg, aliceryhl, tmgross
  Cc: linux-pci, rust-for-linux, linux-kernel

On Wed Mar 19, 2025 at 3:52 PM CET, Danilo Krummrich wrote:
> 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")
> Reported-by: Alice Ryhl <aliceryhl@google.com>
> Closes: https://lore.kernel.org/lkml/Z9rDxOJ2V2bPjj5i@google.com/
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>

Good catch Alice!

Reviewed-by: Benno Lossin <benno.lossin@proton.me>

---
Cheers,
Benno

> ---
>  rust/kernel/platform.rs | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/rust/kernel/platform.rs b/rust/kernel/platform.rs
> index 2811ca53d8b6..e37531bae8e9 100644
> --- a/rust/kernel/platform.rs
> +++ b/rust/kernel/platform.rs
> @@ -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:



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] rust: pci: require Send for Driver trait implementers
  2025-03-19 14:52 [PATCH 1/2] rust: pci: require Send for Driver trait implementers Danilo Krummrich
  2025-03-19 14:52 ` [PATCH 2/2] rust: platform: " Danilo Krummrich
@ 2025-03-19 15:02 ` Benno Lossin
  2025-03-19 17:03 ` Greg KH
  2 siblings, 0 replies; 7+ messages in thread
From: Benno Lossin @ 2025-03-19 15:02 UTC (permalink / raw)
  To: Danilo Krummrich, bhelgaas, gregkh, rafael, ojeda, alex.gaynor,
	boqun.feng, gary, bjorn3_gh, a.hindborg, aliceryhl, tmgross
  Cc: linux-pci, rust-for-linux, linux-kernel

On Wed Mar 19, 2025 at 3:52 PM CET, Danilo Krummrich wrote:
> 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")
> Reported-by: Alice Ryhl <aliceryhl@google.com>
> Closes: https://lore.kernel.org/lkml/Z9rDxOJ2V2bPjj5i@google.com/
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>

Reviewed-by: Benno Lossin <benno.lossin@proton.me>

---
Cheers,
Benno

> ---
>  rust/kernel/pci.rs | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs
> index 0d09ae34a64d..22a32172b108 100644
> --- a/rust/kernel/pci.rs
> +++ b/rust/kernel/pci.rs
> @@ -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:



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] rust: pci: require Send for Driver trait implementers
  2025-03-19 14:52 [PATCH 1/2] rust: pci: require Send for Driver trait implementers Danilo Krummrich
  2025-03-19 14:52 ` [PATCH 2/2] rust: platform: " Danilo Krummrich
  2025-03-19 15:02 ` [PATCH 1/2] rust: pci: " Benno Lossin
@ 2025-03-19 17:03 ` Greg KH
  2025-03-19 17:11   ` Danilo Krummrich
  2 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2025-03-19 17:03 UTC (permalink / raw)
  To: Danilo Krummrich
  Cc: bhelgaas, rafael, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	benno.lossin, a.hindborg, aliceryhl, tmgross, linux-pci,
	rust-for-linux, linux-kernel

On Wed, Mar 19, 2025 at 03:52:55PM +0100, Danilo Krummrich wrote:
> 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")
> Reported-by: Alice Ryhl <aliceryhl@google.com>
> Closes: https://lore.kernel.org/lkml/Z9rDxOJ2V2bPjj5i@google.com/
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
> ---
>  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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] rust: pci: require Send for Driver trait implementers
  2025-03-19 17:03 ` Greg KH
@ 2025-03-19 17:11   ` Danilo Krummrich
  2025-03-19 17:55     ` Greg KH
  0 siblings, 1 reply; 7+ messages in thread
From: Danilo Krummrich @ 2025-03-19 17:11 UTC (permalink / raw)
  To: Greg KH
  Cc: bhelgaas, rafael, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	benno.lossin, a.hindborg, aliceryhl, tmgross, linux-pci,
	rust-for-linux, linux-kernel

On Wed, Mar 19, 2025 at 10:03:49AM -0700, Greg KH wrote:
> On Wed, Mar 19, 2025 at 03:52:55PM +0100, Danilo Krummrich wrote:
> > 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")
> > Reported-by: Alice Ryhl <aliceryhl@google.com>
> > Closes: https://lore.kernel.org/lkml/Z9rDxOJ2V2bPjj5i@google.com/
> > Signed-off-by: Danilo Krummrich <dakr@kernel.org>
> > ---
> >  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?

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] rust: pci: require Send for Driver trait implementers
  2025-03-19 17:11   ` Danilo Krummrich
@ 2025-03-19 17:55     ` Greg KH
  0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2025-03-19 17:55 UTC (permalink / raw)
  To: Danilo Krummrich
  Cc: bhelgaas, rafael, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	benno.lossin, a.hindborg, aliceryhl, tmgross, linux-pci,
	rust-for-linux, linux-kernel

On Wed, Mar 19, 2025 at 06:11:13PM +0100, Danilo Krummrich wrote:
> On Wed, Mar 19, 2025 at 10:03:49AM -0700, Greg KH wrote:
> > On Wed, Mar 19, 2025 at 03:52:55PM +0100, Danilo Krummrich wrote:
> > > 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")
> > > Reported-by: Alice Ryhl <aliceryhl@google.com>
> > > Closes: https://lore.kernel.org/lkml/Z9rDxOJ2V2bPjj5i@google.com/
> > > Signed-off-by: Danilo Krummrich <dakr@kernel.org>
> > > ---
> > >  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?
> 
> 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.

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

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-03-19 17:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-19 14:52 [PATCH 1/2] rust: pci: require Send for Driver trait implementers Danilo Krummrich
2025-03-19 14:52 ` [PATCH 2/2] rust: platform: " Danilo Krummrich
2025-03-19 15:02   ` Benno Lossin
2025-03-19 15:02 ` [PATCH 1/2] rust: pci: " Benno Lossin
2025-03-19 17:03 ` Greg KH
2025-03-19 17:11   ` Danilo Krummrich
2025-03-19 17:55     ` Greg KH

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).