2020-10-16 02:03:06

by Sean Wang

[permalink] [raw]
Subject: [PATCH 1/2] mt76: mt7663: handle failure event for patch semaphore cmd

From: Sean Wang <[email protected]>

Just follow up vendor driver to retry a few times obtaining patch
semaphore when the event is PATCH_NOT_DL_SEM_FAIL. That usually
happens in Bluetooth and Wifi driver contends to download patch
simultaneously.

Co-developed-by: YN Chen <[email protected]>
Signed-off-by: YN Chen <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
index 2b17bd1c2a32..c990ccd6f472 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
@@ -1945,14 +1945,21 @@ static int mt7615_load_patch(struct mt7615_dev *dev, u32 addr, const char *name)
{
const struct mt7615_patch_hdr *hdr;
const struct firmware *fw = NULL;
- int len, ret, sem;
+ int len, ret, sem, c = 50;

+retry:
sem = mt7615_mcu_patch_sem_ctrl(dev, 1);
switch (sem) {
case PATCH_IS_DL:
return 0;
case PATCH_NOT_DL_SEM_SUCCESS:
break;
+ case PATCH_NOT_DL_SEM_FAIL:
+ if (is_mt7663(&dev->mt76) && c--) {
+ msleep(100);
+ goto retry;
+ }
+ fallthrough;
default:
dev_err(dev->mt76.dev, "Failed to get patch semaphore\n");
return -EAGAIN;
--
2.25.1


2020-10-16 16:31:14

by Lorenzo Bianconi

[permalink] [raw]
Subject: Re: [PATCH 1/2] mt76: mt7663: handle failure event for patch semaphore cmd

> From: Sean Wang <[email protected]>
>
> Just follow up vendor driver to retry a few times obtaining patch
> semaphore when the event is PATCH_NOT_DL_SEM_FAIL. That usually
> happens in Bluetooth and Wifi driver contends to download patch
> simultaneously.
>
> Co-developed-by: YN Chen <[email protected]>
> Signed-off-by: YN Chen <[email protected]>
> Signed-off-by: Sean Wang <[email protected]>
> ---
> drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> index 2b17bd1c2a32..c990ccd6f472 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> @@ -1945,14 +1945,21 @@ static int mt7615_load_patch(struct mt7615_dev *dev, u32 addr, const char *name)
> {
> const struct mt7615_patch_hdr *hdr;
> const struct firmware *fw = NULL;
> - int len, ret, sem;
> + int len, ret, sem, c = 50;
>
> +retry:
> sem = mt7615_mcu_patch_sem_ctrl(dev, 1);
> switch (sem) {
> case PATCH_IS_DL:
> return 0;
> case PATCH_NOT_DL_SEM_SUCCESS:
> break;
> + case PATCH_NOT_DL_SEM_FAIL:
> + if (is_mt7663(&dev->mt76) && c--) {
> + msleep(100);
> + goto retry;
> + }
> + fallthrough;

I guess it is more clear to have a dedicated routine for this. E.g:

int mt7615_mcu_get_patch_semaphore()
{
....
}

Regards,
Lorenzo

> default:
> dev_err(dev->mt76.dev, "Failed to get patch semaphore\n");
> return -EAGAIN;
> --
> 2.25.1


Attachments:
(No filename) (1.61 kB)
signature.asc (235.00 B)
Download all attachments

2020-10-17 05:37:25

by Ryder Lee

[permalink] [raw]
Subject: Re: [PATCH 1/2] mt76: mt7663: handle failure event for patch semaphore cmd

On Fri, 2020-10-16 at 08:26 +0800, [email protected] wrote:
> From: Sean Wang <[email protected]>
>
> Just follow up vendor driver to retry a few times obtaining patch
> semaphore when the event is PATCH_NOT_DL_SEM_FAIL. That usually
> happens in Bluetooth and Wifi driver contends to download patch
> simultaneously.
>
> Co-developed-by: YN Chen <[email protected]>
> Signed-off-by: YN Chen <[email protected]>
> Signed-off-by: Sean Wang <[email protected]>

What's the difference between this and https://github.com/nbd168/wireless/commit/f55bc2f37e247729f8087434b9aafc4d0095c4ca ?

> ---
> drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> index 2b17bd1c2a32..c990ccd6f472 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> @@ -1945,14 +1945,21 @@ static int mt7615_load_patch(struct mt7615_dev *dev, u32 addr, const char *name)
> {
> const struct mt7615_patch_hdr *hdr;
> const struct firmware *fw = NULL;
> - int len, ret, sem;
> + int len, ret, sem, c = 50;
>
> +retry:
> sem = mt7615_mcu_patch_sem_ctrl(dev, 1);
> switch (sem) {
> case PATCH_IS_DL:
> return 0;
> case PATCH_NOT_DL_SEM_SUCCESS:
> break;
> + case PATCH_NOT_DL_SEM_FAIL:
> + if (is_mt7663(&dev->mt76) && c--) {
> + msleep(100);
> + goto retry;
> + }
> + fallthrough;
> default:
> dev_err(dev->mt76.dev, "Failed to get patch semaphore\n");
> return -EAGAIN;