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

Commit 659d8bfe authored by Lin Bai's avatar Lin Bai Committed by snandini
Browse files

qcacmn: Use sync method to wake device

Use sync wake when trying to awake device for register
accessing.
This can avoid device re-enter low power mode after
device_wake asserted.

Change-Id: Iba62f5753ccb7e11d9746a445db4cce48e5e3a14
CRs-Fixed: 2703609
parent 5ca0ca4a
Loading
Loading
Loading
Loading
+23 −25
Original line number Diff line number Diff line
@@ -4945,23 +4945,22 @@ int hif_force_wake_request(struct hif_opaque_softc *hif_handle)
	struct hif_softc *scn = (struct hif_softc *)hif_handle;
	struct hif_pci_softc *pci_scn = HIF_GET_PCI_SOFTC(scn);

	if (pld_force_wake_request(scn->qdf_dev->dev)) {
		hif_err("force wake request send failed");
		return -EINVAL;
	}

	HIF_STATS_INC(pci_scn, mhi_force_wake_request_vote, 1);
	while (!pld_is_device_awake(scn->qdf_dev->dev) &&
	       timeout <= FORCE_WAKE_DELAY_TIMEOUT_MS) {
		qdf_mdelay(FORCE_WAKE_DELAY_MS);
		timeout += FORCE_WAKE_DELAY_MS;
	}

	if (pld_is_device_awake(scn->qdf_dev->dev) <= 0) {
		hif_err("Unable to wake up mhi");
	if (pld_force_wake_request_sync(scn->qdf_dev->dev,
					FORCE_WAKE_DELAY_TIMEOUT_MS * 1000)) {
		hif_err("force wake request send failed");
		HIF_STATS_INC(pci_scn, mhi_force_wake_failure, 1);
		return -EINVAL;
	}

	/* If device's M1 state-change event races here, it can be ignored,
	 * as the device is expected to immediately move from M2 to M0
	 * without entering low power state.
	 */
	if (!pld_is_device_awake(scn->qdf_dev->dev))
		HIF_INFO("%s: state-change event races, ignore", __func__);

	HIF_STATS_INC(pci_scn, mhi_force_wake_success, 1);
	hif_write32_mb(scn,
		       scn->mem +
@@ -5006,28 +5005,27 @@ int hif_force_wake_request(struct hif_opaque_softc *hif_handle)
 */
int hif_force_wake_request(struct hif_opaque_softc *hif_handle)
{
	uint32_t timeout = 0;
	struct hif_softc *scn = (struct hif_softc *)hif_handle;
	struct hif_pci_softc *pci_scn = HIF_GET_PCI_SOFTC(scn);

	if (pld_force_wake_request(scn->qdf_dev->dev)) {
		hif_err("force wake request send failed");
		return -EINVAL;
	}

	HIF_STATS_INC(pci_scn, mhi_force_wake_request_vote, 1);
	while (!pld_is_device_awake(scn->qdf_dev->dev) &&
	       timeout <= FORCE_WAKE_DELAY_TIMEOUT_MS) {
		qdf_mdelay(FORCE_WAKE_DELAY_MS);
		timeout += FORCE_WAKE_DELAY_MS;
	}

	if (pld_is_device_awake(scn->qdf_dev->dev) <= 0) {
		hif_err("Unable to wake up mhi");
	if (pld_force_wake_request_sync(scn->qdf_dev->dev,
					FORCE_WAKE_DELAY_TIMEOUT_MS * 1000)) {
		hif_err("force wake request send failed");
		HIF_STATS_INC(pci_scn, mhi_force_wake_failure, 1);
		return -EINVAL;
	}

	/* If device's M1 state-change event races here, it can be ignored,
	 * as the device is expected to immediately move from M2 to M0
	 * without entering low power state.
	 */
	if (!pld_is_device_awake(scn->qdf_dev->dev))
		HIF_INFO("%s: state-change event races, ignore", __func__);

	HIF_STATS_INC(pci_scn, mhi_force_wake_success, 1);

	return 0;
}
#endif /* DEVICE_FORCE_WAKE_ENABLE */