Re: [PATCHv6 3/5] pci: No config access for disconnected devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 08, 2017 at 07:04:10AM +0100, Lukas Wunner wrote:
> On Tue, Feb 07, 2017 at 02:32:35PM -0500, Keith Busch wrote:
> > If we've  detected the PCI device is disconnected, there is no need to
> > attempt to access its config space since we know the operation will
> > fail. This patch has all the config reads and writes return -ENODEV
> > error immediately when in such a state.
> > 
> > If a config read is sent to a disconnected device, the value will be
> > set to all 1's. This is the same as what hardware is expected to return
> > when accessing a removed device, but software can do this faster without
> > relying on hardware.
> > 
> > Signed-off-by: Keith Busch <keith.busch@xxxxxxxxx>
> > Reviewed-by: Christoph Hellwig <hch@xxxxxx>
> > ---
> >  drivers/pci/access.c | 18 ++++++++++++++++++
> >  1 file changed, 18 insertions(+)
> > 
> > diff --git a/drivers/pci/access.c b/drivers/pci/access.c
> > index d37b2ed..d63e9dd 100644
> > --- a/drivers/pci/access.c
> > +++ b/drivers/pci/access.c
> > @@ -892,12 +892,20 @@ EXPORT_SYMBOL(pcie_capability_clear_and_set_dword);
> >  
> >  int pci_read_config_byte(const struct pci_dev *dev, int where, u8 *val)
> >  {
> > +	if (pci_dev_is_disconnected(dev)) {
> 
> You used to have unlikely() here up until v4 but dropped it in v5.
> Why?  Seemed sensible to me.

Didn't mean to remove the unlikely. The micro-optimization isn't in a
performance path, but I'll build it back in.



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux