Linux-mediatek Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 1/2] mt76: mt7663: handle failure event for patch semaphore cmd
@ 2020-10-16  0:26 sean.wang
  2020-10-16  0:26 ` [PATCH 2/2] mt76: mt7663s: introduce WoW support via GPIO sean.wang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: sean.wang @ 2020-10-16  0:26 UTC (permalink / raw)
  To: nbd, lorenzo.bianconi
  Cc: ryder.lee, Sean Wang, sean.wang, linux-wireless, YN Chen, linux-mediatek

From: Sean Wang <objelf@gmail.com>

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 <YN.Chen@mediatek.com>
Signed-off-by: YN Chen <YN.Chen@mediatek.com>
Signed-off-by:  Sean Wang <sean.wang@mediatek.com>
---
 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
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] mt76: mt7663s: introduce WoW support via GPIO
  2020-10-16  0:26 [PATCH 1/2] mt76: mt7663: handle failure event for patch semaphore cmd sean.wang
@ 2020-10-16  0:26 ` sean.wang
  2020-10-16 15:45 ` [PATCH 1/2] mt76: mt7663: handle failure event for patch semaphore cmd Lorenzo Bianconi
  2020-10-16 23:14 ` Ryder Lee
  2 siblings, 0 replies; 4+ messages in thread
From: sean.wang @ 2020-10-16  0:26 UTC (permalink / raw)
  To: nbd, lorenzo.bianconi
  Cc: ryder.lee, Sean Wang, sean.wang, linux-wireless, YN Chen, linux-mediatek

From: Sean Wang <objelf@gmail.com>

SDIO-based WiFi would rely on an additional GPIO pin to wake up the host.

Co-developed-by: YN Chen <YN.Chen@mediatek.com>
Signed-off-by: YN Chen <YN.Chen@mediatek.com>
Signed-off-by:  Sean Wang <sean.wang@mediatek.com>
---
 drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 14 ++++++++++++--
 drivers/net/wireless/mediatek/mt76/mt7615/mcu.h | 16 ++++++++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
index c990ccd6f472..ecf6c6165e72 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
@@ -3525,6 +3525,8 @@ int mt7615_mcu_set_hif_suspend(struct mt7615_dev *dev, bool suspend)
 		req.hdr.hif_type = 2;
 	else if (mt76_is_usb(&dev->mt76))
 		req.hdr.hif_type = 1;
+	else if (mt76_is_sdio(&dev->mt76))
+		req.hdr.hif_type = 0;
 
 	return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD_HIF_CTRL, &req,
 				 sizeof(req), true);
@@ -3543,6 +3545,7 @@ mt7615_mcu_set_wow_ctrl(struct mt7615_phy *phy, struct ieee80211_vif *vif,
 			u8 pad[3];
 		} __packed hdr;
 		struct mt7615_wow_ctrl_tlv wow_ctrl_tlv;
+		struct mt7615_wow_gpio_param_tlv gpio_tlv;
 	} req = {
 		.hdr = {
 			.bss_idx = mvif->idx,
@@ -3552,6 +3555,11 @@ mt7615_mcu_set_wow_ctrl(struct mt7615_phy *phy, struct ieee80211_vif *vif,
 			.len = cpu_to_le16(sizeof(struct mt7615_wow_ctrl_tlv)),
 			.cmd = suspend ? 1 : 2,
 		},
+		.gpio_tlv = {
+			.tag = cpu_to_le16(UNI_SUSPEND_WOW_GPIO_PARAM),
+			.len = cpu_to_le16(sizeof(struct mt7615_wow_gpio_param_tlv)),
+			.gpio_pin = 0xff, /* follow fw about GPIO pin */
+		},
 	};
 
 	if (wowlan->magic_pkt)
@@ -3565,9 +3573,11 @@ mt7615_mcu_set_wow_ctrl(struct mt7615_phy *phy, struct ieee80211_vif *vif,
 	}
 
 	if (mt76_is_mmio(&dev->mt76))
-		req.wow_ctrl_tlv.wakeup_hif = 2;
+		req.wow_ctrl_tlv.wakeup_hif = WOW_PCIE;
 	else if (mt76_is_usb(&dev->mt76))
-		req.wow_ctrl_tlv.wakeup_hif = 1;
+		req.wow_ctrl_tlv.wakeup_hif = WOW_USB;
+	else if (mt76_is_sdio(&dev->mt76))
+		req.wow_ctrl_tlv.wakeup_hif = WOW_GPIO;
 
 	return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD_SUSPEND, &req,
 				 sizeof(req), true);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.h
index 7b856e9eee1e..59ad6ac15e41 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.h
@@ -477,6 +477,12 @@ struct mt7615_bss_qos_tlv {
 	u8 pad[3];
 } __packed;
 
+enum {
+	WOW_USB = 1,
+	WOW_PCIE = 2,
+	WOW_GPIO = 3,
+};
+
 struct mt7615_wow_ctrl_tlv {
 	__le16 tag;
 	__le16 len;
@@ -501,6 +507,16 @@ struct mt7615_wow_ctrl_tlv {
 	u8 rsv[4];
 } __packed;
 
+struct mt7615_wow_gpio_param_tlv {
+	__le16 tag;
+	__le16 len;
+	u8 gpio_pin;
+	u8 trigger_lvl;
+	u8 pad[2];
+	__le32 gpio_interval;
+	u8 rsv[4];
+} __packed;
+
 #define MT7615_WOW_MASK_MAX_LEN		16
 #define MT7615_WOW_PATTEN_MAX_LEN	128
 struct mt7615_wow_pattern_tlv {
-- 
2.25.1
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] mt76: mt7663: handle failure event for patch semaphore cmd
  2020-10-16  0:26 [PATCH 1/2] mt76: mt7663: handle failure event for patch semaphore cmd sean.wang
  2020-10-16  0:26 ` [PATCH 2/2] mt76: mt7663s: introduce WoW support via GPIO sean.wang
@ 2020-10-16 15:45 ` Lorenzo Bianconi
  2020-10-16 23:14 ` Ryder Lee
  2 siblings, 0 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2020-10-16 15:45 UTC (permalink / raw)
  To: sean.wang
  Cc: ryder.lee, Sean Wang, linux-wireless, YN Chen, linux-mediatek,
	lorenzo.bianconi, nbd

[-- Attachment #1.1: Type: text/plain, Size: 1647 bytes --]

> From: Sean Wang <objelf@gmail.com>
> 
> 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 <YN.Chen@mediatek.com>
> Signed-off-by: YN Chen <YN.Chen@mediatek.com>
> Signed-off-by:  Sean Wang <sean.wang@mediatek.com>
> ---
>  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

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] mt76: mt7663: handle failure event for patch semaphore cmd
  2020-10-16  0:26 [PATCH 1/2] mt76: mt7663: handle failure event for patch semaphore cmd sean.wang
  2020-10-16  0:26 ` [PATCH 2/2] mt76: mt7663s: introduce WoW support via GPIO sean.wang
  2020-10-16 15:45 ` [PATCH 1/2] mt76: mt7663: handle failure event for patch semaphore cmd Lorenzo Bianconi
@ 2020-10-16 23:14 ` Ryder Lee
  2 siblings, 0 replies; 4+ messages in thread
From: Ryder Lee @ 2020-10-16 23:14 UTC (permalink / raw)
  To: sean.wang
  Cc: Sean Wang, linux-wireless, YN Chen, linux-mediatek,
	lorenzo.bianconi, nbd

On Fri, 2020-10-16 at 08:26 +0800, sean.wang@mediatek.com wrote:
> From: Sean Wang <objelf@gmail.com>
> 
> 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 <YN.Chen@mediatek.com>
> Signed-off-by: YN Chen <YN.Chen@mediatek.com>
> Signed-off-by:  Sean Wang <sean.wang@mediatek.com>

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;


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-16  0:26 [PATCH 1/2] mt76: mt7663: handle failure event for patch semaphore cmd sean.wang
2020-10-16  0:26 ` [PATCH 2/2] mt76: mt7663s: introduce WoW support via GPIO sean.wang
2020-10-16 15:45 ` [PATCH 1/2] mt76: mt7663: handle failure event for patch semaphore cmd Lorenzo Bianconi
2020-10-16 23:14 ` Ryder Lee

Linux-mediatek Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mediatek/0 linux-mediatek/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mediatek linux-mediatek/ https://lore.kernel.org/linux-mediatek \
		linux-mediatek@lists.infradead.org
	public-inbox-index linux-mediatek

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-mediatek


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git