For Gen1 isoc-in transfer, host still send out unexpected ACK after device finish the burst with a short packet, this will cause an exception on the connected device, such as, a usb 4k camera. It can be fixed by setting rxfifo depth less than 4k bytes, prefer to use 3k here, the side-effect is that may cause performance drop about 10%, including bulk transfer.
Fixes: 926d60ae64a6 ("usb: xhci-mtk: modify the SOF/ITP interval for mt8195") Cc: stable@vger.kernel.org Signed-off-by: Chunfeng Yun chunfeng.yun@mediatek.com --- v3: add Cc stable change @rxfifo_depth from int to u32, due to property's value range is changed v2: use 'rx-fifo-depth' property; add header file 'linux/bitfield.h' to avoid building error on some ARCH; --- drivers/usb/host/xhci-mtk.c | 37 +++++++++++++++++++++++++++++++++++-- drivers/usb/host/xhci-mtk.h | 2 ++ 2 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index bbdf1b0b7be1..868793b82348 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -7,6 +7,7 @@ * Chunfeng Yun chunfeng.yun@mediatek.com */
+#include <linux/bitfield.h> #include <linux/dma-mapping.h> #include <linux/iopoll.h> #include <linux/kernel.h> @@ -73,6 +74,9 @@ #define FRMCNT_LEV1_RANG (0x12b << 8) #define FRMCNT_LEV1_RANG_MASK GENMASK(19, 8)
+#define HSCH_CFG1 0x960 +#define SCH3_RXFIFO_DEPTH_MASK GENMASK(21, 20) + #define SS_GEN2_EOF_CFG 0x990 #define SSG2EOF_OFFSET 0x3c
@@ -165,6 +169,34 @@ static void xhci_mtk_set_frame_interval(struct xhci_hcd_mtk *mtk) writel(value, hcd->regs + SS_GEN2_EOF_CFG); }
+/* + * workaround: usb3.2 gen1 isoc rx hw issue + * host send out unexpected ACK afer device fininsh a burst transfer with + * a short packet. + */ +static void xhci_mtk_rxfifo_depth_set(struct xhci_hcd_mtk *mtk) +{ + struct usb_hcd *hcd = mtk->hcd; + u32 value; + + if (!mtk->rxfifo_depth) + return; + + value = readl(hcd->regs + HSCH_CFG1); + value &= ~SCH3_RXFIFO_DEPTH_MASK; + value |= FIELD_PREP(SCH3_RXFIFO_DEPTH_MASK, mtk->rxfifo_depth - 1); + writel(value, hcd->regs + HSCH_CFG1); +} + +static void xhci_mtk_init_quirk(struct xhci_hcd_mtk *mtk) +{ + /* workaround only for mt8195 */ + xhci_mtk_set_frame_interval(mtk); + + /* workaround for SoCs using SSUSB about before IPM v1.6.0 */ + xhci_mtk_rxfifo_depth_set(mtk); +} + static int xhci_mtk_host_enable(struct xhci_hcd_mtk *mtk) { struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs; @@ -448,8 +480,7 @@ static int xhci_mtk_setup(struct usb_hcd *hcd) if (ret) return ret;
- /* workaround only for mt8195 */ - xhci_mtk_set_frame_interval(mtk); + xhci_mtk_init_quirk(mtk); }
ret = xhci_gen_setup(hcd, xhci_mtk_quirks); @@ -527,6 +558,8 @@ static int xhci_mtk_probe(struct platform_device *pdev) of_property_read_u32(node, "mediatek,u2p-dis-msk", &mtk->u2p_dis_msk);
+ of_property_read_u32(node, "rx-fifo-depth", &mtk->rxfifo_depth); + ret = usb_wakeup_of_property_parse(mtk, node); if (ret) { dev_err(dev, "failed to parse uwk property\n"); diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h index 39f7ae7d3087..f5e2bd66bb1b 100644 --- a/drivers/usb/host/xhci-mtk.h +++ b/drivers/usb/host/xhci-mtk.h @@ -171,6 +171,8 @@ struct xhci_hcd_mtk { struct regmap *uwk; u32 uwk_reg_base; u32 uwk_vers; + /* quirk */ + u32 rxfifo_depth; };
static inline struct xhci_hcd_mtk *hcd_to_mtk(struct usb_hcd *hcd)
On Wed, Dec 20, 2023 at 10:58:41AM +0800, Chunfeng Yun wrote:
For Gen1 isoc-in transfer, host still send out unexpected ACK after device finish the burst with a short packet, this will cause an exception on the connected device, such as, a usb 4k camera. It can be fixed by setting rxfifo depth less than 4k bytes, prefer to use 3k here, the side-effect is that may cause performance drop about 10%, including bulk transfer.
Fixes: 926d60ae64a6 ("usb: xhci-mtk: modify the SOF/ITP interval for mt8195") Cc: stable@vger.kernel.org Signed-off-by: Chunfeng Yun chunfeng.yun@mediatek.com
v3: add Cc stable
Why is a patch that you are marking for stable inclusion (and I am guessing inclusion in 6.7-final) in the middle of other patches that are not marked as such?
Always split out bugfixes from other things so that they can go through the two different branches, one for this current release, and one for the next one.
Otherwise you will have to wait until 6.8-rc1 for this bugfix to land, which I doubt you intend to have happen.
Please fix up and resend 2 different patch series.
thanks,
greg k-h
On Wed, 2023-12-20 at 06:57 +0100, Greg Kroah-Hartman wrote:
External email : Please do not click links or open attachments until you have verified the sender or the content. On Wed, Dec 20, 2023 at 10:58:41AM +0800, Chunfeng Yun wrote:
For Gen1 isoc-in transfer, host still send out unexpected ACK after
device
finish the burst with a short packet, this will cause an exception
on the
connected device, such as, a usb 4k camera. It can be fixed by setting rxfifo depth less than 4k bytes, prefer
to use
3k here, the side-effect is that may cause performance drop about
10%,
including bulk transfer.
Fixes: 926d60ae64a6 ("usb: xhci-mtk: modify the SOF/ITP interval
for mt8195")
Cc: stable@vger.kernel.org Signed-off-by: Chunfeng Yun chunfeng.yun@mediatek.com
v3: add Cc stable
Why is a patch that you are marking for stable inclusion (and I am guessing inclusion in 6.7-final) in the middle of other patches that are not marked as such?
I'll remove Cc.
Always split out bugfixes from other things so that they can go through the two different branches, one for this current release, and one for the next one.
Otherwise you will have to wait until 6.8-rc1 for this bugfix to land, which I doubt you intend to have happen.
Please fix up and resend 2 different patch series.
Send v3 today, and modify property;
Thanks a lot
thanks,
greg k-h
Il 20/12/23 03:58, Chunfeng Yun ha scritto:
For Gen1 isoc-in transfer, host still send out unexpected ACK after device finish the burst with a short packet, this will cause an exception on the connected device, such as, a usb 4k camera. It can be fixed by setting rxfifo depth less than 4k bytes, prefer to use 3k here, the side-effect is that may cause performance drop about 10%, including bulk transfer.
Fixes: 926d60ae64a6 ("usb: xhci-mtk: modify the SOF/ITP interval for mt8195") Cc: stable@vger.kernel.org Signed-off-by: Chunfeng Yun chunfeng.yun@mediatek.com
Reviewed-by: AngeloGioacchino Del Regno angelogioacchino.delregno@collabora.com
linux-stable-mirror@lists.linaro.org