Hi All, I have recently noticed a problem with dwc2 and audio gadget.
The expected behavior: The uac2 function acts as a kind of a pass-through. For example to play audio from USB host on an Odroid U3 the following command is issued at the host: aplay -D plughw:CARD=Gadget,DEV=0 /usr/share/sounds/alsa/Front_Center.wav while the following command is used at the device: arecord -f dat -t wav -D plughw:CARD=UAC2Gadget,DEV=0 \| aplay -D default:CARD=OdroidU3 At the device we "record" from the audio device provided by the usb gadget and pipe the resulting stream to the actual hardware device present in the chip on board. What actually happens: On recent kernels this does not work in a stable manner and sometimes the kernel panics. I traced the problem back and it seems that the last kernel without the below problems is 4.7. I am using a compiled-in, legacy audio gadget with only uac2 function selected in Kconfig. 4.7 works 4.8 kernel crashes at boot time (bisect identifies 381fc8f8228923026b3d75c8230fa2ee4d688f32 "usb: dwc2: gadget: Add Incomplete ISO IN/OUT Interrupt handlers"), compiling as a module does not help (crash at module load time), composing the gagdet with configfs does not help either. 4.9 kernel crashes at boot time 4.10 kernel crashes at boot time 4.11 kernel crashes at boot time 4.12 kernel crashes at boot time 4.13 kernel crashes at boot time 4.14 kernel usually crashes at boot time, but sometimes it boots, if it boots, it crashes the same way as at boot time when the gadget is actually used (aplay at host and arecord | aplay at the device) 4.15 kernel sometimes crashes at boot time, but otherwise it boots, if it boots, it crashes the same way as at boot time when the gadget is actually used (aplay at host and arecord | aplay at the device) 4.16 kernel crashes at boot time 4.17 kernel sometimes crashes at boot time, but otherwise it boots, if it boots, it crashes the same way as at boot time when the gadget is actually used (aplay at host and arecord | aplay at the device) 4.18 kernel sometimes crashes at boot time or even silently freezes, but otherwise it boots, if it boots, it crashes the same way as at boot time when the gadget is actually used (aplay at host and arecord | aplay at the device) 4.19 and 4.20-rc4 kernel boots, but after some time the gadget stops working: at the device with 4.19: # arecord -f dat -t wav -D plughw:CARD=UAC2Gadget,DEV=0 | aplay -D default:CARD=OdroidU3 Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo [ 26.245056] max98090 1-0010: PLL unlocked underrun!!! (at least 1256.128 ms long) [ 29.363400] max98090 1-0010: PLL unlocked underrun!!! (at least 930.612 ms long) underrun!!! (at least 447.733 ms long) [ 34.475390] max98090 1-0010: PLL unlocked underrun!!! (at least 319.622 ms long) [ 36.678554] max98090 1-0010: PLL unlocked underrun!!! (at least 611.690 ms long) [ 39.153660] max98090 1-0010: PLL unlocked underrun!!! (at least 724.196 ms long) [ 41.741488] max98090 1-0010: PLL unlocked underrun!!! (at least 695.816 ms long) [ 44.428490] max98090 1-0010: PLL unlocked underrun!!! (at least 795.061 ms long) [ 47.106276] max98090 1-0010: PLL unlocked underrun!!! (at least 760.757 ms long) underrun!!! (at least 2685.446 ms long) [ 54.288479] max98090 1-0010: PLL unlocked underrun!!! (at least 1591.909 ms long) [ 57.764445] max98090 1-0010: PLL unlocked underrun!!! (at least 223.942 ms long) underrun!!! (at least 237.751 ms long) [ 61.974963] max98090 1-0010: PLL unlocked underrun!!! (at least 677.925 ms long) [ 64.645406] max98090 1-0010: PLL unlocked underrun!!! (at least 550.651 ms long) [ 67.079379] max98090 1-0010: PLL unlocked underrun!!! (at least 1575.582 ms long) [ 70.521155] max98090 1-0010: PLL unlocked underrun!!! (at least 832.604 ms long) [ 73.219814] max98090 1-0010: PLL unlocked underrun!!! (at least 721.516 ms long) while at the host: $ aplay -D plughw:CARD=Gadget,DEV=0 /usr/share/sounds/alsa/Front_Center.wav Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono .... several times ok .... $ aplay -D plughw:CARD=Gadget,DEV=0 /usr/share/sounds/alsa/Front_Center.wav Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono aplay: set_params:1297: Unable to install hw params: ACCESS: RW_INTERLEAVED FORMAT: S16_LE SUBFORMAT: STD SAMPLE_BITS: 16 FRAME_BITS: 16 CHANNELS: 1 RATE: 48000 PERIOD_TIME: 125000 PERIOD_SIZE: 6000 PERIOD_BYTES: 12000 PERIODS: 4 BUFFER_TIME: 500000 BUFFER_SIZE: 24000 BUFFER_BYTES: 48000 TICK_TIME: 0 Any ideas on how to test it further to identify the problem? Definitely the commit identified with bisect was a problem at least until 4.13. Perhaps it still is the root cause, but I can't tell. It is difficult to revert it, because there were later changes which depend on it. Andrzej