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 083FEEDEBFA for ; Tue, 3 Mar 2026 21:15:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3C75F10E8F5; Tue, 3 Mar 2026 21:15:50 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="hz8H+xr9"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id C070410E8E4 for ; Tue, 3 Mar 2026 21:15:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772572547; 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=Ld6zN/9/7YmG/EDhmcZckbqpb8XwO0ah+2Ai3kR30j8=; b=hz8H+xr9T3FX0kUls2B4gH+1yJaj48XJcOK/9kNSqMjEauvAJOhyIJzL8aUBvOGKS39MLy /SU3xyav4Op3NxKCYwqaYXSo7639eyqmGDERrzva5j9UDdARpvBXf6NwncRiNZjIPKzZ9Z cxtiYOz3yzhYi/4xDM+CaX0QJl+vHaQ= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-157-uA_iadSgMX-23bJvmR6iKg-1; Tue, 03 Mar 2026 16:15:45 -0500 X-MC-Unique: uA_iadSgMX-23bJvmR6iKg-1 X-Mimecast-MFC-AGG-ID: uA_iadSgMX-23bJvmR6iKg_1772572545 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-899f757514bso171441986d6.1 for ; Tue, 03 Mar 2026 13:15:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772572545; x=1773177345; 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=Ld6zN/9/7YmG/EDhmcZckbqpb8XwO0ah+2Ai3kR30j8=; b=YjxZ0cr7Fu3YHqX3BmWvTdFEdVY4TK1pI0NOzYEFT8i8M2zLwN6gk0hI9NbHREmkKF bTkAvgALVOHQcEu+GKyEpbticG7vh53PXNIBU3fHuRTQgWalr4OK6w2Tttw1YS/lPSGB LuIb1ufJJEcwikqmvDWVEWOeTO4YT2wPY7aFoaprZ2ffh+vmhN+vfcnVFQsfruz7kbK7 X/MmxYUPTDFrduV8v5nOm5yzdcL8jJmBTt0Enpk8g4gKtAvkUy57hwUt9+IulnwAySt0 T5BL9CHvocajR1aQAaIMQt5kWtO2mnm0AXgQh8pXtLBMitIs0/OPkm/nhCofoZdOM3LF gIRA== X-Forwarded-Encrypted: i=1; AJvYcCWNLd6GOLeSKFsnUT/LYMoEcHiV0eqsRDAhJMkYWAYcEbLk8RcnQeze4yOw0WrbBC71Ya3ecU7s+Ws=@lists.freedesktop.org X-Gm-Message-State: AOJu0YziegwujDQ63+i6LU/lrSegVacFpcu/tAtmNly5zI0I/BMEopLJ w3GB4jEaskI7vgVuAyQbOgCI5GXChAiGAlnZW4OZjngreS9LCV1T1NdDN442lpnP+lWS7SaN3yb fC7rliwnuGXq6QN4cRRhhRuu+1cq9ujT8Vh97oVpxUck62ZFiBE+1JnAY2M1BBnm5NcBviXk+em +0PF9aEt+5O+sAyNJUosMPXENqbWxgzCOI9Qhs5bjYyQuupHfgcvpVl2X+ X-Gm-Gg: ATEYQzw4NXeOf7TxDALt8jcR5wMYLd+405BqPBGbuYEbnHWgKInhYqZWJxakgJ9bqXr zd/I91mCfzNUcpWgS3QAHEbuPk4daCztmcfYA9qZhYZfaexpAEsieJUcCsNq+GSdtgAI24VdtuL s9KXWsYC3Jft2gCcihAqJBVUX2zwgOzlSQ1R8aJoUPDoofcGLplvBXC4o0SR70pLTAMl1eFKWxC V4gyII9oq3KHuoi5/bTn+Pa4JfForOzw42uA2UpW9Fp72HXWkyrZwXmz3NxcRKDm0ZNT7GQSVrK 409e7O8A9bYsvyNSSDT4eBdmPQdKtgLaezqurRGfC6oWq/03EPq8byHgjDkQdAf07hRabXS3GeH u9qPqUx4aewPwa6qBnVXohpPRNA== X-Received: by 2002:a05:6214:509e:b0:899:fdd6:9ada with SMTP id 6a1803df08f44-899fdd6a682mr113464086d6.4.1772572545192; Tue, 03 Mar 2026 13:15:45 -0800 (PST) X-Received: by 2002:a05:6214:509e:b0:899:fdd6:9ada with SMTP id 6a1803df08f44-899fdd6a682mr113462916d6.4.1772572544344; Tue, 03 Mar 2026 13:15:44 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2026 13:15:44 -0800 (PST) From: Peter Colberg Date: Tue, 03 Mar 2026 16:15:26 -0500 Subject: [PATCH v3 06/10] rust: pci: add is_virtfn(), to check for VFs MIME-Version: 1.0 Message-Id: <20260303-rust-pci-sriov-v3-6-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: n-xUjSvemgjzRar0IY8hP0l0HHk9AqqZs8HZ0SawYaE_1772572545 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" From: John Hubbard Add a method to check if a PCI device is a Virtual Function (VF) created through Single Root I/O Virtualization (SR-IOV). Signed-off-by: John Hubbard Reviewed-by: Alistair Popple Reviewed-by: Joel Fernandes Signed-off-by: Peter Colberg --- Changes in v2: - Add #[inline] to is_virtfn(). This patch was originally part of the series "rust: pci: expose is_virtfn() and reject VFs in nova-core" and modified as follows: - Replace true -> `true` in doc comment. - Shorten description and omit justification specific to nova-core. Link: https://lore.kernel.org/rust-for-linux/20250930220759.288528-2-jhubbard@nvidia.com/ --- rust/kernel/pci.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs index 88bd114970431bf8c3edef94c1d48567d895eaf6..db05641186c3a42922e2b6a463de9c1b099a4673 100644 --- a/rust/kernel/pci.rs +++ b/rust/kernel/pci.rs @@ -484,6 +484,13 @@ pub fn resource_start(&self, bar: u32) -> Result { Ok(unsafe { bindings::pci_resource_start(self.as_raw(), bar.try_into()?) }) } + /// Returns `true` if this device is a Virtual Function (VF). + #[inline] + pub fn is_virtfn(&self) -> bool { + // SAFETY: `self.as_raw` is a valid pointer to a `struct pci_dev`. + unsafe { (*self.as_raw()).is_virtfn() != 0 } + } + /// Returns the size of the given PCI BAR resource. pub fn resource_len(&self, bar: u32) -> Result { if !Bar::index_is_valid(bar) { -- 2.53.0