Re: [PATCH v2 2/2] PCI: pciehp: Prevent deadlock on disconnect

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

 



On Thu, Oct 24, 2019 at 12:38:03PM +0300, Mika Westerberg wrote:
> On Wed, Oct 23, 2019 at 10:52:53AM +0300, Mika Westerberg wrote:
> > > Shouldn't we check for slot_status being an error response (~0)
> > > instead of looking for PCIBIOS_DEVICE_NOT_FOUND?  There are 7 RsvdP
> > > bits in Slot Status, so ~0 is not a valid value for the register.
> > > 
> > > All 16 bits of Link Status are defined, but ~0 is still an invalid
> > > value because the Current Link Speed and Negotiated Link Width fields
> > > only define a few valid encodings.
> > 
> > Indeed that's a good point. I'll try that.
> 
> Just checking if I understand correctly what you are suggesting.
> 
> Currently we use pcie_capability_read_word() and check the return value.
> If the device is gone it returns an error and resets *val to 0. That
> only works if pci_dev_is_disconnected() is true so we would need to do
> something like below.
> 
> pciehp_check_link_active():
> 
> 	ret = pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status);
> 	if (ret == PCIBIOS_DEVICE_NOT_FOUND || lnk_status == (u16)~0)
> 		return -ENODEV;

Yes, I guess this is what you'd have to do.

> Or you mean that we check only for ~0 in which case we either need to
> use pci_read_config_word() directly here or modify pcie_capability_read_word()
> return ~0 instead of clearing it?

I *would* like to explore removing the "*val = 0" code from
pci_capability_read*(), but not in the context of this issue.



[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