[usbdev] Repeated link_reset interrupt
Hi @vogelpi @mdhayter
I am currently trying to merge our version of the usb peripheral with the one hosted here, but it's currently not working correctly. One thing I noticed is that the 'event_link_reset' signal is now pulsed regularly when the reset condition is applied, which will result in a large number of interrupts for the processor to handle. It appears that this behaviour was introduced with #3359. Is this intentional or a bug?
Old behaviour (running the hello_usbdev app, at 098128c9003b1ab226ff17001ac59845a6755f24)

New behaviour (one event every 49 USB clock cycles, at 3ad4fd1bb674ea103204af0892b5c8d870b2159f):

Hi @stefanlippuner, thanks for reporting the issue. This seems to be related to #3388 . Mark mentioned some things to look at but unfortunately, I did not yet have a chance to debug this as I am busy with other work.
I think that this issue is not related to #3388.
The issue seems to be caused by the changes to usbdev_linkstate. The link_reset se0 detection is now based on line_history_q in usb_fs_rx.sv, which is cleared when a link reset is detected, resulting in the oscillation behaviour.
I would suggest to undo the related changes from #3359 by moving the se0 detection back to usbdev_linkstate. That would probably also be better suited to low power optimizations.
Seems correct diagnosis and fix to me. I reviewed the PR (no comments on the commit for this fix).
Resolved with d631fa86e8da5cc6e126b29940d516ce9f9f284d from #4053.