From nobody Mon Feb 9 15:11:23 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 4BE44330B3B for ; Thu, 5 Feb 2026 21:00:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770325232; cv=none; b=i8bACQbu4+9jFVuPURP10qkmjLCMSC2rcoQUh8+eHEpl8hkd2em27BGk3yv/TxJlI5UrfkBrhhGgfdwigmlvunMtq47MUBKT0PoF1E9SliE32wGx6bNGPQxFvaz/oYRkp1wt4pbcLt2HwnBrOLcFhCi0wb9/iwDsT2CwWLFy/KY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770325232; c=relaxed/simple; bh=jkpwy4GP+toHnd9AMJZipLXyNcEvG6BNgGl4osE5Tb4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=p8CTAv+hrPD1SnHZpGCmvzSDCQnoSgAiX/4/PDh76vKpyzBuH6qqJ1Ok0a79PmNtnAWX7D9RP2MbGXJPAW0XKnZiYFbUyIbGuguAxevZ09MmQPucbBTVFDcSSTsyed3onlKXbbldOUmYbDzIXfDLBndPx5//tbS6fCsViCfWSQs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=hzqmQK0C; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=JAnT6UMa; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hzqmQK0C"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="JAnT6UMa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770325231; 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=ADQ8gPT48rFRIIyS12cDuNBpt1e1vav+7FNrnrbDyrE=; b=hzqmQK0CNvw3Cu+thmIafXiIRu6LYRd9MaV1VLxPVbQp+UHewitiTiJdIpsAuVCCruhsb0 jwjBpTuqadazh0fQwMiSviFysQ7ofSMaiTcFL+MAZbppJsoKmwUdRagIpLpbOmeqGSid+A swy7nAsk5UhoimflF1ZEE9ezCMp+UNE= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-80-1Trd43CqN5aMR3ygXPljWQ-1; Thu, 05 Feb 2026 16:00:30 -0500 X-MC-Unique: 1Trd43CqN5aMR3ygXPljWQ-1 X-Mimecast-MFC-AGG-ID: 1Trd43CqN5aMR3ygXPljWQ_1770325230 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-8c70e610242so380967785a.2 for ; Thu, 05 Feb 2026 13:00:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1770325230; x=1770930030; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ADQ8gPT48rFRIIyS12cDuNBpt1e1vav+7FNrnrbDyrE=; b=JAnT6UMaNIA9JW4/9YywS/xvrZb4nwmW5NiyPOLO8yVQSY+mdc8d3gqkqAOZqP/MAY +Q/GL31jy3sc5qJ5UI+lsh9kSb86w3cJ82EjvVMerNxNPgjxAGWsa2SRKBZ4o1w4qsyK C9bJlasRoEWQSammJg9CGCwCi8n+mRfqnhESsE6qnI/9+TrkGrQy1HjjHfWZh3B/d/Dp 8u37WFqfkvjVVe9qHYMgRLdwAmcyc48H5wYe5WcmgDxWdu5rQWgorZb38wxBHLO43lNX jAE/Mpbv+2mz/klOPrR68r+XLPysPlgWp6tXoze7oc41ooP4y5XuI2uduf8M3wlBzm35 mz6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770325230; x=1770930030; 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=ADQ8gPT48rFRIIyS12cDuNBpt1e1vav+7FNrnrbDyrE=; b=Zu/vSO7tMcCQb7q3hBT6WTCnus3/ohcxyEoLuDnkyTg11LC0xbBTz15R2guwPDY3Gj vOEApumhzonkyK95+LRjAxBpxw1hsDiTfF+vzxvpLpw4EJiuw3MBshbIMbTV7Q5lcQc2 0tLXAXkzg15JsoQqSqQBKg0z2JVtQ90YReSaO+SgSk+SIb3CIiX/Cj20UDACnbIiik4u jHV//F6yk69cilZaRDLTjplyg4mHVZa1Fcef9jH9pWJkMhLfQ9rjRcCjGjQYvmd7McwU sOeiSaRKOg4S+XoPjN6qTE5ExyGdys6wD2lB9QwZt8DulIpr6mgwdMBpqcWk0VjIbaSI I0Xw== X-Forwarded-Encrypted: i=1; AJvYcCV9LJIbgdqSFgk0zjTloeil/IEXTsRpOfY8NHDIqKPe7DcfoQXHhbw+VqEheEMEkIc0VkdthONv8stjscU=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+TXxfeKZaze4y5BxLf2m6l43Ome9Dx3+9xXMQbmZfEMyN+Bh8 huAVVyVe+tiD8eAZ3kG5DExhFgprIdE7oZpsQFnmQOAQhpCP6NxUhAQSooI4K87WPU4TAYM0WsL p/TmTpINuUb/PfFiPGwAEBsqnNMJnISMl1BTDFJqhABNjwlX9uI1rZQl8BPz9F7xV2GJxL9kVlg == X-Gm-Gg: AZuq6aK0uIYkRK4+PqOOuDvpPNmsw3J3SMzzAIxIL488s873U4+5KjiTEhYNfqv4Omu 3+oraHxbW7kZl11hSnQ+Mlzgul0E2z3JO3dAU9SOklpwusjgJ/98cM5vx3lw39biPM4HSHurbU+ DGDyXFUWwOsWF4YHqp97yjEzDOlxher9tgOg15zJrLKbtRRuYanz4pprD/pI5j+72PCrDPTSSET 236LqVV6p1STDvmDAX/ilyogYZ9CaRD+T2/IasXqF6hDqcSOpye/EE+tS875BVGj2vqy4rPfR9Y c2IdEUL3rXqyIj/5kwnUHCuTPVgMGb71QtRatzBLUY/g30G86Qf7IEHqo5vRCCz7xovsqZodl6X Prda4PMfjJSQTvg0= X-Received: by 2002:a05:620a:28cf:b0:8ca:d5cb:6842 with SMTP id af79cd13be357-8caf0c44afdmr60948285a.44.1770325229802; Thu, 05 Feb 2026 13:00:29 -0800 (PST) X-Received: by 2002:a05:620a:28cf:b0:8ca:d5cb:6842 with SMTP id af79cd13be357-8caf0c44afdmr60935085a.44.1770325228925; Thu, 05 Feb 2026 13:00:28 -0800 (PST) Received: from [172.16.1.8] ([2607:f2c0:b010:9000:4c85:f148:4c91:943a]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8caf9fdf692sm17571285a.44.2026.02.05.13.00.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Feb 2026 13:00:28 -0800 (PST) From: Peter Colberg Date: Thu, 05 Feb 2026 15:59:51 -0500 Subject: [PATCH v2 04/10] rust: pci: add vtable attribute to pci::Driver trait Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260205-rust-pci-sriov-v2-4-ef9400c7767b@redhat.com> References: <20260205-rust-pci-sriov-v2-0-ef9400c7767b@redhat.com> In-Reply-To: <20260205-rust-pci-sriov-v2-0-ef9400c7767b@redhat.com> To: Danilo Krummrich , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Miguel Ojeda , Alex Gaynor , Boqun Feng , 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" 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 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 b8b0cc0f2d93599358c8cd6562d23c27e4654a87..3944077adf550ac91422ca1cb23= 5365b8502586e 100644 --- a/drivers/gpu/nova-core/driver.rs +++ b/drivers/gpu/nova-core/driver.rs @@ -65,6 +65,7 @@ pub(crate) struct NovaCore { ] ); =20 +#[vtable] impl pci::Driver for NovaCore { type IdInfo =3D (); const ID_TABLE: pci::IdTable =3D &PCI_TABLE; diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs index e1cab1574a3d309d25bf5267c0b0d8da8fb66d44..a4c27c674bd8bdf5e3316789d38= d566e90b93fe2 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 =3D (); /// const ID_TABLE: pci::IdTable =3D &PCI_TABLE; @@ -292,6 +293,7 @@ macro_rules! pci_device_table { ///``` /// Drivers must implement this trait in order to get a PCI driver registe= red. 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..ae6f7328b830e32bcaf7f8b5f8b= 1f117135ebf8e 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), ())] ); =20 +#[vtable] impl pci::Driver for DmaSampleDriver { type IdInfo =3D (); const ID_TABLE: pci::IdTable =3D &PCI_TABLE; diff --git a/samples/rust/rust_driver_auxiliary.rs b/samples/rust/rust_driv= er_auxiliary.rs index c20961f168356c6bbe0faefc0079d7a90b013684..67a17f4b4657b5f91a4fc603ca7= 025478d79df2d 100644 --- a/samples/rust/rust_driver_auxiliary.rs +++ b/samples/rust/rust_driver_auxiliary.rs @@ -66,6 +66,7 @@ struct ParentDriver { [(pci::DeviceId::from_id(pci::Vendor::REDHAT, 0x5), ())] ); =20 +#[vtable] impl pci::Driver for ParentDriver { type IdInfo =3D (); =20 diff --git a/samples/rust/rust_driver_pci.rs b/samples/rust/rust_driver_pci= .rs index 4dfb8a6a47077d2c565b09f7c7822f7f5e2641c8..fe4db08d42a74abb5865c759682= 49b58bedc01fd 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) { } } =20 +#[vtable] impl pci::Driver for SampleDriver { type IdInfo =3D TestIndex; =20 --=20 2.52.0