树莓派CM4 usb dwc2驱动报:dwc2_hc_chhltd_intr_dma: Channel 7 - ChHltd set, but reason is unknown

问题描述:

  在CM4的USB2.0外置USB口上接了一个realtek的usb2eth网卡,型号如下:

ID 0bda:8153 Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet Adapter

usb2eth网卡不能稳定工作,dmesg里能看到kernel里dwc2驱动一直报warning。

Dec 10 15:11:23 raspberrypi kernel: [ 8505.396473] dwc2 fe980000.usb: dwc2_hc_chhltd_intr_dma: Channel 7 - ChHltd set, but reason is unknown
Dec 10 15:11:23 raspberrypi kernel: [ 8505.396490] dwc2 fe980000.usb: hcint 0x00000002, intsts 0x04400009
Dec 10 15:11:24 raspberrypi kernel: [ 8506.367465] dwc2 fe980000.usb: dwc2_hc_chhltd_intr_dma: Channel 1 - ChHltd set, but reason is unknown
Dec 10 15:11:24 raspberrypi kernel: [ 8506.367472] dwc2 fe980000.usb: hcint 0x00000002, intsts 0x04400001
Dec 10 15:11:30 raspberrypi kernel: [ 8512.359278] dwc2 fe980000.usb: dwc2_hc_chhltd_intr_dma: Channel 5 - ChHltd set, but reason is unknown
Dec 10 15:11:30 raspberrypi kernel: [ 8512.359285] dwc2 fe980000.usb: hcint 0x00000002, intsts 0x04400001
Dec 10 15:11:30 raspberrypi kernel: [ 8512.359415] dwc2 fe980000.usb: dwc2_hc_chhltd_intr_dma: Channel 7 - ChHltd set, but reason is unknown
Dec 10 15:11:30 raspberrypi kernel: [ 8512.359420] dwc2 fe980000.usb: hcint 0x00000002, intsts 0x04400001
Dec 10 15:11:30 raspberrypi kernel: [ 8512.359650] dwc2 fe980000.usb: dwc2_hc_chhltd_intr_dma: Channel 6 - ChHltd set, but reason is unknown
Dec 10 15:11:30 raspberrypi kernel: [ 8512.359654] dwc2 fe980000.usb: hcint 0x00000002, intsts 0x04400001
Dec 10 15:11:30 raspberrypi kernel: [ 8512.359682] dwc2 fe980000.usb: dwc2_hc_chhltd_intr_dma: Channel 3 - ChHltd set, but reason is unknown
Dec 10 15:11:30 raspberrypi kernel: [ 8512.359686] dwc2 fe980000.usb: hcint 0x00000002, intsts 0x04400001
Dec 10 15:11:30 raspberrypi kernel: [ 8512.359774] dwc2 fe980000.usb: dwc2_hc_chhltd_intr_dma: Channel 2 - ChHltd set, but reason is unknown
Dec 10 15:11:30 raspberrypi kernel: [ 8512.359778] dwc2 fe980000.usb: hcint 0x00000002, intsts 0x04400001
Dec 10 15:11:30 raspberrypi kernel: [ 8512.361090] dwc2 fe980000.usb: dwc2_hc_chhltd_intr_dma: Channel 1 - ChHltd set, but reason is unknown
Dec 10 15:11:30 raspberrypi kernel: [ 8512.361095] dwc2 fe980000.usb: hcint 0x00000002, intsts 0x04400001

 

解决办法:

diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c
index d5f4ec1..4989ec7 100644
--- a/drivers/usb/dwc2/hcd_intr.c
+++ b/drivers/usb/dwc2/hcd_intr.c
@@ -1180,7 +1180,10 @@ static void dwc2_update_urb_state_abn(struct dwc2_hsotg *hsotg,
 
        if (urb->actual_length + xfer_length > urb->length) {
                dev_warn(hsotg->dev, "%s(): trimming xfer length\n", __func__);
-               xfer_length = urb->length - urb->actual_length;
+               if (urb->length & 0x3)
+                       xfer_length = 0;
+               else
+                       xfer_length = urb->length - urb->actual_length;
        }
 
        urb->actual_length += xfer_length;
@@ -2065,8 +2068,6 @@ static void dwc2_hc_n_intr(struct dwc2_hsotg *hsotg, int chnum)
                         hcint, hcintmsk, hcint & hcintmsk);
        }
 
-       dwc2_writel(hsotg, hcint, HCINT(chnum));
-
        /*
         * If we got an interrupt after someone called
         * dwc2_hcd_endpoint_disable() we don't want to crash below
@@ -2079,6 +2080,8 @@ static void dwc2_hc_n_intr(struct dwc2_hsotg *hsotg, int chnum)
        chan->hcint = hcint;
        hcint &= hcintmsk;
 
+       dwc2_writel(hsotg, hcint, HCINT(chnum));
+
        /*
         * If the channel was halted due to a dequeue, the qtd list might
         * be empty or at least the first entry will not be the active qtd.

注意:

这个补丁只清除未屏蔽中断,以避免触发未知通道停止中断。然而,如果通道停止中断意外发生,我们需要检查dwc2_update_urb_state_abn()中的urb->length是否为4字节对齐,这可以帮助避免上述警告。

posted @ 2021-12-10 18:09  闹闹爸爸  阅读(1592)  评论(1编辑  收藏  举报