PCI: pciehp: replace unconditional sleep with config space access check
authorYinghai Lu <yinghai@kernel.org>
Fri, 27 Jan 2012 18:55:11 +0000 (10:55 -0800)
committerJesse Barnes <jbarnes@virtuousgeek.org>
Tue, 14 Feb 2012 16:45:00 +0000 (08:45 -0800)
commit2f5d8e4ff947ad6673397083b48719cd6c59cd61
tree46e1c6901937b7f983b511d6e14498000e2989bb
parentefdc87dab1cdf25ba631181ac0ead3fb2023dd10
PCI: pciehp: replace unconditional sleep with config space access check

During reviewing
| PCI: pciehp: wait 1000 ms before Link Training check
Linus said:
>...
> That's a *long* time, and it's irritating to the user. It makes the
> user think "the machine is slow".
>...
> And quite frankly, an unconditional one-second delay here seems bad.
>Two seconds was unacceptable, one second is just bad.

Try to access the pci conf of a pci device that is supposed to show up
in 1s.  If we can read back a valid vendor/device id, we can return
early.

Related discussion could be found:
https://lkml.org/lkml/2011/12/6/339

-v2: seperate code to pci_bus_read_dev_vendor_id() from pci_scan_device()
    and reuse it from pciehp code. Suggested by Matthew Wilcox.
-v3: According to Kenj, don't use array in stack, and don't wait too long
    for crs, also return fail status if not found.
    Also separate pci_bus_dev_read_vendor_id() change to another patch.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
drivers/pci/hotplug/pciehp_hpc.c