Mouse not working on the console with the latest Windows Blue
PATCH 1/1 Mouse not working on the console with the latest Windows Blue
Windows 8.1 (Blue) on initialization check if usb frame number increase after 5 ms. It could happen however that timer function is not run in that amount of time so Windows believe that usb controller is not working properly. This patch prevent this detecting that timer function was not run and run it.
--- hw/usb-uhci.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
hw/usb-uhci.c +15 -4
@@ -129,6 +129,7 @@ typedef struct UHCIState {uint32_t fl_base_addr;/* frame list base address */ uint8_t sof_timing;uint8_t status2;/* bit 0 and 1 are used to generate UHCI_STS_USBINT */ +int64_t expire_time;QEMUTimer *frame_timer;UHCIPort ports[NB_PORTS ];
@@ -166,6 +167,8 @@ static UHCIAsync *uhci_async_alloc(UHCIState *s)return async; } +static void uhci_frame_timer (void *opaque); +static void uhci_async_free (UHCIState *s,UHCIAsync *async) {qemu_free (async);
@@ -398,6 +401,8 @@ static int uhci_load(QEMUFile *f, void *opaque, int version_id)qemu_get_8s (f, &s->sof_timing);qemu_get_8s (f, &s->status2);qemu_get_timer (f, s->frame_timer); + s->expire_time =qemu_get_clock (vm_clock) + + (ticks_per_sec /FRAME_TIMER_FREQ );return 0 ; }
@@ -441,8 +446,11 @@ static void uhci_ioport_writew(void *opaque, uint32_t addr, uint32_t val)switch (addr) {case 0x00 :if ((val &UHCI_CMD_RS ) && !(s->cmd &UHCI_CMD_RS )) { +int64_t t_now =qemu_get_clock (vm_clock);/* start frame processing */ -qemu_mod_timer (s->frame_timer,qemu_get_clock (vm_clock)); + s->expire_time = t_now + + (ticks_per_sec /FRAME_TIMER_FREQ ); +qemu_mod_timer (s->frame_timer, t_now); s->status &= ~UHCI_STS_HCHALTED ; }else if (!(val &UHCI_CMD_RS )) { s->status |=UHCI_STS_HCHALTED ;
@@ -528,6 +536,10 @@ static uint32_t uhci_ioport_readw(void *opaque, uint32_t addr) val = s->intr;break ;case 0x06 : +/* keep frame number in sync */ +if ((s->status &UHCI_STS_HCHALTED ) ==0 && + s->expire_time <=qemu_get_clock (vm_clock)) +uhci_frame_timer (s); val = s->frnum;break ; case 0x10 ... 0x1f:
@@ -1020,7 +1032,6 @@ static void uhci_process_frame(UHCIState *s)static void uhci_frame_timer (void *opaque) {UHCIState *s = opaque; -int64_t expire_time;if (!(s->cmd &UHCI_CMD_RS )) {/* Full stop */
@@ -1051,9 +1062,9 @@ static void uhci_frame_timer(void *opaque)uhci_async_validate_end (s);/* prepare the timer for the next frame */ - expire_time =qemu_get_clock (vm_clock) + + s->expire_time =qemu_get_clock (vm_clock) + (ticks_per_sec /FRAME_TIMER_FREQ ); -qemu_mod_timer (s->frame_timer, expire_time); +qemu_mod_timer (s->frame_timer, s->expire_time); } static void uhci_map(PCIDevice *pci_dev, int region_num,
Signature · 1 line
1.7.10.4
Ping
Quoted 85 lines · Frediano Ziglio
Windows 8.1 (Blue) on initialization check if usb frame number increase after 5 ms. It could happen however that timer function is not run in that amount of time so Windows believe that usb controller is not working properly. This patch prevent this detecting that timer function was not run and run it.
Signed-off-by Frediano Ziglio <[email protected]>--- hw/usb-uhci.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)hw/usb-uhci.c +15
-4@@ -129,6 +129,7 @@ typedef struct UHCIState {uint32_t fl_base_addr;/* frame list base address */ uint8_t sof_timing;uint8_t status2;/* bit 0 and 1 are used to generate UHCI_STS_USBINT */ +int64_t expire_time;QEMUTimer *frame_timer;UHCIPort ports[NB_PORTS ];@@ -166,6 +167,8 @@ static UHCIAsync *uhci_async_alloc(UHCIState *s)return async; } +static void uhci_frame_timer (void *opaque); +static void uhci_async_free (UHCIState *s,UHCIAsync *async) {qemu_free (async);@@ -398,6 +401,8 @@ static int uhci_load(QEMUFile *f, void *opaque, int version_id)qemu_get_8s (f, &s->sof_timing);qemu_get_8s (f, &s->status2);qemu_get_timer (f, s->frame_timer); + s->expire_time =qemu_get_clock (vm_clock) + + (ticks_per_sec /FRAME_TIMER_FREQ );return 0 ; }@@ -441,8 +446,11 @@ static void uhci_ioport_writew(void *opaque, uint32_t addr, uint32_t val)switch (addr) {case 0x00 :if ((val &UHCI_CMD_RS ) && !(s->cmd &UHCI_CMD_RS )) { +int64_t t_now =qemu_get_clock (vm_clock);/* start frame processing */ -qemu_mod_timer (s->frame_timer,qemu_get_clock (vm_clock)); + s->expire_time = t_now + + (ticks_per_sec /FRAME_TIMER_FREQ ); +qemu_mod_timer (s->frame_timer, t_now); s->status &= ~UHCI_STS_HCHALTED ; }else if (!(val &UHCI_CMD_RS )) { s->status |=UHCI_STS_HCHALTED ;@@ -528,6 +536,10 @@ static uint32_t uhci_ioport_readw(void *opaque, uint32_t addr) val = s->intr;break ;case 0x06 : +/* keep frame number in sync */ +if ((s->status &UHCI_STS_HCHALTED ) ==0 && + s->expire_time <=qemu_get_clock (vm_clock)) +uhci_frame_timer (s); val = s->frnum;break ; case 0x10 ... 0x1f:@@ -1020,7 +1032,6 @@ static void uhci_process_frame(UHCIState *s)static void uhci_frame_timer (void *opaque) {UHCIState *s = opaque; -int64_t expire_time;if (!(s->cmd &UHCI_CMD_RS )) {/* Full stop */ @@ -1051,9 +1062,9 @@ static void uhci_frame_timer(void *opaque)uhci_async_validate_end (s);/* prepare the timer for the next frame */ - expire_time =qemu_get_clock (vm_clock) + + s->expire_time =qemu_get_clock (vm_clock) + (ticks_per_sec /FRAME_TIMER_FREQ ); -qemu_mod_timer (s->frame_timer, expire_time); +qemu_mod_timer (s->frame_timer, s->expire_time); } static void uhci_map(PCIDevice *pci_dev, int region_num,
Quoted 5 lines · Frediano Ziglio
Windows 8.1 (Blue) on initialization check if usb frame number increase after 5 ms. It could happen however that timer function is not run in that amount of time so Windows believe that usb controller is not working properly. This patch prevent this detecting that timer function was not run and run it.
Is this for qemu-trad? Please mention this in the future.
Is a similar fix needed for upstream qemu?
Quoted 80 lines
Signed-off-by Frediano Ziglio <[email protected]>--- hw/usb-uhci.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)hw/usb-uhci.c +15
-4@@ -129,6 +129,7 @@ typedef struct UHCIState {uint32_t fl_base_addr;/* frame list base address */ uint8_t sof_timing;uint8_t status2;/* bit 0 and 1 are used to generate UHCI_STS_USBINT */ +int64_t expire_time;QEMUTimer *frame_timer;UHCIPort ports[NB_PORTS ];@@ -166,6 +167,8 @@ static UHCIAsync *uhci_async_alloc(UHCIState *s)return async; } +static void uhci_frame_timer (void *opaque); +static void uhci_async_free (UHCIState *s,UHCIAsync *async) {qemu_free (async);@@ -398,6 +401,8 @@ static int uhci_load(QEMUFile *f, void *opaque, int version_id)qemu_get_8s (f, &s->sof_timing);qemu_get_8s (f, &s->status2);qemu_get_timer (f, s->frame_timer); + s->expire_time =qemu_get_clock (vm_clock) + + (ticks_per_sec /FRAME_TIMER_FREQ );return 0 ; }@@ -441,8 +446,11 @@ static void uhci_ioport_writew(void *opaque, uint32_t addr, uint32_t val)switch (addr) {case 0x00 :if ((val &UHCI_CMD_RS ) && !(s->cmd &UHCI_CMD_RS )) { +int64_t t_now =qemu_get_clock (vm_clock);/* start frame processing */ -qemu_mod_timer (s->frame_timer,qemu_get_clock (vm_clock)); + s->expire_time = t_now + + (ticks_per_sec /FRAME_TIMER_FREQ ); +qemu_mod_timer (s->frame_timer, t_now); s->status &= ~UHCI_STS_HCHALTED ; }else if (!(val &UHCI_CMD_RS )) { s->status |=UHCI_STS_HCHALTED ;@@ -528,6 +536,10 @@ static uint32_t uhci_ioport_readw(void *opaque, uint32_t addr) val = s->intr;break ;case 0x06 : +/* keep frame number in sync */ +if ((s->status &UHCI_STS_HCHALTED ) ==0 && + s->expire_time <=qemu_get_clock (vm_clock)) +uhci_frame_timer (s); val = s->frnum;break ; case 0x10 ... 0x1f:@@ -1020,7 +1032,6 @@ static void uhci_process_frame(UHCIState *s)static void uhci_frame_timer (void *opaque) {UHCIState *s = opaque; -int64_t expire_time;if (!(s->cmd &UHCI_CMD_RS )) {/* Full stop */ @@ -1051,9 +1062,9 @@ static void uhci_frame_timer(void *opaque)uhci_async_validate_end (s);/* prepare the timer for the next frame */ - expire_time =qemu_get_clock (vm_clock) + + s->expire_time =qemu_get_clock (vm_clock) + (ticks_per_sec /FRAME_TIMER_FREQ ); -qemu_mod_timer (s->frame_timer, expire_time); +qemu_mod_timer (s->frame_timer, s->expire_time); } static void uhci_map(PCIDevice *pci_dev, int region_num,
Quoted 9 lines · Ian Campbell
Quoted 5 lines · Frediano Ziglio
Windows 8.1 (Blue) on initialization check if usb frame number increase after 5 ms. It could happen however that timer function is not run in that amount of time so Windows believe that usb controller is not working properly. This patch prevent this detecting that timer function was not run and run it.
Is this for qemu-trad? Please mention this in the future.
I'll try to remember. Yes, it apply to traditional.
Quoted 2 lines
Is a similar fix needed for upstream qemu?
It's a good question. Unfortunately code is quite different and setting up everything (VM, test environment, etc) with upstream is not that straight forward (at least for me).
Frediano
Quoted 82 lines
Quoted 80 lines
Signed-off-by Frediano Ziglio <[email protected]>--- hw/usb-uhci.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)hw/usb-uhci.c +15
-4@@ -129,6 +129,7 @@ typedef struct UHCIState {uint32_t fl_base_addr;/* frame list base address */ uint8_t sof_timing;uint8_t status2;/* bit 0 and 1 are used to generate UHCI_STS_USBINT */ +int64_t expire_time;QEMUTimer *frame_timer;UHCIPort ports[NB_PORTS ];@@ -166,6 +167,8 @@ static UHCIAsync *uhci_async_alloc(UHCIState *s)return async; } +static void uhci_frame_timer (void *opaque); +static void uhci_async_free (UHCIState *s,UHCIAsync *async) {qemu_free (async);@@ -398,6 +401,8 @@ static int uhci_load(QEMUFile *f, void *opaque, int version_id)qemu_get_8s (f, &s->sof_timing);qemu_get_8s (f, &s->status2);qemu_get_timer (f, s->frame_timer); + s->expire_time =qemu_get_clock (vm_clock) + + (ticks_per_sec /FRAME_TIMER_FREQ );return 0 ; }@@ -441,8 +446,11 @@ static void uhci_ioport_writew(void *opaque, uint32_t addr, uint32_t val)switch (addr) {case 0x00 :if ((val &UHCI_CMD_RS ) && !(s->cmd &UHCI_CMD_RS )) { +int64_t t_now =qemu_get_clock (vm_clock);/* start frame processing */ -qemu_mod_timer (s->frame_timer,qemu_get_clock (vm_clock)); + s->expire_time = t_now + + (ticks_per_sec /FRAME_TIMER_FREQ ); +qemu_mod_timer (s->frame_timer, t_now); s->status &= ~UHCI_STS_HCHALTED ; }else if (!(val &UHCI_CMD_RS )) { s->status |=UHCI_STS_HCHALTED ;@@ -528,6 +536,10 @@ static uint32_t uhci_ioport_readw(void *opaque, uint32_t addr) val = s->intr;break ;case 0x06 : +/* keep frame number in sync */ +if ((s->status &UHCI_STS_HCHALTED ) ==0 && + s->expire_time <=qemu_get_clock (vm_clock)) +uhci_frame_timer (s); val = s->frnum;break ; case 0x10 ... 0x1f:@@ -1020,7 +1032,6 @@ static void uhci_process_frame(UHCIState *s)static void uhci_frame_timer (void *opaque) {UHCIState *s = opaque; -int64_t expire_time;if (!(s->cmd &UHCI_CMD_RS )) {/* Full stop */ @@ -1051,9 +1062,9 @@ static void uhci_frame_timer(void *opaque)uhci_async_validate_end (s);/* prepare the timer for the next frame */ - expire_time =qemu_get_clock (vm_clock) + + s->expire_time =qemu_get_clock (vm_clock) + (ticks_per_sec /FRAME_TIMER_FREQ ); -qemu_mod_timer (s->frame_timer, expire_time); +qemu_mod_timer (s->frame_timer, s->expire_time); } static void uhci_map(PCIDevice *pci_dev, int region_num,