All of lore.kernel.org
 help / color / mirror / Atom feed
From: William Wu <william.wu@rock-chips.com>
To: hminas@synopsys.com, felipe.balbi@linux.intel.com,
	gregkh@linuxfoundation.org
Cc: sergei.shtylyov@cogentembedded.com, heiko@sntech.de,
	linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-rockchip@lists.infradead.org, frank.wang@rock-chips.com,
	huangtao@rock-chips.com, dianders@google.com,
	daniel.meng@rock-chips.com, John.Youn@synopsys.com,
	william.wu@rock-chips.com, wzz@rock-chips.com,
	zsq@rock-chips.com, Allen.Hsu@quantatw.com, StanTsui@AOPEN.com,
	Spruce.Wu@quantatw.com, Martin.Tsai@quantatw.com,
	Kevin.Shai@quantatw.com, Mon-Jer.Wu@quantatw.com,
	Claud.Chang@quantatw.com, San.Lin@quantatw.com,
	Ren.Kuo@quantatw.com, davidhtwang@aopen.com, fonglin@aopen.com,
	stevencheng@aopen.com, tomchen@aopen.com, donchang@aopen.com,
	milesschofield@aopen.com
Subject: [PATCH v5 2/2] usb: dwc2: fix isoc split in transfer with no data
Date: Fri, 11 May 2018 17:46:32 +0800	[thread overview]
Message-ID: <1526031992-16565-3-git-send-email-william.wu@rock-chips.com> (raw)
In-Reply-To: <1526031992-16565-1-git-send-email-william.wu@rock-chips.com>

If isoc split in transfer with no data (the length of DATA0
packet is zero), we can't simply return immediately. Because
the DATA0 can be the first transaction or the second transaction
for the isoc split in transaction. If the DATA0 packet with no
data is in the first transaction, we can return immediately.
But if the DATA0 packet with no data is in the second transaction
of isoc split in transaction sequence, we need to increase the
qtd->isoc_frame_index and giveback urb to device driver if needed,
otherwise, the MDATA packet will be lost.

A typical test case is that connect the dwc2 controller with an
usb hs Hub (GL852G-12), and plug an usb fs audio device (Plantronics
headset) into the downstream port of Hub. Then use the usb mic
to record, we can find noise when playback.

In the case, the isoc split in transaction sequence like this:

- SSPLIT IN transaction
- CSPLIT IN transaction
  - MDATA packet (176 bytes)
- CSPLIT IN transaction
  - DATA0 packet (0 byte)

This patch use both the length of DATA0 and qtd->isoc_split_offset
to check if the DATA0 is in the second transaction.

Signed-off-by: William Wu <william.wu@rock-chips.com>
---
Changes in v5:
- None

Changes in v4:
- None

Changes in v3:
- Remove "qtd->isoc_split_offset = 0" in the if test

Changes in v2:
- Modify the commit message

 drivers/usb/dwc2/hcd_intr.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c
index ba6229e..9751785 100644
--- a/drivers/usb/dwc2/hcd_intr.c
+++ b/drivers/usb/dwc2/hcd_intr.c
@@ -930,9 +930,8 @@ static int dwc2_xfercomp_isoc_split_in(struct dwc2_hsotg *hsotg,
 	frame_desc = &qtd->urb->iso_descs[qtd->isoc_frame_index];
 	len = dwc2_get_actual_xfer_length(hsotg, chan, chnum, qtd,
 					  DWC2_HC_XFER_COMPLETE, NULL);
-	if (!len) {
+	if (!len && !qtd->isoc_split_offset) {
 		qtd->complete_split = 0;
-		qtd->isoc_split_offset = 0;
 		return 0;
 	}
 
-- 
2.0.0



WARNING: multiple messages have this Message-ID (diff)
From: William Wu <william.wu@rock-chips.com>
To: hminas@synopsys.com, felipe.balbi@linux.intel.com,
	gregkh@linuxfoundation.org
Cc: sergei.shtylyov@cogentembedded.com, heiko@sntech.de,
	linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-rockchip@lists.infradead.org, frank.wang@rock-chips.com,
	huangtao@rock-chips.com, dianders@google.com,
	daniel.meng@rock-chips.com, John.Youn@synopsys.com,
	william.wu@rock-chips.com, wzz@rock-chips.com,
	zsq@rock-chips.com, Allen.Hsu@quantatw.com, StanTsui@AOPEN.com,
	Spruce.Wu@quantatw.com, Martin.Tsai@quantatw.com,
	Kevin.Shai@quantatw.com, Mon-Jer.Wu@quantatw.com,
	Claud.Chang@quantatw.com, San.Lin@quantatw.com,
	Ren.Kuo@quantatw.com, davidhtwang@aopen.com, fonglin@aopen.com,
	stevencheng@aopen.com, tomchen@aopen.com, donchang@aopen.com,
	milesschofield@aopen.com
Subject: [v5,2/2] usb: dwc2: fix isoc split in transfer with no data
Date: Fri, 11 May 2018 17:46:32 +0800	[thread overview]
Message-ID: <1526031992-16565-3-git-send-email-william.wu@rock-chips.com> (raw)

If isoc split in transfer with no data (the length of DATA0
packet is zero), we can't simply return immediately. Because
the DATA0 can be the first transaction or the second transaction
for the isoc split in transaction. If the DATA0 packet with no
data is in the first transaction, we can return immediately.
But if the DATA0 packet with no data is in the second transaction
of isoc split in transaction sequence, we need to increase the
qtd->isoc_frame_index and giveback urb to device driver if needed,
otherwise, the MDATA packet will be lost.

A typical test case is that connect the dwc2 controller with an
usb hs Hub (GL852G-12), and plug an usb fs audio device (Plantronics
headset) into the downstream port of Hub. Then use the usb mic
to record, we can find noise when playback.

In the case, the isoc split in transaction sequence like this:

- SSPLIT IN transaction
- CSPLIT IN transaction
  - MDATA packet (176 bytes)
- CSPLIT IN transaction
  - DATA0 packet (0 byte)

This patch use both the length of DATA0 and qtd->isoc_split_offset
to check if the DATA0 is in the second transaction.

Signed-off-by: William Wu <william.wu@rock-chips.com>
---
Changes in v5:
- None

Changes in v4:
- None

Changes in v3:
- Remove "qtd->isoc_split_offset = 0" in the if test

Changes in v2:
- Modify the commit message

 drivers/usb/dwc2/hcd_intr.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c
index ba6229e..9751785 100644
--- a/drivers/usb/dwc2/hcd_intr.c
+++ b/drivers/usb/dwc2/hcd_intr.c
@@ -930,9 +930,8 @@ static int dwc2_xfercomp_isoc_split_in(struct dwc2_hsotg *hsotg,
 	frame_desc = &qtd->urb->iso_descs[qtd->isoc_frame_index];
 	len = dwc2_get_actual_xfer_length(hsotg, chan, chnum, qtd,
 					  DWC2_HC_XFER_COMPLETE, NULL);
-	if (!len) {
+	if (!len && !qtd->isoc_split_offset) {
 		qtd->complete_split = 0;
-		qtd->isoc_split_offset = 0;
 		return 0;
 	}
 

  parent reply	other threads:[~2018-05-11  9:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-11  9:46 [PATCH v5 0/2] usb: dwc2: fix isoc split in transfer issue William Wu
2018-05-11  9:46 ` [PATCH v5 1/2] usb: dwc2: alloc dma aligned buffer for isoc split in William Wu
2018-05-11  9:46   ` [v5,1/2] " William Wu
2018-05-11  9:46 ` William Wu [this message]
2018-05-11  9:46   ` [v5,2/2] usb: dwc2: fix isoc split in transfer with no data William Wu
2018-05-20 10:38 ` [PATCH v5 0/2] usb: dwc2: fix isoc split in transfer issue Heiko Stuebner
2018-05-29 14:30 ` Gevorg Sahakyan
2018-05-29 14:30   ` Gevorg Sahakyan
2018-05-29 14:44 ` Minas Harutyunyan
2018-05-29 14:44   ` Minas Harutyunyan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1526031992-16565-3-git-send-email-william.wu@rock-chips.com \
    --to=william.wu@rock-chips.com \
    --cc=Allen.Hsu@quantatw.com \
    --cc=Claud.Chang@quantatw.com \
    --cc=John.Youn@synopsys.com \
    --cc=Kevin.Shai@quantatw.com \
    --cc=Martin.Tsai@quantatw.com \
    --cc=Mon-Jer.Wu@quantatw.com \
    --cc=Ren.Kuo@quantatw.com \
    --cc=San.Lin@quantatw.com \
    --cc=Spruce.Wu@quantatw.com \
    --cc=StanTsui@AOPEN.com \
    --cc=daniel.meng@rock-chips.com \
    --cc=davidhtwang@aopen.com \
    --cc=dianders@google.com \
    --cc=donchang@aopen.com \
    --cc=felipe.balbi@linux.intel.com \
    --cc=fonglin@aopen.com \
    --cc=frank.wang@rock-chips.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heiko@sntech.de \
    --cc=hminas@synopsys.com \
    --cc=huangtao@rock-chips.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=milesschofield@aopen.com \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=stevencheng@aopen.com \
    --cc=tomchen@aopen.com \
    --cc=wzz@rock-chips.com \
    --cc=zsq@rock-chips.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.