230e891cea1e8b39508e064fe6de6ccd3cf302d6
[oweals/openwrt.git] /
1 From 4b5adc736828dc25ca33e263ad8c0b9dcd3bf325 Mon Sep 17 00:00:00 2001
2 From: Arend Van Spriel <arend.vanspriel@broadcom.com>
3 Date: Tue, 20 Feb 2018 00:14:19 +0100
4 Subject: [PATCH] brcmfmac: move allocation of control rx buffer to
5  brcmf_sdio_bus_preinit()
6
7 Allocate the control rx buffer needed for firmware control interface
8 during brcmf_sdio_bus_preinit(). This relies on common layer setting
9 struct brcmf_bus::maxctl during brcmf_attach(). By moving the allocation
10 we can move brcmf_attach() in subsequent change.
11
12 Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
13 Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
14 Reviewed-by: Franky Lin <franky.lin@broadcom.com>
15 Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
16 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
17 ---
18  .../wireless/broadcom/brcm80211/brcmfmac/sdio.c    | 26 ++++++++++------------
19  1 file changed, 12 insertions(+), 14 deletions(-)
20
21 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
22 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
23 @@ -1707,7 +1707,6 @@ brcmf_sdio_read_control(struct brcmf_sdi
24         int sdret;
25  
26         brcmf_dbg(TRACE, "Enter\n");
27 -
28         if (bus->rxblen)
29                 buf = vzalloc(bus->rxblen);
30         if (!buf)
31 @@ -3411,6 +3410,18 @@ static int brcmf_sdio_bus_preinit(struct
32         u32 value;
33         int err;
34  
35 +       /* maxctl provided by common layer */
36 +       if (WARN_ON(!bus_if->maxctl))
37 +               return -EINVAL;
38 +
39 +       /* Allocate control receive buffer */
40 +       bus_if->maxctl += bus->roundup;
41 +       value = roundup((bus_if->maxctl + SDPCM_HDRLEN), ALIGNMENT);
42 +       value += bus->head_align;
43 +       bus->rxbuf = kmalloc(value, GFP_ATOMIC);
44 +       if (bus->rxbuf)
45 +               bus->rxblen = value;
46 +
47         /* the commands below use the terms tx and rx from
48          * a device perspective, ie. bus:txglom affects the
49          * bus transfers from device to host.
50 @@ -4209,19 +4220,6 @@ struct brcmf_sdio *brcmf_sdio_probe(stru
51         bus->blocksize = bus->sdiodev->func2->cur_blksize;
52         bus->roundup = min(max_roundup, bus->blocksize);
53  
54 -       /* Allocate buffers */
55 -       if (bus->sdiodev->bus_if->maxctl) {
56 -               bus->sdiodev->bus_if->maxctl += bus->roundup;
57 -               bus->rxblen =
58 -                   roundup((bus->sdiodev->bus_if->maxctl + SDPCM_HDRLEN),
59 -                           ALIGNMENT) + bus->head_align;
60 -               bus->rxbuf = kmalloc(bus->rxblen, GFP_ATOMIC);
61 -               if (!(bus->rxbuf)) {
62 -                       brcmf_err("rxbuf allocation failed\n");
63 -                       goto fail;
64 -               }
65 -       }
66 -
67         sdio_claim_host(bus->sdiodev->func1);
68  
69         /* Disable F2 to clear any intermediate frame state on the dongle */