From mboxrd@z Thu Jan 1 00:00:00 1970 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 81FCC2EFD81 for ; Tue, 9 Dec 2025 18:22:51 +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=1765304573; cv=none; b=gpAWmHNu9zeEkqrughVZGr5OAETe0nqA/i6Wl6DrN+RcUO9ORawSfJmYQ/48vJNMX4I0TJwOKHGkyBTryOx9P7Rn5l4QF3DKa1z2Ax0Meotw5Bd/DsxMID+7qKExzB70w5kU9VxkCnCo9yDrhNik53lZzW13CbTR7JIqRVQSQu8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765304573; c=relaxed/simple; bh=EE7wXtjs9EBC1pz96zdtJaDICazZ+qtIBI35mNOiwXM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UrWd1Vbe2y4V2i3eQ2Yuc8YQZ/8tBYK3ARxpRW1jiwXQbfWsKa7pwvo/C7pApIt/sl5hJsgwgtUV1yOxh7OiaEcQvLD0zaYw6xLK8HOQeDzlBB/Z8UsiFNjBA9uAc/V2JanQI4hofP3Fq5HH7yFZA733zLRvjQYWahrf3AEwQUI= 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=c8pe1A1n; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=mBHvIHnd; 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="c8pe1A1n"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="mBHvIHnd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765304570; 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: in-reply-to:in-reply-to:references:references; bh=WMOszaFVk9dmDMFq0LvRTh2fbh1Zhs/4RFuYjDJSUZI=; b=c8pe1A1nGwyCqWBct88u5gpCknUn5KBS7APJZvdQ1cNSXZwlWx90eq0FSj7uLmPOdSnHhh vQdL50GBroeZF1byrVnybJWELaaVGUj0Diw8b0fINNL1rd6/g9SQOILLybH/B2I+odgAwR Yhh54vrvzX+N5VKOgEYktpgLV+XgZlg= Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-382-Ydj78-NcM7-hYQjIsx7wqA-1; Tue, 09 Dec 2025 13:22:49 -0500 X-MC-Unique: Ydj78-NcM7-hYQjIsx7wqA-1 X-Mimecast-MFC-AGG-ID: Ydj78-NcM7-hYQjIsx7wqA_1765304568 Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-7b80de683efso9296386b3a.3 for ; Tue, 09 Dec 2025 10:22:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1765304568; x=1765909368; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=WMOszaFVk9dmDMFq0LvRTh2fbh1Zhs/4RFuYjDJSUZI=; b=mBHvIHndRo2/RD1R/K80w3VY8OW8pZr1pNhw/LamSbINatqTKmSOJlVS7/0IUaUJvj gwy2vhXefWLxeKdTZsWhHrW+M5yWb4KLyS8BV9IPDzIOsyXk1vOhnUrIcLXp1PYF1rIS DQnkTu8ZzPK1PH4Z7/D50zw4k+f3a5yQZhS+EWBzlle8Nc/8vNp+NiocH9s13ngllybI 1M0uVgDbZErT51mtK7WzZeSfSpuX0KbFt15CIVVHVeJ1VxbvrLMpxXC3Dxg2sc+vnz97 /QFe1bm5+QDCmN23VHDPpE+FXP9EKPMQWzf/urbXYfNWYaJTNuQrIK9O4qTmb/rTFmEa BWvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765304568; x=1765909368; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WMOszaFVk9dmDMFq0LvRTh2fbh1Zhs/4RFuYjDJSUZI=; b=M0tyme34UiHzDV7ojC+kd9vdISOMVy3eFSdV6iGZBCfkbrrydZwCLB6XUpjrD09F/+ HkL2pL0FQJwEpdC9ljn0eiYk0DMIsjn4ofpfl2rH4wpUeIorXj0hfBKvGRx3L5JR2AUo IWOHp6xOPHRYigL32WMaURnm6g6WJYbXY8WgY+DWBssxjSvvwCu/tNqOGs3NoU6bY98e X+t3QVG3yBcdw0PGCyYdDDbgz4b7NDwmw+RLRL/WIQq7omJsoZ3estdwr05Wpd59CHdv oHUOJHI3vJs0hw1wLl0r1VJrz4rSX5xThczlg9viuet4DjPmfd+9aE7HafHlu+PUa2YX oyfA== X-Forwarded-Encrypted: i=1; AJvYcCURVByh9gS+AZP3jkEsAabnkzz0iFj1IE3rwqss8ALYlkC0+3JzY10cnE/rpWfYvpShIPhJoJYw2/Kts8Y=@vger.kernel.org X-Gm-Message-State: AOJu0Yxsc+CdNgKRJuReTx/xvUa8Ysv2S1ptr5+pyA6b9RwM42R63zfO Rj6Vsqn/moPlUlZ8ZF1s0r8zPlkVvxsGmZa56nVfH0pxC+L5LWcXNV/T8OueFLR9NEK4Akkux75 xN01I0k5ZhJdcGFXk7Z/JDqFqMEboUW/Ya1bcNs1wOO9zhDJKF2Mf9jiVbiGUxMFlvQ== X-Gm-Gg: ASbGncsgS9yTkFw7V8sGbQwtDP3OSxMGGj7JJ+I1OeAP3RiKQXCwjU5uoa6QgORW0+t C6n99vRzm8GTAdQ0LnV0ytehdCgLyc9TcgOHtc+R9Ysm64whKVOsOoXp+qFS0Wzzsj6JYo5Zfic 9SIdLGYEvqb11ISzUTMnaGEAzU7Pl8/p4Akq6VUKW/2tflbg3R1b0DWDfpC7l0E+ZkfOEVvYAlq 5WwXTjlgXyl+1XqOBcOIFBKY7gEbaxpegG+LVsc52PCVzyfyzQKFBDMFL57XwN/dNE8eYfTXaB/ Oyz6dr7p9+Zpc75SkR1FHV9rSqrvmwYIVXalhYDbVfIcJpnfwTAYYZykQPot0OhZyxE453v3Ye9 FGU0XVn0v7g== X-Received: by 2002:a05:7022:401:b0:11d:f464:5c97 with SMTP id a92af1059eb24-11e032d86admr10001650c88.39.1765304567922; Tue, 09 Dec 2025 10:22:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDwilm5GiGAv7e/m6VA+/VyYDDyNis+KEVWPuuPoKnNewKlxbpy5fSUp7p0RlzrwnLtnLoLg== X-Received: by 2002:a05:7022:401:b0:11d:f464:5c97 with SMTP id a92af1059eb24-11e032d86admr10001629c88.39.1765304567147; Tue, 09 Dec 2025 10:22:47 -0800 (PST) Received: from localhost ([2607:f2c0:b021:e700:1a3d:b7ef:5d4d:bee5]) by smtp.gmail.com with UTF8SMTPSA id a92af1059eb24-11f283d465csm1567525c88.14.2025.12.09.10.22.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 10:22:46 -0800 (PST) Date: Tue, 9 Dec 2025 13:22:43 -0500 From: Peter Colberg To: Joel Fernandes Cc: Danilo Krummrich , Bjorn Helgaas , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?B?QmrDtnJu?= 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 , linux-pci@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Alexandre Courbot , Alistair Popple , John Hubbard , Zhi Wang , Jason Gunthorpe Subject: Re: [PATCH 1/8] rust: pci: add is_virtfn(), to check for VFs Message-ID: Mail-Followup-To: Joel Fernandes , Danilo Krummrich , Bjorn Helgaas , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?B?QmrDtnJu?= 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 , linux-pci@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Alexandre Courbot , Alistair Popple , John Hubbard , Zhi Wang , Jason Gunthorpe References: <20251119-rust-pci-sriov-v1-0-883a94599a97@redhat.com> <20251119-rust-pci-sriov-v1-1-883a94599a97@redhat.com> <20251207062819.GA212851@joelbox2> 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=us-ascii Content-Disposition: inline In-Reply-To: <20251207062819.GA212851@joelbox2> On Sun, Dec 07, 2025 at 01:28:19AM -0500, Joel Fernandes wrote: > On Wed, Nov 19, 2025 at 05:19:05PM -0500, Peter Colberg wrote: > > 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 > > Signed-off-by: Peter Colberg > > --- > > 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 | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs > > index 82e128431f080fde78a06dc5c284ab12739e747e..c20b8daeb7aadbef9f6ecfc48c972436efac9a08 100644 > > --- a/rust/kernel/pci.rs > > +++ b/rust/kernel/pci.rs > > @@ -409,6 +409,12 @@ 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). > > + pub fn is_virtfn(&self) -> bool { > > Add #[inline] here and to `is_physfn()` similar to other methods in this struct? Thanks for your review! Where should the line be drawn for #[inline]? Should these be #[inline] as well and why (not)? - Device::num_vf() - Device::enable_sriov() - Device::disable_sriov() Why is Device::enable_device_mem() not #[inline], while Device::set_master() is [1]? Is the former an oversight? [1] https://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git/tree/rust/kernel/pci.rs?id=67a454e6b1c604555c04501c77b7fedc5d98a779#n433 Thanks, Peter > > With that, > > Reviewed-by: Joel Fernandes > > thanks, > > - Joel > > > > + // 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.51.1 > > >