Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d83388f9 authored by Siddartha Mohanadoss's avatar Siddartha Mohanadoss
Browse files

msm: pci-msm: Add delay during system resume



With a PCIe switch connected to application processor
during system resume the clients host driver tries to
access the config space over the link but the end
point may not be accessible yet. This causes invalid
config space read. Therefore poll to give the end point
enough time to link up before any access to the
end points config space.

Change-Id: Id45b6f313461c4169507df8071d53f7cacd59bb5
Signed-off-by: default avatarSiddartha Mohanadoss <smohanad@codeaurora.org>
parent 48476141
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -7150,7 +7150,8 @@ int msm_pcie_pm_control(enum msm_pcie_pm_opt pm_opt, u32 busnr, void *user,
{
	int ret = 0;
	struct pci_dev *dev;
	u32 rc_idx = 0;
	u32 rc_idx = 0, count = 0;
	u16 device_id;
	struct msm_pcie_dev_t *pcie_dev;

	PCIE_GEN_DBG("PCIe: pm_opt:%d;busnr:%d;options:%d\n",
@@ -7240,6 +7241,23 @@ int msm_pcie_pm_control(enum msm_pcie_pm_opt pm_opt, u32 busnr, void *user,
				"PCIe: RC%d: requested to resume when link is not disabled:%d. Number of active EP(s): %d\n",
				rc_idx, msm_pcie_dev[rc_idx].link_status,
				msm_pcie_dev[rc_idx].num_active_ep);
			pci_read_config_word((struct pci_dev *)user,
						PCI_DEVICE_ID, &device_id);
			while (device_id != (((struct pci_dev *)user)->device)
					&& count < LINK_UP_CHECK_MAX_COUNT) {
				usleep_range(LINK_UP_TIMEOUT_US_MIN,
						LINK_UP_TIMEOUT_US_MAX);
				pci_read_config_word((struct pci_dev *)user,
						PCI_DEVICE_ID, &device_id);
				PCIE_DBG(&msm_pcie_dev[rc_idx],
					"PCIe: RC:%d, device_id_read:0x%x\n",
					rc_idx, device_id);
				count++;
			}
			if (count >= LINK_UP_CHECK_MAX_COUNT)
				PCIE_ERR(&msm_pcie_dev[rc_idx],
					"PCIe: RC:%d invalid device id\n",
					rc_idx);
			break;
		}