ath10k: increase bmi timeout to fix OTP on qca99xx boards and add bmi identification...
[librecmc/librecmc.git] / package / kernel / mac80211 / patches / 328-ath10k-log-when-longer-bmi-cmds-happen.patch
1 From: Ben Greear <greearb@candelatech.com>
2 Date: Wed, 31 May 2017 14:21:21 +0300
3 Subject: [PATCH] ath10k: log when longer bmi cmds happen
4
5 This lets one have a clue that maybe timeouts are happening
6 when we just aren't waiting long enough.
7
8 Signed-off-by: Ben Greear <greearb@candelatech.com>
9 Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
10 ---
11
12 --- a/drivers/net/wireless/ath/ath10k/pci.c
13 +++ b/drivers/net/wireless/ath/ath10k/pci.c
14 @@ -101,7 +101,8 @@ static int ath10k_pci_init_irq(struct at
15  static int ath10k_pci_deinit_irq(struct ath10k *ar);
16  static int ath10k_pci_request_irq(struct ath10k *ar);
17  static void ath10k_pci_free_irq(struct ath10k *ar);
18 -static int ath10k_pci_bmi_wait(struct ath10k_ce_pipe *tx_pipe,
19 +static int ath10k_pci_bmi_wait(struct ath10k *ar,
20 +                              struct ath10k_ce_pipe *tx_pipe,
21                                struct ath10k_ce_pipe *rx_pipe,
22                                struct bmi_xfer *xfer);
23  static int ath10k_pci_qca99x0_chip_reset(struct ath10k *ar);
24 @@ -1843,7 +1844,7 @@ int ath10k_pci_hif_exchange_bmi_msg(stru
25         if (ret)
26                 goto err_resp;
27  
28 -       ret = ath10k_pci_bmi_wait(ce_tx, ce_rx, &xfer);
29 +       ret = ath10k_pci_bmi_wait(ar, ce_tx, ce_rx, &xfer);
30         if (ret) {
31                 u32 unused_buffer;
32                 unsigned int unused_nbytes;
33 @@ -1910,23 +1911,37 @@ static void ath10k_pci_bmi_recv_data(str
34         xfer->rx_done = true;
35  }
36  
37 -static int ath10k_pci_bmi_wait(struct ath10k_ce_pipe *tx_pipe,
38 +static int ath10k_pci_bmi_wait(struct ath10k *ar,
39 +                              struct ath10k_ce_pipe *tx_pipe,
40                                struct ath10k_ce_pipe *rx_pipe,
41                                struct bmi_xfer *xfer)
42  {
43         unsigned long timeout = jiffies + BMI_COMMUNICATION_TIMEOUT_HZ;
44 +       unsigned long started = jiffies;
45 +       unsigned long dur;
46 +       int ret;
47  
48         while (time_before_eq(jiffies, timeout)) {
49                 ath10k_pci_bmi_send_done(tx_pipe);
50                 ath10k_pci_bmi_recv_data(rx_pipe);
51  
52 -               if (xfer->tx_done && (xfer->rx_done == xfer->wait_for_resp))
53 -                       return 0;
54 +               if (xfer->tx_done && (xfer->rx_done == xfer->wait_for_resp)) {
55 +                       ret = 0;
56 +                       goto out;
57 +               }
58  
59                 schedule();
60         }
61  
62 -       return -ETIMEDOUT;
63 +       ret = -ETIMEDOUT;
64 +
65 +out:
66 +       dur = jiffies - started;
67 +       if (dur > HZ)
68 +               ath10k_dbg(ar, ATH10K_DBG_BMI,
69 +                          "bmi cmd took %lu jiffies hz %d ret %d\n",
70 +                          dur, HZ, ret);
71 +       return ret;
72  }
73  
74  /*