DM USB: xHCI: fix emulation code for MFINDEX register

The old logic to emulate MFINDEX register is not right, this patch
is used to fix it.

Tracked-On: #3628
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
Xiaoguang Wu 2019-08-22 17:06:45 +08:00 committed by wenlingz
parent bda43ee352
commit 685b1a7b66

View File

@ -3614,13 +3614,16 @@ pci_xhci_rtsregs_read(struct pci_xhci_vdev *xdev, uint64_t offset)
if (offset == XHCI_MFINDEX) { if (offset == XHCI_MFINDEX) {
clock_gettime(CLOCK_MONOTONIC, &t); clock_gettime(CLOCK_MONOTONIC, &t);
time_diff = (t.tv_sec - xdev->init_time.tv_sec) * 1000000 /*
+ (t.tv_nsec - xdev->init_time.tv_nsec) / 1000; * let delta seconds be ds, delta nanoseconds be dns,
xdev->init_time = t; * the following calculation is derived from:
value = time_diff / 125; *
* ds * 1000000 / 125 + dns / 1000 / 125
*/
time_diff = (t.tv_sec - xdev->init_time.tv_sec) * 8000
+ (t.tv_nsec - xdev->init_time.tv_nsec) / 125000;
if (value >= 1) value = XHCI_MFINDEX_GET(time_diff);
xdev->rtsregs.mfindex += value;
} else if (offset >= XHCI_RT_IR_BASE) { } else if (offset >= XHCI_RT_IR_BASE) {
int item; int item;
uint32_t *p; uint32_t *p;