--- - branch: MAIN date: Sat Jan 29 21:37:07 UTC 2022 files: - new: '1.44' old: '1.43' path: src/sys/dev/usb/usbnet.c pathrev: src/sys/dev/usb/usbnet.c@1.44 type: modified id: 20220129T213707Z.b957c16d73f90f9bf2c3854f6ce4407427e22a33 log: | usbnet: Defer hardware multicast filter updates to USB task. Breaks deadlock: - usbnet_detach holds usbnet lock, awaits kpause in ure_reset - callout holds softclock `lock' (sequential softints, blocks kpause wakeup), awaits softnet_lock in tcp_timer_keep, frag6_fasttimo, &c. - soclose holds softnet_lock, awaits usbnet lock in SIOCDELMULTI This change breaks the deadlock by not passing the SIOCADDMULTI or SIOCDELMULTI ioctl synchronously to the driver, which typically takes the usbnet lock. With this change, the ethernet layer still maintains the list of multicast addresses synchronously, but we defer the driver logic that updates the hardware multicast filter to an asynchronous USB task without softnet_lock held. This doesn't cause exactly the same ioctl to be sent to the driver -- usbnet just sends SIOCDELMULTI with an all-zero struct ifreq, and might drop some ioctls if issued in quick succession. This is OK because none of the drivers actually distinguish between SIOCADDMULTI and SIOCDELMULTI, or examine the argument; the drivers just commit whatever multicast addresses are listed in the ethercom. Other than the different ioctl submitted, there is no change to the ABI or locking scheme of usbnet, so this is safe to pull up to netbsd-9. This means we unfortunately can't guarantee that if a process issues SIOCADDMULTI and then sendto, the multicast filter update will be done by the time of the sendto -- and, more importantly, the packets received in reply to it. But failing to guarantee that is better than deadlocking! Later changes on HEAD will restore the synchronous multicast filter updates with much more extensive ABI changes and API simplifications in usbnet(9). Proposed on tech-net: https://mail-index.netbsd.org/tech-net/2021/12/30/msg008164.html XXX pullup-9 module: src subject: 'CVS commit: src/sys/dev/usb' unixtime: '1643492227' user: riastradh