Skip to contentSkip to conversation

usb: dwc2: Disable gadget descriptor DMA for Sophgo CV18XX/SG200X

PATCH In review Chen-Yu Yeh 3 participants 3 messages Oct 24 – Nov 5

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

PATCH 1/1 usb: dwc2: Disable gadget descriptor DMA for Sophgo CV18XX/SG200X

dwc2_set_cv1800_params() disables gadget DMA (g_dma) but leaves g_dma_desc at its default, which dwc2_set_default_params() takes from the hardware capability. Descriptor DMA requires g_dma, so dwc2_check_params() rejects the combination at probe time:

dwc2 4340000.usb: dwc2_check_params: Invalid parameter g_dma_desc=1

The check then clears g_dma_desc, so the final configuration is already correct and only the warning is spurious. Disable g_dma_desc together with g_dma in the platform parameters instead.

The gadget parameters are only set up when dr_mode is "peripheral" or "otg". All in-tree CV18XX/SG200X boards use "host", which is why this has gone unnoticed.

Tested on Milk-V Duo 256M (SG2002) with CONFIG_USB_DWC2_DUAL_ROLE=y and dr_mode = "peripheral": the warning is gone.

Fixes 63aa7ab955e7 ("usb: dwc2: add support for Sophgo CV18XX/SG200X series SoC")
---
 drivers/usb/dwc2/params.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/dwc2/params.c +1 -0
index 091bfcfef753..6941705e426d 100644
@@ -226,6 +226,7 @@ static void dwc2_set_cv1800_params(struct dwc2_hsotg *hsotg)
 	p->otg_caps.srp_support = false;
 	p->host_dma = false;
 	p->g_dma = false;
+	p->g_dma_desc = false;
 	p->speed = DWC2_SPEED_PARAM_HIGH;
 	p->phy_type = DWC2_PHY_TYPE_PARAM_UTMI;
 	p->phy_utmi_width = 16;
Signature · 1 line
2.43.0
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 15 lines

dwc2_set_cv1800_params() disables gadget DMA (g_dma) but leaves g_dma_desc at its default, which dwc2_set_default_params() takes from the hardware capability. Descriptor DMA requires g_dma, so dwc2_check_params() rejects the combination at probe time:

dwc2 4340000.usb: dwc2_check_params: Invalid parameter g_dma_desc=1

The check then clears g_dma_desc, so the final configuration is already correct and only the warning is spurious. Disable g_dma_desc together with g_dma in the platform parameters instead.

The gadget parameters are only set up when dr_mode is "peripheral" or "otg". All in-tree CV18XX/SG200X boards use "host", which is why this has gone unnoticed.

Quoted 5 lines

Tested on Milk-V Duo 256M (SG2002) with CONFIG_USB_DWC2_DUAL_ROLE=y and dr_mode = "peripheral": the warning is gone.

Fixes 63aa7ab955e7 ("usb: dwc2: add support for Sophgo CV18XX/SG200X series SoC")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Acked-by on v1 1/1
#2 lore raw
In reply to Chen-Yu Yeh
Quoted 40 lines · Chen-Yu Yeh

dwc2_set_cv1800_params() disables gadget DMA (g_dma) but leaves g_dma_desc at its default, which dwc2_set_default_params() takes from the hardware capability. Descriptor DMA requires g_dma, so dwc2_check_params() rejects the combination at probe time:

dwc2 4340000.usb: dwc2_check_params: Invalid parameter g_dma_desc=1

The check then clears g_dma_desc, so the final configuration is already correct and only the warning is spurious. Disable g_dma_desc together with g_dma in the platform parameters instead.

The gadget parameters are only set up when dr_mode is "peripheral" or "otg". All in-tree CV18XX/SG200X boards use "host", which is why this has gone unnoticed.

Tested on Milk-V Duo 256M (SG2002) with CONFIG_USB_DWC2_DUAL_ROLE=y and dr_mode = "peripheral": the warning is gone.

Fixes 63aa7ab955e7 ("usb: dwc2: add support for Sophgo CV18XX/SG200X series SoC")
---
 drivers/usb/dwc2/params.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/dwc2/params.c +1 -0
index 091bfcfef753..6941705e426d 100644
@@ -226,6 +226,7 @@ static void dwc2_set_cv1800_params(struct dwc2_hsotg *hsotg)
 	p->otg_caps.srp_support = false;
 	p->host_dma = false;
 	p->g_dma = false;
+	p->g_dma_desc = false;
 	p->speed = DWC2_SPEED_PARAM_HIGH;
 	p->phy_type = DWC2_PHY_TYPE_PARAM_UTMI;
 	p->phy_utmi_width = 16;
Signature · 1 line
2.43.0

Thanks,
Thinh