mwlwifi: fix excessive use of busy-waiting that was tripping up the flash driver
[librecmc/librecmc.git] / package / kernel / mwlwifi / patches / 200-fix_excessive_delays.patch
1 --- a/fwcmd.c
2 +++ b/fwcmd.c
3 @@ -132,7 +132,7 @@ static int mwl_fwcmd_wait_complete(struc
4                         int_code = le16_to_cpu(*((__le16 *)&priv->pcmd_buf[2]));
5                 else
6                         int_code = le16_to_cpu(*((__le16 *)&priv->pcmd_buf[0]));
7 -               mdelay(1);
8 +               usleep_range(1000, 2000);
9         } while ((int_code != cmd) && (--curr_iteration));
10  
11         if (curr_iteration == 0) {
12 @@ -142,7 +142,7 @@ static int mwl_fwcmd_wait_complete(struc
13                 return -EIO;
14         }
15  
16 -       mdelay(3);
17 +       usleep_range(3000, 5000);
18  
19         return 0;
20  }
21 --- a/fwdl.c
22 +++ b/fwdl.c
23 @@ -74,7 +74,7 @@ int mwl_fwdl_download_firmware(struct ie
24         /* FW before jumping to boot rom, it will enable PCIe transaction retry,
25          * wait for boot code to stop it.
26          */
27 -       mdelay(FW_CHECK_MSECS);
28 +       usleep_range(FW_CHECK_MSECS * 1000, FW_CHECK_MSECS * 2000);
29  
30         writel(MACREG_A2HRIC_BIT_MASK,
31                priv->iobase1 + MACREG_REG_A2H_INTERRUPT_CLEAR_SEL);
32 @@ -95,7 +95,7 @@ int mwl_fwdl_download_firmware(struct ie
33  
34         /* make sure SCRATCH2 C40 is clear, in case we are too quick */
35         while (readl(priv->iobase1 + 0xc40) == 0)
36 -               ;
37 +               cond_resched();
38  
39         while (size_fw_downloaded < fw->size) {
40                 len = readl(priv->iobase1 + 0xc40);
41 @@ -125,6 +125,7 @@ int mwl_fwdl_download_firmware(struct ie
42                         int_code = readl(priv->iobase1 + 0xc1c);
43                         if (int_code != 0)
44                                 break;
45 +                       cond_resched();
46                         curr_iteration--;
47                 } while (curr_iteration);
48  
49 @@ -133,6 +134,7 @@ int mwl_fwdl_download_firmware(struct ie
50                         if ((int_code & MACREG_H2ARIC_BIT_DOOR_BELL) !=
51                             MACREG_H2ARIC_BIT_DOOR_BELL)
52                                 break;
53 +                       cond_resched();
54                         curr_iteration--;
55                 } while (curr_iteration);
56  
57 @@ -167,12 +169,14 @@ int mwl_fwdl_download_firmware(struct ie
58         do {
59                 curr_iteration--;
60                 if (priv->mfg_mode && priv->chip_type == MWL8897) {
61 -                       mdelay(FW_CHECK_MSECS);
62 +                       usleep_range(FW_CHECK_MSECS * 1000,
63 +                                    FW_CHECK_MSECS * 2000);
64                         int_code = readl(priv->iobase1 + 0xc44);
65                 } else {
66                         writel(HOSTCMD_SOFTAP_MODE,
67                                priv->iobase1 + MACREG_REG_GEN_PTR);
68 -                       mdelay(FW_CHECK_MSECS);
69 +                       usleep_range(FW_CHECK_MSECS * 1000,
70 +                                    FW_CHECK_MSECS * 2000);
71                         int_code = readl(priv->iobase1 + MACREG_REG_INT_CODE);
72                 }
73                 if (!(curr_iteration % 0xff) && (int_code != 0))