qemu/qemu/c18d951793fea06a1d8fd643b3aa8955d5968091 hw/usb/hcd-xhci: fix interval alignment after MFINDEX passes 2^32
epctx->interval is an unsigned int, so ~(epctx->interval - 1) is a
32-bit mask that is zero-extended when and-ed with the 64-bit microframe
index. Once mfindex no longer fits in 32 bits (2^32 * 125us, about 6.2
days after the controller was started), asap loses its upper half and
always compares below mfindex. Isoch TDs with SIA are then run at once
instead of at the next interval boundary. xhci_calc_intr_kick() has the
same expression.
Use ROUND_UP(), which builds the mask in the type of mfindex. The
interval is always a power of two.
The reporter of #3973 also saw the symptom with UHCI. This change does
not explain that.
Fixes: 3d1396842d ("xhci: iso xfer support")
Fixes: 4d7a81c06f ("xhci: emulate intr endpoint intervals correctly")
Link: https://gitlab.com/qemu-project/qemu/-/issues/3973
Cc: qemu-stable@nongnu.org
Signed-off-by: Junjie Cao <junjie.cao@intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <52c9f935428f2cfc65e4dee7e37638fcb965c6b2.1789968699.git.junjie.cao@intel.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
(cherry picked from commit bfb82d57e7299cb59471f7060cbab0b1ed39504e)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
1 file changed