* [PATCH] usb: mtu3: fix the failure of qmu stop
@ 2023-01-19 3:33 ` Chunfeng Yun
0 siblings, 0 replies; 4+ messages in thread
From: Chunfeng Yun @ 2023-01-19 3:33 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Chunfeng Yun, Matthias Brugger, linux-usb, linux-arm-kernel,
linux-mediatek, linux-kernel, Eddie Hung, Min Guo
This happens when do stress test of uvc stream on/off which will
enable/disable endpoints. uvc has four tx requests, and may disable
endpoint between queue tx requests as following:
enable ep --> start qmu
queue tx request0
queue tx request1
queue tx request2 --> resume qmu
disable ep --> stop qmu may fail [1]
queue tx request3 --> will resume qmu, may cause qmu can't work
when enable ep next time [2]
[1]: when the tx fifo has some data to transmit, and
try to stop qmu (stop ep) meanwhile resume qmu (queue tx request),
it may cause stop qmu timeout, then can be fixed by flushing fifo
when stop qmu.
[2]: it resumes qmu again, shall stop qmu again.
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Reported-by: Min Guo <min.guo@mediatek.com>
---
drivers/usb/mtu3/mtu3_gadget.c | 3 +--
drivers/usb/mtu3/mtu3_hw_regs.h | 1 +
drivers/usb/mtu3/mtu3_qmu.c | 7 +++++++
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c
index 80236e7b0895..c0264d5426bf 100644
--- a/drivers/usb/mtu3/mtu3_gadget.c
+++ b/drivers/usb/mtu3/mtu3_gadget.c
@@ -133,10 +133,9 @@ static int mtu3_ep_disable(struct mtu3_ep *mep)
{
struct mtu3 *mtu = mep->mtu;
- mtu3_qmu_stop(mep);
-
/* abort all pending requests */
nuke(mep, -ESHUTDOWN);
+ mtu3_qmu_stop(mep);
mtu3_deconfig_ep(mtu, mep);
mtu3_gpd_ring_free(mep);
diff --git a/drivers/usb/mtu3/mtu3_hw_regs.h b/drivers/usb/mtu3/mtu3_hw_regs.h
index 519a58301f45..ee30ae0a4b54 100644
--- a/drivers/usb/mtu3/mtu3_hw_regs.h
+++ b/drivers/usb/mtu3/mtu3_hw_regs.h
@@ -128,6 +128,7 @@
#define TX_FIFOEMPTY BIT(24)
#define TX_SENTSTALL BIT(22)
#define TX_SENDSTALL BIT(21)
+#define TX_FLUSHFIFO BIT(20)
#define TX_TXPKTRDY BIT(16)
#define TX_TXMAXPKTSZ_MSK GENMASK(10, 0)
#define TX_TXMAXPKTSZ(x) ((x) & TX_TXMAXPKTSZ_MSK)
diff --git a/drivers/usb/mtu3/mtu3_qmu.c b/drivers/usb/mtu3/mtu3_qmu.c
index 2ea3157ddb6e..a2fdab8b63b2 100644
--- a/drivers/usb/mtu3/mtu3_qmu.c
+++ b/drivers/usb/mtu3/mtu3_qmu.c
@@ -388,6 +388,9 @@ void mtu3_qmu_stop(struct mtu3_ep *mep)
}
mtu3_writel(mbase, qcsr, QMU_Q_STOP);
+ if (mep->is_in)
+ mtu3_setbits(mbase, MU3D_EP_TXCR0(epnum), TX_FLUSHFIFO);
+
ret = readl_poll_timeout_atomic(mbase + qcsr, value,
!(value & QMU_Q_ACTIVE), 1, 1000);
if (ret) {
@@ -395,6 +398,10 @@ void mtu3_qmu_stop(struct mtu3_ep *mep)
return;
}
+ /* flush fifo again to make sure the fifo is empty */
+ if (mep->is_in)
+ mtu3_setbits(mbase, MU3D_EP_TXCR0(epnum), TX_FLUSHFIFO);
+
dev_dbg(mtu->dev, "%s's qmu stop now!\n", mep->name);
}
--
2.18.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] usb: mtu3: fix the failure of qmu stop
@ 2023-01-19 3:33 ` Chunfeng Yun
0 siblings, 0 replies; 4+ messages in thread
From: Chunfeng Yun @ 2023-01-19 3:33 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Chunfeng Yun, Matthias Brugger, linux-usb, linux-arm-kernel,
linux-mediatek, linux-kernel, Eddie Hung, Min Guo
This happens when do stress test of uvc stream on/off which will
enable/disable endpoints. uvc has four tx requests, and may disable
endpoint between queue tx requests as following:
enable ep --> start qmu
queue tx request0
queue tx request1
queue tx request2 --> resume qmu
disable ep --> stop qmu may fail [1]
queue tx request3 --> will resume qmu, may cause qmu can't work
when enable ep next time [2]
[1]: when the tx fifo has some data to transmit, and
try to stop qmu (stop ep) meanwhile resume qmu (queue tx request),
it may cause stop qmu timeout, then can be fixed by flushing fifo
when stop qmu.
[2]: it resumes qmu again, shall stop qmu again.
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Reported-by: Min Guo <min.guo@mediatek.com>
---
drivers/usb/mtu3/mtu3_gadget.c | 3 +--
drivers/usb/mtu3/mtu3_hw_regs.h | 1 +
drivers/usb/mtu3/mtu3_qmu.c | 7 +++++++
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c
index 80236e7b0895..c0264d5426bf 100644
--- a/drivers/usb/mtu3/mtu3_gadget.c
+++ b/drivers/usb/mtu3/mtu3_gadget.c
@@ -133,10 +133,9 @@ static int mtu3_ep_disable(struct mtu3_ep *mep)
{
struct mtu3 *mtu = mep->mtu;
- mtu3_qmu_stop(mep);
-
/* abort all pending requests */
nuke(mep, -ESHUTDOWN);
+ mtu3_qmu_stop(mep);
mtu3_deconfig_ep(mtu, mep);
mtu3_gpd_ring_free(mep);
diff --git a/drivers/usb/mtu3/mtu3_hw_regs.h b/drivers/usb/mtu3/mtu3_hw_regs.h
index 519a58301f45..ee30ae0a4b54 100644
--- a/drivers/usb/mtu3/mtu3_hw_regs.h
+++ b/drivers/usb/mtu3/mtu3_hw_regs.h
@@ -128,6 +128,7 @@
#define TX_FIFOEMPTY BIT(24)
#define TX_SENTSTALL BIT(22)
#define TX_SENDSTALL BIT(21)
+#define TX_FLUSHFIFO BIT(20)
#define TX_TXPKTRDY BIT(16)
#define TX_TXMAXPKTSZ_MSK GENMASK(10, 0)
#define TX_TXMAXPKTSZ(x) ((x) & TX_TXMAXPKTSZ_MSK)
diff --git a/drivers/usb/mtu3/mtu3_qmu.c b/drivers/usb/mtu3/mtu3_qmu.c
index 2ea3157ddb6e..a2fdab8b63b2 100644
--- a/drivers/usb/mtu3/mtu3_qmu.c
+++ b/drivers/usb/mtu3/mtu3_qmu.c
@@ -388,6 +388,9 @@ void mtu3_qmu_stop(struct mtu3_ep *mep)
}
mtu3_writel(mbase, qcsr, QMU_Q_STOP);
+ if (mep->is_in)
+ mtu3_setbits(mbase, MU3D_EP_TXCR0(epnum), TX_FLUSHFIFO);
+
ret = readl_poll_timeout_atomic(mbase + qcsr, value,
!(value & QMU_Q_ACTIVE), 1, 1000);
if (ret) {
@@ -395,6 +398,10 @@ void mtu3_qmu_stop(struct mtu3_ep *mep)
return;
}
+ /* flush fifo again to make sure the fifo is empty */
+ if (mep->is_in)
+ mtu3_setbits(mbase, MU3D_EP_TXCR0(epnum), TX_FLUSHFIFO);
+
dev_dbg(mtu->dev, "%s's qmu stop now!\n", mep->name);
}
--
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: mtu3: fix the failure of qmu stop
2023-01-19 3:33 ` Chunfeng Yun
@ 2023-01-20 13:06 ` AngeloGioacchino Del Regno
-1 siblings, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-01-20 13:06 UTC (permalink / raw)
To: Chunfeng Yun, Greg Kroah-Hartman
Cc: Matthias Brugger, linux-usb, linux-arm-kernel, linux-mediatek,
linux-kernel, Eddie Hung, Min Guo
Il 19/01/23 04:33, Chunfeng Yun ha scritto:
> This happens when do stress test of uvc stream on/off which will
> enable/disable endpoints. uvc has four tx requests, and may disable
> endpoint between queue tx requests as following:
> enable ep --> start qmu
> queue tx request0
> queue tx request1
> queue tx request2 --> resume qmu
> disable ep --> stop qmu may fail [1]
> queue tx request3 --> will resume qmu, may cause qmu can't work
> when enable ep next time [2]
>
> [1]: when the tx fifo has some data to transmit, and
> try to stop qmu (stop ep) meanwhile resume qmu (queue tx request),
> it may cause stop qmu timeout, then can be fixed by flushing fifo
> when stop qmu.
> [2]: it resumes qmu again, shall stop qmu again.
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> Reported-by: Min Guo <min.guo@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: mtu3: fix the failure of qmu stop
@ 2023-01-20 13:06 ` AngeloGioacchino Del Regno
0 siblings, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-01-20 13:06 UTC (permalink / raw)
To: Chunfeng Yun, Greg Kroah-Hartman
Cc: Matthias Brugger, linux-usb, linux-arm-kernel, linux-mediatek,
linux-kernel, Eddie Hung, Min Guo
Il 19/01/23 04:33, Chunfeng Yun ha scritto:
> This happens when do stress test of uvc stream on/off which will
> enable/disable endpoints. uvc has four tx requests, and may disable
> endpoint between queue tx requests as following:
> enable ep --> start qmu
> queue tx request0
> queue tx request1
> queue tx request2 --> resume qmu
> disable ep --> stop qmu may fail [1]
> queue tx request3 --> will resume qmu, may cause qmu can't work
> when enable ep next time [2]
>
> [1]: when the tx fifo has some data to transmit, and
> try to stop qmu (stop ep) meanwhile resume qmu (queue tx request),
> it may cause stop qmu timeout, then can be fixed by flushing fifo
> when stop qmu.
> [2]: it resumes qmu again, shall stop qmu again.
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> Reported-by: Min Guo <min.guo@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-01-20 13:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-19 3:33 [PATCH] usb: mtu3: fix the failure of qmu stop Chunfeng Yun
2023-01-19 3:33 ` Chunfeng Yun
2023-01-20 13:06 ` AngeloGioacchino Del Regno
2023-01-20 13:06 ` AngeloGioacchino Del Regno
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.