From nobody Mon Feb 9 16:02:16 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 3527A332EB9 for ; Thu, 5 Feb 2026 21:00:36 +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=1770325236; cv=none; b=uKRciaKtmlb8+RfuSAdw0VhZHBq9bFgAm70TVk1woE4EvEYzLb+mj1c95RFnrzUoWJIA5BX9V3qrkn7SsyWMXsNZul+QkalPHDHqRe64ARztG6Vdj48zaNEnHeSqPTl1mxNACAEAL9iFUi4Cn0VyB/X3h9w2cli0q1eMHiHPIqU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770325236; c=relaxed/simple; bh=goR6NT6+KiuW9XKjlJCHBNrcq9pPIxNj+WVW2jrpGs0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CPih7aET46CHQITJPXXCREGGKsX9vg8cqSzGJiEE8NJdX54ZidI6i99lX8UvUFE2OMn0bkhgSGqfW2sJp+L3fFMLLMd6Ori+uqPjtRELeA0Xwk/ZxKuwq2V+mRdowhMC7cq/VVWPx84owtkQmN60PX3cBk4kiR9xUtcH2RWaeiE= 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=B838K7RV; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=QbJ6YRsm; 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="B838K7RV"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="QbJ6YRsm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770325235; 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=qEZ/NIGEd7tvljUjuiPoVXU22CsIWWTrf8BQDchgWf0=; b=B838K7RVZ3xvEyVUrLjkRi2Mv926uLlnBlH/Jc+7jGLN2q9RyTqfAOEt0Iijwy4e4UWe+/ 9A1FMzTVr3CXgWlv+YhyVsuT+/E/7MWpaLVaLcs3rIMKqYD3HWBhYz7BGsryJG8T4yAFcO TDiiEu0dxWIQfEmkXWXxiBMqaySVAWU= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-332-9bw-SOxMPnynmPFMYWATwQ-1; Thu, 05 Feb 2026 16:00:34 -0500 X-MC-Unique: 9bw-SOxMPnynmPFMYWATwQ-1 X-Mimecast-MFC-AGG-ID: 9bw-SOxMPnynmPFMYWATwQ_1770325233 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-894766748f9so85881886d6.1 for ; Thu, 05 Feb 2026 13:00:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1770325233; x=1770930033; 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=qEZ/NIGEd7tvljUjuiPoVXU22CsIWWTrf8BQDchgWf0=; b=QbJ6YRsm+Bp7e4TG7/79hxn8+evKLC73comgETOLNF75gBfZwyaiE4g0SzGd9tA0AV Kn02G4hDOALkgCDanHrG9Gy43LVj8eTuRJyGbM1jzJn/+ECbEmhNJ82hFDUGHQ3evob6 07CuUDOxhefiwxG6+iVC0ykQJpIRbSDvy0HU/ohlxB+kAiBH4MPHfN8f5RKfklXKZau4 Rqrd6apfjGELR/SVIxtKbz4q1SB2OjAa+jLDxJVhrY3HuvxLhWVG4KWNia9kY0X9IVp9 I0R4IR4xHmYbGX4nHoblTYQjJ/UPOETOJcpg1i4p+taieciQ+fungMNd/LQlG7UnzpHo vkNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770325233; x=1770930033; 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=qEZ/NIGEd7tvljUjuiPoVXU22CsIWWTrf8BQDchgWf0=; b=gmZjxRYSe/hxzSuQUpk6u/7c+KBwZQOs+hcBBxkTxBoSP3DyKCVXOVbIpmF+TrWf9E teMHQ2GIAy5iLij2w3+YRVeCvdAL8JiBp7t3lnoAdZ43BzAs5P0UD150mjNInl30jjjO 0X/uTrLgPl49HRQ9BPd0XOTGDzocpdeDlcoxsnu9wufRRpMK2znIqwfzw7m7915ukeyv SroJ9WdiSXn309oDSYS94OSMLzl0QJGZMXyVd2BMO1iBRYzqSibMKfuf5aflo7JmxRyL Y62RohbjNc2LVpLf6ew8s0a/SumfbJ8LVFnRnHkXhFMrwKyp0BiPex310oDqqFWhtwM2 AfGw== X-Forwarded-Encrypted: i=1; AJvYcCXBtGL1MV83F4jdxKXU/8e3HPwZKFT2xp/gdb3rpBVqgPDDrQ0Pph49JfN3x80eWN06UtY6nSXo3xmqJLg=@vger.kernel.org X-Gm-Message-State: AOJu0YzN0o2QGXNlAnN8gOeUcbpzaSDWTmrWCmfuO2/HxI5tgsiYBdKs 9M6bXPGu1HPRn6dWffzDTSv+lhR/FgGUL5ctlJcv4bHdRPhksTBmu4AfkfEwpfiZa8/qcnelw21 zjxv1MYgTOYpGAlXFqRGW+aL1vicPVTmvVy5JQPfoO7vt9DrNk8ISTRRkDevN24bSWw== X-Gm-Gg: AZuq6aLu4rOnWS24nQJphzBr193rOvw2QlfvR+o/+HY90vjRyLMC1bVU1h6oCy2m6om bb233xHt/K/nVVeauyppvO8ndHHcIm/S+xMtJyUdrB5Jks6opRPrm1ENube6Oy0AliHthv+5k5k EjREU1czTHYTEB/rggiNGsgOg5KCJCbx8iHNE3jh1Pm/iw1+v1LSRT49WOyVnxr0hTKoxVbMcZs KvNqOpvi4fH392HtPkPIEuYuVMj8ajS0vRCQCowrxXr2ioUDgVJkumndH4jmX4bfO196fuGeQ5u fBVXdwsZkIFmowzyXa5x9rfeWdztcc1WM0xJ+Wxz7LeMKCDz8HNj0B4vGzqK86yddll3Fw6Qjif TPRmBbpJPwY1xclU= X-Received: by 2002:a05:6214:4017:b0:88a:3681:1d96 with SMTP id 6a1803df08f44-8953cd9c94fmr5941876d6.63.1770325233451; Thu, 05 Feb 2026 13:00:33 -0800 (PST) X-Received: by 2002:a05:6214:4017:b0:88a:3681:1d96 with SMTP id 6a1803df08f44-8953cd9c94fmr5941106d6.63.1770325232827; Thu, 05 Feb 2026 13:00:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Feb 2026 13:00:32 -0800 (PST) From: Peter Colberg Date: Thu, 05 Feb 2026 15:59:53 -0500 Subject: [PATCH v2 06/10] rust: pci: add is_virtfn(), to check for VFs 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-6-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 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-jhubba= rd@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..db05641186c3a42922e2b6a463d= e9c1b099a4673 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_in= to()?) }) } =20 + /// 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() !=3D 0 } + } + /// Returns the size of the given PCI BAR resource. pub fn resource_len(&self, bar: u32) -> Result { if !Bar::index_is_valid(bar) { --=20 2.52.0