From nobody Thu Apr 2 01:49:45 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 7D26B3DBD63 for ; Tue, 3 Mar 2026 21:15:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772572549; cv=none; b=mYh8Wp8GTtMrw+OSBq4Q8yDXvNGgnDhTkupvqULZ5liyWtIL5DHAg1ZF13rQ2iEGZQL+s7vtUufM6UaDmUBWEKd94iFigVnacHReeUW5lKosQap50P2HAyyVKfbyGEz35/dK7OV5ExVXsF0494G3RFJQ2A0/F29YCQ+aVSVUeyY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772572549; c=relaxed/simple; bh=lJwT02KVG7/pESXAOG8cyaW742ucvP9hALO2Uv3N7Ys=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mQ6UpKIYNUGGtz0DWsaur1PPaxwIyLMv+CPSZrnKZMCz5NpejKItPYoDl5UlV3l51AZvVJ7UYk9cF3yWhZGVRHyrFVLwxFX34ml+M+sg9n+sQHAEKo1oDSa1kfxC33snt/Pcf0HwyRo3EjQQENd4/b2ptgcsqbgjNa4fD1535zM= 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=d1agVTT1; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=M9pAa5ka; arc=none smtp.client-ip=170.10.129.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="d1agVTT1"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="M9pAa5ka" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772572546; 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=d1agVTT1mdHe2RTcnyqqu47Hr+4NPzeFPlaO7lQyK+XY4kfWdXgMB6RgxkSerwvoVXRE5B bzQBh2MkjW8m/GDJNVnETrOz8RimqCb8sEYaJAY+ml/0X9z0zZhuljhtltUpDz67JKk+CP zkn9swyNG/bYIi0VCEWI020vrHOh9JY= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-147-T2RB9K5lOseHbX31n3PVPw-1; Tue, 03 Mar 2026 16:15:45 -0500 X-MC-Unique: T2RB9K5lOseHbX31n3PVPw-1 X-Mimecast-MFC-AGG-ID: T2RB9K5lOseHbX31n3PVPw_1772572545 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-899f619264fso177751876d6.0 for ; Tue, 03 Mar 2026 13:15:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1772572545; x=1773177345; 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=Ld6zN/9/7YmG/EDhmcZckbqpb8XwO0ah+2Ai3kR30j8=; b=M9pAa5kamLG4d42fKOUrWooO7+revNokH+wbAuoUluLIDuYwpiIuNgFI5FJouogS1T cPiv5ftgGB1gNgsSR+mQCQRqNq1eiTVP1LNpIoD4jxpabHcsU08junB0y8G+T/U4IOAZ 1HbakjfN/rD3BUDtGIGKQuu00lGe05CbSwslU1W9GDhG2Q/sJDLszCfHBUiYvuO4Wupw +vSfZWjydEIKPzYWQQw1gzfOyhRVN6zXpdoZunfDvGz8qRqlf+Ea2gOtSPKjFpSCkLxY UrcAwqruUX97dmn6ho9CC5kKtatKfY2ycEkgNgfISI6JDmJII5rWcoLdJUyPWjIGFfVu Vk3A== 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=JElK7846EdYkVxSQo7gTdG+Mk0sYiLgAESmJM/tzSmrSkQ2boM4bqmwBWuJKTwiUz5 ScgYy65XNz2bFpa4zs3BZmzkNgkBPYRiHXDiL8Pf9gm2yPep+Y9tMVRqj3824q9kmuBM hwolS9Lct6CbtpbGpGbUXsw+CVpOz6kbiw/BkQAj9P2BVyGJSJ/so5J2tdCFvN2Nnc+0 yuYRGA2Grxan2iKSVxZTdF+lhwYJNC62vwl6q7zwDBKfJUN5rA7FUnN2Hft+n0Lt05br ZoqkhIH2mUBAHGVJ+n1+hpu+gS3uCz/jNySb9IyG1ylWW0eu4qg6bR9JCD4D/u8yEZW0 XDrA== X-Forwarded-Encrypted: i=1; AJvYcCXpyxrvF8ir3tQobxdc9N3HorjTRPJ9OISg/i84lR/JxekAN75s7SfkzTR1J5GqoY5+8aANzxSNjeO+bOY=@vger.kernel.org X-Gm-Message-State: AOJu0Yyt0paF0nJpsQpjclbu6HoyTLq56TKzPY2R8DiyFGyqsM9u/5pP hwuvjhpNGIW5zJn1ArsNCaze/Y0GL68HuiWK3zxEUvrIlHvh7QIgd+2OHYx4SEqLAnIcD0/ADKJ KK+k8lOVI7XrK5bONUy65VaD5Nk4xroHJnNs1BEbtl8MZBEXULjnJ/SERZqxONxb7hw== X-Gm-Gg: ATEYQzzQNTOmHRqv/Uw5AIDquR1VcfIK3xCgBECRZT74F+4prz1ZzT+4ZHldnpZX5AN 7neFeFNgAhF8YngCGSTq8obzIdavAgiut9pf6pRKTgmtvztlT9Yol8T7xLPAzGLP/ZygfThP6GB ZnN9bkXKyRvJNm+ZjBd6cPRMfBt2zvAhRxiSqyoywCMVQpDiir333P2dReaQZT8/9Teoif4Qmun XA8wCuVYBSGOydVRCku/j6abwrn84iZ3ON0ctxY0W8noAnro53N8zx+OEdJahxQtPeZaVU374eR xmgchrPRCye2a5C3fyDiqkDDAxP3MVmwKC2l7UqNTKSER+aSZ47DUwGO//4zOikSuu7RvpM9nO/ VpSkUZJkpOV+qK0kB+54QjiL5CQ== X-Received: by 2002:a05:6214:509e:b0:899:fdd6:9ada with SMTP id 6a1803df08f44-899fdd6a682mr113463496d6.4.1772572544927; Tue, 03 Mar 2026 13:15:44 -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 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: <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 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.53.0