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 1D985EDEBF6 for ; Tue, 3 Mar 2026 21:15:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3027910E8DF; Tue, 3 Mar 2026 21:15:51 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="BTkyQ1MI"; 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 7EB3910E8F0 for ; Tue, 3 Mar 2026 21:15:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772572548; 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=qLYDkNQ8A4x2T95jGRETa6NwStvleq7OKd2uXV0vocw=; b=BTkyQ1MIwdUr4SBnXaUoXkx2/qFXyrU5CIbfGcjArGrolbt/qJhAi2ziLVJz6vGm6IY23v UryGmw1nwaJVbxhzmYw/2pymwQ8XtHp17lugdIOZ9Q9g6Og820zug/p1Ip5J8SE0Mk91mb 7FMRsKvQOEObo489Ivyt+Wyxi/oCehw= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-530-mxVTMNzGOqe_tCo9u8Ksvw-1; Tue, 03 Mar 2026 16:15:47 -0500 X-MC-Unique: mxVTMNzGOqe_tCo9u8Ksvw-1 X-Mimecast-MFC-AGG-ID: mxVTMNzGOqe_tCo9u8Ksvw_1772572547 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-503342386c7so91937431cf.0 for ; Tue, 03 Mar 2026 13:15:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772572547; x=1773177347; 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=qLYDkNQ8A4x2T95jGRETa6NwStvleq7OKd2uXV0vocw=; b=hEU61UmXMYYkc8jPh18Zu18/Rt/3O+KJyBzHs5rqdkBr1f6Pfzu8zUG7kzwNbmn7Ph t2DjUKK8D9HNpuvTDyVHTZ1lgkc+7twUkRPo9oDBX5aeFhbxvl/mJUIb51E0D1OWaxLP HCMoeB0o75M92bg6xJDyTn0Jdyr2O4U685z/SW1vEVnjIYAMOCChs+2o++iHQYMtUNLe EpALW9uPN4BSFZv092f8Lemokf9rxSE+6Z1OvtohqEpuPpoVvKI2RpozxSd/vAHsTVoD 4tMpKDRVjk2izYNVinmEmYlm0a3I7UN+pOlbi3f1Df6nJmVaeA1kjaFblcc/Abwqp7i1 skSg== X-Forwarded-Encrypted: i=1; AJvYcCXdE8nC7oDuKu9vzuQcKJwFv+D/xq2BvYqGUDXa62P9AFDE1fVaiCrVMZ8lQeL7yzr7z1zvuYoozyM=@lists.freedesktop.org X-Gm-Message-State: AOJu0YxI6QzxaRtxhjnB+Vg0OXap8i0HnLrcU7KBh04wQez9JfFh6UQi tCiFHKprY+BoMeYEiyt/EYSI1vPM1UJNayVzEWu36/tVIwaM/7VPRukAasHbWX+ruXRoZCzXLGJ mgJrwhPNnieFnSbVr32ae1qu1Ku/ZG6bAJcBOqYpcFc9uwnGFICi+KxFtG3xTXi5w95yLgJ1Uhe Ec7fG0dc9CX/UWNlY+WGn8G5KDs+n9xSaOigQTiOxeyKXfXdZUKX9B/+8T X-Gm-Gg: ATEYQzw3y97VWEVG9BVuR/oTSJq/NAoKdPENbQAb1RDibwVjZMf0nZgwvE2FRikpz7W JpEoCUFxBmsbqbKR1LjPhA6y36uxZT1orAC5hbGi2z8jGSqUSEmNQ0iiWHYuhT+4GYgrukPMK0Q kPG68Gh0XkNnJ11Nml9SYr6E/p3eQTITfwpwC3rRV5jBSpstcT17qGKjoLPphC0zjJ/21jZSl60 HDyhd1WIcTUsSIdHHRoaiVEGJl7A2gxz+mdqcXFrVJcLYhKGdNEHmtjaRQ7hngD/qBahtN3cXYP L/0CTutxJmI+5n1HtgV8BdDHQo3WxP09sHYPJFlfR1axb+2Vr3cvzAQRh6QLp5RgGH7qHyEW6ta 0EGTD1csE3nkvkv8budxnOS21SQ== X-Received: by 2002:a05:622a:64c:b0:4f3:5652:6743 with SMTP id d75a77b69052e-507527cc1c1mr213309181cf.39.1772572546938; Tue, 03 Mar 2026 13:15:46 -0800 (PST) X-Received: by 2002:a05:622a:64c:b0:4f3:5652:6743 with SMTP id d75a77b69052e-507527cc1c1mr213308331cf.39.1772572546254; Tue, 03 Mar 2026 13:15:46 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2026 13:15:45 -0800 (PST) From: Peter Colberg Date: Tue, 03 Mar 2026 16:15:27 -0500 Subject: [PATCH v3 07/10] rust: pci: add is_physfn(), to check for PFs MIME-Version: 1.0 Message-Id: <20260303-rust-pci-sriov-v3-7-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: V_14BQiCTC7RtfxuAykjMI3VE2jNmfBmon_vzHwNafo_1772572547 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 a method to check if a PCI device is a Physical Function (PF). Reviewed-by: Joel Fernandes Signed-off-by: Peter Colberg --- Changes in v2: - Replace VF -> PF in doc comment of is_physfn(). - Add #[inline] to is_physfn(). --- rust/kernel/pci.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs index db05641186c3a42922e2b6a463de9c1b099a4673..df39ad3f0d5fd898b034609efb03368f83c2a2e9 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 Physical Function (PF). + #[inline] + pub fn is_physfn(&self) -> bool { + // SAFETY: `self.as_raw` is a valid pointer to a `struct pci_dev`. + unsafe { (*self.as_raw()).is_physfn() != 0 } + } + /// Returns `true` if this device is a Virtual Function (VF). #[inline] pub fn is_virtfn(&self) -> bool { -- 2.53.0