From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E0873EDEBF8 for ; Tue, 3 Mar 2026 21:15:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3202610E8D0; Tue, 3 Mar 2026 21:15:47 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="X+snYV5Y"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6016210E8E6 for ; Tue, 3 Mar 2026 21:15:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772572544; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nmGZI5WblWd631ssrKt08f4BijC6XK/3q+5rIjFI99c=; b=X+snYV5YDAJDuDwdhgZsnhFnZfstNwyY7PJzJbTCf7i7oUREYurhBsZZqXs8TFjt4XQ3SG pzrkOQ+/uCrutTgiEuBkfK2le0SVVWkltR9l5zrtPz5dL9LluFfjv5g+JqH4Ha7T2k+GtM 9C1mzkHdotWTzvFg6AHomt7t9+MJJaU= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-96-V8flfqiUNMC6VbptG6UTkw-1; Tue, 03 Mar 2026 16:15:43 -0500 X-MC-Unique: V8flfqiUNMC6VbptG6UTkw-1 X-Mimecast-MFC-AGG-ID: V8flfqiUNMC6VbptG6UTkw_1772572542 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-503915b0a88so661311811cf.1 for ; Tue, 03 Mar 2026 13:15:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772572542; x=1773177342; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=nmGZI5WblWd631ssrKt08f4BijC6XK/3q+5rIjFI99c=; b=G0dNnH11Yp9jTzC9NRRrIAGPEO3H08DbkjkPLsCILbl33vsKlVc46j5UnpxviEgj9M w5hiW8s+IWqoABglSjkfqyUr838+ZzpVDbcnIdX67ujhAOH4YE0AHbk/KgtRkj+vAYbf iZJ3Z41xmPBFuKEaaL/7ml+SBorRi7I6v8pO8sAitsK3MU3Tnc8TcWCGFSLmrBHPFeOP sOtVsNcZQbTh2LylqZU7jo6DzDadp/RwToQI5IF2QIDTSQfjgg4mTxe7izutzpvtjK+O ozqRkKStEcQPrMUMXg727h54Ekghyf61/nP3NaczdUrh82wu7bs1RWYlhJJXpIhg/dPS R1Xw== X-Forwarded-Encrypted: i=1; AJvYcCUA709ZyYCcfam+pirRDcdPnEXMSumHD8fGjqiDURv1RHbVqcvCkvPcGWoro1kA5S4uc1FdfBgnVLk=@lists.freedesktop.org X-Gm-Message-State: AOJu0YymjQc3FjtniopbU57rrS2WsSXbXb1EPJaXaitQ0Wbmpj4VgRaE lb0Wlo0No/Zn3S/OR0cgHSh6QYOEXCuJ4aU1ktJxJEIO/Vfcj569Xs7s3TOY2kldMUNaFuLg29/ QeLEkkVE9mf4E5lcc5WNH624N8oObi+zlc4Ttg30mjj6O/NNtyuilQ/Uz400pDFBP4rOyBRSn1n qe7P1+guADx5YsdH9etB1kQh/tMHpE7wCCU1r0Z7ykKufrpNo6slzjrjzY X-Gm-Gg: ATEYQzwogcXHlCHCUEecHP0wg+yW5UO8h7JLUl+1/39zTgUehRPVQXlHsWkLYmDee2B N/pphNPmW6i0YWStMz/dgu5aYubfekPqvDH+dX+BrnOKBs5Wczxl5KvcQdY5Ni8tJ7ZZFbxzVaW 7t1iEOGwqAlKpC/FS0etsGMJqM1iNrN1ZZwDxSMFosWY0E+HWFDcYM1hMnNmhTV8RXzWyVogBSt NQLfNBAPJR5+qu55YfsfmJfusNyymfgfK5qqhEwPq0V4VGBCecqOr3VDhMmUSJmTGOW80XuttTi k6FaBLOjWdQ6QPx35RrVDYF5b1w+uwvO0lUibdv2NpiFvC620M4wdwESB/nOfXfG7xWlJGIGdtL TOFzCTsSrsNjDDJRx6WQttApcUA== X-Received: by 2002:a05:622a:18a8:b0:502:a1bc:5691 with SMTP id d75a77b69052e-507525a5444mr232050931cf.0.1772572542284; Tue, 03 Mar 2026 13:15:42 -0800 (PST) X-Received: by 2002:a05:622a:18a8:b0:502:a1bc:5691 with SMTP id d75a77b69052e-507525a5444mr232049271cf.0.1772572540438; Tue, 03 Mar 2026 13:15:40 -0800 (PST) Received: from [172.16.1.8] ([2607:f2c0:b1e3:9a00:3c7:56c2:f819:96d2]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-5074481c0e5sm156286991cf.0.2026.03.03.13.15.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2026 13:15:40 -0800 (PST) From: Peter Colberg Date: Tue, 03 Mar 2026 16:15:24 -0500 Subject: [PATCH v3 04/10] rust: pci: add vtable attribute to pci::Driver trait MIME-Version: 1.0 Message-Id: <20260303-rust-pci-sriov-v3-4-4443c35f0c88@redhat.com> References: <20260303-rust-pci-sriov-v3-0-4443c35f0c88@redhat.com> In-Reply-To: <20260303-rust-pci-sriov-v3-0-4443c35f0c88@redhat.com> To: Danilo Krummrich , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Miguel Ojeda , Alex Gaynor , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Abdiel Janulgue , Daniel Almeida , Robin Murphy , Greg Kroah-Hartman , Dave Ertman , Ira Weiny , Leon Romanovsky , David Airlie , Simona Vetter , Jonathan Corbet , Xu Yilun , Tom Rix , Moritz Fischer , "Rafael J. Wysocki" , Boqun Feng Cc: linux-pci@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Alexandre Courbot , Alistair Popple , Joel Fernandes , John Hubbard , Zhi Wang , nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-fpga@vger.kernel.org, driver-core@lists.linux.dev, Peter Colberg , Jason Gunthorpe X-Mailer: b4 0.14.2 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: LpqH-z8sPVVsVZFmz5t3wAOF33mpPkaDApAE7fDCP3Q_1772572542 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add the #[vtable] attribute to pci::Driver trait and implementations, to prepare a subsequent patch that adds an optional bus callback sriov_configure() to enable or disable the SR-IOV capability. Suggested-by: Danilo Krummrich Signed-off-by: Peter Colberg --- Changes in v2: - Add missing #[vtable] attribute in PCI driver trait example. - Add missing #[vtable] attribute in nova-core driver. --- drivers/gpu/nova-core/driver.rs | 1 + rust/kernel/pci.rs | 2 ++ samples/rust/rust_dma.rs | 1 + samples/rust/rust_driver_auxiliary.rs | 1 + samples/rust/rust_driver_pci.rs | 1 + 5 files changed, 6 insertions(+) diff --git a/drivers/gpu/nova-core/driver.rs b/drivers/gpu/nova-core/driver.rs index 5a4cc047bcfc9fcef61373ace84ed43958a3bcbd..66a68048006fb33477bb00f61856c1aa92c0a8f1 100644 --- a/drivers/gpu/nova-core/driver.rs +++ b/drivers/gpu/nova-core/driver.rs @@ -64,6 +64,7 @@ pub(crate) struct NovaCore { ] ); +#[vtable] impl pci::Driver for NovaCore { type IdInfo = (); const ID_TABLE: pci::IdTable = &PCI_TABLE; diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs index e1cab1574a3d309d25bf5267c0b0d8da8fb66d44..a4c27c674bd8bdf5e3316789d38d566e90b93fe2 100644 --- a/rust/kernel/pci.rs +++ b/rust/kernel/pci.rs @@ -278,6 +278,7 @@ macro_rules! pci_device_table { /// ] /// ); /// +/// #[vtable] /// impl pci::Driver for MyDriver { /// type IdInfo = (); /// const ID_TABLE: pci::IdTable = &PCI_TABLE; @@ -292,6 +293,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. +#[vtable] pub trait Driver: Send { /// The type holding information about each device id supported by the driver. // TODO: Use `associated_type_defaults` once stabilized: diff --git a/samples/rust/rust_dma.rs b/samples/rust/rust_dma.rs index 9c45851c876ef33414eb0071c42a2fb4ac3f1e78..ae6f7328b830e32bcaf7f8b5f8b1f117135ebf8e 100644 --- a/samples/rust/rust_dma.rs +++ b/samples/rust/rust_dma.rs @@ -51,6 +51,7 @@ unsafe impl kernel::transmute::FromBytes for MyStruct {} [(pci::DeviceId::from_id(pci::Vendor::REDHAT, 0x5), ())] ); +#[vtable] impl pci::Driver for DmaSampleDriver { type IdInfo = (); const ID_TABLE: pci::IdTable = &PCI_TABLE; diff --git a/samples/rust/rust_driver_auxiliary.rs b/samples/rust/rust_driver_auxiliary.rs index 5c5a5105a3fff90f5e396186776e1b3ffdf479b4..2f7ac8f7391f45827c086b704950fd01907c1825 100644 --- a/samples/rust/rust_driver_auxiliary.rs +++ b/samples/rust/rust_driver_auxiliary.rs @@ -65,6 +65,7 @@ struct ParentDriver { [(pci::DeviceId::from_id(pci::Vendor::REDHAT, 0x5), ())] ); +#[vtable] impl pci::Driver for ParentDriver { type IdInfo = (); diff --git a/samples/rust/rust_driver_pci.rs b/samples/rust/rust_driver_pci.rs index d3d4a7931deb0c1085cfd817990737717f466ea9..27e603a9509c19b6845c10ef06a0af897aa0e84b 100644 --- a/samples/rust/rust_driver_pci.rs +++ b/samples/rust/rust_driver_pci.rs @@ -92,6 +92,7 @@ fn config_space(pdev: &pci::Device) { } } +#[vtable] impl pci::Driver for SampleDriver { type IdInfo = TestIndex; -- 2.53.0