Re: [PATCH RFC 1/2] PCI: Add controller reset method

Manivannan Sadhasivam <[email protected]>
Newsgroups org.kernel.vger.linux-pci,org.kernel.vger.linux-hyperv,org.kernel.vger.linux-kernel
Message-ID <rlgkynaq654kznkcxfgwi7mv3w2qymq5dieof5zskdq23gaica@o4zcrt2pgxdk>
On Mon, Aug 10, 2026 at 11:55:45AM -0700, Wei Liu wrote:
> Hi Bjorn,
> 
> Since this is adding to the PCI reset framework, this patch needs your
> approval.
> 
> Please see below for my questions. I'm happy to change the code however
> you see fit.
> 
> On Fri, Jul 24, 2026 at 04:08:42PM -0700, [email protected] wrote:
> > From: Wei Liu <[email protected]>
> > 
> > Some PCI controllers provide a function reset mechanism that is not
> > advertised in PCI configuration space. Allow them to expose it through an
> > optional pci_ops callback.
> > 
> > Add the controller reset method to the standard reset_method interface.
> > Prefer FLR and AF FLR by default, and use the controller operation before
> > PM and bus reset fallbacks.
> > 
> > Signed-off-by: Wei Liu <[email protected]>
> > ---
> >  drivers/pci/pci.c   | 22 ++++++++++++++++++++++
> >  include/linux/pci.h |  3 ++-
> >  2 files changed, 24 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> > index 77b17b13ee61..4e55da202cad 100644
> > --- a/drivers/pci/pci.c
> > +++ b/drivers/pci/pci.c
> > @@ -4962,6 +4962,27 @@ static int pci_reset_bus_function(struct pci_dev *dev, bool probe)
> >  	return rc;
> >  }
> >  
> > +static int pci_controller_reset(struct pci_dev *dev, bool probe)
> > +{
> > +	int rc;
> > +
> > +	if (!dev->bus->ops->reset)
> > +		return -ENOTTY;
> > +
> > +	if (probe)
> > +		return dev->bus->ops->reset(dev, probe);
> > +
> > +	rc = pci_dev_reset_iommu_prepare(dev);
> > +	if (rc) {
> > +		pci_err(dev, "failed to stop IOMMU for a PCI reset: %d\n", rc);
> > +		return rc;
> > +	}
> > +
> > +	rc = dev->bus->ops->reset(dev, probe);
> > +	pci_dev_reset_iommu_done(dev);
> > +	return rc;
> > +}
> > +
> 
> The first question is whether modelling this on the controller level
> is the correct approach.
> 
> Please refer to the second patch for the intended usage in the Hyper-V
> vPCI code.
> 
> Whatever is added here, a new reset_method value will be added to the
> table. I chose "controller" to reflect the decision above.
> 

I recently added a hook for resetting the Root Ports in a platform specific way
[1]. This new hook is called in the SBR reset path. Will it work for you?

- Mani

[1] https://lore.kernel.org/all/[email protected]/

-- 
மணிவண்ணன் சதாசிவம்
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.