Skip to contentSkip to conversation

mt76x0u: Probing issues on Raspberry Pi 3 B+

BUG Stanislaw Gruszka 1 participant 1 message Feb 14, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw
Quoted 6 lines · Stefan Wahren

Hi Stanislaw,

Quoted 4 lines

Stanislaw Gruszka <[email protected]> hat am 12. Februar 2019 um 10:30 geschrieben:

Quoted 8 lines
Quoted 5 lines

In usb_sg_init() urb->num_sgs is set 0 for sg_tablesize = 0 controllers. In mt76 we set urb->num_sgs to 1. I thought it is fine, but now I think this is bug. We can fix that without changing allocation method and still use SG allocation. Attached patch do this, please check if it works on rpi. Patch is on top of your error path fixes.

your patch didn't apply cleanly to yesterdays next. After some minor manual fixup, i was able to build them and here are the results starting from boot (please ignore the invalid time in the kernel log):
https://gist.github.com/lategoodbye/33bd5bc75b9fc935faa231bc472defa8

I think this is due to urb->transfer_length and sg[0]->length mismatch, which should be addressed by my other patch. I'm attaching the patch rebased on -next with this line integrated, please test.

But there could be other bug's in mt76-usb SG code.

Quoted 5 lines

Using multi_v7_defconfig i'm getting a warning on the first connect and always this flood of rx urb failed on disconnect. The driver seems to probe but isn't functional even after 2 tries.

Using arm64_defconfig i don't get any warning. But except of this i'm getting similiar results to multi_v7_defconfig.

So in comparison, Lorenzo's workaround behaves better.

I'm pretty sure problem is mt76x0u 4.19 -> 4.20 regression intrduced by integrating mt76x0u in mt76-usb (things do not work from day 0 for mt76x2u). We should find fix(es) that will be proper for -stable.

Stanislaw
From 2b20054fc424e0bb33962bbb05509a7ca16d01bc Mon Sep 17 00:00:00 2001
From: Stanislaw Gruszka <[email protected]>
Date: Thu, 14 Feb 2019 10:01:06 +0100
Subject: [PATCH v5] mt76usb: do not set urb->num_sgs to 1 for non SG usb host
drivers

Track number of segments in mt76u_buf structure and do not submit urbs with urb->num_sgs = 1 if usb host driver sg_tablesize is zero.

This suppose fix problem of mt76 not working with some usb host controllers like dwc2.

---
 drivers/net/wireless/mediatek/mt76/mt76.h          |  1 +
 .../net/wireless/mediatek/mt76/mt76x02_usb_mcu.c   |  1 +
 drivers/net/wireless/mediatek/mt76/usb.c           | 57 ++++++++++++++--------
 3 files changed, 38 insertions(+), 21 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76.h +1 -0
index 2bb9db4ed80a..97ad0270f8a6 100644
@@ -86,6 +86,7 @@ struct mt76_queue_buf {
 struct mt76u_buf {
 	struct mt76_dev *dev;
 	struct urb *urb;
+	int num_sgs;
 	size_t len;
 	bool done;
 };
drivers/net/wireless/mediatek/mt76/mt76x02_usb_mcu.c +1 -0
index 6db789f90269..80a259e1e931 100644
@@ -292,6 +292,7 @@ __mt76x02u_mcu_fw_send_data(struct mt76x02_dev *dev, struct mt76u_buf *buf,
 			MT_FCE_DMA_LEN, len << 16);
 
 	buf->len = MT_CMD_HDR_LEN + len + sizeof(info);
+	buf->urb->sg[0].length = buf->len;
 	err = mt76u_submit_buf(&dev->mt76, USB_DIR_OUT,
 			       MT_EP_OUT_INBAND_CMD,
 			       buf, GFP_KERNEL,
drivers/net/wireless/mediatek/mt76/usb.c +36 -21

125 lines not on this page · raw message