[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 05/13] ehci: switch to nanoseconds
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 05/13] ehci: switch to nanoseconds |
Date: |
Fri, 24 Jun 2011 12:59:27 +0200 |
Make ehci use nanoseconds everywhere.
Simplifies time calculations.
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/usb-ehci.c | 29 +++++++++++------------------
1 files changed, 11 insertions(+), 18 deletions(-)
diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c
index fa9792e..91fb7de 100644
--- a/hw/usb-ehci.c
+++ b/hw/usb-ehci.c
@@ -130,7 +130,7 @@
#define PORTSC_CONNECT (1 << 0) // Current Connect Status
#define FRAME_TIMER_FREQ 1000
-#define FRAME_TIMER_USEC (1000000 / FRAME_TIMER_FREQ)
+#define FRAME_TIMER_NS (1000000000 / FRAME_TIMER_FREQ)
#define NB_MAXINTRATE 8 // Max rate at which controller issues ints
#define NB_PORTS 4 // Number of downstream ports
@@ -348,7 +348,8 @@ struct EHCIQueue {
EHCIState *ehci;
QTAILQ_ENTRY(EHCIQueue) next;
bool async_schedule;
- uint32_t seen, ts;
+ uint32_t seen;
+ uint64_t ts;
/* cached data from guest - needs to be flushed
* when guest removes an entry (doorbell, handshake sequence)
@@ -418,12 +419,11 @@ struct EHCIState {
uint8_t ibuffer[BUFF_SIZE];
int isoch_pause;
- uint32_t last_run_usec;
- uint32_t frame_end_usec;
+ uint64_t last_run_ns;
};
#define SET_LAST_RUN_CLOCK(s) \
- (s)->last_run_usec = qemu_get_clock_ns(vm_clock) / 1000;
+ (s)->last_run_ns = qemu_get_clock_ns(vm_clock);
/* nifty macros from Arnon's EHCI version */
#define get_field(data, field) \
@@ -690,10 +690,10 @@ static void ehci_queues_rip_unused(EHCIState *ehci)
QTAILQ_FOREACH_SAFE(q, &ehci->queues, next, tmp) {
if (q->seen) {
q->seen = 0;
- q->ts = ehci->last_run_usec;
+ q->ts = ehci->last_run_ns;
continue;
}
- if (ehci->last_run_usec < q->ts + 250000) {
+ if (ehci->last_run_ns < q->ts + 250000000) {
/* allow 0.25 sec idle */
continue;
}
@@ -2045,23 +2045,16 @@ static void ehci_frame_timer(void *opaque)
{
EHCIState *ehci = opaque;
int64_t expire_time, t_now;
- int usec_elapsed;
+ uint64_t ns_elapsed;
int frames;
- int usec_now;
int i;
int skipped_frames = 0;
-
t_now = qemu_get_clock_ns(vm_clock);
expire_time = t_now + (get_ticks_per_sec() / ehci->freq);
- if (expire_time == t_now) {
- expire_time++;
- }
- usec_now = t_now / 1000;
- usec_elapsed = usec_now - ehci->last_run_usec;
- frames = usec_elapsed / FRAME_TIMER_USEC;
- ehci->frame_end_usec = usec_now + FRAME_TIMER_USEC - 10;
+ ns_elapsed = t_now - ehci->last_run_ns;
+ frames = ns_elapsed / FRAME_TIMER_NS;
for (i = 0; i < frames; i++) {
if ( !(ehci->usbsts & USBSTS_HALT)) {
@@ -2084,7 +2077,7 @@ static void ehci_frame_timer(void *opaque)
ehci_advance_periodic_state(ehci);
}
- ehci->last_run_usec += FRAME_TIMER_USEC;
+ ehci->last_run_ns += FRAME_TIMER_NS;
}
#if 0
--
1.7.1
- [Qemu-devel] [PATCH 33/34] hw/usb-ohci.c: Implement remote wakeup, (continued)
- [Qemu-devel] [PATCH 33/34] hw/usb-ohci.c: Implement remote wakeup, Gerd Hoffmann, 2011/06/14
- [Qemu-devel] [PATCH 32/34] hw/usb-ohci.c: Ignore writes to HcPeriodCurrentED register, Gerd Hoffmann, 2011/06/14
- Re: [Qemu-devel] [PULL] usb patch queue, Anthony Liguori, 2011/06/15
- [Qemu-devel] [PULL] usb patch queue, Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 03/13] usb-linux: track inflight iso urb count, Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 04/13] ehci: add freq + maxframes properties, Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 02/13] usb-linux: make iso urb count contigurable, Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 01/13] usb-linux: add get_endp(), Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 06/13] usb-bus: Don't allow attaching a device to a bus with no free ports, Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 05/13] ehci: switch to nanoseconds,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 09/13] usb-linux: allow "compatible" high speed devices to connect at fullspeed, Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 08/13] usb: Add a speedmask to devices, Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 13/13] usb: ignore USB_DT_DEBUG, Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 11/13] hw/usb-ohci.c: Fix handling of remote wakeup corner cases, Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 07/13] usb: Proper error propagation for usb_device_attach errors, Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 12/13] usb-storage: Turn drive serial into a qdev property usb-storage.serial, Gerd Hoffmann, 2011/06/24
- [Qemu-devel] [PATCH 10/13] usb-bus: Don't allow speed mismatch while attaching devices, Gerd Hoffmann, 2011/06/24
- Re: [Qemu-devel] [PULL] usb patch queue, Hans de Goede, 2011/06/24
- Re: [Qemu-devel] [PULL] usb patch queue, Anthony Liguori, 2011/06/27