2020-02-13 08:45:47

by Chi-Hsien Lin

[permalink] [raw]
Subject: [PATCH 0/6] brcmfmac: USB change series

USB runtime PM and console print support added, alone with several of bug fixes for usb devices.

Madhan Mohan R (1):
brcmfmac: increase max hanger slots from 1K to 3K in fws layer

Raveendran Somu (4):
brcmfmac: Fix driver crash on USB control transfer timeout
brcmfmac: Fix double freeing in the fmac usb data path
brcmfmac: fix the incorrect return value in brcmf_inform_single_bss().
brcmfmac: To support printing USB console messages

Wright Feng (1):
brcmfmac: add USB autosuspend feature support

.../net/wireless/broadcom/brcm80211/brcmfmac/bus.h | 1 +
.../broadcom/brcm80211/brcmfmac/cfg80211.c | 2 +-
.../wireless/broadcom/brcm80211/brcmfmac/core.c | 8 ++
.../wireless/broadcom/brcm80211/brcmfmac/debug.c | 82 ++++++++++++
.../wireless/broadcom/brcm80211/brcmfmac/debug.h | 24 ++++
.../broadcom/brcm80211/brcmfmac/fwsignal.c | 5 +-
.../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 141 +++++++++++++--------
7 files changed, 207 insertions(+), 56 deletions(-)

--
2.1.0


2020-02-13 08:45:47

by Chi-Hsien Lin

[permalink] [raw]
Subject: [PATCH 1/6] brcmfmac: Fix driver crash on USB control transfer timeout

From: Raveendran Somu <[email protected]>

When the control transfer gets timed out, the error status
was returned without killing that urb, this leads to using
the same urb. This issue causes the kernel crash as the same
urb is sumbitted multiple times. The fix is to kill the
urb for timeout transfer before returning error

Signed-off-by: Raveendran Somu <[email protected]>
Signed-off-by: Chi-hsien Lin <[email protected]>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
index 575ed19e9195..10387a7f5d56 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
@@ -328,11 +328,12 @@ static int brcmf_usb_tx_ctlpkt(struct device *dev, u8 *buf, u32 len)
return err;
}
timeout = brcmf_usb_ioctl_resp_wait(devinfo);
- clear_bit(0, &devinfo->ctl_op);
if (!timeout) {
brcmf_err("Txctl wait timed out\n");
+ usb_kill_urb(devinfo->ctl_urb);
err = -EIO;
}
+ clear_bit(0, &devinfo->ctl_op);
return err;
}

@@ -358,11 +359,12 @@ static int brcmf_usb_rx_ctlpkt(struct device *dev, u8 *buf, u32 len)
}
timeout = brcmf_usb_ioctl_resp_wait(devinfo);
err = devinfo->ctl_urb_status;
- clear_bit(0, &devinfo->ctl_op);
if (!timeout) {
brcmf_err("rxctl wait timed out\n");
+ usb_kill_urb(devinfo->ctl_urb);
err = -EIO;
}
+ clear_bit(0, &devinfo->ctl_op);
if (!err)
return devinfo->ctl_urb_actual_length;
else
--
2.1.0

2020-02-13 08:46:01

by Chi-Hsien Lin

[permalink] [raw]
Subject: [PATCH 2/6] brcmfmac: Fix double freeing in the fmac usb data path

From: Raveendran Somu <[email protected]>

When the brcmf_fws_process_skb() fails to get hanger slot for
queuing the skb, it tries to free the skb.
But the caller brcmf_netdev_start_xmit() of that funciton frees
the packet on error return value.
This causes the double freeing and which caused the kernel crash.

Signed-off-by: Raveendran Somu <[email protected]>
Signed-off-by: Chi-hsien Lin <[email protected]>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
index 5e1a11c07551..10022c765354 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
@@ -2145,8 +2145,7 @@ int brcmf_fws_process_skb(struct brcmf_if *ifp, struct sk_buff *skb)
brcmf_fws_enq(fws, BRCMF_FWS_SKBSTATE_DELAYED, fifo, skb);
brcmf_fws_schedule_deq(fws);
} else {
- bphy_err(drvr, "drop skb: no hanger slot\n");
- brcmf_txfinalize(ifp, skb, false);
+ bphy_err(drvr, "no hanger slot available\n");
rc = -ENOMEM;
}
brcmf_fws_unlock(fws);
--
2.1.0

2020-02-13 08:46:03

by Chi-Hsien Lin

[permalink] [raw]
Subject: [PATCH 3/6] brcmfmac: fix the incorrect return value in brcmf_inform_single_bss().

From: Raveendran Somu <[email protected]>

The function brcmf_inform_single_bss returns the value as success,
even when the length exceeds the maximum value.
The fix is to send appropriate code on this error.
This issue is observed when SVT reported random fmac crashes
when running their tests and the path was identified from the
crash logs. With this fix the random failure issue in SVT was
resolved.

Signed-off-by: Raveendran Somu <[email protected]>
Signed-off-by: Chi-hsien Lin <[email protected]>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index a2328d3eee03..2ba165330038 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -2953,7 +2953,7 @@ static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_info *cfg,

if (le32_to_cpu(bi->length) > WL_BSS_INFO_MAX) {
bphy_err(drvr, "Bss info is larger than buffer. Discarding\n");
- return 0;
+ return -EINVAL;
}

if (!bi->ctl_ch) {
--
2.1.0

2020-02-13 08:46:04

by Chi-Hsien Lin

[permalink] [raw]
Subject: [PATCH 4/6] brcmfmac: increase max hanger slots from 1K to 3K in fws layer

From: Madhan Mohan R <[email protected]>

Will enable FMAC to push more packets to bus tx queue and help
improve throughput when fws queuing is enabled. This change is
required to tune the throughput for passing WMM CERT tests.

Signed-off-by: Madhan Mohan R <[email protected]>
Signed-off-by: Chi-hsien Lin <[email protected]>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
index 10022c765354..8cc52935fd41 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
@@ -404,7 +404,7 @@ struct brcmf_fws_mac_descriptor {
u8 traffic_lastreported_bmp;
};

-#define BRCMF_FWS_HANGER_MAXITEMS 1024
+#define BRCMF_FWS_HANGER_MAXITEMS 3072

/**
* enum brcmf_fws_hanger_item_state - state of hanger item.
--
2.1.0

2020-02-13 08:46:13

by Chi-Hsien Lin

[permalink] [raw]
Subject: [PATCH 5/6] brcmfmac: add USB autosuspend feature support

From: Wright Feng <[email protected]>

We add enable dynamic suspend(autosuspend) support in host driver. It
can let platform cut down idle power consumption. To support autosuspend
feature in host driver. Kernel need to be build with CONFIG_USB_SUSPEND
and autosuspend need to be turn on.

Signed-off-by: Wright Feng <[email protected]>
Signed-off-by: Chi-hsien Lin <[email protected]>
---
.../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 121 ++++++++++++---------
1 file changed, 71 insertions(+), 50 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
index 10387a7f5d56..ac5463838fcf 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
@@ -164,7 +164,6 @@ struct brcmf_usbdev_info {

struct urb *bulk_urb; /* used for FW download */

- bool wowl_enabled;
struct brcmf_mp_device *settings;
};

@@ -312,28 +311,43 @@ static int brcmf_usb_tx_ctlpkt(struct device *dev, u8 *buf, u32 len)
int err = 0;
int timeout = 0;
struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(dev);
+ struct usb_interface *intf = to_usb_interface(dev);

brcmf_dbg(USB, "Enter\n");
- if (devinfo->bus_pub.state != BRCMFMAC_USB_STATE_UP)
- return -EIO;

- if (test_and_set_bit(0, &devinfo->ctl_op))
- return -EIO;
+ err = usb_autopm_get_interface(intf);
+ if (err)
+ goto out;
+
+ if (devinfo->bus_pub.state != BRCMFMAC_USB_STATE_UP) {
+ err = -EIO;
+ goto fail;
+ }
+
+ if (test_and_set_bit(0, &devinfo->ctl_op)) {
+ err = -EIO;
+ goto fail;
+ }

devinfo->ctl_completed = false;
err = brcmf_usb_send_ctl(devinfo, buf, len);
if (err) {
brcmf_err("fail %d bytes: %d\n", err, len);
clear_bit(0, &devinfo->ctl_op);
- return err;
+ goto fail;
}
timeout = brcmf_usb_ioctl_resp_wait(devinfo);
if (!timeout) {
brcmf_err("Txctl wait timed out\n");
usb_kill_urb(devinfo->ctl_urb);
err = -EIO;
+ goto fail;
}
clear_bit(0, &devinfo->ctl_op);
+
+fail:
+ usb_autopm_put_interface(intf);
+out:
return err;
}

@@ -342,20 +356,30 @@ static int brcmf_usb_rx_ctlpkt(struct device *dev, u8 *buf, u32 len)
int err = 0;
int timeout = 0;
struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(dev);
+ struct usb_interface *intf = to_usb_interface(dev);

brcmf_dbg(USB, "Enter\n");
- if (devinfo->bus_pub.state != BRCMFMAC_USB_STATE_UP)
- return -EIO;

- if (test_and_set_bit(0, &devinfo->ctl_op))
- return -EIO;
+ err = usb_autopm_get_interface(intf);
+ if (err)
+ goto out;
+
+ if (devinfo->bus_pub.state != BRCMFMAC_USB_STATE_UP) {
+ err = -EIO;
+ goto fail;
+ }
+
+ if (test_and_set_bit(0, &devinfo->ctl_op)) {
+ err = -EIO;
+ goto fail;
+ }

devinfo->ctl_completed = false;
err = brcmf_usb_recv_ctl(devinfo, buf, len);
if (err) {
brcmf_err("fail %d bytes: %d\n", err, len);
clear_bit(0, &devinfo->ctl_op);
- return err;
+ goto fail;
}
timeout = brcmf_usb_ioctl_resp_wait(devinfo);
err = devinfo->ctl_urb_status;
@@ -363,12 +387,15 @@ static int brcmf_usb_rx_ctlpkt(struct device *dev, u8 *buf, u32 len)
brcmf_err("rxctl wait timed out\n");
usb_kill_urb(devinfo->ctl_urb);
err = -EIO;
+ goto fail;
}
clear_bit(0, &devinfo->ctl_op);
+fail:
+ usb_autopm_put_interface(intf);
if (!err)
return devinfo->ctl_urb_actual_length;
- else
- return err;
+out:
+ return err;
}

static struct brcmf_usbreq *brcmf_usb_deq(struct brcmf_usbdev_info *devinfo,
@@ -502,10 +529,12 @@ static void brcmf_usb_rx_complete(struct urb *urb)
return;
}

- if (devinfo->bus_pub.state == BRCMFMAC_USB_STATE_UP) {
+ if (devinfo->bus_pub.state == BRCMFMAC_USB_STATE_UP ||
+ devinfo->bus_pub.state == BRCMFMAC_USB_STATE_SLEEP) {
skb_put(skb, urb->actual_length);
brcmf_rx_frame(devinfo->dev, skb, true);
brcmf_usb_rx_refill(devinfo, req);
+ usb_mark_last_busy(urb->dev);
} else {
brcmu_pkt_buf_free_skb(skb);
brcmf_usb_enq(devinfo, &devinfo->rx_freeq, req, NULL);
@@ -589,6 +618,11 @@ static int brcmf_usb_tx(struct device *dev, struct sk_buff *skb)
struct brcmf_usbreq *req;
int ret;
unsigned long flags;
+ struct usb_interface *intf = to_usb_interface(dev);
+
+ ret = usb_autopm_get_interface(intf);
+ if (ret)
+ goto out;

brcmf_dbg(USB, "Enter, skb=%p\n", skb);
if (devinfo->bus_pub.state != BRCMFMAC_USB_STATE_UP) {
@@ -627,9 +661,10 @@ static int brcmf_usb_tx(struct device *dev, struct sk_buff *skb)
devinfo->tx_flowblock = true;
}
spin_unlock_irqrestore(&devinfo->tx_flowblock_lock, flags);
- return 0;

fail:
+ usb_autopm_put_interface(intf);
+out:
return ret;
}

@@ -993,20 +1028,32 @@ static int
brcmf_usb_fw_download(struct brcmf_usbdev_info *devinfo)
{
int err;
+ struct usb_interface *intf;

brcmf_dbg(USB, "Enter\n");
- if (devinfo == NULL)
- return -ENODEV;
+ if (!devinfo) {
+ err = -ENODEV;
+ goto out;
+ }

if (!devinfo->image) {
brcmf_err("No firmware!\n");
- return -ENOENT;
+ err = -ENOENT;
+ goto out;
}

+ intf = to_usb_interface(devinfo->dev);
+ err = usb_autopm_get_interface(intf);
+ if (err)
+ goto out;
+
err = brcmf_usb_dlstart(devinfo,
(u8 *)devinfo->image, devinfo->image_len);
if (err == 0)
err = brcmf_usb_dlrun(devinfo);
+
+ usb_autopm_put_interface(intf);
+out:
return err;
}

@@ -1107,18 +1154,6 @@ struct brcmf_usbdev *brcmf_usb_attach(struct brcmf_usbdev_info *devinfo,
return NULL;
}

-static void brcmf_usb_wowl_config(struct device *dev, bool enabled)
-{
- struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(dev);
-
- brcmf_dbg(USB, "Configuring WOWL, enabled=%d\n", enabled);
- devinfo->wowl_enabled = enabled;
- if (enabled)
- device_set_wakeup_enable(devinfo->dev, true);
- else
- device_set_wakeup_enable(devinfo->dev, false);
-}
-
static
int brcmf_usb_get_fwname(struct device *dev, const char *ext, u8 *fw_name)
{
@@ -1145,7 +1180,6 @@ static const struct brcmf_bus_ops brcmf_usb_bus_ops = {
.txdata = brcmf_usb_tx,
.txctl = brcmf_usb_tx_ctlpkt,
.rxctl = brcmf_usb_rx_ctlpkt,
- .wowl_config = brcmf_usb_wowl_config,
.get_fwname = brcmf_usb_get_fwname,
};

@@ -1334,6 +1368,8 @@ brcmf_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)

usb_set_intfdata(intf, devinfo);

+ intf->needs_remote_wakeup = 1;
+
/* Check that the device supports only one configuration */
if (usb->descriptor.bNumConfigurations != 1) {
brcmf_err("Number of configurations: %d not supported\n",
@@ -1447,12 +1483,8 @@ static int brcmf_usb_suspend(struct usb_interface *intf, pm_message_t state)

brcmf_dbg(USB, "Enter\n");
devinfo->bus_pub.state = BRCMFMAC_USB_STATE_SLEEP;
- if (devinfo->wowl_enabled) {
- brcmf_cancel_all_urbs(devinfo);
- } else {
- brcmf_detach(&usb->dev);
- brcmf_free(&usb->dev);
- }
+ brcmf_cancel_all_urbs(devinfo);
+ device_set_wakeup_enable(devinfo->dev, true);
return 0;
}

@@ -1465,22 +1497,10 @@ static int brcmf_usb_resume(struct usb_interface *intf)
struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(&usb->dev);

brcmf_dbg(USB, "Enter\n");
- if (!devinfo->wowl_enabled) {
- int err;
-
- err = brcmf_alloc(&usb->dev, devinfo->settings);
- if (err)
- return err;
-
- err = brcmf_attach(devinfo->dev);
- if (err) {
- brcmf_free(devinfo->dev);
- return err;
- }
- }

devinfo->bus_pub.state = BRCMFMAC_USB_STATE_UP;
brcmf_usb_rx_fill_all(devinfo);
+ device_set_wakeup_enable(devinfo->dev, false);
return 0;
}

@@ -1537,6 +1557,7 @@ static struct usb_driver brcmf_usbdrvr = {
.suspend = brcmf_usb_suspend,
.resume = brcmf_usb_resume,
.reset_resume = brcmf_usb_reset_resume,
+ .supports_autosuspend = true,
.disable_hub_initiated_lpm = 1,
};

--
2.1.0

2020-02-13 08:46:25

by Chi-Hsien Lin

[permalink] [raw]
Subject: [PATCH 6/6] brcmfmac: To support printing USB console messages

From: Raveendran Somu <[email protected]>

This change is to add support for printing the firmware
console messges of a USB interface chip to the host.
To enable this feature, build option '-msgtrace' should be
enabled in the firmware. And in the host, debug=0x100000
should be provided as a module parameter.

Signed-off-by: Raveendran Somu <[email protected]>
Signed-off-by: Chi-hsien Lin <[email protected]>
---
.../net/wireless/broadcom/brcm80211/brcmfmac/bus.h | 1 +
.../wireless/broadcom/brcm80211/brcmfmac/core.c | 8 +++
.../wireless/broadcom/brcm80211/brcmfmac/debug.c | 82 ++++++++++++++++++++++
.../wireless/broadcom/brcm80211/brcmfmac/debug.h | 24 +++++++
.../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 14 ++++
5 files changed, 129 insertions(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
index 623c0168da79..c8063ca50611 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
@@ -271,6 +271,7 @@ void brcmf_bus_change_state(struct brcmf_bus *bus, enum brcmf_bus_state state);

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

#ifdef CONFIG_BRCMFMAC_SDIO
void brcmf_sdio_exit(void);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 23627c953a5e..fab852461cf1 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -1117,6 +1117,14 @@ static int brcmf_inet6addr_changed(struct notifier_block *nb,
}
#endif

+int brcmf_fwlog_attach(struct device *dev)
+{
+ struct brcmf_bus *bus_if = dev_get_drvdata(dev);
+ struct brcmf_pub *drvr = bus_if->drvr;
+
+ return brcmf_debug_fwlog_init(drvr);
+}
+
static int brcmf_revinfo_read(struct seq_file *s, void *data)
{
struct brcmf_bus *bus_if = dev_get_drvdata(s->private);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
index 120515fe8250..64c8ba0ef8af 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
@@ -14,6 +14,82 @@
#include "fweh.h"
#include "debug.h"

+static int
+brcmf_debug_msgtrace_seqchk(u32 *prev, u32 cur)
+{
+ if ((cur == 0 && *prev == 0xFFFFFFFF) || ((cur - *prev) == 1)) {
+ goto done;
+ } else if (cur == *prev) {
+ brcmf_dbg(FWCON, "duplicate trace\n");
+ return -1;
+ } else if (cur > *prev) {
+ brcmf_dbg(FWCON, "lost %d packets\n", cur - *prev);
+ } else {
+ brcmf_dbg(FWCON, "seq out of order, host %d, dongle %d\n",
+ *prev, cur);
+ }
+done:
+ *prev = cur;
+ return 0;
+}
+
+static int
+brcmf_debug_msg_parser(void *event_data)
+{
+ int err = 0;
+ struct msgtrace_hdr *hdr;
+ char *data, *s;
+ static u32 seqnum_prev;
+
+ hdr = (struct msgtrace_hdr *)event_data;
+ data = (char *)event_data + MSGTRACE_HDRLEN;
+
+ /* There are 2 bytes available at the end of data */
+ data[ntohs(hdr->len)] = '\0';
+
+ if (ntohl(hdr->discarded_bytes) || ntohl(hdr->discarded_printf)) {
+ brcmf_dbg(FWCON, "Discarded_bytes %d discarded_printf %d\n",
+ ntohl(hdr->discarded_bytes),
+ ntohl(hdr->discarded_printf));
+ }
+
+ err = brcmf_debug_msgtrace_seqchk(&seqnum_prev, ntohl(hdr->seqnum));
+ if (err)
+ return err;
+
+ while (*data != '\0' && (s = strstr(data, "\n")) != NULL) {
+ *s = '\0';
+ brcmf_dbg(FWCON, "CONSOLE: %s\n", data);
+ data = s + 1;
+ }
+ if (*data)
+ brcmf_dbg(FWCON, "CONSOLE: %s", data);
+
+ return err;
+}
+
+static int
+brcmf_debug_trace_parser(struct brcmf_if *ifp,
+ const struct brcmf_event_msg *evtmsg,
+ void *event_data)
+{
+ int err = 0;
+ struct msgtrace_hdr *hdr;
+
+ hdr = (struct msgtrace_hdr *)event_data;
+ if (hdr->version != MSGTRACE_VERSION) {
+ brcmf_dbg(FWCON, "trace version mismatch host %d dngl %d\n",
+ MSGTRACE_VERSION, hdr->version);
+ err = -EPROTO;
+ return err;
+ }
+
+ if (hdr->trace_type == MSGTRACE_HDR_TYPE_MSG)
+ err = brcmf_debug_msg_parser(event_data);
+
+ return err;
+}
+
int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data,
size_t len)
{
@@ -42,6 +118,12 @@ int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data,
return 0;
}

+int brcmf_debug_fwlog_init(struct brcmf_pub *drvr)
+{
+ return brcmf_fweh_register(drvr, BRCMF_E_TRACE,
+ brcmf_debug_trace_parser);
+}
+
struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr)
{
return drvr->wiphy->debugfsdir;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
index 9b221b509ade..d61508b62d2c 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
@@ -103,6 +103,10 @@ do { \

#endif /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */

+#define MSGTRACE_VERSION 1
+#define MSGTRACE_HDR_TYPE_MSG 0
+#define MSGTRACE_HDR_TYPE_LOG 1
+
#define brcmf_dbg_hex_dump(test, data, len, fmt, ...) \
do { \
trace_brcmf_hexdump((void *)data, len); \
@@ -120,6 +124,7 @@ int brcmf_debugfs_add_entry(struct brcmf_pub *drvr, const char *fn,
int (*read_fn)(struct seq_file *seq, void *data));
int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data,
size_t len);
+int brcmf_debug_fwlog_init(struct brcmf_pub *drvr);
#else
static inline struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr)
{
@@ -137,6 +142,25 @@ int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data,
{
return 0;
}
+
+static inline
+int brcmf_debug_fwlog_init(struct brcmf_pub *drvr)
+{
+ return 0;
+}
#endif

+/* Message trace header */
+struct msgtrace_hdr {
+ u8 version;
+ u8 trace_type;
+ u16 len; /* Len of the trace */
+ u32 seqnum; /* Sequence number of message */
+ /* Number of discarded bytes because of trace overflow */
+ u32 discarded_bytes;
+ /* Number of discarded printf because of trace overflow */
+ u32 discarded_printf;
+};
+
+#define MSGTRACE_HDRLEN sizeof(struct msgtrace_hdr)
#endif /* BRCMFMAC_DEBUG_H */
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
index ac5463838fcf..89220cf3a4de 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
@@ -1219,6 +1219,12 @@ static void brcmf_usb_probe_phase2(struct device *dev, int ret,
if (ret)
goto error;

+ if (BRCMF_FWCON_ON()) {
+ ret = brcmf_fwlog_attach(devinfo->dev);
+ if (ret)
+ goto error;
+ }
+
/* Attach to the common driver interface */
ret = brcmf_attach(devinfo->dev);
if (ret)
@@ -1295,9 +1301,17 @@ static int brcmf_usb_probe_cb(struct brcmf_usbdev_info *devinfo)
ret = brcmf_alloc(devinfo->dev, devinfo->settings);
if (ret)
goto fail;
+
+ if (BRCMF_FWCON_ON()) {
+ ret = brcmf_fwlog_attach(devinfo->dev);
+ if (ret)
+ goto fail;
+ }
+
ret = brcmf_attach(devinfo->dev);
if (ret)
goto fail;
+
/* we are done */
complete(&devinfo->dev_init_done);
return 0;
--
2.1.0

2020-02-13 09:30:53

by Arend van Spriel

[permalink] [raw]
Subject: Re: [PATCH 3/6] brcmfmac: fix the incorrect return value in brcmf_inform_single_bss().

On 2/13/2020 9:44 AM, Chi-Hsien Lin wrote:
> From: Raveendran Somu <[email protected]>
>
> The function brcmf_inform_single_bss returns the value as success,
> even when the length exceeds the maximum value.
> The fix is to send appropriate code on this error.
> This issue is observed when SVT reported random fmac crashes
> when running their tests and the path was identified from the
> crash logs. With this fix the random failure issue in SVT was
> resolved.

Although I know what SVT is it not clear in a public commit message.
Just refer to "Broadcom test group" or something similar. It would be
good to have the crash log in the commit message though. I suspect it
occurs upon next_bss_le() call, but having the crash log is better than
having me guess. Anyway, here is my...

Reviewed-by: Arend van Spriel <[email protected]>

Regards,
Arend

2020-02-13 09:37:14

by Arend van Spriel

[permalink] [raw]
Subject: Re: [PATCH 5/6] brcmfmac: add USB autosuspend feature support

On 2/13/2020 9:44 AM, Chi-Hsien Lin wrote:
> From: Wright Feng <[email protected]>
>
> We add enable dynamic suspend(autosuspend) support in host driver. It
> can let platform cut down idle power consumption. To support autosuspend
> feature in host driver. Kernel need to be build with CONFIG_USB_SUSPEND
> and autosuspend need to be turn on.

You really have to explain why you are killing WOWL here!? I can come up
with a reason, but better you do the explaining ;-)

Regards,
Arend

2020-02-14 14:59:20

by Chi-Hsien Lin

[permalink] [raw]
Subject: Re: [PATCH 3/6] brcmfmac: fix the incorrect return value in brcmf_inform_single_bss().



On 02/13/2020 5:30, Arend Van Spriel wrote:
> On 2/13/2020 9:44 AM, Chi-Hsien Lin wrote:
>> From: Raveendran Somu <[email protected]>
>>
>> The function brcmf_inform_single_bss returns the value as success,
>> even when the length exceeds the maximum value.
>> The fix is to send appropriate code on this error.
>> This issue is observed when SVT reported random fmac crashes
>> when running their tests and the path was identified from the
>> crash logs. With this fix the random failure issue in SVT was
>> resolved.
>
> Although I know what SVT is it not clear in a public commit message.
> Just refer to "Broadcom test group" or something similar. It would be
> good to have the crash log in the commit message though. I suspect it
> occurs upon next_bss_le() call, but having the crash log is better than
> having me guess. Anyway, here is my...
>
> Reviewed-by: Arend van Spriel <[email protected]>

Arend,

Thanks a lot for the feedback. I'll update the comment in V2. This is an
issue that we solved a while back. I'll do some search and see if I can
find the crash log.

Regards,
Chi-hsien Lin

>
> Regards,
> Arend
> .
>

2020-02-17 12:42:28

by Chi-Hsien Lin

[permalink] [raw]
Subject: Re: [PATCH 5/6] brcmfmac: add USB autosuspend feature support



On 02/13/2020 5:36, Arend Van Spriel wrote:
> On 2/13/2020 9:44 AM, Chi-Hsien Lin wrote:
>> From: Wright Feng <[email protected]>
>>
>> We add enable dynamic suspend(autosuspend) support in host driver. It
>> can let platform cut down idle power consumption. To support autosuspend
>> feature in host driver. Kernel need to be build with CONFIG_USB_SUSPEND
>> and autosuspend need to be turn on.
>
> You really have to explain why you are killing WOWL here!? I can come up
> with a reason, but better you do the explaining ;-)

Hi Arend,

Thanks for reviewing. It was because WOWL keeps waking up the host
during autosuspend, but you're right, WOWL shouldn't be killed. We will
explore if we can use "needs_remote_wakeup" feature to allow support for
both.

Regards,
Chi-hsien Lin

>
> Regards,
> Arend
>

2020-03-12 13:20:57

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 1/6] brcmfmac: Fix driver crash on USB control transfer timeout

Chi-Hsien Lin <[email protected]> wrote:

> From: Raveendran Somu <[email protected]>
>
> When the control transfer gets timed out, the error status
> was returned without killing that urb, this leads to using
> the same urb. This issue causes the kernel crash as the same
> urb is sumbitted multiple times. The fix is to kill the
> urb for timeout transfer before returning error
>
> Signed-off-by: Raveendran Somu <[email protected]>
> Signed-off-by: Chi-hsien Lin <[email protected]>

I assume there will be v2 based on comments.

6 patches set to Changes Requested.

11380001 [1/6] brcmfmac: Fix driver crash on USB control transfer timeout
11380003 [2/6] brcmfmac: Fix double freeing in the fmac usb data path
11380005 [3/6] brcmfmac: fix the incorrect return value in brcmf_inform_single_bss().
11380007 [4/6] brcmfmac: increase max hanger slots from 1K to 3K in fws layer
11380009 [5/6] brcmfmac: add USB autosuspend feature support
11380011 [6/6] brcmfmac: To support printing USB console messages

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

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