linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wifi: mt76: mt7921e: Perform FLR to recovery the device
@ 2023-06-14  6:32 Kai-Heng Feng
  2023-06-14 11:18 ` AngeloGioacchino Del Regno
  0 siblings, 1 reply; 3+ messages in thread
From: Kai-Heng Feng @ 2023-06-14  6:32 UTC (permalink / raw)
  To: nbd, lorenzo, ryder.lee
  Cc: Kai-Heng Feng, Shayne Chen, Sean Wang, Kalle Valo,
	Matthias Brugger, AngeloGioacchino Del Regno, Deren Wu, Leon Yen,
	linux-wireless, linux-kernel, linux-arm-kernel, linux-mediatek

When "Pre-boot WiFi" is enabled in BIOS, the mt7921e device may not
work:
mt7921e 0000:02:00.0: ASIC revision: 79220010
mt7921e 0000:02:00.0: Message 00000010 (seq 1) timeout
mt7921e 0000:02:00.0: Failed to get patch semaphore
mt7921e 0000:02:00.0: Message 00000010 (seq 2) timeout
mt7921e 0000:02:00.0: Failed to get patch semaphore
mt7921e 0000:02:00.0: Message 00000010 (seq 3) timeout
mt7921e 0000:02:00.0: Failed to get patch semaphore
mt7921e 0000:02:00.0: Message 00000010 (seq 4) timeout
mt7921e 0000:02:00.0: Failed to get patch semaphore
mt7921e 0000:02:00.0: Message 00000010 (seq 5) timeout
mt7921e 0000:02:00.0: Failed to get patch semaphore
mt7921e 0000:02:00.0: Message 00000010 (seq 6) timeout
mt7921e 0000:02:00.0: Failed to get patch semaphore
mt7921e 0000:02:00.0: Message 00000010 (seq 7) timeout
mt7921e 0000:02:00.0: Failed to get patch semaphore
mt7921e 0000:02:00.0: Message 00000010 (seq 8) timeout
mt7921e 0000:02:00.0: Failed to get patch semaphore
mt7921e 0000:02:00.0: Message 00000010 (seq 9) timeout
mt7921e 0000:02:00.0: Failed to get patch semaphore
mt7921e 0000:02:00.0: Message 00000010 (seq 10) timeout
mt7921e 0000:02:00.0: Failed to get patch semaphore
mt7921e 0000:02:00.0: hardware init failed

After some trials and errors, it shows that PCI function level reset can
recover the device back to a functional state.

So perform FLR at probe routine to workaround the issue.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
index ddb1fa4ee01d..9671fbe35a8e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
@@ -262,6 +262,10 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
 	int ret;
 	u16 cmd;
 
+	ret = pci_reset_function_locked(pdev);
+	if (ret)
+		pci_info(pdev, "Unable to perform FLR\n");
+
 	ret = pcim_enable_device(pdev);
 	if (ret)
 		return ret;
-- 
2.34.1


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

* Re: [PATCH] wifi: mt76: mt7921e: Perform FLR to recovery the device
  2023-06-14  6:32 [PATCH] wifi: mt76: mt7921e: Perform FLR to recovery the device Kai-Heng Feng
@ 2023-06-14 11:18 ` AngeloGioacchino Del Regno
  2023-06-16 14:17   ` Deren Wu (武德仁)
  0 siblings, 1 reply; 3+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-06-14 11:18 UTC (permalink / raw)
  To: Kai-Heng Feng, nbd, lorenzo, ryder.lee
  Cc: Shayne Chen, Sean Wang, Kalle Valo, Matthias Brugger, Deren Wu,
	Leon Yen, linux-wireless, linux-kernel, linux-arm-kernel,
	linux-mediatek

Il 14/06/23 08:32, Kai-Heng Feng ha scritto:
> When "Pre-boot WiFi" is enabled in BIOS, the mt7921e device may not
> work:
> mt7921e 0000:02:00.0: ASIC revision: 79220010
> mt7921e 0000:02:00.0: Message 00000010 (seq 1) timeout
> mt7921e 0000:02:00.0: Failed to get patch semaphore
> mt7921e 0000:02:00.0: Message 00000010 (seq 2) timeout
> mt7921e 0000:02:00.0: Failed to get patch semaphore
> mt7921e 0000:02:00.0: Message 00000010 (seq 3) timeout
> mt7921e 0000:02:00.0: Failed to get patch semaphore
> mt7921e 0000:02:00.0: Message 00000010 (seq 4) timeout
> mt7921e 0000:02:00.0: Failed to get patch semaphore
> mt7921e 0000:02:00.0: Message 00000010 (seq 5) timeout
> mt7921e 0000:02:00.0: Failed to get patch semaphore
> mt7921e 0000:02:00.0: Message 00000010 (seq 6) timeout
> mt7921e 0000:02:00.0: Failed to get patch semaphore
> mt7921e 0000:02:00.0: Message 00000010 (seq 7) timeout
> mt7921e 0000:02:00.0: Failed to get patch semaphore
> mt7921e 0000:02:00.0: Message 00000010 (seq 8) timeout
> mt7921e 0000:02:00.0: Failed to get patch semaphore
> mt7921e 0000:02:00.0: Message 00000010 (seq 9) timeout
> mt7921e 0000:02:00.0: Failed to get patch semaphore
> mt7921e 0000:02:00.0: Message 00000010 (seq 10) timeout
> mt7921e 0000:02:00.0: Failed to get patch semaphore
> mt7921e 0000:02:00.0: hardware init failed
> 
> After some trials and errors, it shows that PCI function level reset can
> recover the device back to a functional state.
> 
> So perform FLR at probe routine to workaround the issue.

Is there any way to check if the device was enabled before booting Linux?

I'm thinking of something like

if (device_is_already_enabled)
	ret = pci_reset_function_locked(....)

Regards,
Angelo

> 
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
>   drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> index ddb1fa4ee01d..9671fbe35a8e 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> @@ -262,6 +262,10 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
>   	int ret;
>   	u16 cmd;
>   
> +	ret = pci_reset_function_locked(pdev);
> +	if (ret)
> +		pci_info(pdev, "Unable to perform FLR\n");
> +
>   	ret = pcim_enable_device(pdev);
>   	if (ret)
>   		return ret;



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

* Re: [PATCH] wifi: mt76: mt7921e: Perform FLR to recovery the device
  2023-06-14 11:18 ` AngeloGioacchino Del Regno
@ 2023-06-16 14:17   ` Deren Wu (武德仁)
  0 siblings, 0 replies; 3+ messages in thread
From: Deren Wu (武德仁) @ 2023-06-16 14:17 UTC (permalink / raw)
  To: kai.heng.feng, nbd, angelogioacchino.delregno, lorenzo, Ryder Lee
  Cc: linux-kernel, linux-mediatek, Leon Yen (顏良儒),
	Shayne Chen (陳軒丞),
	Sean Wang, kvalo, linux-arm-kernel, matthias.bgg, linux-wireless

On Wed, 2023-06-14 at 13:18 +0200, AngeloGioacchino Del Regno wrote:
>  	 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>  Il 14/06/23 08:32, Kai-Heng Feng ha scritto:
> > When "Pre-boot WiFi" is enabled in BIOS, the mt7921e device may not
> > work:
> > mt7921e 0000:02:00.0: ASIC revision: 79220010
> > mt7921e 0000:02:00.0: Message 00000010 (seq 1) timeout
> > mt7921e 0000:02:00.0: Failed to get patch semaphore
> > mt7921e 0000:02:00.0: Message 00000010 (seq 2) timeout
> > mt7921e 0000:02:00.0: Failed to get patch semaphore
> > mt7921e 0000:02:00.0: Message 00000010 (seq 3) timeout
> > mt7921e 0000:02:00.0: Failed to get patch semaphore
> > mt7921e 0000:02:00.0: Message 00000010 (seq 4) timeout
> > mt7921e 0000:02:00.0: Failed to get patch semaphore
> > mt7921e 0000:02:00.0: Message 00000010 (seq 5) timeout
> > mt7921e 0000:02:00.0: Failed to get patch semaphore
> > mt7921e 0000:02:00.0: Message 00000010 (seq 6) timeout
> > mt7921e 0000:02:00.0: Failed to get patch semaphore
> > mt7921e 0000:02:00.0: Message 00000010 (seq 7) timeout
> > mt7921e 0000:02:00.0: Failed to get patch semaphore
> > mt7921e 0000:02:00.0: Message 00000010 (seq 8) timeout
> > mt7921e 0000:02:00.0: Failed to get patch semaphore
> > mt7921e 0000:02:00.0: Message 00000010 (seq 9) timeout
> > mt7921e 0000:02:00.0: Failed to get patch semaphore
> > mt7921e 0000:02:00.0: Message 00000010 (seq 10) timeout
> > mt7921e 0000:02:00.0: Failed to get patch semaphore
> > mt7921e 0000:02:00.0: hardware init failed
> > 
> > After some trials and errors, it shows that PCI function level
> reset can
> > recover the device back to a functional state.
> > 
> > So perform FLR at probe routine to workaround the issue.
> 
> Is there any way to check if the device was enabled before booting
> Linux?
> 
> I'm thinking of something like
> 
> if (device_is_already_enabled)
> ret = pci_reset_function_locked(....)
> 
> Regards,
> Angelo

Hi Kai-Heng,

Thanks for the patch. But we found there are some problems on different
platform. We will provide another solution for this case.


Hi Angelo,

Because the problem is caused by mt7912e enabled and some status was
changed to an unpreditable value durgin boot process, we may have to
force reset devices in probe(). We still try to find out a good way to
do it and will post the patch once the verification is done.


Regards,
Deren

> 
> > 
> > Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> > ---
> >   drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 4 ++++
> >   1 file changed, 4 insertions(+)
> > 
> > diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> > index ddb1fa4ee01d..9671fbe35a8e 100644
> > --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> > +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> > @@ -262,6 +262,10 @@ static int mt7921_pci_probe(struct pci_dev
> *pdev,
> >   int ret;
> >   u16 cmd;
> >   
> > +ret = pci_reset_function_locked(pdev);
> > +if (ret)
> > +pci_info(pdev, "Unable to perform FLR\n");
> > +
> >   ret = pcim_enable_device(pdev);
> >   if (ret)
> >   return ret;
> 
> 

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

end of thread, other threads:[~2023-06-16 14:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-14  6:32 [PATCH] wifi: mt76: mt7921e: Perform FLR to recovery the device Kai-Heng Feng
2023-06-14 11:18 ` AngeloGioacchino Del Regno
2023-06-16 14:17   ` Deren Wu (武德仁)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).