[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251124135959.GP233636@ziepe.ca>
Date: Mon, 24 Nov 2025 09:59:59 -0400
From: Jason Gunthorpe <jgg@...pe.ca>
To: Danilo Krummrich <dakr@...nel.org>
Cc: Peter Colberg <pcolberg@...hat.com>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Krzysztof Wilczyński <kwilczynski@...nel.org>,
Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
Abdiel Janulgue <abdiel.janulgue@...il.com>,
Daniel Almeida <daniel.almeida@...labora.com>,
Robin Murphy <robin.murphy@....com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Dave Ertman <david.m.ertman@...el.com>,
Ira Weiny <ira.weiny@...el.com>, Leon Romanovsky <leon@...nel.org>,
linux-pci@...r.kernel.org, rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org,
Alexandre Courbot <acourbot@...dia.com>,
Alistair Popple <apopple@...dia.com>,
Joel Fernandes <joelagnelf@...dia.com>,
John Hubbard <jhubbard@...dia.com>, Zhi Wang <zhiw@...dia.com>
Subject: Re: [PATCH 7/8] rust: pci: add physfn(), to return PF device for VF
device
On Sun, Nov 23, 2025 at 11:43:08AM +1300, Danilo Krummrich wrote:
> On Sun Nov 23, 2025 at 5:16 AM NZDT, Jason Gunthorpe wrote:
> > I think to make progress along this line you need to still somehow
> > validate that the PF driver is working right, either by checking that
> > the driver is bound to a rust driver somehow or using the same
> > approach as the core helper.
>
> Do you refer to the
>
> if (pf_dev->driver != pf_driver)
>
> check? If so, that's (in a slightly different form) already part of the generic
> Device::drvdata() accessor.
Yeah, but by that point it has already returned a bound device pointer
without proving it is safe to do so..
If you check the flag you are proposing below then it would be OK:
> > I'm not sure the idea to force all drivers to do disable sriov is
> > going to be easy, and I'd rather see rust bindings progress without
> > opening such a topic..
>
> I'm sorry, I should have mentioned what I actually propose:
>
> My idea would be to provide a bool in struct pci_driver, which, if set,
> guarantees that all VFs are unbound when the PF is unbound.
>
> With this bool being set, the PCI bus can provide the guarantee that VF bound
> implies PF bound; the Rust accessor can then leverage this guarantee.
>
> This can also be leveraged by the C code, where we could have a separate
> accessor that checks the bool rather than askes the driver to promise that the
> PF is bound, which pci_iov_get_pf_drvdata() does.
>
> (Although I have to admit that without the additional type system capabilities
> we have in Rust, it is not that big of an improvement.)
This seems like it has a decent chance of succeeding..
Though as I said in my other email, you'd probably want a version
where there is WARN_ON if that common code is actually triggered as it
would be a driver bug to misorder its destruction.
Jason
Powered by blists - more mailing lists