From: Hans de Goede <hdegoede@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: Hans de Goede <hdegoede@redhat.com>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 5/8] ehci: Lower timer freq when there are no iso packets in the periodic schedule
Date: Tue, 6 Nov 2012 15:08:18 +0100 [thread overview]
Message-ID: <1352210901-1923-6-git-send-email-hdegoede@redhat.com> (raw)
In-Reply-To: <1352210901-1923-1-git-send-email-hdegoede@redhat.com>
If there are no iso packets in the periodic schedule, then there can only
be interrupt packets there, and for these usb-devices either return nak,
meaning that the executing state will get passed every frame, causing
async_stepdown to stay 0, or they are handled async, and then ehci_frame_timer
will get called immediately from a bh, thus not introducing any latency
to async handled interrupt packets.
The advantage of this is that when we only have async handled interrupt
packets in the periodic schedule, async_stepdown can do its work and
significantly lower the frequency at which the frame_timer runs.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
hw/usb/hcd-ehci.c | 18 ++++++++++++++----
hw/usb/hcd-ehci.h | 1 +
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index ee6c9ae..b804474 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -114,6 +114,7 @@
#define BUFF_SIZE 5*4096 // Max bytes to transfer per transaction
#define MAX_QH 100 // Max allowable queue heads in a chain
#define MIN_FR_PER_TICK 3 // Min frames to process when catching up
+#define ISO_ACTIVE_COUNT 64
/* Internal periodic / asynchronous schedule state machine states
*/
@@ -1325,6 +1326,8 @@ static int ehci_process_itd(EHCIState *ehci,
uint32_t i, len, pid, dir, devaddr, endp;
uint32_t pg, off, ptr1, ptr2, max, mult;
+ ehci->iso_active_counter = ISO_ACTIVE_COUNT;
+
dir =(itd->bufptr[1] & ITD_BUFPTR_DIRECTION);
devaddr = get_field(itd->bufptr[0], ITD_BUFPTR_DEVADDR);
endp = get_field(itd->bufptr[0], ITD_BUFPTR_EP);
@@ -2157,9 +2160,12 @@ static void ehci_frame_timer(void *opaque)
ns_elapsed = t_now - ehci->last_run_ns;
frames = ns_elapsed / FRAME_TIMER_NS;
+ if (ehci->async_stepdown < ehci->maxframes / 2) {
+ ehci->async_stepdown++;
+ }
+
if (ehci_periodic_enabled(ehci) || ehci->pstate != EST_INACTIVE) {
need_timer++;
- ehci->async_stepdown = 0;
if (frames > ehci->maxframes) {
skipped_frames = frames - ehci->maxframes;
@@ -2183,14 +2189,18 @@ static void ehci_frame_timer(void *opaque)
break;
}
}
+ if (ehci->iso_active_counter) {
+ ehci->iso_active_counter--;
+ }
ehci_update_frindex(ehci, 1);
ehci_advance_periodic_state(ehci);
ehci->last_run_ns += FRAME_TIMER_NS;
}
- } else {
- if (ehci->async_stepdown < ehci->maxframes / 2) {
- ehci->async_stepdown++;
+
+ if (ehci->iso_active_counter) {
+ ehci->async_stepdown = 0;
}
+ } else {
ehci_update_frindex(ehci, frames);
ehci->last_run_ns += FRAME_TIMER_NS * frames;
}
diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h
index d8078f4..ed9d89c 100644
--- a/hw/usb/hcd-ehci.h
+++ b/hw/usb/hcd-ehci.h
@@ -311,6 +311,7 @@ struct EHCIState {
uint64_t last_run_ns;
uint32_t async_stepdown;
+ uint32_t iso_active_counter;
bool int_req_by_async;
};
--
1.7.12.1
next prev parent reply other threads:[~2012-11-06 14:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-06 14:08 [Qemu-devel] usb: Move interrupt handling from poll to async handling Hans de Goede
2012-11-06 14:08 ` [Qemu-devel] [PATCH 1/8] usb-redir: Split usb_handle_interrupt_data into separate in/out functions Hans de Goede
2012-11-06 14:08 ` [Qemu-devel] [PATCH 2/8] usb-redir: Store interrupt receiving status in the bufp-queue Hans de Goede
2012-11-07 9:51 ` Paolo Bonzini
2012-11-06 14:08 ` [Qemu-devel] [PATCH 3/8] usb-redir: Only add actually in flight packets to the in flight queue Hans de Goede
2012-11-06 14:08 ` [Qemu-devel] [PATCH 4/8] usb-redir: Handle interrupt packets async Hans de Goede
2012-11-06 14:08 ` Hans de Goede [this message]
2012-11-06 14:08 ` [Qemu-devel] [PATCH 6/8] hid: Change idle handling to use a timer Hans de Goede
2012-11-06 14:08 ` [Qemu-devel] [PATCH 7/8] usb-hid: Move from NAK/polling to async packet handling Hans de Goede
2012-11-08 15:35 ` Gerd Hoffmann
2012-11-06 14:08 ` [Qemu-devel] [PATCH 8/8] usb-hid: Allow connecting to a USB-2 device Hans de Goede
2012-11-07 9:47 ` Paolo Bonzini
2012-11-08 15:36 ` Gerd Hoffmann
2012-11-12 11:19 ` Hans de Goede
2012-11-06 22:05 ` [Qemu-devel] usb: Move interrupt handling from poll to async handling Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1352210901-1923-6-git-send-email-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).