2017-04-10 09:09:41

by Xinming Hu

[permalink] [raw]
Subject: [PATCH v3 1/4] mwifiex: remove unnecessary wakeup interrupt number sanity check

From: Xinming Hu <[email protected]>

If wakeup interrupt handler is called, we know that the wakeup
interrupt number is valid, there is no need to check it.

Signed-off-by: Xinming Hu <[email protected]>
Signed-off-by: Cathy Luo <[email protected]>
Reviewed-by: Dmitry Torokhov <[email protected]>
Reviewed-by: Brian Norris <[email protected]>
---
v2: modify description(Dimtry)
v3: same as v2
---
drivers/net/wireless/marvell/mwifiex/main.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c
index 0dfbac8..98fd491 100644
--- a/drivers/net/wireless/marvell/mwifiex/main.c
+++ b/drivers/net/wireless/marvell/mwifiex/main.c
@@ -1513,11 +1513,9 @@ static irqreturn_t mwifiex_irq_wakeup_handler(int irq, void *priv)
{
struct mwifiex_adapter *adapter = priv;

- if (adapter->irq_wakeup >= 0) {
- dev_dbg(adapter->dev, "%s: wake by wifi", __func__);
- adapter->wake_by_wifi = true;
- disable_irq_nosync(irq);
- }
+ dev_dbg(adapter->dev, "%s: wake by wifi", __func__);
+ adapter->wake_by_wifi = true;
+ disable_irq_nosync(irq);

/* Notify PM core we are wakeup source */
pm_wakeup_event(adapter->dev, 0);
--
1.8.1.4


2017-04-11 01:37:29

by Brian Norris

[permalink] [raw]
Subject: Re: [PATCH v3 4/4] mwifiex: pcie: extract wifi part from combo firmware during function level reset

Hi,

On Mon, Apr 10, 2017 at 09:09:34AM +0000, Xinming Hu wrote:
> From: Xinming Hu <[email protected]>
>
> A seperate wifi-only firmware was download during pcie function level reset.
> It is in fact the tail part of wifi/bt combo firmware. Per Brian's and
> Dmitry's suggestion, this patch extract the wifi part from combo firmware.
>
> After that, we can discard the redudant image in linux-firmware repo.
>
> Signed-off-by: Xinming Hu <[email protected]>
> Signed-off-by: Ganapathi Bhat <[email protected]>
> Signed-off-by: Cathy Luo <[email protected]>
> ---
> v2: extract wifi part from combo firmware(Dimtry and Brain)
> add more description(Kalle)
> v3: same as v2
> ---
> drivers/net/wireless/marvell/mwifiex/fw.h | 18 +++++++
> drivers/net/wireless/marvell/mwifiex/pcie.c | 83 ++++++++++++++++++++++++++---
> drivers/net/wireless/marvell/mwifiex/pcie.h | 2 +
> 3 files changed, 96 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/wireless/marvell/mwifiex/fw.h b/drivers/net/wireless/marvell/mwifiex/fw.h
> index 0b68374..6cf9ab9 100644
> --- a/drivers/net/wireless/marvell/mwifiex/fw.h
> +++ b/drivers/net/wireless/marvell/mwifiex/fw.h
> @@ -43,6 +43,24 @@ struct tx_packet_hdr {
> struct rfc_1042_hdr rfc1042_hdr;
> } __packed;
>
> +struct mwifiex_fw_header {
> + __le32 dnld_cmd;
> + __le32 base_addr;
> + __le32 data_length;
> + __le32 crc;
> +} __packed;
> +
> +struct mwifiex_fw_data {
> + struct mwifiex_fw_header header;
> + __le32 seq_num;
> + u8 data[1];
> +} __packed;
> +
> +#define MWIFIEX_FW_DNLD_CMD_1 0x1
> +#define MWIFIEX_FW_DNLD_CMD_5 0x5
> +#define MWIFIEX_FW_DNLD_CMD_6 0x6
> +#define MWIFIEX_FW_DNLD_CMD_7 0x7
> +
> #define B_SUPPORTED_RATES 5
> #define G_SUPPORTED_RATES 9
> #define BG_SUPPORTED_RATES 13
> diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
> index a07cb0a..ebf00d9 100644
> --- a/drivers/net/wireless/marvell/mwifiex/pcie.c
> +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
> @@ -1956,6 +1956,63 @@ static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter,
> return ret;
> }
>
> +/* Extract wifi part from wifi-bt combo firmware image.
> + */
> +
> +static int mwifiex_extract_wifi_fw(struct mwifiex_adapter *adapter,
> + u8 *firmware, u32 firmware_len) {

Can you make 'firmware' const? Also, to help below, it might work better
as 'const void *'.

> + struct mwifiex_fw_data fwdata;
> + u32 offset = 0, data_len, dnld_cmd;
> + int ret = 0;
> + bool cmd7_before = false;
> +
> + while (1) {
> + if (offset + sizeof(fwdata.header) >= firmware_len) {
> + mwifiex_dbg(adapter, ERROR,
> + "extract wifi-only firmware failure!");
> + ret = -1;
> + goto done;
> + }
> +
> + memcpy(&fwdata.header, firmware + offset,
> + sizeof(fwdata.header));

Do you actually need to copy this? Can't you just keep a pointer to the
location? e.g.

const struct mwifiex_fw_data *fwdata;
...
fwdata = firmware + offset;

> + dnld_cmd = le32_to_cpu(fwdata.header.dnld_cmd);
> + data_len = le32_to_cpu(fwdata.header.data_length);
> +
> + switch (dnld_cmd) {
> + case MWIFIEX_FW_DNLD_CMD_1:
> + if (!cmd7_before) {
> + mwifiex_dbg(adapter, ERROR,
> + "no cmd7 before cmd1!");
> + ret = -1;
> + goto done;
> + }
> + offset += data_len + sizeof(fwdata.header);

Technically, we need an overflow check to make sure that 'data_len'
isn't some bogus value that overflows 'offset'.

> + break;
> + case MWIFIEX_FW_DNLD_CMD_5:
> + offset += data_len + sizeof(fwdata.header);

Same here.

> + break;
> + case MWIFIEX_FW_DNLD_CMD_6:

Can we have a comment, either here or above this function, to describe
what this sequence is? Or particularly, what is this terminating
condition? "CMD_6" doesn't really tell me that this is the start of the
Wifi blob.

> + offset += data_len + sizeof(fwdata.header);

You don't check for overflow here. Check this before returning this
(either here, or in the 'done' label).

> + ret = offset;
> + goto done;
> + case MWIFIEX_FW_DNLD_CMD_7:
> + if (!cmd7_before)

^^ This 'if' isn't really needed.

> + cmd7_before = true;
> + offset += sizeof(fwdata.header);
> + break;
> + default:
> + mwifiex_dbg(adapter, ERROR, "unknown dnld_cmd %d\n",
> + dnld_cmd);
> + ret = -1;
> + goto done;
> + }
> + }
> +
> +done:
> + return ret;
> +}
> +
> /*
> * This function downloads the firmware to the card.
> *
> @@ -1971,7 +2028,7 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter,
> u32 firmware_len = fw->fw_len;
> u32 offset = 0;
> struct sk_buff *skb;
> - u32 txlen, tx_blocks = 0, tries, len;
> + u32 txlen, tx_blocks = 0, tries, len, val;
> u32 block_retry_cnt = 0;
> struct pcie_service_card *card = adapter->card;
> const struct mwifiex_pcie_card_reg *reg = card->pcie.reg;
> @@ -1998,6 +2055,24 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter,
> goto done;
> }
>
> + ret = mwifiex_read_reg(adapter, PCIE_SCRATCH_13_REG, &val);
> + if (ret) {
> + mwifiex_dbg(adapter, FATAL, "Failed to read scratch register 13\n");
> + goto done;
> + }
> +
> + /* PCIE FLR case: extract wifi part from combo firmware*/
> + if (val == MWIFIEX_PCIE_FLR_HAPPENS) {
> + ret = mwifiex_extract_wifi_fw(adapter, firmware, firmware_len);
> + if (ret < 0) {
> + mwifiex_dbg(adapter, ERROR, "Failed to extract wifi fw\n");
> + goto done;
> + }
> + offset = ret;
> + mwifiex_dbg(adapter, MSG,
> + "info: dnld wifi firmware from %d bytes\n", offset);
> + }
> +
> /* Perform firmware data transfer */
> do {
> u32 ireg_intr = 0;
> @@ -3060,12 +3135,6 @@ static void mwifiex_pcie_up_dev(struct mwifiex_adapter *adapter)
> struct pci_dev *pdev = card->dev;
> const struct mwifiex_pcie_card_reg *reg = card->pcie.reg;
>
> - /* Bluetooth is not on pcie interface. Download Wifi only firmware
> - * during pcie FLR, so that bluetooth part of firmware which is
> - * already running doesn't get affected.
> - */
> - strcpy(adapter->fw_name, PCIE8997_DEFAULT_WIFIFW_NAME);

Now that there's no users, delete PCIE8997_DEFAULT_WIFIFW_NAME from
pcie.h.

Brian

> -
> /* tx_buf_size might be changed to 3584 by firmware during
> * data transfer, we should reset it to default size.
> */
> diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.h b/drivers/net/wireless/marvell/mwifiex/pcie.h
> index 7e2450c..54aecda 100644
> --- a/drivers/net/wireless/marvell/mwifiex/pcie.h
> +++ b/drivers/net/wireless/marvell/mwifiex/pcie.h
> @@ -120,6 +120,8 @@
> #define MWIFIEX_SLEEP_COOKIE_SIZE 4
> #define MWIFIEX_MAX_DELAY_COUNT 100
>
> +#define MWIFIEX_PCIE_FLR_HAPPENS 0xFEDCBABA
> +
> struct mwifiex_pcie_card_reg {
> u16 cmd_addr_lo;
> u16 cmd_addr_hi;
> --
> 1.8.1.4
>

2017-04-14 03:28:34

by Xinming Hu

[permalink] [raw]
Subject: RE: Re: Re: [PATCH v3 4/4] mwifiex: pcie: extract wifi part from combo firmware during function level reset

SGkgQnJhaW4sDQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogQnJpYW4g
Tm9ycmlzIFttYWlsdG86YnJpYW5ub3JyaXNAY2hyb21pdW0ub3JnXQ0KPiBTZW50OiAyMDE35bm0
NOaciDE05pelIDE6NTANCj4gVG86IFhpbm1pbmcgSHUNCj4gQ2M6IExpbnV4IFdpcmVsZXNzOyBL
YWxsZSBWYWxvOyBEbWl0cnkgVG9yb2tob3Y7IHJhamF0amFAZ29vZ2xlLmNvbTsNCj4gQW1pdGt1
bWFyIEthcndhcjsgQ2F0aHkgTHVvOyBHYW5hcGF0aGkgQmhhdA0KPiBTdWJqZWN0OiBbRVhUXSBS
ZTogUmU6IFtQQVRDSCB2MyA0LzRdIG13aWZpZXg6IHBjaWU6IGV4dHJhY3Qgd2lmaSBwYXJ0IGZy
b20NCj4gY29tYm8gZmlybXdhcmUgZHVyaW5nIGZ1bmN0aW9uIGxldmVsIHJlc2V0DQo+IA0KPiBF
eHRlcm5hbCBFbWFpbA0KPiANCj4gLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQ0KPiBIaSwNCj4gDQo+IE9uIFRodSwg
QXByIDEzLCAyMDE3IG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Y21kKTsN
Cj4gPiA+ID4gKwkJCXJldCA9IC0xOw0KPiA+ID4gPiArCQkJZ290byBkb25lOw0KPiA+ID4gPiAr
CQl9DQo+ID4gPiA+ICsJfQ0KPiA+ID4gPiArDQo+ID4gPiA+ICtkb25lOg0KPiA+ID4gPiArCXJl
dHVybiByZXQ7DQo+ID4gPiA+ICt9DQo+IA0KPiBbLi4uXQ0KPiANCj4gQnJpYW4NCg==

2017-04-10 09:09:48

by Xinming Hu

[permalink] [raw]
Subject: [PATCH v3 4/4] mwifiex: pcie: extract wifi part from combo firmware during function level reset

From: Xinming Hu <[email protected]>

A seperate wifi-only firmware was download during pcie function level reset.
It is in fact the tail part of wifi/bt combo firmware. Per Brian's and
Dmitry's suggestion, this patch extract the wifi part from combo firmware.

After that, we can discard the redudant image in linux-firmware repo.

Signed-off-by: Xinming Hu <[email protected]>
Signed-off-by: Ganapathi Bhat <[email protected]>
Signed-off-by: Cathy Luo <[email protected]>
---
v2: extract wifi part from combo firmware(Dimtry and Brain)
add more description(Kalle)
v3: same as v2
---
drivers/net/wireless/marvell/mwifiex/fw.h | 18 +++++++
drivers/net/wireless/marvell/mwifiex/pcie.c | 83 ++++++++++++++++++++++++++---
drivers/net/wireless/marvell/mwifiex/pcie.h | 2 +
3 files changed, 96 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/fw.h b/drivers/net/wireless/marvell/mwifiex/fw.h
index 0b68374..6cf9ab9 100644
--- a/drivers/net/wireless/marvell/mwifiex/fw.h
+++ b/drivers/net/wireless/marvell/mwifiex/fw.h
@@ -43,6 +43,24 @@ struct tx_packet_hdr {
struct rfc_1042_hdr rfc1042_hdr;
} __packed;

+struct mwifiex_fw_header {
+ __le32 dnld_cmd;
+ __le32 base_addr;
+ __le32 data_length;
+ __le32 crc;
+} __packed;
+
+struct mwifiex_fw_data {
+ struct mwifiex_fw_header header;
+ __le32 seq_num;
+ u8 data[1];
+} __packed;
+
+#define MWIFIEX_FW_DNLD_CMD_1 0x1
+#define MWIFIEX_FW_DNLD_CMD_5 0x5
+#define MWIFIEX_FW_DNLD_CMD_6 0x6
+#define MWIFIEX_FW_DNLD_CMD_7 0x7
+
#define B_SUPPORTED_RATES 5
#define G_SUPPORTED_RATES 9
#define BG_SUPPORTED_RATES 13
diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
index a07cb0a..ebf00d9 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -1956,6 +1956,63 @@ static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter,
return ret;
}

+/* Extract wifi part from wifi-bt combo firmware image.
+ */
+
+static int mwifiex_extract_wifi_fw(struct mwifiex_adapter *adapter,
+ u8 *firmware, u32 firmware_len) {
+ struct mwifiex_fw_data fwdata;
+ u32 offset = 0, data_len, dnld_cmd;
+ int ret = 0;
+ bool cmd7_before = false;
+
+ while (1) {
+ if (offset + sizeof(fwdata.header) >= firmware_len) {
+ mwifiex_dbg(adapter, ERROR,
+ "extract wifi-only firmware failure!");
+ ret = -1;
+ goto done;
+ }
+
+ memcpy(&fwdata.header, firmware + offset,
+ sizeof(fwdata.header));
+ dnld_cmd = le32_to_cpu(fwdata.header.dnld_cmd);
+ data_len = le32_to_cpu(fwdata.header.data_length);
+
+ switch (dnld_cmd) {
+ case MWIFIEX_FW_DNLD_CMD_1:
+ if (!cmd7_before) {
+ mwifiex_dbg(adapter, ERROR,
+ "no cmd7 before cmd1!");
+ ret = -1;
+ goto done;
+ }
+ offset += data_len + sizeof(fwdata.header);
+ break;
+ case MWIFIEX_FW_DNLD_CMD_5:
+ offset += data_len + sizeof(fwdata.header);
+ break;
+ case MWIFIEX_FW_DNLD_CMD_6:
+ offset += data_len + sizeof(fwdata.header);
+ ret = offset;
+ goto done;
+ case MWIFIEX_FW_DNLD_CMD_7:
+ if (!cmd7_before)
+ cmd7_before = true;
+ offset += sizeof(fwdata.header);
+ break;
+ default:
+ mwifiex_dbg(adapter, ERROR, "unknown dnld_cmd %d\n",
+ dnld_cmd);
+ ret = -1;
+ goto done;
+ }
+ }
+
+done:
+ return ret;
+}
+
/*
* This function downloads the firmware to the card.
*
@@ -1971,7 +2028,7 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter,
u32 firmware_len = fw->fw_len;
u32 offset = 0;
struct sk_buff *skb;
- u32 txlen, tx_blocks = 0, tries, len;
+ u32 txlen, tx_blocks = 0, tries, len, val;
u32 block_retry_cnt = 0;
struct pcie_service_card *card = adapter->card;
const struct mwifiex_pcie_card_reg *reg = card->pcie.reg;
@@ -1998,6 +2055,24 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter,
goto done;
}

+ ret = mwifiex_read_reg(adapter, PCIE_SCRATCH_13_REG, &val);
+ if (ret) {
+ mwifiex_dbg(adapter, FATAL, "Failed to read scratch register 13\n");
+ goto done;
+ }
+
+ /* PCIE FLR case: extract wifi part from combo firmware*/
+ if (val == MWIFIEX_PCIE_FLR_HAPPENS) {
+ ret = mwifiex_extract_wifi_fw(adapter, firmware, firmware_len);
+ if (ret < 0) {
+ mwifiex_dbg(adapter, ERROR, "Failed to extract wifi fw\n");
+ goto done;
+ }
+ offset = ret;
+ mwifiex_dbg(adapter, MSG,
+ "info: dnld wifi firmware from %d bytes\n", offset);
+ }
+
/* Perform firmware data transfer */
do {
u32 ireg_intr = 0;
@@ -3060,12 +3135,6 @@ static void mwifiex_pcie_up_dev(struct mwifiex_adapter *adapter)
struct pci_dev *pdev = card->dev;
const struct mwifiex_pcie_card_reg *reg = card->pcie.reg;

- /* Bluetooth is not on pcie interface. Download Wifi only firmware
- * during pcie FLR, so that bluetooth part of firmware which is
- * already running doesn't get affected.
- */
- strcpy(adapter->fw_name, PCIE8997_DEFAULT_WIFIFW_NAME);
-
/* tx_buf_size might be changed to 3584 by firmware during
* data transfer, we should reset it to default size.
*/
diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.h b/drivers/net/wireless/marvell/mwifiex/pcie.h
index 7e2450c..54aecda 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.h
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.h
@@ -120,6 +120,8 @@
#define MWIFIEX_SLEEP_COOKIE_SIZE 4
#define MWIFIEX_MAX_DELAY_COUNT 100

+#define MWIFIEX_PCIE_FLR_HAPPENS 0xFEDCBABA
+
struct mwifiex_pcie_card_reg {
u16 cmd_addr_lo;
u16 cmd_addr_hi;
--
1.8.1.4

2017-04-15 08:55:34

by Xinming Hu

[permalink] [raw]
Subject: RE: Re: Re: Re: [PATCH v3 4/4] mwifiex: pcie: extract wifi part from combo firmware during function level reset

SGkgQnJhaW4sDQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogQnJpYW4g
Tm9ycmlzIFttYWlsdG86YnJpYW5ub3JyaXNAY2hyb21pdW0ub3JnXQ0KPiBTZW50OiAyMDE3xOo0
1MIxNcjVIDA6NTYNCj4gVG86IFhpbm1pbmcgSHUNCj4gQ2M6IExpbnV4IFdpcmVsZXNzOyBLYWxs
ZSBWYWxvOyBEbWl0cnkgVG9yb2tob3Y7IHJhamF0amFAZ29vZ2xlLmNvbTsNCj4gQW1pdGt1bWFy
IEthcndhcjsgQ2F0aHkgTHVvOyBHYW5hcGF0aGkgQmhhdA0KPiBTdWJqZWN0OiBbRVhUXSBSZTog
UmU6IFJlOiBbUEFUQ0ggdjMgNC80XSBtd2lmaWV4OiBwY2llOiBleHRyYWN0IHdpZmkgcGFydCBm
cm9tDQo+IGNvbWJvIGZpcm13YXJlIGR1cmluZyBmdW5jdGlvbiBsZXZlbCByZXNldA0KPiANCj4g
RXh0ZXJuYWwgRW1haWwNCj4gDQo+IC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t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vb3QNCj4gUk9NLg0KPiANCj4gU28sIHdlICpjYW4qIGltcGxl
bWVudCBjaGVja3MgbGlrZSB0aGlzLCBidXQgSSdkIHJlYWxseSBob3BlIHdlIGRvbid0IG5lZWQg
dGhpcw0KPiBwYXJ0aWN1bGFyIG9uZSwgYmVjYXVzZSB5b3VyIGNhcmQgc2hvdWxkIGJlIHRha2lu
ZyBjYXJlIG9mIHRoYXQuDQo+IA0KDQpHb3QgaXQsIHdlIHdpbGwga2VlcCBpbiBtaW5kIHRvIGNo
ZWNrIHRoZSBwb3NzaWJsZSBvdmVyZmxvdyBpbiBmdXR1cmUsIGVpdGhlciB1c2luZyBnZW5lcmFs
DQpwcm90ZWN0IG9yIHVuZGVyIGxpbWl0IGJ5IG91ciBkZXZpY2UgcmVxdWlyZW1lbnQuDQoNCj4g
UGxlYXNlIGNvbnNpZGVyIHJldmlld2luZyBteSBsYXRlc3Qgc3VibWlzc2lvbi4NCj4gDQoNClN1
cmUuDQoNClRoYW5rcywNClNpbW9uDQo+IFJlZ2FyZHMsDQo+IEJyaWFuDQo=

2017-04-10 09:09:43

by Xinming Hu

[permalink] [raw]
Subject: [PATCH v3 2/4] mwifiex: fall back mwifiex_dbg to pr_info when adapter->dev not set

From: Xinming Hu <[email protected]>

mwifiex_dbg will do nothing before adapter->dev get assigned. several logs
lost in this case. it can be avoided by fall back to pr_info.

Signed-off-by: Xinming Hu <[email protected]>
Reviewed-by: Brian Norris <[email protected]>
Reviewed-by: Dmitry Torokhov <[email protected]>
---
v2: enhance adapter->dev null case.(Brain)
v3: use va_list in pr_info.(Dmitry)
---
drivers/net/wireless/marvell/mwifiex/main.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c
index 98fd491..16cd14e 100644
--- a/drivers/net/wireless/marvell/mwifiex/main.c
+++ b/drivers/net/wireless/marvell/mwifiex/main.c
@@ -1750,7 +1750,7 @@ void _mwifiex_dbg(const struct mwifiex_adapter *adapter, int mask,
struct va_format vaf;
va_list args;

- if (!adapter->dev || !(adapter->debug_mask & mask))
+ if (!(adapter->debug_mask & mask))
return;

va_start(args, fmt);
@@ -1758,7 +1758,10 @@ void _mwifiex_dbg(const struct mwifiex_adapter *adapter, int mask,
vaf.fmt = fmt;
vaf.va = &args;

- dev_info(adapter->dev, "%pV", &vaf);
+ if (adapter->dev)
+ dev_info(adapter->dev, "%pV", &vaf);
+ else
+ pr_info("%pV", &vaf);

va_end(args);
}
--
1.8.1.4

2017-04-12 17:32:20

by Brian Norris

[permalink] [raw]
Subject: Re: [PATCH v3 4/4] mwifiex: pcie: extract wifi part from combo firmware during function level reset

Hi,

One more thing, since you need to update this patchset anyway:

On Mon, Apr 10, 2017 at 09:09:34AM +0000, Xinming Hu wrote:
> From: Xinming Hu <[email protected]>
>
> A seperate wifi-only firmware was download during pcie function level reset.

You might consider running checkpatch.pl on your submissions. It's
helpful in general, but in this case, it would actually catch a spelling
error:

s/seperate/separate/

> It is in fact the tail part of wifi/bt combo firmware. Per Brian's and
> Dmitry's suggestion, this patch extract the wifi part from combo firmware.
>
> After that, we can discard the redudant image in linux-firmware repo.
>
> Signed-off-by: Xinming Hu <[email protected]>
> Signed-off-by: Ganapathi Bhat <[email protected]>
> Signed-off-by: Cathy Luo <[email protected]>

Brian

2017-04-14 16:55:39

by Brian Norris

[permalink] [raw]
Subject: Re: Re: Re: [PATCH v3 4/4] mwifiex: pcie: extract wifi part from combo firmware during function level reset

Hi,

On Fri, Apr 14, 2017 at 03:28:28AM +0000, Xinming Hu wrote:
> According to the firmware download protocol, every CMD should not exceed MWIFIEX_UPLD_SIZE.
> we can add a sanity check , like,
> if (data_len > MWIFIEX_UPLD_SIZE - sizeof(fwdata->header))
> *error*

I was primarily interested in protecting the kernel itself. Once the
kernel starts parsing the firmware, we have to make sure a bad firmware
file won't end up with us looping infinitely, reading/writing invalid
memory, or otherwise exposing security or stability issues. I wasn't
necessarily interested in validating every requirement of the end-point
device. For example, we're not bothering checking the CRCs. I figured that
this was all the job of your Wifi card's boot ROM.

So, we *can* implement checks like this, but I'd really hope we don't
need this particular one, because your card should be taking care of
that.

Please consider reviewing my latest submission.

Regards,
Brian

2017-04-13 17:50:14

by Brian Norris

[permalink] [raw]
Subject: Re: Re: [PATCH v3 4/4] mwifiex: pcie: extract wifi part from combo firmware during function level reset

Hi,

On Thu, Apr 13, 2017 at 06:47:59AM +0000, Xinming Hu wrote:
> > -----Original Message-----
> > From: Brian Norris [mailto:[email protected]]
> > Sent: 2017年4月11日 9:37
> > To: Xinming Hu
> > Cc: Linux Wireless; Kalle Valo; Dmitry Torokhov; [email protected];
> > Amitkumar Karwar; Cathy Luo; Xinming Hu; Ganapathi Bhat
> > Subject: [EXT] Re: [PATCH v3 4/4] mwifiex: pcie: extract wifi part from combo
> > firmware during function level reset
> >
> > External Email
> >

> > On Mon, Apr 10, 2017 at 09:09:34AM +0000, Xinming Hu wrote:
> > > + while (1) {
> > > + if (offset + sizeof(fwdata.header) >= firmware_len) {
> > > + mwifiex_dbg(adapter, ERROR,
> > > + "extract wifi-only firmware failure!");
> > > + ret = -1;
> > > + goto done;
> > > + }
> > > +
> > > + memcpy(&fwdata.header, firmware + offset,
> > > + sizeof(fwdata.header));
> >
> > Do you actually need to copy this? Can't you just keep a pointer to the location?
> > e.g.
> >
> > const struct mwifiex_fw_data *fwdata;
> > ...
> > fwdata = firmware + offset;
> >
>
> Ok.
>
> > > + dnld_cmd = le32_to_cpu(fwdata.header.dnld_cmd);
> > > + data_len = le32_to_cpu(fwdata.header.data_length);
> > > +
> > > + switch (dnld_cmd) {
> > > + case MWIFIEX_FW_DNLD_CMD_1:
> > > + if (!cmd7_before) {
> > > + mwifiex_dbg(adapter, ERROR,
> > > + "no cmd7 before cmd1!");
> > > + ret = -1;
> > > + goto done;
> > > + }
> > > + offset += data_len + sizeof(fwdata.header);
> >
> > Technically, we need an overflow check to make sure that 'data_len'
> > isn't some bogus value that overflows 'offset'.
> >
>
> There is the sanity check for the offset after bypass CMD1/5/7 in the start of while-loop, enhanced in v4 as,
> if (offset >= firmware_len)

That's not an enhancement!! That's a *weaker* condition, and it's wrong.
If 'offset == firmware_len - 1', then we'll still be out of bounds when
we read the next header at 'offset + {1, 2, 3, ...}'.

My point was that adding 'data_len' might actually overflow the u32, not
that the bounds check ('offset + sizeof(...header) >= firmware_len') was
wrong.

For this kind of overflow check, you need to do the check here, not
after you've saved the new offset.

e.g., suppose data_len = 0xfffffff0. Then:

offset += data_len + sizeof(fwdata.header);
=>
offset += 0xfffffff0 + 16;
=>
offset += 0;

and then...we have an infinite loop. Changing the bounds check at the
start of the loop does nothing to help this.

Something like this (put before the addition) is sufficient, I think:

if (offset + data_len + sizeof(fwdata.header) < data_len)
... error ...

Or this would actually all be slightly cleaner if you just did this
outside the 'switch':

// Presuming you already did the check for
// offset + sizeof(fwdata.header) >= firmware_len
offset += sizeof(fwdata.header);

Then inside this 'case', you have:

if (offset + data_len < data_len)
... error out ...
offset += data_len;

> > > + break;
> > > + case MWIFIEX_FW_DNLD_CMD_5:
> > > + offset += data_len + sizeof(fwdata.header);
> >
> > Same here.
> >
> > > + break;
> > > + case MWIFIEX_FW_DNLD_CMD_6:
> >
> > Can we have a comment, either here or above this function, to describe what
> > this sequence is? Or particularly, what is this terminating condition? "CMD_6"
> > doesn't really tell me that this is the start of the Wifi blob.
> >
> > > + offset += data_len + sizeof(fwdata.header);
> >
>
> The sequence have been added to function comments in v4.
>
> > You don't check for overflow here. Check this before returning this (either here,
> > or in the 'done' label).
> >
>
> Yes, add sanity check for the offset in end of CMD6.
>
> > > + ret = offset;
> > > + goto done;
> > > + case MWIFIEX_FW_DNLD_CMD_7:
> > > + if (!cmd7_before)
> >
> > ^^ This 'if' isn't really needed.
>
> Done.
>
> >
> > > + cmd7_before = true;
> > > + offset += sizeof(fwdata.header);
> > > + break;
> > > + default:
> > > + mwifiex_dbg(adapter, ERROR, "unknown dnld_cmd %d\n",
> > > + dnld_cmd);
> > > + ret = -1;
> > > + goto done;
> > > + }
> > > + }
> > > +
> > > +done:
> > > + return ret;
> > > +}

[...]

Brian

2017-04-13 06:48:13

by Xinming Hu

[permalink] [raw]
Subject: RE: Re: [PATCH v3 4/4] mwifiex: pcie: extract wifi part from combo firmware during function level reset

SGkgQnJhaW4sDQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogQnJpYW4g
Tm9ycmlzIFttYWlsdG86YnJpYW5ub3JyaXNAY2hyb21pdW0ub3JnXQ0KPiBTZW50OiAyMDE3xOo0
1MIxMcjVIDk6MzcNCj4gVG86IFhpbm1pbmcgSHUNCj4gQ2M6IExpbnV4IFdpcmVsZXNzOyBLYWxs
ZSBWYWxvOyBEbWl0cnkgVG9yb2tob3Y7IHJhamF0amFAZ29vZ2xlLmNvbTsNCj4gQW1pdGt1bWFy
IEthcndhcjsgQ2F0aHkgTHVvOyBYaW5taW5nIEh1OyBHYW5hcGF0aGkgQmhhdA0KPiBTdWJqZWN0
OiBbRVhUXSBSZTogW1BBVENIIHYzIDQvNF0gbXdpZmlleDogcGNpZTogZXh0cmFjdCB3aWZpIHBh
cnQgZnJvbSBjb21ibw0KPiBmaXJtd2FyZSBkdXJpbmcgZnVuY3Rpb24gbGV2ZWwgcmVzZXQNCj4g
DQo+IEV4dGVybmFsIEVtYWlsDQo+IA0KPiAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tDQo+IEhpLA0KPiANCj4gT24g
TW9uLCBBcHIgMTAsIDIwMTcgYXQgMDk6MDk6MzRBTSArMDAwMCwgWGlubWluZyBIdSB3cm90ZToN
Cj4gPiBGcm9tOiBYaW5taW5nIEh1IDxodXhtQG1hcnZlbGwuY29tPg0KPiA+DQo+ID4gQSBzZXBl
cmF0ZSB3aWZpLW9ubHkgZmlybXdhcmUgd2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PiAgCS8qIHR4X2J1Zl9zaXplIG1pZ2h0
IGJlIGNoYW5nZWQgdG8gMzU4NCBieSBmaXJtd2FyZSBkdXJpbmcNCj4gPiAgCSAqIGRhdGEgdHJh
bnNmZXIsIHdlIHNob3VsZCByZXNldCBpdCB0byBkZWZhdWx0IHNpemUuDQo+ID4gIAkgKi8NCj4g
PiBkaWZmIC0tZ2l0IGEvZHJpdmVycy9uZXQvd2lyZWxlc3MvbWFydmVsbC9td2lmaWV4L3BjaWUu
aA0KPiA+IGIvZHJpdmVycy9uZXQvd2lyZWxlc3MvbWFydmVsbC9td2lmaWV4L3BjaWUuaA0KPiA+
IGluZGV4IDdlMjQ1MGMuLjU0YWVjZGEgMTAwNjQ0DQo+ID4gLS0tIGEvZHJpdmVycy9uZXQvd2ly
ZWxlc3MvbWFydmVsbC9td2lmaWV4L3BjaWUuaA0KPiA+ICsrKyBiL2RyaXZlcnMvbmV0L3dpcmVs
ZXNzL21hcnZlbGwvbXdpZmlleC9wY2llLmgNCj4gPiBAQCAtMTIwLDYgKzEyMCw4IEBADQo+ID4g
ICNkZWZpbmUgTVdJRklFWF9TTEVFUF9DT09LSUVfU0laRQkJCTQNCj4gPiAgI2RlZmluZSBNV0lG
SUVYX01BWF9ERUxBWV9DT1VOVAkJCQkxMDANCj4gPg0KPiA+ICsjZGVmaW5lIE1XSUZJRVhfUENJ
RV9GTFJfSEFQUEVOUyAweEZFRENCQUJBDQo+ID4gKw0KPiA+ICBzdHJ1Y3QgbXdpZmlleF9wY2ll
X2NhcmRfcmVnIHsNCj4gPiAgCXUxNiBjbWRfYWRkcl9sbzsNCj4gPiAgCXUxNiBjbWRfYWRkcl9o
aTsNCj4gPiAtLQ0KPiA+IDEuOC4xLjQNCj4gPg0K

2017-04-10 09:09:46

by Xinming Hu

[permalink] [raw]
Subject: [PATCH v3 3/4] mwifiex: pcie: correct scratch register name

From: Xinming Hu <[email protected]>

This patch correct pcie scratch register name, to keep the same with
chipset side definition.

Signed-off-by: Xinming Hu <[email protected]>
---
v2: code clean and prepare for next patch 4/4
v3: same as v2
---
drivers/net/wireless/marvell/mwifiex/pcie.c | 4 ++--
drivers/net/wireless/marvell/mwifiex/pcie.h | 13 +++++++------
2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
index f45ab12..a07cb0a 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -2494,8 +2494,8 @@ static int mwifiex_pcie_host_to_card(struct mwifiex_adapter *adapter, u8 type,
struct pcie_service_card *card = adapter->card;
const struct mwifiex_pcie_card_reg *reg = card->pcie.reg;
int pcie_scratch_reg[] = {PCIE_SCRATCH_12_REG,
- PCIE_SCRATCH_13_REG,
- PCIE_SCRATCH_14_REG};
+ PCIE_SCRATCH_14_REG,
+ PCIE_SCRATCH_15_REG};

if (!p)
return 0;
diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.h b/drivers/net/wireless/marvell/mwifiex/pcie.h
index 00e8ee5..7e2450c 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.h
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.h
@@ -77,8 +77,9 @@
#define PCIE_SCRATCH_10_REG 0xCE8
#define PCIE_SCRATCH_11_REG 0xCEC
#define PCIE_SCRATCH_12_REG 0xCF0
-#define PCIE_SCRATCH_13_REG 0xCF8
-#define PCIE_SCRATCH_14_REG 0xCFC
+#define PCIE_SCRATCH_13_REG 0xCF4
+#define PCIE_SCRATCH_14_REG 0xCF8
+#define PCIE_SCRATCH_15_REG 0xCFC
#define PCIE_RD_DATA_PTR_Q0_Q1 0xC08C
#define PCIE_WR_DATA_PTR_Q0_Q1 0xC05C

@@ -217,8 +218,8 @@ struct mwifiex_pcie_card_reg {
.ring_tx_start_ptr = MWIFIEX_BD_FLAG_TX_START_PTR,
.pfu_enabled = 1,
.sleep_cookie = 0,
- .fw_dump_ctrl = 0xcf4,
- .fw_dump_start = 0xcf8,
+ .fw_dump_ctrl = PCIE_SCRATCH_13_REG,
+ .fw_dump_start = PCIE_SCRATCH_14_REG,
.fw_dump_end = 0xcff,
.fw_dump_host_ready = 0xee,
.fw_dump_read_done = 0xfe,
@@ -254,8 +255,8 @@ struct mwifiex_pcie_card_reg {
.ring_tx_start_ptr = MWIFIEX_BD_FLAG_TX_START_PTR,
.pfu_enabled = 1,
.sleep_cookie = 0,
- .fw_dump_ctrl = 0xcf4,
- .fw_dump_start = 0xcf8,
+ .fw_dump_ctrl = PCIE_SCRATCH_13_REG,
+ .fw_dump_start = PCIE_SCRATCH_14_REG,
.fw_dump_end = 0xcff,
.fw_dump_host_ready = 0xcc,
.fw_dump_read_done = 0xdd,
--
1.8.1.4