2018-02-19 23:14:33

by Arend Van Spriel

[permalink] [raw]
Subject: [PATCH 0/8] brcmfmac: cleanup and some rework

This series is intended for 4.17 and includes following:

* rework bus layer attach code.
* remove duplicate variable declaration.

These patches apply to the master branch of the wireless-drivers-next
repository.

Arend van Spriel (8):
brcmfmac: move brcmf_bus_preinit() call just after changing bus state
brcmfmac: move allocation of control rx buffer to
brcmf_sdio_bus_preinit()
brcmfmac: call brcmf_attach() just before calling brcmf_bus_started()
brcmfmac: usb: call brcmf_usb_up() during brcmf_bus_preinit()
brcmfmac: move brcmf_attach() function in core.c
brcmfmac: remove brcmf_bus_started() from bus api
brcmfmac: change log level for some low-level sdio functions
brcmfmac: remove duplicate pointer variable from
brcmf_sdio_firmware_callback()

.../net/wireless/broadcom/brcm80211/brcmfmac/bus.h | 1 -
.../wireless/broadcom/brcm80211/brcmfmac/common.c | 3 -
.../wireless/broadcom/brcm80211/brcmfmac/core.c | 119 ++++++++++++---------
.../wireless/broadcom/brcm80211/brcmfmac/pcie.c | 20 +---
.../wireless/broadcom/brcm80211/brcmfmac/sdio.c | 95 ++++++++--------
.../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 35 ++----
6 files changed, 117 insertions(+), 156 deletions(-)

--
1.9.1


2018-02-19 23:14:34

by Arend Van Spriel

[permalink] [raw]
Subject: [PATCH 4/8] brcmfmac: usb: call brcmf_usb_up() during brcmf_bus_preinit()

By calling brcmf_usb_up() during brcmf_bus_preinit() it does not need
to be called in brcmf_usb_bus_setup().

Reviewed-by: Hante Meuleman <[email protected]>
Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Franky Lin <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
index b27170c..d22cd166 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
@@ -1146,8 +1146,9 @@ static int brcmf_usb_get_fwname(struct device *dev, u32 chip, u32 chiprev,
}

static const struct brcmf_bus_ops brcmf_usb_bus_ops = {
- .txdata = brcmf_usb_tx,
+ .preinit = brcmf_usb_up,
.stop = brcmf_usb_down,
+ .txdata = brcmf_usb_tx,
.txctl = brcmf_usb_tx_ctlpkt,
.rxctl = brcmf_usb_rx_ctlpkt,
.wowl_config = brcmf_usb_wowl_config,
@@ -1165,10 +1166,6 @@ static int brcmf_usb_bus_setup(struct brcmf_usbdev_info *devinfo)
return ret;
}

- ret = brcmf_usb_up(devinfo->dev);
- if (ret)
- goto fail;
-
ret = brcmf_bus_started(devinfo->dev);
if (ret)
goto fail;
--
1.9.1

2018-02-19 23:14:34

by Arend Van Spriel

[permalink] [raw]
Subject: [PATCH 6/8] brcmfmac: remove brcmf_bus_started() from bus api

No longer needed to call this in bus layer so make it static and call
it in the last phase of brcmf_attach() instead.

Reviewed-by: Hante Meuleman <[email protected]>
Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Franky Lin <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
---
.../net/wireless/broadcom/brcm80211/brcmfmac/bus.h | 1 -
.../wireless/broadcom/brcm80211/brcmfmac/core.c | 14 +++++++----
.../wireless/broadcom/brcm80211/brcmfmac/pcie.c | 20 +---------------
.../wireless/broadcom/brcm80211/brcmfmac/sdio.c | 10 ++------
.../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 28 ++++------------------
5 files changed, 16 insertions(+), 57 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
index 0b76a61..0b90a63b 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
@@ -253,7 +253,6 @@ int brcmf_bus_get_fwname(struct brcmf_bus *bus, uint chip, uint chiprev,
/* Configure the "global" bus state used by upper layers */
void brcmf_bus_change_state(struct brcmf_bus *bus, enum brcmf_bus_state state);

-int brcmf_bus_started(struct device *dev);
s32 brcmf_iovar_data_set(struct device *dev, char *name, void *data, u32 len);
void brcmf_bus_add_txhdrlen(struct device *dev, uint len);

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 9eab7a9..1904852 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -944,11 +944,10 @@ static int brcmf_revinfo_read(struct seq_file *s, void *data)
return 0;
}

-int brcmf_bus_started(struct device *dev)
+static int brcmf_bus_started(struct brcmf_pub *drvr)
{
int ret = -1;
- struct brcmf_bus *bus_if = dev_get_drvdata(dev);
- struct brcmf_pub *drvr = bus_if->drvr;
+ struct brcmf_bus *bus_if = drvr->bus_if;
struct brcmf_if *ifp;
struct brcmf_if *p2p_ifp;

@@ -965,7 +964,7 @@ int brcmf_bus_started(struct device *dev)
brcmf_bus_change_state(bus_if, BRCMF_BUS_UP);

/* do bus specific preinit here */
- ret = brcmf_bus_preinit(ifp->drvr->bus_if);
+ ret = brcmf_bus_preinit(bus_if);
if (ret < 0)
goto fail;

@@ -1085,7 +1084,12 @@ int brcmf_attach(struct device *dev, struct brcmf_mp_device *settings)
/* attach firmware event handler */
brcmf_fweh_attach(drvr);

- return ret;
+ ret = brcmf_bus_started(drvr);
+ if (ret != 0) {
+ brcmf_err("dongle is not responding: err=%d\n", ret);
+ goto fail;
+ }
+ return 0;

fail:
brcmf_detach(dev);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index 8752707..a7d827c 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -1581,24 +1581,6 @@ static void brcmf_pcie_release_resource(struct brcmf_pciedev_info *devinfo)
}


-static int brcmf_pcie_attach_bus(struct brcmf_pciedev_info *devinfo)
-{
- int ret;
-
- /* Attach to the common driver interface */
- ret = brcmf_attach(&devinfo->pdev->dev, devinfo->settings);
- if (ret) {
- brcmf_err("brcmf_attach failed\n");
- } else {
- ret = brcmf_bus_started(&devinfo->pdev->dev);
- if (ret)
- brcmf_err("dongle is not responding\n");
- }
-
- return ret;
-}
-
-
static u32 brcmf_pcie_buscore_prep_addr(const struct pci_dev *pdev, u32 addr)
{
u32 ret_addr;
@@ -1735,7 +1717,7 @@ static void brcmf_pcie_setup(struct device *dev, int ret,
init_waitqueue_head(&devinfo->mbdata_resp_wait);

brcmf_pcie_intr_enable(devinfo);
- if (brcmf_pcie_attach_bus(devinfo) == 0)
+ if (brcmf_attach(&devinfo->pdev->dev, devinfo->settings) == 0)
return;

brcmf_pcie_bus_console_read(devinfo);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index 0f1e452..aa82336 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -3422,6 +3422,8 @@ static int brcmf_sdio_bus_preinit(struct device *dev)
if (bus->rxbuf)
bus->rxblen = value;

+ brcmf_sdio_debugfs_create(bus);
+
/* the commands below use the terms tx and rx from
* a device perspective, ie. bus:txglom affects the
* bus transfers from device to host.
@@ -4136,14 +4138,6 @@ static void brcmf_sdio_firmware_callback(struct device *dev, int err,
goto fail;
}

- brcmf_sdio_debugfs_create(bus);
-
- err = brcmf_bus_started(dev);
- if (err != 0) {
- brcmf_err("dongle is not responding\n");
- goto fail;
- }
-
/* ready */
return;

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
index d22cd166..41642dd 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
@@ -1155,27 +1155,6 @@ static int brcmf_usb_get_fwname(struct device *dev, u32 chip, u32 chiprev,
.get_fwname = brcmf_usb_get_fwname,
};

-static int brcmf_usb_bus_setup(struct brcmf_usbdev_info *devinfo)
-{
- int ret;
-
- /* Attach to the common driver interface */
- ret = brcmf_attach(devinfo->dev, devinfo->settings);
- if (ret) {
- brcmf_err("brcmf_attach failed\n");
- return ret;
- }
-
- ret = brcmf_bus_started(devinfo->dev);
- if (ret)
- goto fail;
-
- return 0;
-fail:
- brcmf_detach(devinfo->dev);
- return ret;
-}
-
static void brcmf_usb_probe_phase2(struct device *dev, int ret,
const struct firmware *fw,
void *nvram, u32 nvlen)
@@ -1203,7 +1182,8 @@ static void brcmf_usb_probe_phase2(struct device *dev, int ret,
if (ret)
goto error;

- ret = brcmf_usb_bus_setup(devinfo);
+ /* Attach to the common driver interface */
+ ret = brcmf_attach(devinfo->dev, devinfo->settings);
if (ret)
goto error;

@@ -1253,7 +1233,7 @@ static int brcmf_usb_probe_cb(struct brcmf_usbdev_info *devinfo)
}

if (!brcmf_usb_dlneeded(devinfo)) {
- ret = brcmf_usb_bus_setup(devinfo);
+ ret = brcmf_attach(devinfo->dev, devinfo->settings);
if (ret)
goto fail;
/* we are done */
@@ -1456,7 +1436,7 @@ static int brcmf_usb_resume(struct usb_interface *intf)

brcmf_dbg(USB, "Enter\n");
if (!devinfo->wowl_enabled)
- return brcmf_usb_bus_setup(devinfo);
+ return brcmf_attach(devinfo->dev, devinfo->settings);

devinfo->bus_pub.state = BRCMFMAC_USB_STATE_UP;
brcmf_usb_rx_fill_all(devinfo);
--
1.9.1

2018-02-19 23:14:34

by Arend Van Spriel

[permalink] [raw]
Subject: [PATCH 2/8] brcmfmac: move allocation of control rx buffer to brcmf_sdio_bus_preinit()

Allocate the control rx buffer needed for firmware control interface
during brcmf_sdio_bus_preinit(). This relies on common layer setting
struct brcmf_bus::maxctl during brcmf_attach(). By moving the allocation
we can move brcmf_attach() in subsequent change.

Reviewed-by: Hante Meuleman <[email protected]>
Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Franky Lin <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
---
.../wireless/broadcom/brcm80211/brcmfmac/sdio.c | 26 ++++++++++------------
1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index 0868614..9ea525e 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -1707,7 +1707,6 @@ static int brcmf_sdio_dcmd_resp_wake(struct brcmf_sdio *bus)
int sdret;

brcmf_dbg(TRACE, "Enter\n");
-
if (bus->rxblen)
buf = vzalloc(bus->rxblen);
if (!buf)
@@ -3411,6 +3410,18 @@ static int brcmf_sdio_bus_preinit(struct device *dev)
u32 value;
int err;

+ /* maxctl provided by common layer */
+ if (WARN_ON(!bus_if->maxctl))
+ return -EINVAL;
+
+ /* Allocate control receive buffer */
+ bus_if->maxctl += bus->roundup;
+ value = roundup((bus_if->maxctl + SDPCM_HDRLEN), ALIGNMENT);
+ value += bus->head_align;
+ bus->rxbuf = kmalloc(value, GFP_ATOMIC);
+ if (bus->rxbuf)
+ bus->rxblen = value;
+
/* the commands below use the terms tx and rx from
* a device perspective, ie. bus:txglom affects the
* bus transfers from device to host.
@@ -4208,19 +4219,6 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)
bus->blocksize = bus->sdiodev->func2->cur_blksize;
bus->roundup = min(max_roundup, bus->blocksize);

- /* Allocate buffers */
- if (bus->sdiodev->bus_if->maxctl) {
- bus->sdiodev->bus_if->maxctl += bus->roundup;
- bus->rxblen =
- roundup((bus->sdiodev->bus_if->maxctl + SDPCM_HDRLEN),
- ALIGNMENT) + bus->head_align;
- bus->rxbuf = kmalloc(bus->rxblen, GFP_ATOMIC);
- if (!(bus->rxbuf)) {
- brcmf_err("rxbuf allocation failed\n");
- goto fail;
- }
- }
-
sdio_claim_host(bus->sdiodev->func1);

/* Disable F2 to clear any intermediate frame state on the dongle */
--
1.9.1

2018-02-27 16:23:24

by Kalle Valo

[permalink] [raw]
Subject: Re: [1/8] brcmfmac: move brcmf_bus_preinit() call just after changing bus state

Arend Van Spriel <[email protected]> wrote:

> Moving the brcmf_bus_preinit() call allows the bus code to do some
> required initialization before handling firmware control messages.
>
> Reviewed-by: Hante Meuleman <[email protected]>
> Reviewed-by: Pieter-Paul Giesberts <[email protected]>
> Reviewed-by: Franky Lin <[email protected]>
> Signed-off-by: Arend van Spriel <[email protected]>

8 patches applied to wireless-drivers-next.git, thanks.

da472385a29f brcmfmac: move brcmf_bus_preinit() call just after changing bus state
4b5adc736828 brcmfmac: move allocation of control rx buffer to brcmf_sdio_bus_preinit()
262f2b53f679 brcmfmac: call brcmf_attach() just before calling brcmf_bus_started()
a7f4a80c0070 brcmfmac: usb: call brcmf_usb_up() during brcmf_bus_preinit()
0542503c4c16 brcmfmac: move brcmf_attach() function in core.c
de2a3027f6f1 brcmfmac: remove brcmf_bus_started() from bus api
d678296bfb9a brcmfmac: change log level for some low-level sdio functions
2d6edad4b2da brcmfmac: remove duplicate pointer variable from brcmf_sdio_firmware_callback()

--
https://patchwork.kernel.org/patch/10229211/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2018-02-19 23:14:33

by Arend Van Spriel

[permalink] [raw]
Subject: [PATCH 7/8] brcmfmac: change log level for some low-level sdio functions

Reducing the number of trace level messages in sdio code giving
them sdio log level instead.

Reviewed-by: Hante Meuleman <[email protected]>
Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Franky Lin <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index aa82336..b94ef3c 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -1706,7 +1706,7 @@ static int brcmf_sdio_dcmd_resp_wake(struct brcmf_sdio *bus)
u8 *buf = NULL, *rbuf;
int sdret;

- brcmf_dbg(TRACE, "Enter\n");
+ brcmf_dbg(SDIO, "Enter\n");
if (bus->rxblen)
buf = vzalloc(bus->rxblen);
if (!buf)
@@ -1809,7 +1809,7 @@ static uint brcmf_sdio_readframes(struct brcmf_sdio *bus, uint maxframes)
struct brcmf_sdio_hdrinfo *rd = &bus->cur_read, rd_new;
u8 head_read = 0;

- brcmf_dbg(TRACE, "Enter\n");
+ brcmf_dbg(SDIO, "Enter\n");

/* Not finished unless we encounter no more frames indication */
bus->rxpending = true;
@@ -2344,7 +2344,7 @@ static int brcmf_sdio_tx_ctrlframe(struct brcmf_sdio *bus, u8 *frame, u16 len)
struct brcmf_sdio_hdrinfo hd_info = {0};
int ret;

- brcmf_dbg(TRACE, "Enter\n");
+ brcmf_dbg(SDIO, "Enter\n");

/* Back the pointer to make room for bus header */
frame -= bus->tx_hdrlen;
@@ -2520,7 +2520,7 @@ static void brcmf_sdio_dpc(struct brcmf_sdio *bus)
uint framecnt; /* Temporary counter of tx/rx frames */
int err = 0;

- brcmf_dbg(TRACE, "Enter\n");
+ brcmf_dbg(SDIO, "Enter\n");

sdio_claim_host(bus->sdiodev->func1);

@@ -2605,7 +2605,7 @@ static void brcmf_sdio_dpc(struct brcmf_sdio *bus)

/* Would be active due to wake-wlan in gSPI */
if (intstatus & I_CHIPACTIVE) {
- brcmf_dbg(INFO, "Dongle reports CHIPACTIVE\n");
+ brcmf_dbg(SDIO, "Dongle reports CHIPACTIVE\n");
intstatus &= ~I_CHIPACTIVE;
}

--
1.9.1

2018-02-19 23:14:33

by Arend Van Spriel

[permalink] [raw]
Subject: [PATCH 3/8] brcmfmac: call brcmf_attach() just before calling brcmf_bus_started()

Now we can move brcmf_attach() until after the firmware has been downloaded
to the device. Make the call just before brcmf_bus_started().

Reviewed-by: Hante Meuleman <[email protected]>
Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Franky Lin <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
---
.../wireless/broadcom/brcm80211/brcmfmac/core.c | 6 ++++
.../wireless/broadcom/brcm80211/brcmfmac/sdio.c | 34 +++++++++++-----------
2 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 6dd6da7..e553d1a 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -1190,6 +1190,12 @@ void brcmf_bus_change_state(struct brcmf_bus *bus, enum brcmf_bus_state state)
int ifidx;

brcmf_dbg(TRACE, "%d -> %d\n", bus->state, state);
+
+ if (!drvr) {
+ brcmf_dbg(INFO, "ignoring transition, bus not attached yet\n");
+ return;
+ }
+
bus->state = state;

if (state == BRCMF_BUS_UP) {
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index 9ea525e..0f1e452 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -4048,9 +4048,6 @@ static void brcmf_sdio_firmware_callback(struct device *dev, int err,
if (err)
goto fail;

- if (!bus_if->drvr)
- return;
-
/* try to download image and nvram to the dongle */
bus->alp_only = true;
err = brcmf_sdio_download_firmware(bus, code, nvram, nvram_len);
@@ -4126,11 +4123,28 @@ static void brcmf_sdio_firmware_callback(struct device *dev, int err,

sdio_release_host(sdiodev->func1);

+ /* Assign bus interface call back */
+ sdiodev->bus_if->dev = sdiodev->dev;
+ sdiodev->bus_if->ops = &brcmf_sdio_bus_ops;
+ sdiodev->bus_if->chip = bus->ci->chip;
+ sdiodev->bus_if->chiprev = bus->ci->chiprev;
+
+ /* Attach to the common layer, reserve hdr space */
+ err = brcmf_attach(sdiodev->dev, sdiodev->settings);
+ if (err != 0) {
+ brcmf_err("brcmf_attach failed\n");
+ goto fail;
+ }
+
+ brcmf_sdio_debugfs_create(bus);
+
err = brcmf_bus_started(dev);
if (err != 0) {
brcmf_err("dongle is not responding\n");
goto fail;
}
+
+ /* ready */
return;

release:
@@ -4199,22 +4213,9 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)
bus->dpc_triggered = false;
bus->dpc_running = false;

- /* Assign bus interface call back */
- bus->sdiodev->bus_if->dev = bus->sdiodev->dev;
- bus->sdiodev->bus_if->ops = &brcmf_sdio_bus_ops;
- bus->sdiodev->bus_if->chip = bus->ci->chip;
- bus->sdiodev->bus_if->chiprev = bus->ci->chiprev;
-
/* default sdio bus header length for tx packet */
bus->tx_hdrlen = SDPCM_HWHDR_LEN + SDPCM_SWHDR_LEN;

- /* Attach to the common layer, reserve hdr space */
- ret = brcmf_attach(bus->sdiodev->dev, bus->sdiodev->settings);
- if (ret != 0) {
- brcmf_err("brcmf_attach failed\n");
- goto fail;
- }
-
/* Query the F2 block size, set roundup accordingly */
bus->blocksize = bus->sdiodev->func2->cur_blksize;
bus->roundup = min(max_roundup, bus->blocksize);
@@ -4239,7 +4240,6 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)
/* SR state */
bus->sr_enabled = false;

- brcmf_sdio_debugfs_create(bus);
brcmf_dbg(INFO, "completed!!\n");

ret = brcmf_fw_map_chip_to_name(bus->ci->chip, bus->ci->chiprev,
--
1.9.1

2018-02-19 23:14:34

by Arend Van Spriel

[permalink] [raw]
Subject: [PATCH 5/8] brcmfmac: move brcmf_attach() function in core.c

Moving the function in preparation of subsequent patch.

Reviewed-by: Hante Meuleman <[email protected]>
Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Franky Lin <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
---
.../wireless/broadcom/brcm80211/brcmfmac/core.c | 98 +++++++++++-----------
1 file changed, 49 insertions(+), 49 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index e553d1a..9eab7a9 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -914,55 +914,6 @@ static int brcmf_inet6addr_changed(struct notifier_block *nb,
}
#endif

-int brcmf_attach(struct device *dev, struct brcmf_mp_device *settings)
-{
- struct brcmf_pub *drvr = NULL;
- int ret = 0;
- int i;
-
- brcmf_dbg(TRACE, "Enter\n");
-
- /* Allocate primary brcmf_info */
- drvr = kzalloc(sizeof(struct brcmf_pub), GFP_ATOMIC);
- if (!drvr)
- return -ENOMEM;
-
- for (i = 0; i < ARRAY_SIZE(drvr->if2bss); i++)
- drvr->if2bss[i] = BRCMF_BSSIDX_INVALID;
-
- mutex_init(&drvr->proto_block);
-
- /* Link to bus module */
- drvr->hdrlen = 0;
- drvr->bus_if = dev_get_drvdata(dev);
- drvr->bus_if->drvr = drvr;
- drvr->settings = settings;
-
- /* attach debug facilities */
- brcmf_debug_attach(drvr);
-
- /* Attach and link in the protocol */
- ret = brcmf_proto_attach(drvr);
- if (ret != 0) {
- brcmf_err("brcmf_prot_attach failed\n");
- goto fail;
- }
-
- /* Attach to events important for core code */
- brcmf_fweh_register(drvr, BRCMF_E_PSM_WATCHDOG,
- brcmf_psm_watchdog_notify);
-
- /* attach firmware event handler */
- brcmf_fweh_attach(drvr);
-
- return ret;
-
-fail:
- brcmf_detach(dev);
-
- return ret;
-}
-
static int brcmf_revinfo_read(struct seq_file *s, void *data)
{
struct brcmf_bus *bus_if = dev_get_drvdata(s->private);
@@ -1093,6 +1044,55 @@ int brcmf_bus_started(struct device *dev)
return ret;
}

+int brcmf_attach(struct device *dev, struct brcmf_mp_device *settings)
+{
+ struct brcmf_pub *drvr = NULL;
+ int ret = 0;
+ int i;
+
+ brcmf_dbg(TRACE, "Enter\n");
+
+ /* Allocate primary brcmf_info */
+ drvr = kzalloc(sizeof(*drvr), GFP_ATOMIC);
+ if (!drvr)
+ return -ENOMEM;
+
+ for (i = 0; i < ARRAY_SIZE(drvr->if2bss); i++)
+ drvr->if2bss[i] = BRCMF_BSSIDX_INVALID;
+
+ mutex_init(&drvr->proto_block);
+
+ /* Link to bus module */
+ drvr->hdrlen = 0;
+ drvr->bus_if = dev_get_drvdata(dev);
+ drvr->bus_if->drvr = drvr;
+ drvr->settings = settings;
+
+ /* attach debug facilities */
+ brcmf_debug_attach(drvr);
+
+ /* Attach and link in the protocol */
+ ret = brcmf_proto_attach(drvr);
+ if (ret != 0) {
+ brcmf_err("brcmf_prot_attach failed\n");
+ goto fail;
+ }
+
+ /* Attach to events important for core code */
+ brcmf_fweh_register(drvr, BRCMF_E_PSM_WATCHDOG,
+ brcmf_psm_watchdog_notify);
+
+ /* attach firmware event handler */
+ brcmf_fweh_attach(drvr);
+
+ return ret;
+
+fail:
+ brcmf_detach(dev);
+
+ return ret;
+}
+
void brcmf_bus_add_txhdrlen(struct device *dev, uint len)
{
struct brcmf_bus *bus_if = dev_get_drvdata(dev);
--
1.9.1

2018-02-19 23:14:33

by Arend Van Spriel

[permalink] [raw]
Subject: [PATCH 1/8] brcmfmac: move brcmf_bus_preinit() call just after changing bus state

Moving the brcmf_bus_preinit() call allows the bus code to do some
required initialization before handling firmware control messages.

Reviewed-by: Hante Meuleman <[email protected]>
Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Franky Lin <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 3 ---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 5 +++++
2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
index 9be0b05..70ef983 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
@@ -365,9 +365,6 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)

/* Enable tx beamforming, errors can be ignored (not supported) */
(void)brcmf_fil_iovar_int_set(ifp, "txbf", 1);
-
- /* do bus specific preinit here */
- err = brcmf_bus_preinit(ifp->drvr->bus_if);
done:
return err;
}
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 930e423..6dd6da7 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -1013,6 +1013,11 @@ int brcmf_bus_started(struct device *dev)
/* signal bus ready */
brcmf_bus_change_state(bus_if, BRCMF_BUS_UP);

+ /* do bus specific preinit here */
+ ret = brcmf_bus_preinit(ifp->drvr->bus_if);
+ if (ret < 0)
+ goto fail;
+
/* Bus is ready, do any initialization */
ret = brcmf_c_preinit_dcmds(ifp);
if (ret < 0)
--
1.9.1

2018-02-19 23:14:33

by Arend Van Spriel

[permalink] [raw]
Subject: [PATCH 8/8] brcmfmac: remove duplicate pointer variable from brcmf_sdio_firmware_callback()

In brcmf_sdio_firmware_callback() two pointer variables were used
pointing to the same construct. Get rid of sdiodev variable.

Signed-off-by: Arend van Spriel <[email protected]>
---
.../wireless/broadcom/brcm80211/brcmfmac/sdio.c | 37 +++++++++++-----------
1 file changed, 18 insertions(+), 19 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index b94ef3c..4a6459a 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -4039,9 +4039,8 @@ static void brcmf_sdio_firmware_callback(struct device *dev, int err,
void *nvram, u32 nvram_len)
{
struct brcmf_bus *bus_if = dev_get_drvdata(dev);
- struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio;
- struct brcmf_sdio *bus = sdiodev->bus;
- struct brcmf_sdio_dev *sdiod = bus->sdiodev;
+ struct brcmf_sdio_dev *sdiod = bus_if->bus_priv.sdio;
+ struct brcmf_sdio *bus = sdiod->bus;
struct brcmf_core *core = bus->sdio_core;
u8 saveclk;

@@ -4061,7 +4060,7 @@ static void brcmf_sdio_firmware_callback(struct device *dev, int err,
bus->sdcnt.tickcnt = 0;
brcmf_sdio_wd_timer(bus, true);

- sdio_claim_host(sdiodev->func1);
+ sdio_claim_host(sdiod->func1);

/* Make sure backplane clock is on, needed to generate F2 interrupt */
brcmf_sdio_clkctl(bus, CLK_AVAIL, false);
@@ -4069,9 +4068,9 @@ static void brcmf_sdio_firmware_callback(struct device *dev, int err,
goto release;

/* Force clocks on backplane to be sure F2 interrupt propagates */
- saveclk = brcmf_sdiod_readb(sdiodev, SBSDIO_FUNC1_CHIPCLKCSR, &err);
+ saveclk = brcmf_sdiod_readb(sdiod, SBSDIO_FUNC1_CHIPCLKCSR, &err);
if (!err) {
- brcmf_sdiod_writeb(sdiodev, SBSDIO_FUNC1_CHIPCLKCSR,
+ brcmf_sdiod_writeb(sdiod, SBSDIO_FUNC1_CHIPCLKCSR,
(saveclk | SBSDIO_FORCE_HT), &err);
}
if (err) {
@@ -4083,7 +4082,7 @@ static void brcmf_sdio_firmware_callback(struct device *dev, int err,
brcmf_sdiod_writel(sdiod, core->base + SD_REG(tosbmailboxdata),
SDPCM_PROT_VERSION << SMB_DATA_VERSION_SHIFT, NULL);

- err = sdio_enable_func(sdiodev->func2);
+ err = sdio_enable_func(sdiod->func2);

brcmf_dbg(INFO, "enable F2: err=%d\n", err);

@@ -4095,10 +4094,10 @@ static void brcmf_sdio_firmware_callback(struct device *dev, int err,
bus->hostintmask, NULL);


- brcmf_sdiod_writeb(sdiodev, SBSDIO_WATERMARK, 8, &err);
+ brcmf_sdiod_writeb(sdiod, SBSDIO_WATERMARK, 8, &err);
} else {
/* Disable F2 again */
- sdio_disable_func(sdiodev->func2);
+ sdio_disable_func(sdiod->func2);
goto release;
}

@@ -4106,7 +4105,7 @@ static void brcmf_sdio_firmware_callback(struct device *dev, int err,
brcmf_sdio_sr_init(bus);
} else {
/* Restore previous clock setting */
- brcmf_sdiod_writeb(sdiodev, SBSDIO_FUNC1_CHIPCLKCSR,
+ brcmf_sdiod_writeb(sdiod, SBSDIO_FUNC1_CHIPCLKCSR,
saveclk, &err);
}

@@ -4114,7 +4113,7 @@ static void brcmf_sdio_firmware_callback(struct device *dev, int err,
/* Allow full data communication using DPC from now on. */
brcmf_sdiod_change_state(bus->sdiodev, BRCMF_SDIOD_DATA);

- err = brcmf_sdiod_intr_register(sdiodev);
+ err = brcmf_sdiod_intr_register(sdiod);
if (err != 0)
brcmf_err("intr register failed:%d\n", err);
}
@@ -4123,16 +4122,16 @@ static void brcmf_sdio_firmware_callback(struct device *dev, int err,
if (err != 0)
brcmf_sdio_clkctl(bus, CLK_NONE, false);

- sdio_release_host(sdiodev->func1);
+ sdio_release_host(sdiod->func1);

/* Assign bus interface call back */
- sdiodev->bus_if->dev = sdiodev->dev;
- sdiodev->bus_if->ops = &brcmf_sdio_bus_ops;
- sdiodev->bus_if->chip = bus->ci->chip;
- sdiodev->bus_if->chiprev = bus->ci->chiprev;
+ sdiod->bus_if->dev = sdiod->dev;
+ sdiod->bus_if->ops = &brcmf_sdio_bus_ops;
+ sdiod->bus_if->chip = bus->ci->chip;
+ sdiod->bus_if->chiprev = bus->ci->chiprev;

/* Attach to the common layer, reserve hdr space */
- err = brcmf_attach(sdiodev->dev, sdiodev->settings);
+ err = brcmf_attach(sdiod->dev, sdiod->settings);
if (err != 0) {
brcmf_err("brcmf_attach failed\n");
goto fail;
@@ -4142,10 +4141,10 @@ static void brcmf_sdio_firmware_callback(struct device *dev, int err,
return;

release:
- sdio_release_host(sdiodev->func1);
+ sdio_release_host(sdiod->func1);
fail:
brcmf_dbg(TRACE, "failed: dev=%s, err=%d\n", dev_name(dev), err);
- device_release_driver(&sdiodev->func2->dev);
+ device_release_driver(&sdiod->func2->dev);
device_release_driver(dev);
}

--
1.9.1