2017-04-13 06:48:29

by Xinming Hu

[permalink] [raw]
Subject: [PATCH v4 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)
v4: same as v2, v3
---
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-13 13:59:04

by Kalle Valo

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

Xinming Hu <[email protected]> writes:

> From: Xinming Hu <[email protected]>
>
> A seprate 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.

If you mean with discarding removing the actual image from
linux-firmware, then you cannot do that. The image is still needed so
that linux-firmware works with older kernels.

--
Kalle Valo

2017-04-15 09:33:44

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3Y0LmJpbiINCj4gLSNkZWZpbmUgUENJRTg5OTdfREVGQVVMVF9XSUZJRldfTkFNRSAi
bXJ2bC9wY2llODk5N193bGFuX3Y0LmJpbiINCj4gDQo+ICAjZGVmaW5lIFBDSUVfVkVORE9SX0lE
X01BUlZFTEwgICAgICAgICAgICAgICgweDExYWIpDQo+ICAjZGVmaW5lIFBDSUVfVkVORE9SX0lE
X1YyX01BUlZFTEwgICAgICAgICAgICgweDFiNGIpDQo+IEBAIC0xMjAsNiArMTE5LDggQEANCj4g
ICNkZWZpbmUgTVdJRklFWF9TTEVFUF9DT09LSUVfU0laRQkJCTQNCj4gICNkZWZpbmUgTVdJRklF
WF9NQVhfREVMQVlfQ09VTlQJCQkJMTAwDQo+IA0KPiArI2RlZmluZSBNV0lGSUVYX1BDSUVfRkxS
X0hBUFBFTlMgMHhGRURDQkFCQQ0KPiArDQo+ICBzdHJ1Y3QgbXdpZmlleF9wY2llX2NhcmRfcmVn
IHsNCj4gIAl1MTYgY21kX2FkZHJfbG87DQo+ICAJdTE2IGNtZF9hZGRyX2hpOw0KPiAtLQ0KPiAy
LjEyLjIuNzYyDQo=

2017-04-13 18:46:33

by Brian Norris

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

Hi Xinming,

On Thu, Apr 13, 2017 at 06:48:22AM +0000, Xinming Hu wrote:
> From: Xinming Hu <[email protected]>
>
> A seprate 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]>
> Reviewed-by: Brian Norris <[email protected]>

Please don't add my Reviewed-by tag unless I've provided it explicitly.
And especially not if you have to change the patch significantly. (It's
fair to carry an old tag I've provided, if you only have to make minor
changes, or if I suggest *exactly* what needs changed, along with a
conditional 'Reviewed-by'.)

As it stands, this patch is worse than the previous one. I replied to
some of your commnets on v3, but I'll carry some here.

> ---
> v2: extract wifi part from combo firmware(Dimtry and Brain)
> add more description(Kalle)
> v3: same as v2
> v4: add sequence comments, code enhance(Brain)
> ---
> drivers/net/wireless/marvell/mwifiex/fw.h | 18 ++++++
> drivers/net/wireless/marvell/mwifiex/pcie.c | 93 ++++++++++++++++++++++++++---
> drivers/net/wireless/marvell/mwifiex/pcie.h | 3 +-
> 3 files changed, 106 insertions(+), 8 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..7b24bb4 100644
> --- a/drivers/net/wireless/marvell/mwifiex/pcie.c
> +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
> @@ -1956,6 +1956,73 @@ static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter,
> return ret;
> }
>
> +/* Combo firmware image is a combination of
> + * (1) combo crc heaer, start with CMD5
> + * (2) bluetooth image, start with CMD7, end with CMD6, data wrapped in CMD1.
> + * (3) wifi image.
> + *
> + * This function bypass the header and bluetooth part, return
> + * the offset of tail wifi-only part.
> + */
> +
> +static int mwifiex_extract_wifi_fw(struct mwifiex_adapter *adapter,
> + const void *firmware, u32 firmware_len) {
> + const struct mwifiex_fw_data *fwdata;
> + u32 offset = 0, data_len, dnld_cmd;
> + int ret = 0;
> + bool cmd7_before = false;
> +
> + while (1) {
> + if (offset >= firmware_len) {

This is worse than what you used to have. This should still be:

if (offset + sizeof(fwdata->header) >= firmware_len) {

And you might add an overflow check here too, so:

/* Check for integer and buffer overflow */
if (offset + sizeof(fwdata->header) < sizeof(fwdata->header) ||
offset + sizeof(fwdata->header) >= firmware_len) {

> + mwifiex_dbg(adapter, ERROR,
> + "extract wifi-only fw failure!");

Needs a '\n'.

> + ret = -1;
> + goto done;
> + }
> +
> + fwdata = firmware + offset;
> + dnld_cmd = le32_to_cpu(fwdata->header.dnld_cmd);
> + data_len = le32_to_cpu(fwdata->header.data_length);
> +

Then:

offset += sizeof(fwdata->header);

> + switch (dnld_cmd) {
> + case MWIFIEX_FW_DNLD_CMD_1:
> + if (!cmd7_before) {
> + mwifiex_dbg(adapter, ERROR,
> + "no cmd7 before cmd1!");

Needs a '\n'.

> + ret = -1;
> + goto done;
> + }
> + offset += data_len + sizeof(fwdata->header);

Replace with:

if (offset + data_len < data_len) {
mwifiex_dbg(adapter, ERROR, "bad firmware\n");
ret = -1;
goto done;
}
offset += data_len;

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

Replace with:

if (offset + data_len < data_len) {
mwifiex_dbg(adapter, ERROR, "bad firmware\n");
ret = -1;
goto done;
}
offset += data_len;

> + break;
> + case MWIFIEX_FW_DNLD_CMD_6:
> + offset += data_len + sizeof(fwdata->header);

Replace with:

if (offset + data_len < data_len) {
mwifiex_dbg(adapter, ERROR, "bad firmware\n");
ret = -1;
goto done;
}
offset += data_len;

> + if (offset >= firmware_len) {
> + mwifiex_dbg(adapter, ERROR,
> + "extract wifi-only fw failure!");

Needs a '\n'.

> + ret = -1;
> + } else {
> + ret = offset;
> + }
> + goto done;
> + case MWIFIEX_FW_DNLD_CMD_7:
> + cmd7_before = true;
> + offset += sizeof(fwdata->header);

Now you can delete this line.

> + 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.
> *

[...]

I might just rewrite this and send it myself, if I get the time.

Brian

2017-04-13 06:48:33

by Xinming Hu

[permalink] [raw]
Subject: [PATCH v4 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
v4: same as v2, v3
---
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

2017-04-20 07:18:32

by Kalle Valo

[permalink] [raw]
Subject: Re: [v4, 1/4] mwifiex: remove unnecessary wakeup interrupt number sanity check

Xinming Hu <[email protected]> wrote:
> 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]>

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

625b4dba57b2 mwifiex: remove unnecessary wakeup interrupt number sanity check
ef6c7d3cb731 mwifiex: fall back mwifiex_dbg to pr_info when adapter->dev not set
127ee1db0970 mwifiex: pcie: correct scratch register name

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

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

2017-04-20 07:21:21

by Kalle Valo

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

Brian Norris <[email protected]> wrote:
> From: Xinming Hu <[email protected]>
>
> A separate 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, the mrvl/pcie8997_wlan_v4.bin image in linux-firmware repo
> is redundant (though I guess we keep it around to support older
> kernels).
>
> Signed-off-by: Xinming Hu <[email protected]>
> Signed-off-by: Ganapathi Bhat <[email protected]>
> Signed-off-by: Cathy Luo <[email protected]>
> Signed-off-by: Brian Norris <[email protected]>

Patch applied to wireless-drivers-next.git, thanks.

efde6648a618 mwifiex: pcie: extract wifi part from combo firmware during function level reset

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

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

2017-04-13 06:48:36

by Xinming Hu

[permalink] [raw]
Subject: [PATCH v4 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)
v4: same as v3
---
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-13 20:10:37

by Brian Norris

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

From: Xinming Hu <[email protected]>

A separate 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, the mrvl/pcie8997_wlan_v4.bin image in linux-firmware repo
is redundant (though I guess we keep it around to support older
kernels).

Signed-off-by: Xinming Hu <[email protected]>
Signed-off-by: Ganapathi Bhat <[email protected]>
Signed-off-by: Cathy Luo <[email protected]>
Signed-off-by: Brian Norris <[email protected]>
---
On Thu, Apr 13, 2017 at 11:46:30AM -0700, Brian Norris wrote:
> I might just rewrite this and send it myself, if I get the time.

Done.

v2: extract wifi part from combo firmware(Dmitry and Brian)
add more description(Kalle)
v3: same as v2
v4: add sequence comments, code enhance(Brian)
v5: (Brian) fix overflow errors
(Brian) add missing newline chars
(Brian) consolidate header-skipping logic

Note: I only resubmitted the 4th patch, as the others look fine
---
drivers/net/wireless/marvell/mwifiex/fw.h | 18 +++++
drivers/net/wireless/marvell/mwifiex/pcie.c | 114 ++++++++++++++++++++++++++--
drivers/net/wireless/marvell/mwifiex/pcie.h | 3 +-
3 files changed, 127 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/fw.h b/drivers/net/wireless/marvell/mwifiex/fw.h
index 0b683742e30c..6cf9ab9133ea 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 061223149bed..63102efb388e 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -1956,6 +1956,94 @@ static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter,
return ret;
}

+/* Combo firmware image is a combination of
+ * (1) combo crc heaer, start with CMD5
+ * (2) bluetooth image, start with CMD7, end with CMD6, data wrapped in CMD1.
+ * (3) wifi image.
+ *
+ * This function bypass the header and bluetooth part, return
+ * the offset of tail wifi-only part.
+ */
+
+static int mwifiex_extract_wifi_fw(struct mwifiex_adapter *adapter,
+ const void *firmware, u32 firmware_len) {
+ const struct mwifiex_fw_data *fwdata;
+ u32 offset = 0, data_len, dnld_cmd;
+ int ret = 0;
+ bool cmd7_before = false;
+
+ while (1) {
+ /* Check for integer and buffer overflow */
+ if (offset + sizeof(fwdata->header) < sizeof(fwdata->header) ||
+ offset + sizeof(fwdata->header) >= firmware_len) {
+ mwifiex_dbg(adapter, ERROR,
+ "extract wifi-only fw failure!\n");
+ ret = -1;
+ goto done;
+ }
+
+ fwdata = firmware + offset;
+ dnld_cmd = le32_to_cpu(fwdata->header.dnld_cmd);
+ data_len = le32_to_cpu(fwdata->header.data_length);
+
+ /* Skip past header */
+ offset += sizeof(fwdata->header);
+
+ switch (dnld_cmd) {
+ case MWIFIEX_FW_DNLD_CMD_1:
+ if (!cmd7_before) {
+ mwifiex_dbg(adapter, ERROR,
+ "no cmd7 before cmd1!\n");
+ ret = -1;
+ goto done;
+ }
+ if (offset + data_len < data_len) {
+ mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
+ ret = -1;
+ goto done;
+ }
+ offset += data_len;
+ break;
+ case MWIFIEX_FW_DNLD_CMD_5:
+ /* Check for integer overflow */
+ if (offset + data_len < data_len) {
+ mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
+ ret = -1;
+ goto done;
+ }
+ offset += data_len;
+ break;
+ case MWIFIEX_FW_DNLD_CMD_6:
+ /* Check for integer overflow */
+ if (offset + data_len < data_len) {
+ mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
+ ret = -1;
+ goto done;
+ }
+ offset += data_len;
+ if (offset >= firmware_len) {
+ mwifiex_dbg(adapter, ERROR,
+ "extract wifi-only fw failure!\n");
+ ret = -1;
+ } else {
+ ret = offset;
+ }
+ goto done;
+ case MWIFIEX_FW_DNLD_CMD_7:
+ cmd7_before = true;
+ 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 +2059,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 +2086,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;
@@ -3070,12 +3176,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 7e2450ce79d3..f7ce9b6db6b4 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.h
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.h
@@ -35,7 +35,6 @@
#define PCIE8897_B0_FW_NAME "mrvl/pcie8897_uapsta.bin"
#define PCIEUART8997_FW_NAME_V4 "mrvl/pcieuart8997_combo_v4.bin"
#define PCIEUSB8997_FW_NAME_V4 "mrvl/pcieusb8997_combo_v4.bin"
-#define PCIE8997_DEFAULT_WIFIFW_NAME "mrvl/pcie8997_wlan_v4.bin"

#define PCIE_VENDOR_ID_MARVELL (0x11ab)
#define PCIE_VENDOR_ID_V2_MARVELL (0x1b4b)
@@ -120,6 +119,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;
--
2.12.2.762

2017-04-14 04:51:15

by Xinming Hu

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

SGkgS2FsbGUsDQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogS2FsbGUg
VmFsbyBbbWFpbHRvOmt2YWxvQGNvZGVhdXJvcmEub3JnXQ0KPiBTZW50OiAyMDE3xOo01MIxM8jV
IDIxOjU5DQo+IFRvOiBYaW5taW5nIEh1DQo+IENjOiBMaW51eCBXaXJlbGVzczsgQnJpYW4gTm9y
cmlzOyBEbWl0cnkgVG9yb2tob3Y7IHJhamF0amFAZ29vZ2xlLmNvbTsNCj4gQW1pdGt1bWFyIEth
cndhcjsgQ2F0aHkgTHVvOyBYaW5taW5nIEh1OyBHYW5hcGF0aGkgQmhhdA0KPiBTdWJqZWN0OiBb
RVhUXSBSZTogW1BBVENIIHY0IDQvNF0gbXdpZmlleDogcGNpZTogZXh0cmFjdCB3aWZpIHBhcnQg
ZnJvbSB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pdC4NCg0KVGhhbmtzLA0KU2ltb24N
Cj4gLS0NCj4gS2FsbGUgVmFsbw0K

2017-04-13 06:48:36

by Xinming Hu

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

From: Xinming Hu <[email protected]>

A seprate 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]>
Reviewed-by: Brian Norris <[email protected]>
---
v2: extract wifi part from combo firmware(Dimtry and Brain)
add more description(Kalle)
v3: same as v2
v4: add sequence comments, code enhance(Brain)
---
drivers/net/wireless/marvell/mwifiex/fw.h | 18 ++++++
drivers/net/wireless/marvell/mwifiex/pcie.c | 93 ++++++++++++++++++++++++++---
drivers/net/wireless/marvell/mwifiex/pcie.h | 3 +-
3 files changed, 106 insertions(+), 8 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..7b24bb4 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -1956,6 +1956,73 @@ static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter,
return ret;
}

+/* Combo firmware image is a combination of
+ * (1) combo crc heaer, start with CMD5
+ * (2) bluetooth image, start with CMD7, end with CMD6, data wrapped in CMD1.
+ * (3) wifi image.
+ *
+ * This function bypass the header and bluetooth part, return
+ * the offset of tail wifi-only part.
+ */
+
+static int mwifiex_extract_wifi_fw(struct mwifiex_adapter *adapter,
+ const void *firmware, u32 firmware_len) {
+ const struct mwifiex_fw_data *fwdata;
+ u32 offset = 0, data_len, dnld_cmd;
+ int ret = 0;
+ bool cmd7_before = false;
+
+ while (1) {
+ if (offset >= firmware_len) {
+ mwifiex_dbg(adapter, ERROR,
+ "extract wifi-only fw failure!");
+ ret = -1;
+ goto done;
+ }
+
+ 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);
+ 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);
+ if (offset >= firmware_len) {
+ mwifiex_dbg(adapter, ERROR,
+ "extract wifi-only fw failure!");
+ ret = -1;
+ } else {
+ ret = offset;
+ }
+ goto done;
+ case MWIFIEX_FW_DNLD_CMD_7:
+ 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 +2038,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 +2065,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 +3145,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..f7ce9b6 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.h
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.h
@@ -35,7 +35,6 @@
#define PCIE8897_B0_FW_NAME "mrvl/pcie8897_uapsta.bin"
#define PCIEUART8997_FW_NAME_V4 "mrvl/pcieuart8997_combo_v4.bin"
#define PCIEUSB8997_FW_NAME_V4 "mrvl/pcieusb8997_combo_v4.bin"
-#define PCIE8997_DEFAULT_WIFIFW_NAME "mrvl/pcie8997_wlan_v4.bin"

#define PCIE_VENDOR_ID_MARVELL (0x11ab)
#define PCIE_VENDOR_ID_V2_MARVELL (0x1b4b)
@@ -120,6 +119,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.9.1