Pārlūkot izejas kodu

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
Lin Bai 5 gadi atpakaļ
vecāks
revīzija
21e9784822
1 mainītis faili ar 23 papildinājumiem un 25 dzēšanām
  1. 23 25
      hif/src/pcie/if_pci.c

+ 23 - 25
hif/src/pcie/if_pci.c

@@ -3537,23 +3537,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 +
@@ -3598,28 +3597,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 */