linux icon indicating copy to clipboard operation
linux copied to clipboard

gadget ecm ether tx failed due to wakeup host failure

Open pswarfound opened this issue 8 months ago • 0 comments

Describe the bug

file: drivers/usb/gadget/function/u_ether.c function: eth_start_xmit

if (dev->port_usb && dev->port_usb->is_suspend) {
    DBG(dev, "Port suspended. Triggering wakeup\n");
    netif_stop_queue(net);
    spin_unlock_irqrestore(&dev->lock, flags);
     /*
               if failed to wake up host here, port_usb will always be suspending
              net core will put all packets in queue
              but will never be sent since port_usb is suspending
     */
    ether_wakeup_host(dev->port_usb); 
    return NETDEV_TX_BUSY;
}

according to function 'gether_suspend' in u_ether.c i think we should handle failure when wakeup host in 'eth_start_xmit' too may be like this:

if (dev->port_usb && dev->port_usb->is_suspend) {
    DBG(dev, "Port suspended. Triggering wakeup\n");
    if (!ether_wakeup_host(dev->port_usb)) {
        netif_stop_queue(net);
        spin_unlock_irqrestore(&dev->lock, flags);
    	return NETDEV_TX_BUSY;
    }
}

Steps to reproduce the behaviour

  • edit /boot/config.txt, add 'dtoverlay=dwc2,dr_mode=peripheral'
  • modprobe libcomposite
  • create mass storage and ecm network device
  • config ecm network in PI: ifconfig usb0 192.168.254.1 up
  • use bootable image such as ubuntu.iso for mass storage
  • connect type-c from pi to to another PC
  • power on PC and boot from disk emulated by PI
  • a usb network device should be found under PC, like enx******
  • config usb network in PC: ifconfig enx******192.168.254.1
  • check connection between PC and pi: ping 192.168.254.1
  • ping should failed
  • 'ifconfig usb0' in PI, only rx packet counters are increasing, tx counters are all zero

Device (s)

Raspberry Pi CM5

System

Linux raspberrypi 6.12.25

Logs

No response

Additional context

No response

pswarfound avatar May 02 '25 03:05 pswarfound