From nobody Thu Apr 2 01:54:50 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 3291742B73B for ; Tue, 3 Mar 2026 21:15:49 +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=1772572550; cv=none; b=kCGZ2SF9Ab11oY0Qo9UNsvba+o5YEkIcFExzIUrAXRgTxBspFjSOx7StWnCKUAUJgN8h2AmndalKGCo5g75W1V8jaWOndrq+4ng1nuWciFvpig/06VnFu4JVz9XN1YPwwkwjCUQAAPlZ0GHGxhNNoD0Q+oXCAbNDoAh21hRqh30= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772572550; c=relaxed/simple; bh=s6mYU8Hu6u0tbKnwvAlOQsSAlR2qHgbV7fvzmNOhT1I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HJLUmI5U8lmOdCLxVa4dxKbtD29psdrGIpBjgRFDSQv3dllwNZ1kF4eoFB0hbWVDYeVhWVlr2a5Uh8eDRqteMhwjC0ImDXMJvGm1b/vLGH8zX+IA+YSmFsec5+VepwC2CLpf6VOghBmAKtuE0Xqh9EBk2D0vXEkokF3U5kc7DB4= 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=BTkyQ1MI; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=kCAw1JBI; 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="BTkyQ1MI"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="kCAw1JBI" 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-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-2-g6zWpgz8PTGH22vB1JEVLw-1; Tue, 03 Mar 2026 16:15:47 -0500 X-MC-Unique: g6zWpgz8PTGH22vB1JEVLw-1 X-Mimecast-MFC-AGG-ID: g6zWpgz8PTGH22vB1JEVLw_1772572547 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-506ae021853so72635301cf.1 for ; Tue, 03 Mar 2026 13:15:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1772572547; x=1773177347; 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=qLYDkNQ8A4x2T95jGRETa6NwStvleq7OKd2uXV0vocw=; b=kCAw1JBIAXWRPZw4JUJv49YAWrljxCYbXksrBYpDoKBqfunUfLS7XVJD34AMw7f9pe lBP1ZOc6g2DZt9+ns25+uobgikZUqykOa6qiBIW+8Z6HDs3PQkeOn7oop4BuHgH2fU0+ tyR6uRyuj41vz0FroNhHCjkmE5cabgSEgLWg7iZKShrJDXnc8UMmwJjxTMgiI1P3tsSv x2/6YqkSZgykeNdS9iOKTP25rRy32reg30RkLHB5d9B2be7QENmC9tAVVCikFcbaqii+ 3ExfTwxriP55kHvkyPhwceUhX+3o4RHe6gIsk8tNooyfKnefiYQoBGa7nU78ddbgToCW n2Dw== 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=E0oLhvmgutZAL7SrUVWcFDmcNcRchILDDKJxQ/rgLDt31x6ZAYANVVxLQwD3V/xWZu T0tjd6BwOzTXwCt9hJM/MwECyr4d9+EnLR3dhe160gxbJwuoaxHC3CTcy+ccH19fCMdS 1p5kQn3p8DOiJLKmGCab9inhIrPy/59enuzPRTLv4KasYy+B4scbj58bjnf9Qc4yHkBR lcZYNqredMuHz7kyWreP9g7fXvfLgzsSLwJjJFDALRaVfGmMQU1J93BwVnLwFRevxkQH g0m0VquwGjm//lNK0MX5fDOnLmZbV5L9ZoXB2ZKkH4r8jIKAf3ptRu/xaGQ8ouRx8V2F FWMw== X-Forwarded-Encrypted: i=1; AJvYcCXzHxc5JKpSINj7Js2/eyWgOEvpY5wxZYJCF2Vh8kb0N58Rww9WwYFwx45eQQ3Acnk/JFH/RNp5ZpHrZqc=@vger.kernel.org X-Gm-Message-State: AOJu0YwHOdEIQ53JpzCpJa3xC9TI/7TYBmQhVlyj+tQqVf6IJZjPr9Ch ur6IdCJl/t2X00b4ANN8I+uD62Uv9uHMNtJHjPu9kEk25wQJI0pnats+L0bj3YLx+PMCCiYVe5X 3CF1I1e/x8XhvEHWX7l6oq+uGza5vdprkK9vazkPo9ITDMp6MQHWuPI6iz0C32ZLing== X-Gm-Gg: ATEYQzw+pMp9ADYoTTlf0+k1Yr/+cBPvDYolGw+qbPzwdlZV3bcu5jAVRfrlAu8FH3/ ou8bSwvd1RQbarK9GezxbiWFSKyOHhwhUKo3gFmdXoxvtgc2K9CSQDUHOGXimP5UtG3rQsSaPli ggg2XLcbhquqC8EjzwKuTKjp0ToC19XKtZQfax8GYtWoEMBgkncF9/LM50juk58/uVKS54gDZrC pkM22Gj6FbaVM7+3xfY5CSEE+l3bFuEaP2m0PdEf47cXyGCW8z+XIe03LEp+WQkIZcCVj+XUwT8 vFYV6YMBrXSCERKkM/tMx5Sv+QU+j7zha84erf7EfmwfAFg+DbewqBdU8nUpN6L5fDkZ0fwR7vS uYwmQJmvQSWX4/0+iAoR9PLC29A== X-Received: by 2002:a05:622a:64c:b0:4f3:5652:6743 with SMTP id d75a77b69052e-507527cc1c1mr213308831cf.39.1772572546781; 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 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-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 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..df39ad3f0d5fd898b034609efb0= 3368f83c2a2e9 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 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() !=3D 0 } + } + /// Returns `true` if this device is a Virtual Function (VF). #[inline] pub fn is_virtfn(&self) -> bool { --=20 2.53.0