From patchwork Wed Mar 19 14:52:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 14022671 X-Patchwork-Delegate: bhelgaas@google.com Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E98A12C499; Wed, 19 Mar 2025 14:53:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742396036; cv=none; b=UNGEifcufagRhaNHHCa1QHtSZoWyyuklN6ihE/4HlRsCXhCOkDWtcxtPur6euoFQFBskEUL+AXNfIOpsopr+C1CeD4q19ZoAjcagxBUL6jffVIeHzxqmOmuJ8mMhXLsJ2cUYZWk5NdR8CohwmNsrya8IQcf9co1Hck4vofozSBY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742396036; c=relaxed/simple; bh=LmRLcecLfEFxwXOfArnFJcuffCvuhH8QBekLkUi9knM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Pb/geRZhnSR/MI+NEDC1lVnanLySSKCe1Y/ACjX+XAe5y15352mXC1Nnl5R2O5ACUXF2yOCudXVBHdNXZJpXVKZeMBev1Xgoj72Ow9Doanvp07v7LW/LDt89icN/SVa5QJzDYQiF2ipUPgQgsnHZeOf6skgtNiWmx8UmunXJzgU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YtanLpIj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YtanLpIj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03EC9C4CEE4; Wed, 19 Mar 2025 14:53:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1742396036; bh=LmRLcecLfEFxwXOfArnFJcuffCvuhH8QBekLkUi9knM=; h=From:To:Cc:Subject:Date:From; b=YtanLpIj9G60dVc0/KSfhNAmPL/miWNx6MXQXTg1AYbPPmlPv/nAVWTJG93cZ3EOB kBnBTDjFNduRtvBxoDtfQFzgNQ4ZzYYf/w9+Sgj4LidYMzlv6dBdxS6nARUDf867dz AeBGBKwmQ8tfvU9IxpkB4rnMgKOTHXwgY6crfZyMVx0PzHsfZJA3+aIrV1Xza1IRK+ BQRHE0c0IvIAO/v7iRTJsn16BmRJUf10FqIbTZ9twUCIXU85E80ameHcAWz9EgQXmn 7/TuISM2Da0O/1ONcUQesoz3RpnVXW7TPoGQvrX7utUpY3ZwrqpTDGQPHwJQIqJLA4 fp09hen6hNGIA== From: Danilo Krummrich To: bhelgaas@google.com, gregkh@linuxfoundation.org, rafael@kernel.org, ojeda@kernel.org, alex.gaynor@gmail.com, boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, benno.lossin@proton.me, a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu Cc: linux-pci@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Danilo Krummrich Subject: [PATCH 1/2] rust: pci: require Send for Driver trait implementers Date: Wed, 19 Mar 2025 15:52:55 +0100 Message-ID: <20250319145350.69543-1-dakr@kernel.org> X-Mailer: git-send-email 2.48.1 Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Closes: https://lore.kernel.org/lkml/Z9rDxOJ2V2bPjj5i@google.com/ Signed-off-by: Danilo Krummrich Reviewed-by: Benno Lossin --- 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: From patchwork Wed Mar 19 14:52:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 14022672 X-Patchwork-Delegate: bhelgaas@google.com Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 322B912C499; Wed, 19 Mar 2025 14:53:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742396040; cv=none; b=AA2BrP5Z0Lg+1jzSIGAn1/txPt09vL1JEpi48kpjIboBRJsvOkgmLGTaNVQBtpB1RgLC4Lhz9ZCLvfvKU2FcumnEBefaJi3dOq3eAV2yZVXzk1QyZ4QIeYxwnmtakN/PCrojrN3FZaYIGUQn3grEyaOjsYdZIsOLcOB2Kl/gRhk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742396040; c=relaxed/simple; bh=UbK7w+zXIirXffFtrlTXfemOE22THTSAu37y25idMog=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=moHU8m618CnfRVwN9iOFMU1I2oqXqbBbX91WuXGtC9UitBOVPRWvf12byTI04QpLb5KrEQ7r024F1C8KtLdiDR407ZNWNyF/+oKvMQCLu2yrZUoyagGx+3JBG3drkKN3E0yrpFsObFoM7lmQoRLyTkmUi5+J8HFK0Bl3o56UXMQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Y4qD2VAX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Y4qD2VAX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CA14C4CEEC; Wed, 19 Mar 2025 14:53:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1742396039; bh=UbK7w+zXIirXffFtrlTXfemOE22THTSAu37y25idMog=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y4qD2VAXSvm2lK+Tgjl7+RXJZRdsk4arFDNiB8407Z3Q1AI2bWv7vKlOZhbYc4RQS uCQpUvXtsBQpIxyVwtOvSGcdZAIs9yUsHNwnzdDjP4gEI3YhDoRmHA2JUEsEgHVQzM eB2vG2dZq8koIEATdNPt+0tlPtc2V2vW4xSOztH+Sbiv/I0KmpiZKKDFyi5Q/pCkoB UQYQ2UE7Ijiap1Sqgo3TE3kSeHNkqUNbVoWk/NIFA+arg7jltcNgqgaGVcboVPoXKb uBOxo/ALVfo2SBaK6aEEUcKlDohZ1covUS5SN7DFMLdKL1zQRlSdYdwA+rfFsU72an X32rKGq2lNobA== From: Danilo Krummrich To: bhelgaas@google.com, gregkh@linuxfoundation.org, rafael@kernel.org, ojeda@kernel.org, alex.gaynor@gmail.com, boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, benno.lossin@proton.me, a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu Cc: linux-pci@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Danilo Krummrich Subject: [PATCH 2/2] rust: platform: require Send for Driver trait implementers Date: Wed, 19 Mar 2025 15:52:56 +0100 Message-ID: <20250319145350.69543-2-dakr@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250319145350.69543-1-dakr@kernel.org> References: <20250319145350.69543-1-dakr@kernel.org> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Closes: https://lore.kernel.org/lkml/Z9rDxOJ2V2bPjj5i@google.com/ Signed-off-by: Danilo Krummrich Reviewed-by: Benno Lossin --- 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: