345-brcmfmac-Remove-waitqueue_active-check.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. From: Hui Wang <hui.wang@canonical.com>
  2. Date: Wed, 9 Mar 2016 15:25:26 +0800
  3. Subject: [PATCH] brcmfmac: Remove waitqueue_active check
  4. We met a problem of pm_suspend when repeated closing/opening the lid
  5. on a Lenovo laptop (1/20 reproduce rate), below is the log:
  6. [ 199.735876] PM: Entering mem sleep
  7. [ 199.750516] e1000e: EEE TX LPI TIMER: 00000011
  8. [ 199.856638] Trying to free nonexistent resource <000000000000d000-000000000000d0ff>
  9. [ 201.753566] brcmfmac: brcmf_pcie_suspend: Timeout on response for entering D3 substate
  10. [ 201.753581] pci_legacy_suspend(): brcmf_pcie_suspend+0x0/0x1f0 [brcmfmac] returns -5
  11. [ 201.753585] dpm_run_callback(): pci_pm_suspend+0x0/0x160 returns -5
  12. [ 201.753589] PM: Device 0000:04:00.0 failed to suspend async: error -5
  13. Through debugging, we found when problem happens, it is not the device
  14. fails to enter D3, but the signal D3_ACK comes too early to pass the
  15. waitqueue_active() check.
  16. Just like this:
  17. brcmf_pcie_send_mb_data(devinfo, BRCMF_H2D_HOST_D3_INFORM);
  18. // signal is triggered here
  19. wait_event_timeout(devinfo->mbdata_resp_wait, devinfo->mbdata_completed,
  20. BRCMF_PCIE_MBDATA_TIMEOUT);
  21. So far I think it is safe to remove waitqueue_active check since there
  22. is only one place to trigger this signal (sending
  23. BRCMF_H2D_HOST_D3_INFORM). And it is not a problem calling wake_up
  24. event earlier than calling wait_event.
  25. Cc: Brett Rudley <brudley@broadcom.com>
  26. Cc: Hante Meuleman <meuleman@broadcom.com>
  27. Cc: Franky (Zhenhui) Lin <frankyl@broadcom.com>
  28. Cc: Pieter-Paul Giesberts <pieterpg@broadcom.com>
  29. Cc: Arend van Spriel <arend@broadcom.com>
  30. Signed-off-by: Hui Wang <hui.wang@canonical.com>
  31. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  32. ---
  33. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
  34. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
  35. @@ -677,10 +677,8 @@ static void brcmf_pcie_handle_mb_data(st
  36. brcmf_dbg(PCIE, "D2H_MB_DATA: DEEP SLEEP EXIT\n");
  37. if (dtoh_mb_data & BRCMF_D2H_DEV_D3_ACK) {
  38. brcmf_dbg(PCIE, "D2H_MB_DATA: D3 ACK\n");
  39. - if (waitqueue_active(&devinfo->mbdata_resp_wait)) {
  40. - devinfo->mbdata_completed = true;
  41. - wake_up(&devinfo->mbdata_resp_wait);
  42. - }
  43. + devinfo->mbdata_completed = true;
  44. + wake_up(&devinfo->mbdata_resp_wait);
  45. }
  46. }