USB DWC2 parity fix in isochronous mode
Subsystems (2)
v2 cover USB DWC2 parity fix in isochronous mode
This patch contains a fix for a real world interop problem found when using the Synopsis DWC2 USB controller with isochronous audio as detailed in the commit message.
Changes from v1:
- Address code review comments as per previous responses:
- renamed parity_set to has_correct_parity and reorder some logic
Roman Bacik (1):
usb: dwc2: gadget: parity fix in isochronous mode
drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/gadget.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++- drivers/usb/dwc2/hw.h | 1 + 3 files changed, 52 insertions(+), 1 deletion(-)
Signature · 1 line
2.5.0
PATCH v2 1/1 usb: dwc2: gadget: parity fix in isochronous mode
From: Roman Bacik <[email protected]>
USB OTG driver in isochronous mode has to set the parity of the receiving microframe. The parity is set to even by default. This causes problems for an audio gadget, if the host starts transmitting on odd microframes.
This fix uses Incomplete Periodic Transfer interrupt to toggle between even and odd parity until the Transfer Complete interrupt is received.
--- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/gadget.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++- drivers/usb/dwc2/hw.h | 1 + 3 files changed, 52 insertions(+), 1 deletion(-)
drivers/usb/dwc2/core.h +1 -0
@@ -150,6 +150,7 @@ struct s3c_hsotg_ep { unsigned int periodic:1; unsigned int isochronous:1; unsigned int send_zlp:1; + unsigned int has_correct_parity:1;char name[10 ]; };
drivers/usb/dwc2/gadget.c +50 -1
75 lines not on this page · raw message
drivers/usb/dwc2/hw.h +1 -0
@@ -142,6 +142,7 @@#define GINTSTS_RESETDET (1 << 23)#define GINTSTS_FET_SUSP (1 << 22)#define GINTSTS_INCOMPL_IP (1 << 21) +#define GINTSTS_INCOMPL_SOOUT (1 << 21)#define GINTSTS_INCOMPL_SOIN (1 << 20)#define GINTSTS_OEPINT (1 << 19)#define GINTSTS_IEPINT (1 << 18)
Signature · 1 line
2.5.0
RE: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous mode
Is there anything else we should address in this patch? Thanks,
Roman
Quoted 143 lines
-----Original Message-----
From: Scott Branden [mailto:[email protected]]
Sent: August-31-15 9:17 AM
To: John Youn; Greg Kroah-Hartman; [email protected]; Roman Bacik
Cc: [email protected]; bcm-kernel-feedback-list; Scott Branden
Subject: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeFrom: Roman Bacik <[email protected]>
USB OTG driver in isochronous mode has to set the parity of the receiving microframe. The parity is set to even by default. This causes problems for an audio gadget, if the host starts transmitting on odd microframes.
This fix uses Incomplete Periodic Transfer interrupt to toggle between even and odd parity until the Transfer Complete interrupt is received.
Signed-off-by Roman Bacik <[email protected]>Reviewed-by Abhinav Ratna <[email protected]>Reviewed-by Srinath Mannam <[email protected]>Signed-off-by Scott Branden <[email protected]>--- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/gadget.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++- drivers/usb/dwc2/hw.h | 1 + 3 files changed, 52 insertions(+), 1 deletion(-)drivers/usb/dwc2/core.h index renamed from drivers/usb/dwc2/core.h +0
-00ed87620..a5634fd 100644
drivers/usb/dwc2/core.h +1
-0@@ -150,6 +150,7 @@ struct s3c_hsotg_ep { unsigned int periodic:1; unsigned int isochronous:1; unsigned int send_zlp:1; + unsigned int has_correct_parity:1;char name[10 ]; };drivers/usb/dwc2/gadget.c index renamed from drivers/usb/dwc2/gadget.c +0
-04d47b7c..fac3e2f 100644
drivers/usb/dwc2/gadget.c +1
-0@@ -1954,6 +1954,7 @@ static void s3c_hsotg_epint(struct dwc2_hsotg *hsotg, unsigned int idx, ints &= ~DXEPINT_XFERCOMPL ;if (ints &DXEPINT_XFERCOMPL ) { + hs_ep->has_correct_parity =1 ;if (hs_ep->isochronous && hs_ep->interval ==1 ) {if (ctrl &DXEPCTL_EOFRNUM )drivers/usb/dwc2/gadget.c +2
-1ctrl |=DXEPCTL_SETEVENFR ;@@ -2316,7 +2317,8 @@ void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,GINTSTS_CONIDSTSCHNG |GINTSTS_USBRST |GINTSTS_RESETDET |GINTSTS_ENUMDONE |GINTSTS_OTGINT |GINTSTS_USBSUSP | -GINTSTS_WKUPINT , +GINTSTS_WKUPINT | +GINTSTS_INCOMPL_SOIN |GINTSTS_INCOMPL_SOOUT , hsotg->regs + GINTMSK);drivers/usb/dwc2/gadget.c +32
-0if (using_dma (hsotg))@@ -2581,6 +2583,52 @@ irq_retry: s3c_hsotg_dump(hsotg); } + if (gintsts & GINTSTS_INCOMPL_SOIN) { + u32 idx, epctl_reg, ctrl; + struct s3c_hsotg_ep *hs_ep; + + dev_dbg(hsotg->dev, "%s: GINTSTS_INCOMPL_SOIN\n", __func__); + for (idx = 1; idx < MAX_EPS_CHANNELS; idx++) { + hs_ep = hsotg->eps_in[idx]; + + if (!hs_ep->isochronous || hs_ep- >has_correct_parity) + continue; + + epctl_reg = DIEPCTL(idx); + ctrl = readl(hsotg->regs + epctl_reg); + + if (ctrl & DXEPCTL_EOFRNUM) + ctrl |= DXEPCTL_SETEVENFR; + else + ctrl |= DXEPCTL_SETODDFR; + writel(ctrl, hsotg->regs + epctl_reg); + } + writel(GINTSTS_INCOMPL_SOIN, hsotg->regs + GINTSTS); + } + + if (gintsts & GINTSTS_INCOMPL_SOOUT) { + u32 idx, epctl_reg, ctrl; + struct s3c_hsotg_ep *hs_ep; + + dev_dbg(hsotg->dev, "%s: GINTSTS_INCOMPL_SOOUT\n", __func__); + for (idx = 1; idx < MAX_EPS_CHANNELS; idx++) { + hs_ep = hsotg->eps_out[idx]; + + if (!hs_ep->isochronous || hs_ep-Quoted 1 line
has_correct_parity)drivers/usb/dwc2/gadget.c +15
-1+continue ; + + epctl_reg =DOEPCTL (idx); + ctrl =readl (hsotg->regs + epctl_reg); + +if (ctrl &DXEPCTL_EOFRNUM ) + ctrl |=DXEPCTL_SETEVENFR ; +else + ctrl |=DXEPCTL_SETODDFR ; +writel (ctrl, hsotg->regs + epctl_reg); + } +writel (GINTSTS_INCOMPL_SOOUT , hsotg->regs +GINTSTS ); + } +/* * if we've had fifo events, we should try and go around the * loop again to see if there's any point in returning yet. @@ -2667,6 +2715,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, hs_ep->periodic =0 ; hs_ep->halted =0 ; hs_ep->interval = desc->bInterval; + hs_ep->has_correct_parity =0 ;if (hs_ep->interval >1 && hs_ep->mc >1 ) dev_err(hsotg->dev, "MC > 1 when interval is not 1\n"); diff - -git a/drivers/usb/dwc2/hw.h b/drivers/usb/dwc2/hw.h indexd0a5ed8..553f246 100644
drivers/usb/dwc2/hw.h +1
-1@@ -142,6 +142,7 @@#define GINTSTS_RESETDET (1 << 23)#define GINTSTS_FET_SUSP (1 << 22)#define GINTSTS_INCOMPL_IP (1 << 21) +#define GINTSTS_INCOMPL_SOOUT (1 << 21)#define GINTSTS_INCOMPL_SOIN (1 << 20)#define GINTSTS_OEPINT (1 << 19)#define GINTSTS_IEPINT (1 << 18) --2.5.0
Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous mode
In reply to Scott BrandenQuoted 54 lines · Scott Branden
From: Roman Bacik <[email protected]>
USB OTG driver in isochronous mode has to set the parity of the receiving microframe. The parity is set to even by default. This causes problems for an audio gadget, if the host starts transmitting on odd microframes.
This fix uses Incomplete Periodic Transfer interrupt to toggle between even and odd parity until the Transfer Complete interrupt is received.
Signed-off-by Roman Bacik <[email protected]>Reviewed-by Abhinav Ratna <[email protected]>Reviewed-by Srinath Mannam <[email protected]>Signed-off-by Scott Branden <[email protected]>--- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/gadget.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++- drivers/usb/dwc2/hw.h | 1 + 3 files changed, 52 insertions(+), 1 deletion(-)drivers/usb/dwc2/core.h +1
-0@@ -150,6 +150,7 @@ struct s3c_hsotg_ep { unsigned int periodic:1; unsigned int isochronous:1; unsigned int send_zlp:1; + unsigned int has_correct_parity:1;char name[10 ]; };drivers/usb/dwc2/gadget.c +3
-1@@ -1954,6 +1954,7 @@ static void s3c_hsotg_epint(struct dwc2_hsotg *hsotg, unsigned int idx, ints &= ~DXEPINT_XFERCOMPL ;if (ints &DXEPINT_XFERCOMPL ) { + hs_ep->has_correct_parity =1 ;if (hs_ep->isochronous && hs_ep->interval ==1 ) {if (ctrl &DXEPCTL_EOFRNUM ) ctrl |=DXEPCTL_SETEVENFR ;@@ -2316,7 +2317,8 @@ void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,GINTSTS_CONIDSTSCHNG |GINTSTS_USBRST |GINTSTS_RESETDET |GINTSTS_ENUMDONE |GINTSTS_OTGINT |GINTSTS_USBSUSP | -GINTSTS_WKUPINT , +GINTSTS_WKUPINT | +GINTSTS_INCOMPL_SOIN |GINTSTS_INCOMPL_SOOUT , hsotg->regs + GINTMSK);if (using_dma (hsotg))
drivers/usb/dwc2/gadget.c irq_retry: · line 2591
Quoted 9 lines
drivers/usb/dwc2/gadget.c +6
-0@@ -2581,6 +2583,52 @@ irq_retry:s3c_hsotg_dump (hsotg); } +if (gintsts &GINTSTS_INCOMPL_SOIN ) { +u32 idx, epctl_reg, ctrl; +struct s3c_hsotg_ep *hs_ep; + +dev_dbg (hsotg->dev,"%s: GINTSTS_INCOMPL_SOIN\n" , __func__); +for (idx =1 ; idx <MAX_EPS_CHANNELS ; idx++) {
Valid endpoints are only up to hsotg->num_of_eps so this might crash on certain configurations.
Also, have you tried to find the endpoint which caused the incomplete interrupt by reading the control registers as described in the databook?
drivers/usb/dwc2/gadget.c irq_retry: · line 2604
Quoted 13 lines
drivers/usb/dwc2/gadget.c +13
-0+ hs_ep = hsotg->eps_in[idx]; + +if (!hs_ep->isochronous || hs_ep->has_correct_parity) +continue ; + + epctl_reg =DIEPCTL (idx); + ctrl =readl (hsotg->regs + epctl_reg); + +if (ctrl &DXEPCTL_EOFRNUM ) + ctrl |=DXEPCTL_SETEVENFR ; +else + ctrl |=DXEPCTL_SETODDFR ; +writel (ctrl, hsotg->regs + epctl_reg);
This toggling code could be moved out to a helper function to reduce redundancy as it is in three places now.
Regards,
John
RE: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous mode
Quoted 76 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-03-15 11:53 PM
To: Scott Branden; John Youn; Greg Kroah-Hartman; linux- [email protected]; Roman Bacik
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 5 lines · Scott Branden
From: Roman Bacik <[email protected]>
USB OTG driver in isochronous mode has to set the parity of the receiving microframe. The parity is set to even by default. This causes problems for an audio gadget, if the host starts transmitting on odd
microframes.
Quoted 11 lines
This fix uses Incomplete Periodic Transfer interrupt to toggle between even and odd parity until the Transfer Complete interrupt is received.
Signed-off-by Roman Bacik <[email protected]>Reviewed-by Abhinav Ratna <[email protected]>Reviewed-by Srinath Mannam <[email protected]>Signed-off-by Scott Branden <[email protected]>--- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/gadget.c | 51++++++++++++++++++++++++++++++++++++++++++++++-
drivers/usb/dwc2/gadget.c static void s3c_hsotg_epint(struct dwc2_hsotg
Quoted 20 lines
drivers/usb/dwc2/hw.h | 1 + 3 files changed, 52 insertions(+), 1 deletion(-)drivers/usb/dwc2/core.h index renamed from drivers/usb/dwc2/core.h +0
-00ed87620..a5634fd 100644
drivers/usb/dwc2/core.h +1
-0@@ -150,6 +150,7 @@ struct s3c_hsotg_ep { unsigned int periodic:1; unsigned int isochronous:1; unsigned int send_zlp:1; + unsigned int has_correct_parity:1;char name[10 ]; };drivers/usb/dwc2/gadget.c +0
-0@@ -1954,6 +1954,7 @@ static void s3c_hsotg_epint(struct dwc2_hsotg*hsotg, unsigned int idx,
drivers/usb/dwc2/gadget.c void s3c_hsotg_core_init_disconnected(struct
Quoted 8 lines
drivers/usb/dwc2/gadget.c +1
-0ints &= ~DXEPINT_XFERCOMPL ;if (ints &DXEPINT_XFERCOMPL ) { + hs_ep->has_correct_parity =1 ;if (hs_ep->isochronous && hs_ep->interval ==1 ) {if (ctrl &DXEPCTL_EOFRNUM ) ctrl |=DXEPCTL_SETEVENFR ;@@ -2316,7 +2317,8 @@ void s3c_hsotg_core_init_disconnected(struct
dwc2_hsotg*hsotg,Quoted 10 lines
drivers/usb/dwc2/gadget.c +2
-1GINTSTS_CONIDSTSCHNG |GINTSTS_USBRST |GINTSTS_RESETDET |GINTSTS_ENUMDONE |GINTSTS_OTGINT |GINTSTS_USBSUSP | -GINTSTS_WKUPINT , +GINTSTS_WKUPINT | +GINTSTS_INCOMPL_SOIN |GINTSTS_INCOMPL_SOOUT , hsotg->regs + GINTMSK);if (using_dma (hsotg))drivers/usb/dwc2/gadget.c irq_retry: · line 2590
Quoted 8 lines
drivers/usb/dwc2/gadget.c +5
-0@@ -2581,6 +2583,52 @@ irq_retry:s3c_hsotg_dump (hsotg); } +if (gintsts &GINTSTS_INCOMPL_SOIN ) { +u32 idx, epctl_reg, ctrl; +struct s3c_hsotg_ep *hs_ep; + + dev_dbg(hsotg->dev, "%s: GINTSTS_INCOMPL_SOIN\n",
__func__);
Quoted 8 lines
drivers/usb/dwc2/gadget.c irq_retry: · line 2591
Quoted 1 line
drivers/usb/dwc2/gadget.c +1
-0+for (idx =1 ; idx <MAX_EPS_CHANNELS ; idx++) {Valid endpoints are only up to
hsotg->num_of_epsso this might crash on certain configurations.Also, have you tried to find the endpoint which caused the incomplete interrupt by reading the control registers as described in the databook?
We are using procedure based on description from this source:
Synopsys, Inc. SolvNet 527
DesignWare.com
3.00a
April 2012
USB 2.0 Hi-Speed On-The-Go (OTG) Databook Isochronous Endpoints in DWC_otg Slave Mode
Synopsys databook is not in a public domain to quote the exact paragraph here. You can find it in Chapter E, pp 526-527. There is no register in this databook, which would provide information about the source endpoint of the incomplete interrupt, as you have described.
Please, provide an exact reference and possibly enough information that we can turn it into a working code.
Quoted 20 lines
Quoted 4 lines
drivers/usb/dwc2/gadget.c +3
-0+ hs_ep = hsotg->eps_in[idx]; + +if (!hs_ep->isochronous || hs_ep- has_correct_parity)drivers/usb/dwc2/gadget.c irq_retry: · line 2604
Quoted 10 lines
drivers/usb/dwc2/gadget.c +10
-0+continue ; + + epctl_reg =DIEPCTL (idx); + ctrl =readl (hsotg->regs + epctl_reg); + +if (ctrl &DXEPCTL_EOFRNUM ) + ctrl |=DXEPCTL_SETEVENFR ; +else + ctrl |=DXEPCTL_SETODDFR ; +writel (ctrl, hsotg->regs + epctl_reg);This toggling code could be moved out to a helper function to reduce redundancy as it is in three places now.
Regards,
John
Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous mode
Quoted 93 lines · Roman Bacik
Quoted 76 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-03-15 11:53 PM
To: Scott Branden; John Youn; Greg Kroah-Hartman; linux- [email protected]; Roman Bacik
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 5 lines · Scott Branden
From: Roman Bacik <[email protected]>
USB OTG driver in isochronous mode has to set the parity of the receiving microframe. The parity is set to even by default. This causes problems for an audio gadget, if the host starts transmitting on odd
microframes.
Quoted 11 lines
This fix uses Incomplete Periodic Transfer interrupt to toggle between even and odd parity until the Transfer Complete interrupt is received.
Signed-off-by Roman Bacik <[email protected]>Reviewed-by Abhinav Ratna <[email protected]>Reviewed-by Srinath Mannam <[email protected]>Signed-off-by Scott Branden <[email protected]>--- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/gadget.c | 51++++++++++++++++++++++++++++++++++++++++++++++-
drivers/usb/dwc2/gadget.c static void s3c_hsotg_epint(struct dwc2_hsotg
Quoted 20 lines
drivers/usb/dwc2/hw.h | 1 + 3 files changed, 52 insertions(+), 1 deletion(-)drivers/usb/dwc2/core.h index renamed from drivers/usb/dwc2/core.h +0
-00ed87620..a5634fd 100644
drivers/usb/dwc2/core.h +1
-0@@ -150,6 +150,7 @@ struct s3c_hsotg_ep { unsigned int periodic:1; unsigned int isochronous:1; unsigned int send_zlp:1; + unsigned int has_correct_parity:1;char name[10 ]; };drivers/usb/dwc2/gadget.c +0
-0@@ -1954,6 +1954,7 @@ static void s3c_hsotg_epint(struct dwc2_hsotg*hsotg, unsigned int idx,
drivers/usb/dwc2/gadget.c void s3c_hsotg_core_init_disconnected(struct
Quoted 8 lines
drivers/usb/dwc2/gadget.c +1
-0ints &= ~DXEPINT_XFERCOMPL ;if (ints &DXEPINT_XFERCOMPL ) { + hs_ep->has_correct_parity =1 ;if (hs_ep->isochronous && hs_ep->interval ==1 ) {if (ctrl &DXEPCTL_EOFRNUM ) ctrl |=DXEPCTL_SETEVENFR ;@@ -2316,7 +2317,8 @@ void s3c_hsotg_core_init_disconnected(struct
dwc2_hsotg*hsotg,Quoted 10 lines
drivers/usb/dwc2/gadget.c +2
-1GINTSTS_CONIDSTSCHNG |GINTSTS_USBRST |GINTSTS_RESETDET |GINTSTS_ENUMDONE |GINTSTS_OTGINT |GINTSTS_USBSUSP | -GINTSTS_WKUPINT , +GINTSTS_WKUPINT | +GINTSTS_INCOMPL_SOIN |GINTSTS_INCOMPL_SOOUT , hsotg->regs + GINTMSK);if (using_dma (hsotg))drivers/usb/dwc2/gadget.c irq_retry: · line 2590
Quoted 8 lines
drivers/usb/dwc2/gadget.c +5
-0@@ -2581,6 +2583,52 @@ irq_retry:s3c_hsotg_dump (hsotg); } +if (gintsts &GINTSTS_INCOMPL_SOIN ) { +u32 idx, epctl_reg, ctrl; +struct s3c_hsotg_ep *hs_ep; + + dev_dbg(hsotg->dev, "%s: GINTSTS_INCOMPL_SOIN\n",
__func__);Quoted 8 lines
drivers/usb/dwc2/gadget.c irq_retry: · line 2591
Quoted 1 line
drivers/usb/dwc2/gadget.c +1
-0+for (idx =1 ; idx <MAX_EPS_CHANNELS ; idx++) {Valid endpoints are only up to
hsotg->num_of_epsso this might crash on certain configurations.Also, have you tried to find the endpoint which caused the incomplete interrupt by reading the control registers as described in the databook?
We are using procedure based on description from this source:
Synopsys, Inc. SolvNet 527
DesignWare.com
3.00a
April 2012
USB 2.0 Hi-Speed On-The-Go (OTG) Databook Isochronous Endpoints inDWC_otgSlave Mode
Quoted 4 lines
Synopsys databook is not in a public domain to quote the exact paragraph here. You can find it in Chapter E, pp 526-527. There is no register in this databook, which would provide information about the source endpoint of the incomplete interrupt, as you have described.
Please, provide an exact reference and possibly enough information that we can turn it into a working code.
You can check the source of the interrupt by reading the DSTS and ep control registers as described in the databook page 526, last bullet, and 527 first bullet.
John
RE: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous mode
Quoted 112 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-09-15 7:11 PM
To: Roman Bacik; John Youn; Scott Branden; Greg Kroah-Hartman; linux- [email protected]
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 12 lines · Roman Bacik
Quoted 12 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-03-15 11:53 PM
To: Scott Branden; John Youn; Greg Kroah-Hartman; linux- [email protected]; Roman Bacik
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 2 lines · Scott Branden
From: Roman Bacik <[email protected]>
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
USB OTG driver in isochronous mode has to set the parity of the receiving microframe. The parity is set to even by default. This causes problems for an audio gadget, if the host starts transmitting on odd
microframes.
Quoted 3 lines
This fix uses Incomplete Periodic Transfer interrupt to toggle between even and odd parity until the Transfer Complete interrupt is
received.
Quoted 69 lines
Quoted 58 lines
Quoted 8 lines
Signed-off-by Roman Bacik <[email protected]>Reviewed-by Abhinav Ratna <[email protected]>Reviewed-by Srinath Mannam <[email protected]>Signed-off-by Scott Branden <[email protected]>--- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/gadget.c | 51++++++++++++++++++++++++++++++++++++++++++++++-
drivers/usb/dwc2/gadget.c static void s3c_hsotg_epint(struct dwc2_hsotg
Quoted 20 lines
drivers/usb/dwc2/hw.h | 1 + 3 files changed, 52 insertions(+), 1 deletion(-)drivers/usb/dwc2/core.h index renamed from drivers/usb/dwc2/core.h +0
-00ed87620..a5634fd 100644
drivers/usb/dwc2/core.h +1
-0@@ -150,6 +150,7 @@ struct s3c_hsotg_ep { unsigned int periodic:1; unsigned int isochronous:1; unsigned int send_zlp:1; + unsigned int has_correct_parity:1;char name[10 ]; };drivers/usb/dwc2/gadget.c +0
-0@@ -1954,6 +1954,7 @@ static void s3c_hsotg_epint(struct dwc2_hsotg*hsotg, unsigned int idx,
drivers/usb/dwc2/gadget.c void s3c_hsotg_core_init_disconnected(struct
Quoted 8 lines
drivers/usb/dwc2/gadget.c +1
-0ints &= ~DXEPINT_XFERCOMPL ;if (ints &DXEPINT_XFERCOMPL ) { + hs_ep->has_correct_parity =1 ;if (hs_ep->isochronous && hs_ep->interval ==1 ) {if (ctrl &DXEPCTL_EOFRNUM ) ctrl |=DXEPCTL_SETEVENFR ;@@ -2316,7 +2317,8 @@ void s3c_hsotg_core_init_disconnected(struct
dwc2_hsotg*hsotg,Quoted 10 lines
drivers/usb/dwc2/gadget.c +2
-1GINTSTS_CONIDSTSCHNG |GINTSTS_USBRST |GINTSTS_RESETDET |GINTSTS_ENUMDONE |GINTSTS_OTGINT |GINTSTS_USBSUSP | -GINTSTS_WKUPINT , +GINTSTS_WKUPINT | +GINTSTS_INCOMPL_SOIN |GINTSTS_INCOMPL_SOOUT , hsotg->regs + GINTMSK);if (using_dma (hsotg))drivers/usb/dwc2/gadget.c irq_retry: · line 2590
Quoted 8 lines
drivers/usb/dwc2/gadget.c +5
-0@@ -2581,6 +2583,52 @@ irq_retry:s3c_hsotg_dump (hsotg); } +if (gintsts &GINTSTS_INCOMPL_SOIN ) { +u32 idx, epctl_reg, ctrl; +struct s3c_hsotg_ep *hs_ep; + + dev_dbg(hsotg->dev, "%s: GINTSTS_INCOMPL_SOIN\n",
__func__);Quoted 8 lines
drivers/usb/dwc2/gadget.c irq_retry: · line 2591
Quoted 1 line
drivers/usb/dwc2/gadget.c +1
-0+for (idx =1 ; idx <MAX_EPS_CHANNELS ; idx++) {Valid endpoints are only up to
hsotg->num_of_epsso this might crash on certain configurations.Also, have you tried to find the endpoint which caused the incomplete interrupt by reading the control registers as described in the databook?
We are using procedure based on description from this source:
Quoted 8 lines
Synopsys, Inc. SolvNet 527
DesignWare.com
3.00a
April 2012
USB 2.0 Hi-Speed On-The-Go (OTG) Databook Isochronous Endpoints inDWC_otgSlave ModeSynopsys databook is not in a public domain to quote the exact paragraph
here. You can find it in Chapter E, pp 526-527. There is no register in this databook, which would provide information about the source endpoint of the incomplete interrupt, as you have described.
Quoted 2 lines
Please, provide an exact reference and possibly enough information that
Quoted 9 lines
we can turn it into a working code.
Quoted 1 line
You can check the source of the interrupt by reading the DSTS and ep control registers as described in the databook page 526, last bullet, and 527 first bullet.
John
Yes, that is exactly what we are doing what is described in the last bullet of 526 and the first two bullets of page 527. So what is the problem?
Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous mode
Quoted 115 lines · Roman Bacik
Quoted 115 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-09-15 7:11 PM
To: Roman Bacik; John Youn; Scott Branden; Greg Kroah-Hartman; linux- [email protected]
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 12 lines · Roman Bacik
Quoted 12 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-03-15 11:53 PM
To: Scott Branden; John Youn; Greg Kroah-Hartman; linux- [email protected]; Roman Bacik
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 2 lines · Scott Branden
From: Roman Bacik <[email protected]>
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
USB OTG driver in isochronous mode has to set the parity of the receiving microframe. The parity is set to even by default. This causes problems for an audio gadget, if the host starts transmitting on odd
microframes.
Quoted 3 lines
This fix uses Incomplete Periodic Transfer interrupt to toggle between even and odd parity until the Transfer Complete interrupt is
received.
Quoted 69 lines
Quoted 58 lines
Quoted 8 lines
Signed-off-by Roman Bacik <[email protected]>Reviewed-by Abhinav Ratna <[email protected]>Reviewed-by Srinath Mannam <[email protected]>Signed-off-by Scott Branden <[email protected]>--- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/gadget.c | 51++++++++++++++++++++++++++++++++++++++++++++++-
drivers/usb/dwc2/gadget.c static void s3c_hsotg_epint(struct dwc2_hsotg
Quoted 20 lines
drivers/usb/dwc2/hw.h | 1 + 3 files changed, 52 insertions(+), 1 deletion(-)drivers/usb/dwc2/core.h index renamed from drivers/usb/dwc2/core.h +0
-00ed87620..a5634fd 100644
drivers/usb/dwc2/core.h +1
-0@@ -150,6 +150,7 @@ struct s3c_hsotg_ep { unsigned int periodic:1; unsigned int isochronous:1; unsigned int send_zlp:1; + unsigned int has_correct_parity:1;char name[10 ]; };drivers/usb/dwc2/gadget.c +0
-0@@ -1954,6 +1954,7 @@ static void s3c_hsotg_epint(struct dwc2_hsotg*hsotg, unsigned int idx,
drivers/usb/dwc2/gadget.c void s3c_hsotg_core_init_disconnected(struct
Quoted 8 lines
drivers/usb/dwc2/gadget.c +1
-0ints &= ~DXEPINT_XFERCOMPL ;if (ints &DXEPINT_XFERCOMPL ) { + hs_ep->has_correct_parity =1 ;if (hs_ep->isochronous && hs_ep->interval ==1 ) {if (ctrl &DXEPCTL_EOFRNUM ) ctrl |=DXEPCTL_SETEVENFR ;@@ -2316,7 +2317,8 @@ void s3c_hsotg_core_init_disconnected(struct
dwc2_hsotg*hsotg,Quoted 10 lines
drivers/usb/dwc2/gadget.c +2
-1GINTSTS_CONIDSTSCHNG |GINTSTS_USBRST |GINTSTS_RESETDET |GINTSTS_ENUMDONE |GINTSTS_OTGINT |GINTSTS_USBSUSP | -GINTSTS_WKUPINT , +GINTSTS_WKUPINT | +GINTSTS_INCOMPL_SOIN |GINTSTS_INCOMPL_SOOUT , hsotg->regs + GINTMSK);if (using_dma (hsotg))drivers/usb/dwc2/gadget.c irq_retry: · line 2590
Quoted 8 lines
drivers/usb/dwc2/gadget.c +5
-0@@ -2581,6 +2583,52 @@ irq_retry:s3c_hsotg_dump (hsotg); } +if (gintsts &GINTSTS_INCOMPL_SOIN ) { +u32 idx, epctl_reg, ctrl; +struct s3c_hsotg_ep *hs_ep; + + dev_dbg(hsotg->dev, "%s: GINTSTS_INCOMPL_SOIN\n",
__func__);Quoted 8 lines
drivers/usb/dwc2/gadget.c irq_retry: · line 2591
Quoted 1 line
drivers/usb/dwc2/gadget.c +1
-0+for (idx =1 ; idx <MAX_EPS_CHANNELS ; idx++) {Valid endpoints are only up to
hsotg->num_of_epsso this might crash on certain configurations.Also, have you tried to find the endpoint which caused the incomplete interrupt by reading the control registers as described in the databook?
We are using procedure based on description from this source:
Quoted 8 lines
Synopsys, Inc. SolvNet 527
DesignWare.com
3.00a
April 2012
USB 2.0 Hi-Speed On-The-Go (OTG) Databook Isochronous Endpoints inDWC_otgSlave ModeSynopsys databook is not in a public domain to quote the exact paragraph
here. You can find it in Chapter E, pp 526-527. There is no register in this databook, which would provide information about the source endpoint of the incomplete interrupt, as you have described.
Quoted 2 lines
Please, provide an exact reference and possibly enough information that
we can turn it into a working code.
Quoted 1 line
Quoted 9 lines
Quoted 6 lines
You can check the source of the interrupt by reading the DSTS and ep control registers as described in the databook page 526, last bullet, and 527 first bullet.
John
Yes, that is exactly what we are doing what is described in the last bullet of 526 and the first two bullets of page 527. So what is the problem?
Maybe I missed it. Where exactly are you doing it like it says in these two paragraphs?
Quote:
GINTSTS.incompISOIN is a global interrupt. Therefore, when more than one isochronous endpoints is active, then the application must determine which isochronous IN endpoints have incomplete data.
To accomplish this, read DSTS and DIEPCTLn for all isochronous endpoints. If DSTS.SOFFN[0] =DIEPCTLn.EO_FrNum (Bit 16),then that endpoint has an incomplete transfer
John
RE: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous mode
Quoted 153 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-09-15 7:25 PM
To: Roman Bacik; John Youn; Scott Branden; Greg Kroah-Hartman; linux- [email protected]
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 63 lines · Roman Bacik
Quoted 63 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-09-15 7:11 PM
To: Roman Bacik; John Youn; Scott Branden; Greg Kroah-Hartman; linux- [email protected]
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 16 lines · Roman Bacik
Quoted 16 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-03-15 11:53 PM
To: Scott Branden; John Youn; Greg Kroah-Hartman; linux- [email protected]; Roman Bacik
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 6 lines · Scott Branden
From: Roman Bacik <[email protected]>
USB OTG driver in isochronous mode has to set the parity of the receiving microframe. The parity is set to even by default. This causes problems for an audio gadget, if the host starts transmitting on odd
Quoted 5 lines
Quoted 5 lines
microframes.
Quoted 4 lines
This fix uses Incomplete Periodic Transfer interrupt to toggle between even and odd parity until the Transfer Complete interrupt is
received.
Quoted 31 lines
Quoted 31 lines
Quoted 8 lines
Signed-off-by Roman Bacik <[email protected]>Reviewed-by Abhinav Ratna <[email protected]>Reviewed-by Srinath Mannam <[email protected]>Signed-off-by Scott Branden <[email protected]>--- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/gadget.c | 51++++++++++++++++++++++++++++++++++++++++++++++-
Quoted 20 lines
drivers/usb/dwc2/hw.h | 1 + 3 files changed, 52 insertions(+), 1 deletion(-)drivers/usb/dwc2/core.h +1
-0@@ -150,6 +150,7 @@ struct s3c_hsotg_ep { unsigned int periodic:1; unsigned int isochronous:1; unsigned int send_zlp:1; + unsigned int has_correct_parity:1;char name[10 ]; };drivers/usb/dwc2/gadget.c +0
-0@@ -1954,6 +1954,7 @@ static void s3c_hsotg_epint(structQuoted 1 line
dwc2_hsotg*hsotg, unsigned int idx,
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/usb/dwc2/gadget.c void
Quoted 8 lines
drivers/usb/dwc2/gadget.c +1
-0ints &= ~DXEPINT_XFERCOMPL ;if (ints &DXEPINT_XFERCOMPL ) { + hs_ep->has_correct_parity =1 ;if (hs_ep->isochronous && hs_ep->interval ==1 ) {if (ctrl &DXEPCTL_EOFRNUM ) ctrl |=DXEPCTL_SETEVENFR ;@@ -2316,7 +2317,8 @@ voids3c_hsotg_core_init_disconnected(struct
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
dwc2_hsotg*hsotg,drivers/usb/dwc2/gadget.c void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,
Quoted 6 lines
drivers/usb/dwc2/gadget.c +2
-1GINTSTS_CONIDSTSCHNG |GINTSTS_USBRST |GINTSTS_RESETDET |GINTSTS_ENUMDONE |GINTSTS_OTGINT |GINTSTS_USBSUSP | - GINTSTS_WKUPINT, +GINTSTS_WKUPINT | + GINTSTS_INCOMPL_SOIN |
GINTSTS_INCOMPL_SOOUT,Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/usb/dwc2/gadget.c +0
-0hsotg->regs + GINTMSK);if (using_dma (hsotg))@@ -2581,6 +2583,52 @@ irq_retry:s3c_hsotg_dump (hsotg); }Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/usb/dwc2/gadget.c irq_retry:
Quoted 5 lines
drivers/usb/dwc2/gadget.c +5
-0+if (gintsts &GINTSTS_INCOMPL_SOIN ) { +u32 idx, epctl_reg, ctrl; +struct s3c_hsotg_ep *hs_ep; + + dev_dbg(hsotg->dev, "%s:GINTSTS_INCOMPL_SOIN\n",
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
__func__);drivers/usb/dwc2/gadget.c irq_retry: · line 2591
Quoted 1 line
drivers/usb/dwc2/gadget.c +1
-0+for (idx =1 ; idx <MAX_EPS_CHANNELS ; idx++) {Valid endpoints are only up to
hsotg->num_of_epsso this might crash on certain configurations.Also, have you tried to find the endpoint which caused the incomplete interrupt by reading the control registers as described in
the databook?
Quoted 22 lines
Quoted 22 lines
Quoted 11 lines
Quoted 1 line
We are using procedure based on description from this source:
Synopsys, Inc. SolvNet 527
DesignWare.com
3.00a
April 2012
USB 2.0 Hi-Speed On-The-Go (OTG) Databook Isochronous Endpoints inDWC_otgSlave ModeQuoted 2 lines
Synopsys databook is not in a public domain to quote the exact paragraph
here. You can find it in Chapter E, pp 526-527. There is no register in this databook, which would provide information about the source endpoint of the incomplete interrupt, as you have described.
Quoted 3 lines
Please, provide an exact reference and possibly enough information that
we can turn it into a working code.
Quoted 1 line
Quoted 8 lines
Quoted 6 lines
You can check the source of the interrupt by reading the DSTS and ep control registers as described in the databook page 526, last bullet, and 527 first bullet.
John
Yes, that is exactly what we are doing what is described in the last bullet of
526 and the first two bullets of page 527. So what is the problem?
Quoted 1 line
Maybe I missed it. Where exactly are you doing it like it says in these two paragraphs?
Quote:
GINTSTS.incompISOIN is a global interrupt. Therefore, when more than one isochronous endpoints is active, then the application must determine which isochronous IN endpoints have incomplete data.
Quoted 7 lines
To accomplish this, read DSTS and DIEPCTLn for all isochronous endpoints. If DSTS.SOFFN[0] =DIEPCTLn.EO_FrNum (Bit 16),then that endpoint has an incomplete transfer
John
That is the content of the two for loops. I will paste the code here again for your convenience:
Quoted 50 lines
drivers/usb/dwc2/gadget.c +5
-0+if (gintsts &GINTSTS_INCOMPL_SOIN ) { +u32 idx, epctl_reg, ctrl; +struct s3c_hsotg_ep *hs_ep; + + dev_dbg(hsotg->dev, "%s: GINTSTS_INCOMPL_SOIN\n",
__func__);drivers/usb/dwc2/gadget.c +4
-0+ for (idx = 1; idx < MAX_EPS_CHANNELS; idx++) { + hs_ep = hsotg->eps_in[idx]; + + if (!hs_ep->isochronous || hs_ep-Quoted 1 line
has_correct_parity)drivers/usb/dwc2/gadget.c +19
-0+continue ; + + epctl_reg =DIEPCTL (idx); + ctrl =readl (hsotg->regs + epctl_reg); + +if (ctrl &DXEPCTL_EOFRNUM ) + ctrl |=DXEPCTL_SETEVENFR ; +else + ctrl |=DXEPCTL_SETODDFR ; +writel (ctrl, hsotg->regs + epctl_reg); + } +writel (GINTSTS_INCOMPL_SOIN , hsotg->regs +GINTSTS ); + } + +if (gintsts &GINTSTS_INCOMPL_SOOUT ) { +u32 idx, epctl_reg, ctrl; +struct s3c_hsotg_ep *hs_ep; + + dev_dbg(hsotg->dev, "%s: GINTSTS_INCOMPL_SOOUT\n",
__func__);drivers/usb/dwc2/gadget.c +4
-0+ for (idx = 1; idx < MAX_EPS_CHANNELS; idx++) { + hs_ep = hsotg->eps_out[idx]; + + if (!hs_ep->isochronous || hs_ep-Quoted 1 line
has_correct_parity)drivers/usb/dwc2/gadget.c +14
-0+continue ; + + epctl_reg =DOEPCTL (idx); + ctrl =readl (hsotg->regs + epctl_reg); + +if (ctrl &DXEPCTL_EOFRNUM ) + ctrl |=DXEPCTL_SETEVENFR ; +else + ctrl |=DXEPCTL_SETODDFR ; +writel (ctrl, hsotg->regs + epctl_reg); + } +writel (GINTSTS_INCOMPL_SOOUT , hsotg->regs +GINTSTS ); + } +
RE: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous mode
In reply to John YounQuoted 212 lines
-----Original Message-----
From: Roman Bacik
Sent: September-09-15 7:36 PM
To: 'John Youn'; Scott Branden; Greg Kroah-Hartman; linux- [email protected]
Cc: [email protected]; bcm-kernel-feedback-list
Subject: RE: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 109 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-09-15 7:25 PM
To: Roman Bacik; John Youn; Scott Branden; Greg Kroah-Hartman; linux- [email protected]
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 63 lines · Roman Bacik
Quoted 63 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-09-15 7:11 PM
To: Roman Bacik; John Youn; Scott Branden; Greg Kroah-Hartman; linux- [email protected]
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 16 lines · Roman Bacik
Quoted 16 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-03-15 11:53 PM
To: Scott Branden; John Youn; Greg Kroah-Hartman; linux- [email protected]; Roman Bacik
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 6 lines · Scott Branden
From: Roman Bacik <[email protected]>
USB OTG driver in isochronous mode has to set the parity of the receiving microframe. The parity is set to even by default. This causes problems for an audio gadget, if the host starts transmitting on odd
Quoted 5 lines
Quoted 5 lines
microframes.
Quoted 4 lines
This fix uses Incomplete Periodic Transfer interrupt to toggle between even and odd parity until the Transfer Complete interrupt is
received.
Quoted 31 lines
Quoted 31 lines
Quoted 8 lines
Signed-off-by Roman Bacik <[email protected]>Reviewed-by Abhinav Ratna <[email protected]>Reviewed-by Srinath Mannam <[email protected]>Signed-off-by Scott Branden <[email protected]>--- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/gadget.c | 51++++++++++++++++++++++++++++++++++++++++++++++-
Quoted 20 lines
drivers/usb/dwc2/hw.h | 1 + 3 files changed, 52 insertions(+), 1 deletion(-)drivers/usb/dwc2/core.h +1
-0@@ -150,6 +150,7 @@ struct s3c_hsotg_ep { unsigned int periodic:1; unsigned int isochronous:1; unsigned int send_zlp:1; + unsigned int has_correct_parity:1;char name[10 ]; };(quoted diff) +0
-0
b/drivers/usb/dwc2/gadget.cindex 4d47b7c..fac3e2f 100644drivers/usb/dwc2/gadget.c +0
-0@@ -1954,6 +1954,7 @@ static void s3c_hsotg_epint(structQuoted 1 line
dwc2_hsotg*hsotg, unsigned int idx,
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/usb/dwc2/gadget.c void
Quoted 8 lines
drivers/usb/dwc2/gadget.c +1
-0ints &= ~DXEPINT_XFERCOMPL ;if (ints &DXEPINT_XFERCOMPL ) { + hs_ep->has_correct_parity =1 ;if (hs_ep->isochronous && hs_ep->interval ==1 ) {if (ctrl &DXEPCTL_EOFRNUM ) ctrl |=DXEPCTL_SETEVENFR ;@@ -2316,7 +2317,8 @@ voids3c_hsotg_core_init_disconnected(struct
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
dwc2_hsotg*hsotg,drivers/usb/dwc2/gadget.c void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,
Quoted 6 lines
drivers/usb/dwc2/gadget.c +2
-1GINTSTS_CONIDSTSCHNG |GINTSTS_USBRST |GINTSTS_RESETDET |GINTSTS_ENUMDONE |GINTSTS_OTGINT |GINTSTS_USBSUSP | - GINTSTS_WKUPINT, +GINTSTS_WKUPINT | + GINTSTS_INCOMPL_SOIN |
GINTSTS_INCOMPL_SOOUT,Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/usb/dwc2/gadget.c +0
-0hsotg->regs + GINTMSK);if (using_dma (hsotg))@@ -2581,6 +2583,52 @@ irq_retry:s3c_hsotg_dump (hsotg); }Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/usb/dwc2/gadget.c irq_retry:
Quoted 5 lines
drivers/usb/dwc2/gadget.c +5
-0+if (gintsts &GINTSTS_INCOMPL_SOIN ) { +u32 idx, epctl_reg, ctrl; +struct s3c_hsotg_ep *hs_ep; + + dev_dbg(hsotg->dev, "%s:GINTSTS_INCOMPL_SOIN\n",
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
__func__);drivers/usb/dwc2/gadget.c irq_retry: · line 2591
Quoted 1 line
drivers/usb/dwc2/gadget.c +1
-0+for (idx =1 ; idx <MAX_EPS_CHANNELS ; idx++) {Valid endpoints are only up to
hsotg->num_of_epsso this might crash on certain configurations.Quoted 13 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Also, have you tried to find the endpoint which caused the incomplete interrupt by reading the control registers as described in
the databook?
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
We are using procedure based on description from this source:
Synopsys, Inc. SolvNet 527
DesignWare.com
3.00a
April 2012
USB 2.0 Hi-Speed On-The-Go (OTG) Databook Isochronous Endpointsin
Quoted 34 lines
Quoted 17 lines
Quoted 17 lines
Quoted 4 lines
DWC_otgSlave ModeSynopsys databook is not in a public domain to quote the exact paragraph
here. You can find it in Chapter E, pp 526-527. There is no register in this databook, which would provide information about the source endpoint of the incomplete interrupt, as you have described.
Quoted 3 lines
Please, provide an exact reference and possibly enough information that
we can turn it into a working code.
Quoted 1 line
You can check the source of the interrupt by reading the DSTS and ep control registers as described in the databook page 526, last bullet, and 527 first bullet.
Quoted 5 lines
Quoted 2 lines
John
Yes, that is exactly what we are doing what is described in the last bullet of
526 and the first two bullets of page 527. So what is the problem?
Quoted 1 line
Maybe I missed it. Where exactly are you doing it like it says in these two paragraphs?
Quote:
GINTSTS.incompISOIN is a global interrupt. Therefore, when more than one isochronous endpoints is active, then the application must determine which isochronous IN endpoints have incomplete data.
Quoted 7 lines
To accomplish this, read DSTS and DIEPCTLn for all isochronous endpoints. If DSTS.SOFFN[0] =DIEPCTLn.EO_FrNum (Bit 16),then that endpoint has an incomplete transfer
John
That is the content of the two for loops. I will paste the code here again for your convenience:
Quoted 36 lines
drivers/usb/dwc2/gadget.c +5
-0+if (gintsts &GINTSTS_INCOMPL_SOIN ) { +u32 idx, epctl_reg, ctrl; +struct s3c_hsotg_ep *hs_ep; + + dev_dbg(hsotg->dev, "%s: GINTSTS_INCOMPL_SOIN\n",
__func__);drivers/usb/dwc2/gadget.c +4
-0+ for (idx = 1; idx < MAX_EPS_CHANNELS; idx++) { + hs_ep = hsotg->eps_in[idx]; + + if (!hs_ep->isochronous || hs_ep-Quoted 1 line
has_correct_parity)drivers/usb/dwc2/gadget.c +19
-0+continue ; + + epctl_reg =DIEPCTL (idx); + ctrl =readl (hsotg->regs + epctl_reg); + +if (ctrl &DXEPCTL_EOFRNUM ) + ctrl |=DXEPCTL_SETEVENFR ; +else + ctrl |=DXEPCTL_SETODDFR ; +writel (ctrl, hsotg->regs + epctl_reg); + } +writel (GINTSTS_INCOMPL_SOIN , hsotg->regs +GINTSTS ); + } + +if (gintsts &GINTSTS_INCOMPL_SOOUT ) { +u32 idx, epctl_reg, ctrl; +struct s3c_hsotg_ep *hs_ep; + + dev_dbg(hsotg->dev, "%s: GINTSTS_INCOMPL_SOOUT\n",
__func__);drivers/usb/dwc2/gadget.c +4
-0+ for (idx = 1; idx < MAX_EPS_CHANNELS; idx++) { + hs_ep = hsotg->eps_out[idx]; + + if (!hs_ep->isochronous || hs_ep-Quoted 1 line
has_correct_parity)
Quoted 16 lines
Quoted 4 lines
drivers/usb/dwc2/gadget.c +4
-0+continue ; + + epctl_reg =DOEPCTL (idx); + ctrl =readl (hsotg->regs + epctl_reg);drivers/usb/dwc2/gadget.c irq_retry: · line 2631
Quoted 10 lines
drivers/usb/dwc2/gadget.c +10
-0+ +if (ctrl &DXEPCTL_EOFRNUM ) + ctrl |=DXEPCTL_SETEVENFR ; +else + ctrl |=DXEPCTL_SETODDFR ; +writel (ctrl, hsotg->regs + epctl_reg); + } +writel (GINTSTS_INCOMPL_SOOUT , hsotg->regs +GINTSTS ); + } +
I think I am starting to understand your objection. When the parity is not set on an isochronous endpoint, we flip the parity on that endpoint. I think you would prefer if we flip the parity only on isochronous endpoints, which do not have parity set, and got the actual interrupt. Is this interpretation correct?
We believe the way it is now gets correct parity on all isochronous endpoints faster and it was tested working well. But if you prefer adding another condition before flipping the endpoints we can try it out and retest.
Regards,
Roman
RE: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous mode
In reply to John YounQuoted 141 lines
-----Original Message-----
From: Roman Bacik
Sent: September-09-15 7:59 PM
To: 'John Youn'; Scott Branden; 'Greg Kroah-Hartman'; 'linux- [email protected]'
Cc: '[email protected]'; bcm-kernel-feedback-list
Subject: RE: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 55 lines
-----Original Message-----
From: Roman Bacik
Sent: September-09-15 7:36 PM
To: 'John Youn'; Scott Branden; Greg Kroah-Hartman; linux- [email protected]
Cc: [email protected]; bcm-kernel-feedback-list
Subject: RE: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 46 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-09-15 7:25 PM
To: Roman Bacik; John Youn; Scott Branden; Greg Kroah-Hartman; linux- [email protected]
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 36 lines · Roman Bacik
Quoted 36 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-09-15 7:11 PM
To: Roman Bacik; John Youn; Scott Branden; Greg Kroah-Hartman; linux- [email protected]
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 16 lines · Roman Bacik
Quoted 16 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-03-15 11:53 PM
To: Scott Branden; John Youn; Greg Kroah-Hartman; linux- [email protected]; Roman Bacik
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 6 lines · Scott Branden
From: Roman Bacik <[email protected]>
USB OTG driver in isochronous mode has to set the parity of the receiving microframe. The parity is set to even by default. This causes problems for an audio gadget, if the host starts transmitting on odd
Quoted 5 lines
Quoted 5 lines
microframes.
Quoted 4 lines
This fix uses Incomplete Periodic Transfer interrupt to toggle between even and odd parity until the Transfer Complete interrupt is
received.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Signed-off-by Roman Bacik <[email protected]>Reviewed-by Abhinav Ratna <[email protected]>Reviewed-by Srinath MannamQuoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 4 lines
Signed-off-by Scott Branden <[email protected]>--- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/gadget.c | 51++++++++++++++++++++++++++++++++++++++++++++++-
Quoted 20 lines
drivers/usb/dwc2/hw.h | 1 + 3 files changed, 52 insertions(+), 1 deletion(-)drivers/usb/dwc2/core.h +1
-0@@ -150,6 +150,7 @@ struct s3c_hsotg_ep { unsigned int periodic:1; unsigned int isochronous:1; unsigned int send_zlp:1; + unsigned int has_correct_parity:1;char name[10 ]; };(quoted diff) +0
-0
b/drivers/usb/dwc2/gadget.cindex 4d47b7c..fac3e2f 100644drivers/usb/dwc2/gadget.c +0
-0@@ -1954,6 +1954,7 @@ static void s3c_hsotg_epint(structQuoted 1 line
dwc2_hsotg*hsotg, unsigned int idx,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/usb/dwc2/gadget.c static void s3c_hsotg_epint(struct dwc2_hsotg *hsotg, unsigned int idx,
Quoted 7 lines
drivers/usb/dwc2/gadget.c +1
-0ints &= ~DXEPINT_XFERCOMPL ;if (ints &DXEPINT_XFERCOMPL ) { + hs_ep->has_correct_parity =1 ;if (hs_ep->isochronous && hs_ep->interval ==1 ) {if (ctrl &DXEPCTL_EOFRNUM ) ctrl |= DXEPCTL_SETEVENFR; @@ -2316,7 +2317,8 @@ void
Quoted 42 lines
Quoted 28 lines
s3c_hsotg_core_init_disconnected(struct
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
dwc2_hsotg*hsotg,drivers/usb/dwc2/gadget.c void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,
Quoted 6 lines
drivers/usb/dwc2/gadget.c +2
-1GINTSTS_CONIDSTSCHNG |GINTSTS_USBRST |GINTSTS_RESETDET |GINTSTS_ENUMDONE |GINTSTS_OTGINT |GINTSTS_USBSUSP | - GINTSTS_WKUPINT, +GINTSTS_WKUPINT | + GINTSTS_INCOMPL_SOIN |
GINTSTS_INCOMPL_SOOUT,Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/usb/dwc2/gadget.c +0
-0hsotg->regs + GINTMSK);if (using_dma (hsotg))@@ -2581,6 +2583,52 @@ irq_retry:s3c_hsotg_dump (hsotg); }Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/usb/dwc2/gadget.c irq_retry:
Quoted 5 lines
drivers/usb/dwc2/gadget.c +5
-0+if (gintsts &GINTSTS_INCOMPL_SOIN ) { +u32 idx, epctl_reg, ctrl; +struct s3c_hsotg_ep *hs_ep; + + dev_dbg(hsotg->dev, "%s:GINTSTS_INCOMPL_SOIN\n",
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
__func__);drivers/usb/dwc2/gadget.c irq_retry: · line 2591
Quoted 1 line
drivers/usb/dwc2/gadget.c +1
-0+for (idx =1 ; idx <MAX_EPS_CHANNELS ; idx++) {Valid endpoints are only up to
hsotg->num_of_epsso this might crash on certain configurations.Quoted 13 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Also, have you tried to find the endpoint which caused the incomplete interrupt by reading the control registers as described in
the databook?
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
We are using procedure based on description from this source:
Synopsys, Inc. SolvNet 527
DesignWare.com
3.00a
April 2012
USB 2.0 Hi-Speed On-The-Go (OTG) Databook Isochronous Endpointsin
Quoted 43 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
DWC_otgSlave ModeSynopsys databook is not in a public domain to quote the exact paragraph
here. You can find it in Chapter E, pp 526-527. There is no register in this databook, which would provide information about the source endpoint of the incomplete interrupt, as you have
described.
Quoted 35 lines
Quoted 34 lines
Quoted 10 lines
Quoted 10 lines
Quoted 3 lines
Please, provide an exact reference and possibly enough information that
we can turn it into a working code.
Quoted 1 line
You can check the source of the interrupt by reading the DSTS and ep control registers as described in the databook page 526, last bullet, and 527 first bullet.
Quoted 5 lines
Quoted 2 lines
John
Yes, that is exactly what we are doing what is described in the last bullet of
526 and the first two bullets of page 527. So what is the problem?
Quoted 1 line
Maybe I missed it. Where exactly are you doing it like it says in these two paragraphs?
Quote:
GINTSTS.incompISOIN is a global interrupt. Therefore, when more than one isochronous endpoints is active, then the application must determine which isochronous IN endpoints have incomplete data.
To accomplish this, read DSTS and DIEPCTLn for all isochronous endpoints. If DSTS.SOFFN[0] =DIEPCTLn.EO_FrNum (Bit 16),then that endpoint has an incomplete transfer
John
We have replaced the original code with the following code for both IN and OUT endpoints and retested:
if (gintsts & GINTSTS_INCOMPL_SOIN) {
u32 idx, epctl_reg, ctrl, dsts;
struct s3c_hsotg_ep *hs_ep;+ dsts = readl(hsotg->regs + DSTS);
dev_dbg(hsotg->dev, "%s: GINTSTS_INCOMPL_SOIN\n", __func__);
for (idx = 1; idx < MAX_EPS_CHANNELS; idx++) {
hs_ep = hsotg->eps_in[idx];
if (!hs_ep->isochronous || hs_ep->has_correct_parity)
continue;
epctl_reg = DIEPCTL(idx);
ctrl = readl(hsotg->regs + epctl_reg);+ if (((dsts >> DSTS_SOFFN_SHIFT) & 1) !=
+ ((ctrl >> DXEPCTL_EOFRNUM) & 1))
+ continue;
if (ctrl & DXEPCTL_EOFRNUM) ctrl |= DXEPCTL_SETEVENFR; else ctrl |= DXEPCTL_SETODDFR; writel(ctrl, hsotg->regs + epctl_reg); break; } writel(GINTSTS_INCOMPL_SOIN, hsotg->regs + GINTSTS); }
It still works. However, based on our experience with the audio gadget, USB host would either always use odd microframes or even microframes. It does not change the parity and hence gadget either always works or never works without this patch. So we can call hosts either odd or even.
When a gadget connects to even host, since it has even parity by default, it would receive transfer complete packets. So it recognizes it has correct parity and stop flipping.
When a gadget connects to an odd host, it would flip all parities to the correct one on all endpoints after receiving an incomplete interrupt from any of the endpoints connected to this odd host using the original code. On the other hand it would require an interrupt for each connected endpoint in order to get the parity right using the new code above.
Even when connected to multiple PCs with different parities, the worst case number of swaps (and hence lost packets) would be the number of connected hosts when using the original code, and the total number of endpoints, which is bigger than the number of connected hosts, when using the new code.
Please, let us know if you would prefer the new code anyway.
Regards,
Roman
Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous mode
Quoted 206 lines · Roman Bacik
Quoted 141 lines
-----Original Message-----
From: Roman Bacik
Sent: September-09-15 7:59 PM
To: 'John Youn'; Scott Branden; 'Greg Kroah-Hartman'; 'linux- [email protected]'
Cc: '[email protected]'; bcm-kernel-feedback-list
Subject: RE: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 55 lines
-----Original Message-----
From: Roman Bacik
Sent: September-09-15 7:36 PM
To: 'John Youn'; Scott Branden; Greg Kroah-Hartman; linux- [email protected]
Cc: [email protected]; bcm-kernel-feedback-list
Subject: RE: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 46 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-09-15 7:25 PM
To: Roman Bacik; John Youn; Scott Branden; Greg Kroah-Hartman; linux- [email protected]
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 36 lines · Roman Bacik
Quoted 36 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-09-15 7:11 PM
To: Roman Bacik; John Youn; Scott Branden; Greg Kroah-Hartman; linux- [email protected]
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 16 lines · Roman Bacik
Quoted 16 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-03-15 11:53 PM
To: Scott Branden; John Youn; Greg Kroah-Hartman; linux- [email protected]; Roman Bacik
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 6 lines · Scott Branden
From: Roman Bacik <[email protected]>
USB OTG driver in isochronous mode has to set the parity of the receiving microframe. The parity is set to even by default. This causes problems for an audio gadget, if the host starts transmitting on odd
Quoted 5 lines
Quoted 5 lines
microframes.
Quoted 4 lines
This fix uses Incomplete Periodic Transfer interrupt to toggle between even and odd parity until the Transfer Complete interrupt is
received.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Signed-off-by Roman Bacik <[email protected]>Reviewed-by Abhinav Ratna <[email protected]>Reviewed-by Srinath MannamQuoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 4 lines
Signed-off-by Scott Branden <[email protected]>--- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/gadget.c | 51++++++++++++++++++++++++++++++++++++++++++++++-
Quoted 20 lines
drivers/usb/dwc2/hw.h | 1 + 3 files changed, 52 insertions(+), 1 deletion(-)drivers/usb/dwc2/core.h +1
-0@@ -150,6 +150,7 @@ struct s3c_hsotg_ep { unsigned int periodic:1; unsigned int isochronous:1; unsigned int send_zlp:1; + unsigned int has_correct_parity:1;char name[10 ]; };(quoted diff) +0
-0
b/drivers/usb/dwc2/gadget.cindex 4d47b7c..fac3e2f 100644drivers/usb/dwc2/gadget.c +0
-0@@ -1954,6 +1954,7 @@ static void s3c_hsotg_epint(structQuoted 1 line
dwc2_hsotg*hsotg, unsigned int idx,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/usb/dwc2/gadget.c
Quoted 7 lines
drivers/usb/dwc2/gadget.c +1
-0ints &= ~DXEPINT_XFERCOMPL ;if (ints &DXEPINT_XFERCOMPL ) { + hs_ep->has_correct_parity =1 ;if (hs_ep->isochronous && hs_ep->interval ==1 ) {if (ctrl &DXEPCTL_EOFRNUM ) ctrl |= DXEPCTL_SETEVENFR; @@ -2316,7 +2317,8 @@ void
Quoted 42 lines
Quoted 28 lines
s3c_hsotg_core_init_disconnected(struct
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
dwc2_hsotg*hsotg,drivers/usb/dwc2/gadget.c
Quoted 6 lines
drivers/usb/dwc2/gadget.c +2
-1GINTSTS_CONIDSTSCHNG |GINTSTS_USBRST |GINTSTS_RESETDET |GINTSTS_ENUMDONE |GINTSTS_OTGINT |GINTSTS_USBSUSP | - GINTSTS_WKUPINT, +GINTSTS_WKUPINT | + GINTSTS_INCOMPL_SOIN |
GINTSTS_INCOMPL_SOOUT,Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/usb/dwc2/gadget.c +0
-0hsotg->regs + GINTMSK);if (using_dma (hsotg))@@ -2581,6 +2583,52 @@ irq_retry:s3c_hsotg_dump (hsotg); }Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/usb/dwc2/gadget.c irq_retry: · line 2590
Quoted 5 lines
drivers/usb/dwc2/gadget.c +5
-0+if (gintsts &GINTSTS_INCOMPL_SOIN ) { +u32 idx, epctl_reg, ctrl; +struct s3c_hsotg_ep *hs_ep; + + dev_dbg(hsotg->dev, "%s:GINTSTS_INCOMPL_SOIN\n",
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
__func__);drivers/usb/dwc2/gadget.c irq_retry: · line 2591
Quoted 1 line
drivers/usb/dwc2/gadget.c +1
-0+for (idx =1 ; idx <MAX_EPS_CHANNELS ; idx++) {Valid endpoints are only up to
hsotg->num_of_epsso this might crash on certain configurations.Quoted 13 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Also, have you tried to find the endpoint which caused the incomplete interrupt by reading the control registers as described in
the databook?
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
We are using procedure based on description from this source:
Synopsys, Inc. SolvNet 527
DesignWare.com
3.00a
April 2012
USB 2.0 Hi-Speed On-The-Go (OTG) Databook Isochronous Endpointsin
Quoted 43 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
DWC_otgSlave ModeSynopsys databook is not in a public domain to quote the exact paragraph
here. You can find it in Chapter E, pp 526-527. There is no register in this databook, which would provide information about the source endpoint of the incomplete interrupt, as you have
described.
Quoted 35 lines
Quoted 34 lines
Quoted 10 lines
Quoted 10 lines
Quoted 3 lines
Please, provide an exact reference and possibly enough information that
we can turn it into a working code.
Quoted 1 line
You can check the source of the interrupt by reading the DSTS and ep control registers as described in the databook page 526, last bullet, and 527 first bullet.
Quoted 5 lines
Quoted 2 lines
John
Yes, that is exactly what we are doing what is described in the last bullet of
526 and the first two bullets of page 527. So what is the problem?
Quoted 1 line
Maybe I missed it. Where exactly are you doing it like it says in these two paragraphs?
Quote:
GINTSTS.incompISOIN is a global interrupt. Therefore, when more than one isochronous endpoints is active, then the application must determine which isochronous IN endpoints have incomplete data.
To accomplish this, read DSTS and DIEPCTLn for all isochronous endpoints. If DSTS.SOFFN[0] =DIEPCTLn.EO_FrNum (Bit 16),then that endpoint has an incomplete transfer
John
We have replaced the original code with the following code for both IN and OUT endpoints and retested:
if (gintsts & GINTSTS_INCOMPL_SOIN) { u32 idx, epctl_reg, ctrl, dsts; struct s3c_hsotg_ep *hs_ep;(quoted diff) +1
-0+ dsts = readl(hsotg->regs + DSTS);dev_dbg(hsotg->dev, "%s: GINTSTS_INCOMPL_SOIN\n", __func__); for (idx = 1; idx < MAX_EPS_CHANNELS; idx++) { hs_ep = hsotg->eps_in[idx]; if (!hs_ep->isochronous || hs_ep->has_correct_parity) continue; epctl_reg = DIEPCTL(idx); ctrl = readl(hsotg->regs + epctl_reg);(quoted diff) +3
-0+ if (((dsts >> DSTS_SOFFN_SHIFT) & 1) != + ((ctrl >> DXEPCTL_EOFRNUM) & 1)) + continue;
Quoted 10 lines
if (ctrl & DXEPCTL_EOFRNUM) ctrl |= DXEPCTL_SETEVENFR; else ctrl |= DXEPCTL_SETODDFR; writel(ctrl, hsotg->regs + epctl_reg); break; } writel(GINTSTS_INCOMPL_SOIN, hsotg->regs + GINTSTS); }
Yes that is what I was asking about, checking for the source of the interrupt.
But I'm convinced that the original code should be ok even with multiple iso endpoints given that all you are doing is toggling to find the correct parity the first time.
However a full implementation of this interrupt would need to know the exact source because, even with parity set, you could get this interrupt and will need to handle it properly. For example if you are slow reading or writing the fifo.
Quoted 6 lines
It still works. However, based on our experience with the audio gadget, USB host would either always use odd microframes or even microframes. It does not change the parity and hence gadget either always works or never works without this patch. So we can call hosts either odd or even.
When a gadget connects to even host, since it has even parity by default, it would receive transfer complete packets. So it recognizes it has correct parity and stop flipping.
When a gadget connects to an odd host, it would flip all parities to the correct one on all endpoints after receiving an incomplete interrupt from any of the endpoints connected to this odd host using the original code. On the other hand it would require an interrupt for each connected endpoint in order to get the parity right using the new code above.
You would still get this interrupt just once per microframe. And you would determine all the endpoints that missed that microframe at once in the loop. The result should be the same as before, the only overhead being the register read/check per iteration.
Quoted 3 lines
Even when connected to multiple PCs with different parities, the worst case number of swaps (and hence lost packets) would be the number of connected hosts when using the original code, and the total number of endpoints, which is bigger than the number of connected hosts, when using the new code.
Please, let us know if you would prefer the new code anyway.
The original code is fine. But we do plan to update the gadget code for isochronous so we may change how this is handled in the future.
If you resubmit with my other feedback I will review and test on our platforms.
Regards,
John
RE: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous mode
Quoted 273 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-10-15 12:08 PM
To: Roman Bacik; John Youn; Scott Branden; Greg Kroah-Hartman; linux- [email protected]
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 134 lines · Roman Bacik
Quoted 134 lines
-----Original Message-----
From: Roman Bacik
Sent: September-09-15 7:59 PM
To: 'John Youn'; Scott Branden; 'Greg Kroah-Hartman'; 'linux- [email protected]'
Cc: '[email protected]'; bcm-kernel-feedback-list
Subject: RE: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 55 lines
-----Original Message-----
From: Roman Bacik
Sent: September-09-15 7:36 PM
To: 'John Youn'; Scott Branden; Greg Kroah-Hartman; linux- [email protected]
Cc: [email protected]; bcm-kernel-feedback-list
Subject: RE: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 46 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-09-15 7:25 PM
To: Roman Bacik; John Youn; Scott Branden; Greg Kroah-Hartman; linux- [email protected]
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 36 lines · Roman Bacik
Quoted 36 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-09-15 7:11 PM
To: Roman Bacik; John Youn; Scott Branden; Greg Kroah-Hartman; linux- [email protected]
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 16 lines · Roman Bacik
Quoted 16 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-03-15 11:53 PM
To: Scott Branden; John Youn; Greg Kroah-Hartman; linux- [email protected]; Roman Bacik
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 6 lines · Scott Branden
From: Roman Bacik <[email protected]>
USB OTG driver in isochronous mode has to set the parity of the receiving microframe. The parity is set to even by default. This causes problems for an audio gadget, if the host starts transmitting on odd
Quoted 5 lines
Quoted 5 lines
microframes.
Quoted 4 lines
This fix uses Incomplete Periodic Transfer interrupt to toggle between even and odd parity until the Transfer Complete interrupt is
received.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Signed-off-by Roman Bacik <[email protected]>Reviewed-by Abhinav Ratna <[email protected]>Reviewed-by Srinath MannamQuoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 4 lines
Signed-off-by Scott Branden <[email protected]>--- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/gadget.c | 51++++++++++++++++++++++++++++++++++++++++++++++-
Quoted 20 lines
drivers/usb/dwc2/hw.h | 1 + 3 files changed, 52 insertions(+), 1 deletion(-)drivers/usb/dwc2/core.h +1
-0@@ -150,6 +150,7 @@ struct s3c_hsotg_ep { unsigned int periodic:1; unsigned int isochronous:1; unsigned int send_zlp:1; + unsigned int has_correct_parity:1;char name[10 ]; };(quoted diff) +0
-0
b/drivers/usb/dwc2/gadget.cindex 4d47b7c..fac3e2f 100644drivers/usb/dwc2/gadget.c +0
-0@@ -1954,6 +1954,7 @@ static void s3c_hsotg_epint(structQuoted 1 line
dwc2_hsotg*hsotg, unsigned int idx,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/usb/dwc2/gadget.c
Quoted 7 lines
drivers/usb/dwc2/gadget.c +1
-0ints &= ~DXEPINT_XFERCOMPL ;if (ints &DXEPINT_XFERCOMPL ) { + hs_ep->has_correct_parity =1 ;if (hs_ep->isochronous && hs_ep->interval ==1 ) {if (ctrl &DXEPCTL_EOFRNUM ) ctrl |= DXEPCTL_SETEVENFR; @@ -2316,7 +2317,8 @@ void
Quoted 34 lines
Quoted 34 lines
s3c_hsotg_core_init_disconnected(struct
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
dwc2_hsotg*hsotg,drivers/usb/dwc2/gadget.c
Quoted 6 lines
drivers/usb/dwc2/gadget.c +2
-1GINTSTS_CONIDSTSCHNG |GINTSTS_USBRST |GINTSTS_RESETDET |GINTSTS_ENUMDONE |GINTSTS_OTGINT |GINTSTS_USBSUSP | - GINTSTS_WKUPINT, +GINTSTS_WKUPINT | + GINTSTS_INCOMPL_SOIN |
GINTSTS_INCOMPL_SOOUT,Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/usb/dwc2/gadget.c +0
-0hsotg->regs + GINTMSK);if (using_dma (hsotg))@@ -2581,6 +2583,52 @@ irq_retry:s3c_hsotg_dump (hsotg); }Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/usb/dwc2/gadget.c irq_retry: · line 2590
Quoted 5 lines
drivers/usb/dwc2/gadget.c +5
-0+if (gintsts &GINTSTS_INCOMPL_SOIN ) { +u32 idx, epctl_reg, ctrl; +struct s3c_hsotg_ep *hs_ep; + + dev_dbg(hsotg->dev, "%s:GINTSTS_INCOMPL_SOIN\n",
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
__func__);drivers/usb/dwc2/gadget.c irq_retry: · line 2591
Quoted 1 line
drivers/usb/dwc2/gadget.c +1
-0+for (idx =1 ; idx <MAX_EPS_CHANNELS ; idx++) {Valid endpoints are only up to
hsotg->num_of_epsso this might crash on certain configurations.Also, have you tried to find the endpoint which caused the incomplete interrupt by reading the control registers as described in
the databook?
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
We are using procedure based on description from this source:
Synopsys, Inc. SolvNet 527
DesignWare.com
3.00a
April 2012
USB 2.0 Hi-Speed On-The-Go (OTG) Databook IsochronousEndpoints
Quoted 40 lines
Quoted 40 lines
Quoted 8 lines
in
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
DWC_otgSlave ModeSynopsys databook is not in a public domain to quote the exact paragraph
here. You can find it in Chapter E, pp 526-527. There is no register in this databook, which would provide information about the source endpoint of the incomplete interrupt, as you have
described.
Quoted 31 lines
Quoted 31 lines
Quoted 10 lines
Quoted 10 lines
Quoted 3 lines
Please, provide an exact reference and possibly enough information that
we can turn it into a working code.
Quoted 1 line
You can check the source of the interrupt by reading the DSTS and ep control registers as described in the databook page 526, last bullet, and 527 first bullet.
Quoted 5 lines
Quoted 2 lines
John
Yes, that is exactly what we are doing what is described in the last bullet of
526 and the first two bullets of page 527. So what is the problem?
Quoted 1 line
Maybe I missed it. Where exactly are you doing it like it says in these two paragraphs?
Quote:
GINTSTS.incompISOIN is a global interrupt. Therefore, when more than one isochronous endpoints is active, then the application must determine which isochronous IN endpoints have incomplete data.
To accomplish this, read DSTS and DIEPCTLn for all isochronous endpoints. If DSTS.SOFFN[0] =DIEPCTLn.EO_FrNum (Bit 16),then that endpoint has an incomplete transfer
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
John
We have replaced the original code with the following code for both IN and
OUT endpoints and retested:
Quoted 7 lines
if (gintsts & GINTSTS_INCOMPL_SOIN) { u32 idx, epctl_reg, ctrl, dsts; struct s3c_hsotg_ep *hs_ep;(quoted diff) +1
-0+ dsts = readl(hsotg->regs + DSTS);dev_dbg(hsotg->dev, "%s: GINTSTS_INCOMPL_SOIN\n",
__func__);Quoted 14 lines
for (idx = 1; idx < MAX_EPS_CHANNELS; idx++) { hs_ep = hsotg->eps_in[idx]; if (!hs_ep->isochronous || hs_ep- has_correct_parity) continue; epctl_reg = DIEPCTL(idx); ctrl = readl(hsotg->regs + epctl_reg);(quoted diff) +3
-0+ if (((dsts >> DSTS_SOFFN_SHIFT) & 1) != + ((ctrl >> DXEPCTL_EOFRNUM) & 1)) + continue;Quoted 10 lines
if (ctrl & DXEPCTL_EOFRNUM) ctrl |= DXEPCTL_SETEVENFR; else ctrl |= DXEPCTL_SETODDFR; writel(ctrl, hsotg->regs + epctl_reg); break; } writel(GINTSTS_INCOMPL_SOIN, hsotg->regs + GINTSTS); }Yes that is what I was asking about, checking for the source of the interrupt.
But I'm convinced that the original code should be ok even with multiple iso endpoints given that all you are doing is toggling to find the correct parity the first time.
However a full implementation of this interrupt would need to know the exact source because, even with parity set, you could get this interrupt and will need to handle it properly. For example if you are slow reading or writing the fifo.
Quoted 1 line
It still works. However, based on our experience with the audio gadget,
USB host would either always use odd microframes or even microframes. It does not change the parity and hence gadget either always works or never works without this patch. So we can call hosts either odd or even.
Quoted 2 lines
When a gadget connects to even host, since it has even parity by default, it
would receive transfer complete packets. So it recognizes it has correct parity and stop flipping.
Quoted 2 lines
When a gadget connects to an odd host, it would flip all parities to the
correct one on all endpoints after receiving an incomplete interrupt from any of the endpoints connected to this odd host using the original code. On the other hand it would require an interrupt for each connected endpoint in order to get the parity right using the new code above.
Quoted 1 line
You would still get this interrupt just once per microframe. And you would determine all the endpoints that missed that microframe at once in the loop. The result should be the same as before, the only overhead being the register read/check per iteration.
Quoted 1 line
Even when connected to multiple PCs with different parities, the worst
case number of swaps (and hence lost packets) would be the number of connected hosts when using the original code, and the total number of endpoints, which is bigger than the number of connected hosts, when using the new code.
Quoted 2 lines
Please, let us know if you would prefer the new code anyway.
Quoted 10 lines
The original code is fine. But we do plan to update the gadget code for isochronous so we may change how this is handled in the future.
If you resubmit with my other feedback I will review and test on our platforms.
Regards,
John
I will resubmit with the change to the for loop bound replacing MAX_EPS_CHANNELS with hsotg->num_of_eps and add a method for parity change for three times repeated code:
if (ctrl & DXEPCTL_EOFRNUM) ctrl |= DXEPCTL_SETEVENFR; else ctrl |= DXEPCTL_SETODDFR; writel(ctrl, hsotg->regs + epctl_reg);
Regards,
Roman
RE: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous mode
In reply to John YounQuoted 134 lines
-----Original Message-----
From: Roman Bacik
Sent: September-09-15 7:17 PM
To: 'John Youn'; Scott Branden; Greg Kroah-Hartman; linux- [email protected]
Cc: [email protected]; bcm-kernel-feedback-list
Subject: RE: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 63 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-09-15 7:11 PM
To: Roman Bacik; John Youn; Scott Branden; Greg Kroah-Hartman; linux- [email protected]
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 16 lines · Roman Bacik
Quoted 16 lines
-----Original Message-----
From: John Youn [mailto:[email protected]]
Sent: September-03-15 11:53 PM
To: Scott Branden; John Youn; Greg Kroah-Hartman; linux- [email protected]; Roman Bacik
Cc: [email protected]; bcm-kernel-feedback-list
Subject: Re: [PATCH v2 1/1] usb: dwc2: gadget: parity fix in isochronous modeQuoted 6 lines · Scott Branden
From: Roman Bacik <[email protected]>
USB OTG driver in isochronous mode has to set the parity of the receiving microframe. The parity is set to even by default. This causes problems for an audio gadget, if the host starts transmitting on odd
Quoted 5 lines
Quoted 5 lines
microframes.
Quoted 4 lines
This fix uses Incomplete Periodic Transfer interrupt to toggle between even and odd parity until the Transfer Complete interrupt is
received.
Quoted 31 lines
Quoted 31 lines
Quoted 8 lines
Signed-off-by Roman Bacik <[email protected]>Reviewed-by Abhinav Ratna <[email protected]>Reviewed-by Srinath Mannam <[email protected]>Signed-off-by Scott Branden <[email protected]>--- drivers/usb/dwc2/core.h | 1 + drivers/usb/dwc2/gadget.c | 51++++++++++++++++++++++++++++++++++++++++++++++-
Quoted 20 lines
drivers/usb/dwc2/hw.h | 1 + 3 files changed, 52 insertions(+), 1 deletion(-)drivers/usb/dwc2/core.h +1
-0@@ -150,6 +150,7 @@ struct s3c_hsotg_ep { unsigned int periodic:1; unsigned int isochronous:1; unsigned int send_zlp:1; + unsigned int has_correct_parity:1;char name[10 ]; };drivers/usb/dwc2/gadget.c +0
-0@@ -1954,6 +1954,7 @@ static void s3c_hsotg_epint(structQuoted 1 line
dwc2_hsotg*hsotg, unsigned int idx,
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/usb/dwc2/gadget.c void
Quoted 8 lines
drivers/usb/dwc2/gadget.c +1
-0ints &= ~DXEPINT_XFERCOMPL ;if (ints &DXEPINT_XFERCOMPL ) { + hs_ep->has_correct_parity =1 ;if (hs_ep->isochronous && hs_ep->interval ==1 ) {if (ctrl &DXEPCTL_EOFRNUM ) ctrl |=DXEPCTL_SETEVENFR ;@@ -2316,7 +2317,8 @@ voids3c_hsotg_core_init_disconnected(struct
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
dwc2_hsotg*hsotg,Quoted 10 lines
drivers/usb/dwc2/gadget.c +2
-1GINTSTS_CONIDSTSCHNG |GINTSTS_USBRST |GINTSTS_RESETDET |GINTSTS_ENUMDONE |GINTSTS_OTGINT |GINTSTS_USBSUSP | -GINTSTS_WKUPINT , +GINTSTS_WKUPINT | +GINTSTS_INCOMPL_SOIN |GINTSTS_INCOMPL_SOOUT , hsotg->regs + GINTMSK);if (using_dma (hsotg))drivers/usb/dwc2/gadget.c irq_retry: · line 2590
Quoted 8 lines
drivers/usb/dwc2/gadget.c +5
-0@@ -2581,6 +2583,52 @@ irq_retry:s3c_hsotg_dump (hsotg); } +if (gintsts &GINTSTS_INCOMPL_SOIN ) { +u32 idx, epctl_reg, ctrl; +struct s3c_hsotg_ep *hs_ep; + + dev_dbg(hsotg->dev, "%s: GINTSTS_INCOMPL_SOIN\n",
__func__);Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/usb/dwc2/gadget.c irq_retry: · line 2591
Quoted 1 line
drivers/usb/dwc2/gadget.c +1
-0+for (idx =1 ; idx <MAX_EPS_CHANNELS ; idx++) {Valid endpoints are only up to
hsotg->num_of_epsso this might crash on certain configurations.Also, have you tried to find the endpoint which caused the incomplete interrupt by reading the control registers as described in the
databook?
Quoted 26 lines
Quoted 11 lines
Quoted 1 line
We are using procedure based on description from this source:
Synopsys, Inc. SolvNet 527
DesignWare.com
3.00a
April 2012
USB 2.0 Hi-Speed On-The-Go (OTG) Databook Isochronous Endpoints inDWC_otgSlave ModeQuoted 2 lines
Synopsys databook is not in a public domain to quote the exact paragraph
here. You can find it in Chapter E, pp 526-527. There is no register in this databook, which would provide information about the source endpoint of the incomplete interrupt, as you have described.
Quoted 3 lines
Please, provide an exact reference and possibly enough information that
we can turn it into a working code.
Quoted 1 line
You can check the source of the interrupt by reading the DSTS and ep control registers as described in the databook page 526, last bullet, and 527 first bullet.
Quoted 5 lines
Quoted 2 lines
John
Yes, that is exactly what we are doing what is described in the last bullet of 526 and the first two bullets of page 527. So what is the problem?
In order to avoid any further confusion, here is the quote of the three bullets:
"- GINTSTS.incompISOIN is a global interrupt. Therefore, when more than one isochronous endpoints is active, then the application must determine which isochronous IN endpoints have incomplete data.
- To accomplish this, read DSTS and DIEPCTLn for all isochronous endpoints. If DSTS.SOFFN[0] =DIEPCTLn.EO_FrNum (Bit 16), then that endpoint has an incomplete transfer.
- When there is an incomplete transfer for an endpoint, then toggle the Even/Odd bit."
We believe that this is exactly what we coded in this patch.
Regards,
Roman