Skip to contentSkip to conversation

usb: dwc2: host: fix the data toggle error in full speed descriptor dma

PATCH In review Jianqiang Tang 2 participants 2 messages Jan 26, 2016 – Feb 16, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: dwc2: host: fix the data toggle error in full speed descriptor dma

From: "Tang, Jianqiang" <[email protected]>

There will be data toggle error happen for full speed buld-out transfer. The data toggle bit is saved in qh for non-control transfers, it is wrong to check the qtd for that case.

Also fix one static analysis tool issue after fix the data toggle error.

---
 drivers/usb/dwc2/hcd_ddma.c | 2 +-
 drivers/usb/dwc2/hcd_intr.c | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/usb/dwc2/hcd_ddma.c +1 -1
index 36606fc..6b18956 100644
@@ -1258,7 +1258,7 @@ static void dwc2_complete_non_isoc_xfer_ddma(struct dwc2_hsotg *hsotg,
 		 */
 		if (halt_status == DWC2_HC_XFER_STALL)
 			qh->data_toggle = DWC2_HC_PID_DATA0;
-		else if (qtd)
+		else
 			dwc2_hcd_save_data_toggle(hsotg, chan, chnum, qtd);
 	}
 
drivers/usb/dwc2/hcd_intr.c +4 -0
index f825380..918773f 100644
@@ -530,6 +530,10 @@ void dwc2_hcd_save_data_toggle(struct dwc2_hsotg *hsotg,
 		else
 			chan->qh->data_toggle = DWC2_HC_PID_DATA1;
 	} else {
+		if (!qtd) {
+			dev_err(hsotg->dev, "qtd is null, return\n");
+			return;
+		}
 		if (pid == TSIZ_SC_MC_PID_DATA0)
 			qtd->data_toggle = DWC2_HC_PID_DATA0;
 		else
Signature · 1 line
1.9.1
#1 lore raw
Quoted 34 lines · Jianqiang Tang

From: "Tang, Jianqiang" <[email protected]>

There will be data toggle error happen for full speed buld-out transfer. The data toggle bit is saved in qh for non-control transfers, it is wrong to check the qtd for that case.

Also fix one static analysis tool issue after fix the data toggle error.

---
 drivers/usb/dwc2/hcd_ddma.c | 2 +-
 drivers/usb/dwc2/hcd_intr.c | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/usb/dwc2/hcd_ddma.c +1 -1
index 36606fc..6b18956 100644
@@ -1258,7 +1258,7 @@ static void dwc2_complete_non_isoc_xfer_ddma(struct dwc2_hsotg *hsotg,
 		 */
 		if (halt_status == DWC2_HC_XFER_STALL)
 			qh->data_toggle = DWC2_HC_PID_DATA0;
-		else if (qtd)
+		else
 			dwc2_hcd_save_data_toggle(hsotg, chan, chnum, qtd);
 	}
 
drivers/usb/dwc2/hcd_intr.c +0 -0
index f825380..918773f 100644

drivers/usb/dwc2/hcd_intr.c void dwc2_hcd_save_data_toggle(struct dwc2_hsotg *hsotg, · line 539

Quoted 10 lines
drivers/usb/dwc2/hcd_intr.c +4 -0
@@ -530,6 +530,10 @@ void dwc2_hcd_save_data_toggle(struct dwc2_hsotg *hsotg,
 		else
 			chan->qh->data_toggle = DWC2_HC_PID_DATA1;
 	} else {
+		if (!qtd) {
+			dev_err(hsotg->dev, "qtd is null, return\n");
+			return;
+		}
 		if (pid == TSIZ_SC_MC_PID_DATA0)
 			qtd->data_toggle = DWC2_HC_PID_DATA0;
 		else

Thanks for this. I've applied this internally for testing and added WARNs in the dwc2_hcd_save_data_toggle function(). I will resend for review along with another fix that we have for DDMA in that same area.

Regards,
John