69fbf5c80fdf63d84aeac18c5a2b3c3abe112bb2
[openwrt/staging/blogic.git] /
1 From 21a10846d09db3c5e3bdfb0be0fc7aa9fdc7000a Mon Sep 17 00:00:00 2001
2 From: Ian Molton <ian@mnementh.co.uk>
3 Date: Fri, 8 Dec 2017 13:10:35 +0100
4 Subject: [PATCH] brcmfmac: Remove repeated calls to brcmf_chip_get_core()
5
6 There is no need to repeatdly call brcmf_chip_get_core(), which
7 traverses a list of cores every time its called (including during
8 register access code!).
9
10 Call it once, and store a pointer to the core structure. The existing
11 code does nto keep track of users of the cores anyway, and even so, this
12 will allow for easier refcounting in future.
13
14 Signed-off-by: Ian Molton <ian@mnementh.co.uk>
15 Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
16 Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
17 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
18 ---
19 .../wireless/broadcom/brcm80211/brcmfmac/sdio.c | 25 +++++++++++++---------
20 1 file changed, 15 insertions(+), 10 deletions(-)
21
22 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
23 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
24 @@ -436,6 +436,7 @@ struct brcmf_sdio_count {
25 struct brcmf_sdio {
26 struct brcmf_sdio_dev *sdiodev; /* sdio device handler */
27 struct brcmf_chip *ci; /* Chip info struct */
28 + struct brcmf_core *sdio_core; /* sdio core info struct */
29
30 u32 hostintmask; /* Copy of Host Interrupt Mask */
31 atomic_t intstatus; /* Intstatus bits (events) pending */
32 @@ -665,10 +666,9 @@ static bool data_ok(struct brcmf_sdio *b
33 */
34 static int r_sdreg32(struct brcmf_sdio *bus, u32 *regvar, u32 offset)
35 {
36 - struct brcmf_core *core;
37 + struct brcmf_core *core = bus->sdio_core;
38 int ret;
39
40 - core = brcmf_chip_get_core(bus->ci, BCMA_CORE_SDIO_DEV);
41 *regvar = brcmf_sdiod_readl(bus->sdiodev, core->base + offset, &ret);
42
43 return ret;
44 @@ -676,10 +676,9 @@ static int r_sdreg32(struct brcmf_sdio *
45
46 static int w_sdreg32(struct brcmf_sdio *bus, u32 regval, u32 reg_offset)
47 {
48 - struct brcmf_core *core;
49 + struct brcmf_core *core = bus->sdio_core;
50 int ret;
51
52 - core = brcmf_chip_get_core(bus->ci, BCMA_CORE_SDIO_DEV);
53 brcmf_sdiod_writel(bus->sdiodev, core->base + reg_offset, regval, &ret);
54
55 return ret;
56 @@ -2495,12 +2494,11 @@ static inline void brcmf_sdio_clrintr(st
57
58 static int brcmf_sdio_intr_rstatus(struct brcmf_sdio *bus)
59 {
60 - struct brcmf_core *buscore;
61 + struct brcmf_core *buscore = bus->sdio_core;
62 u32 addr;
63 unsigned long val;
64 int ret;
65
66 - buscore = brcmf_chip_get_core(bus->ci, BCMA_CORE_SDIO_DEV);
67 addr = buscore->base + SD_REG(intstatus);
68
69 val = brcmf_sdiod_readl(bus->sdiodev, addr, &ret);
70 @@ -3377,13 +3375,14 @@ static void brcmf_sdio_sr_init(struct br
71 /* enable KSO bit */
72 static int brcmf_sdio_kso_init(struct brcmf_sdio *bus)
73 {
74 + struct brcmf_core *core = bus->sdio_core;
75 u8 val;
76 int err = 0;
77
78 brcmf_dbg(TRACE, "Enter\n");
79
80 /* KSO bit added in SDIO core rev 12 */
81 - if (brcmf_chip_get_core(bus->ci, BCMA_CORE_SDIO_DEV)->rev < 12)
82 + if (core->rev < 12)
83 return 0;
84
85 val = brcmf_sdiod_readb(bus->sdiodev, SBSDIO_FUNC1_SLEEPCSR, &err);
86 @@ -3412,6 +3411,7 @@ static int brcmf_sdio_bus_preinit(struct
87 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
88 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio;
89 struct brcmf_sdio *bus = sdiodev->bus;
90 + struct brcmf_core *core = bus->sdio_core;
91 uint pad_size;
92 u32 value;
93 int err;
94 @@ -3420,7 +3420,7 @@ static int brcmf_sdio_bus_preinit(struct
95 * a device perspective, ie. bus:txglom affects the
96 * bus transfers from device to host.
97 */
98 - if (brcmf_chip_get_core(bus->ci, BCMA_CORE_SDIO_DEV)->rev < 12) {
99 + if (core->rev < 12) {
100 /* for sdio core rev < 12, disable txgloming */
101 value = 0;
102 err = brcmf_iovar_data_set(dev, "bus:txglom", &value,
103 @@ -3758,11 +3758,10 @@ static void brcmf_sdio_buscore_activate(
104 u32 rstvec)
105 {
106 struct brcmf_sdio_dev *sdiodev = ctx;
107 - struct brcmf_core *core;
108 + struct brcmf_core *core = sdiodev->bus->sdio_core;
109 u32 reg_addr;
110
111 /* clear all interrupts */
112 - core = brcmf_chip_get_core(chip, BCMA_CORE_SDIO_DEV);
113 reg_addr = core->base + SD_REG(intstatus);
114 brcmf_sdiod_writel(sdiodev, reg_addr, 0xFFFFFFFF, NULL);
115
116 @@ -3843,6 +3842,12 @@ brcmf_sdio_probe_attach(struct brcmf_sdi
117 bus->ci = NULL;
118 goto fail;
119 }
120 +
121 + /* Pick up the SDIO core info struct from chip.c */
122 + bus->sdio_core = brcmf_chip_get_core(bus->ci, BCMA_CORE_SDIO_DEV);
123 + if (!bus->sdio_core)
124 + goto fail;
125 +
126 sdiodev->settings = brcmf_get_module_param(sdiodev->dev,
127 BRCMF_BUSTYPE_SDIO,
128 bus->ci->chip,