Skip to content

Commit bae2684

Browse files
Vidya Sagarbjorn-helgaas
authored andcommitted
PCI/PM: Move pci_dev_wait() definition earlier
Move the definition of pci_dev_wait() above pci_power_up() so that it can be called from the latter with no change in functionality. This is a pure code move with no functional change. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vidya Sagar <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent ad9001f commit bae2684

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

drivers/pci/pci.c

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,47 @@ void pci_wakeup_bus(struct pci_bus *bus)
10121012
pci_walk_bus(bus, pci_wakeup, NULL);
10131013
}
10141014

1015+
static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout)
1016+
{
1017+
int delay = 1;
1018+
u32 id;
1019+
1020+
/*
1021+
* After reset, the device should not silently discard config
1022+
* requests, but it may still indicate that it needs more time by
1023+
* responding to them with CRS completions. The Root Port will
1024+
* generally synthesize ~0 data to complete the read (except when
1025+
* CRS SV is enabled and the read was for the Vendor ID; in that
1026+
* case it synthesizes 0x0001 data).
1027+
*
1028+
* Wait for the device to return a non-CRS completion. Read the
1029+
* Command register instead of Vendor ID so we don't have to
1030+
* contend with the CRS SV value.
1031+
*/
1032+
pci_read_config_dword(dev, PCI_COMMAND, &id);
1033+
while (id == ~0) {
1034+
if (delay > timeout) {
1035+
pci_warn(dev, "not ready %dms after %s; giving up\n",
1036+
delay - 1, reset_type);
1037+
return -ENOTTY;
1038+
}
1039+
1040+
if (delay > 1000)
1041+
pci_info(dev, "not ready %dms after %s; waiting\n",
1042+
delay - 1, reset_type);
1043+
1044+
msleep(delay);
1045+
delay *= 2;
1046+
pci_read_config_dword(dev, PCI_COMMAND, &id);
1047+
}
1048+
1049+
if (delay > 1000)
1050+
pci_info(dev, "ready %dms after %s\n", delay - 1,
1051+
reset_type);
1052+
1053+
return 0;
1054+
}
1055+
10151056
/**
10161057
* pci_power_up - Put the given device into D0
10171058
* @dev: PCI device to power up
@@ -4406,47 +4447,6 @@ int pci_wait_for_pending_transaction(struct pci_dev *dev)
44064447
}
44074448
EXPORT_SYMBOL(pci_wait_for_pending_transaction);
44084449

4409-
static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout)
4410-
{
4411-
int delay = 1;
4412-
u32 id;
4413-
4414-
/*
4415-
* After reset, the device should not silently discard config
4416-
* requests, but it may still indicate that it needs more time by
4417-
* responding to them with CRS completions. The Root Port will
4418-
* generally synthesize ~0 data to complete the read (except when
4419-
* CRS SV is enabled and the read was for the Vendor ID; in that
4420-
* case it synthesizes 0x0001 data).
4421-
*
4422-
* Wait for the device to return a non-CRS completion. Read the
4423-
* Command register instead of Vendor ID so we don't have to
4424-
* contend with the CRS SV value.
4425-
*/
4426-
pci_read_config_dword(dev, PCI_COMMAND, &id);
4427-
while (id == ~0) {
4428-
if (delay > timeout) {
4429-
pci_warn(dev, "not ready %dms after %s; giving up\n",
4430-
delay - 1, reset_type);
4431-
return -ENOTTY;
4432-
}
4433-
4434-
if (delay > 1000)
4435-
pci_info(dev, "not ready %dms after %s; waiting\n",
4436-
delay - 1, reset_type);
4437-
4438-
msleep(delay);
4439-
delay *= 2;
4440-
pci_read_config_dword(dev, PCI_COMMAND, &id);
4441-
}
4442-
4443-
if (delay > 1000)
4444-
pci_info(dev, "ready %dms after %s\n", delay - 1,
4445-
reset_type);
4446-
4447-
return 0;
4448-
}
4449-
44504450
/**
44514451
* pcie_has_flr - check if a device supports function level resets
44524452
* @dev: device to check

0 commit comments

Comments
 (0)