From: Paolo Bonzini <pbonzini@redhat.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/8] usb-redir: Store interrupt receiving status in the bufp-queue
Date: Wed, 07 Nov 2012 10:51:21 +0100 [thread overview]
Message-ID: <509A2F19.3020007@redhat.com> (raw)
In-Reply-To: <1352210901-1923-3-git-send-email-hdegoede@redhat.com>
Il 06/11/2012 15:08, Hans de Goede ha scritto:
> Since we handle interrupt out async, and not buffered like iso-out, there is
> no need for a separate status flag, instead store any reported error status
> into the bufp queue.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> hw/usb/redirect.c | 24 +++++++++---------------
> 1 file changed, 9 insertions(+), 15 deletions(-)
>
> diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
> index 9052ef8..b61bb6e 100644
> --- a/hw/usb/redirect.c
> +++ b/hw/usb/redirect.c
> @@ -58,11 +58,11 @@ struct endp_data {
> uint8_t type;
> uint8_t interval;
> uint8_t interface; /* bInterfaceNumber this ep belongs to */
> + uint8_t zero; /* Was interrupt_error, now always 0 for migration compat */
No need for this, use VMSTATE_UNUSED.
But if you do this, you need to bump the migration version because the
old version will not be able to retrieve the interrupt_error value. Can
you somewhat figure out it in the pre_load callback instead?
Hmm... well, migration from usbredir is new in 1.3, so you do have time
to change the protocol. You do not need zero, you do not need
VMSTATE_UNUSED. But you'd better do this change as well in a certain
downstream you care about, otherwise you'll have the same problem soon.
Paolo
> uint16_t max_packet_size; /* In bytes, not wMaxPacketSize format !! */
> uint8_t iso_started;
> uint8_t iso_error; /* For reporting iso errors to the HC */
> uint8_t interrupt_started;
> - uint8_t interrupt_error;
> uint8_t bufpq_prefilled;
> uint8_t bufpq_dropping_packets;
> QTAILQ_HEAD(, buf_packet) bufpq;
> @@ -626,7 +626,7 @@ static void usbredir_handle_interrupt_in_data(USBRedirDevice *dev,
> int status, len;
>
> if (!dev->endpoint[EP2I(ep)].interrupt_started &&
> - !dev->endpoint[EP2I(ep)].interrupt_error) {
> + QTAILQ_EMPTY(&dev->endpoint[EP2I(ep)].bufpq)) {
> struct usb_redir_start_interrupt_receiving_header start_int = {
> .endpoint = ep,
> };
> @@ -645,14 +645,7 @@ static void usbredir_handle_interrupt_in_data(USBRedirDevice *dev,
> intp = QTAILQ_FIRST(&dev->endpoint[EP2I(ep)].bufpq);
> if (intp == NULL) {
> DPRINTF2("interrupt-token-in ep %02X, no intp\n", ep);
> - /* Check interrupt_error for stream errors */
> - status = dev->endpoint[EP2I(ep)].interrupt_error;
> - dev->endpoint[EP2I(ep)].interrupt_error = 0;
> - if (status) {
> - usbredir_handle_status(dev, p, status);
> - } else {
> - p->status = USB_RET_NAK;
> - }
> + p->status = USB_RET_NAK;
> return;
> }
> DPRINTF("interrupt-token-in ep %02X status %d len %d\n", ep,
> @@ -708,7 +701,6 @@ static void usbredir_stop_interrupt_receiving(USBRedirDevice *dev,
> DPRINTF("interrupt recv stopped ep %02X\n", ep);
> dev->endpoint[EP2I(ep)].interrupt_started = 0;
> }
> - dev->endpoint[EP2I(ep)].interrupt_error = 0;
> usbredir_free_bufpq(dev, ep);
> }
>
> @@ -1513,20 +1505,22 @@ static void usbredir_interrupt_receiving_status(void *priv, uint64_t id,
> {
> USBRedirDevice *dev = priv;
> uint8_t ep = interrupt_receiving_status->endpoint;
> + uint8_t status = interrupt_receiving_status->status;
>
> DPRINTF("interrupt recv status %d ep %02X id %"PRIu64"\n",
> interrupt_receiving_status->status, ep, id);
>
> - if (!dev->dev.attached || !dev->endpoint[EP2I(ep)].interrupt_started) {
> + if (!dev->dev.attached || !dev->endpoint[EP2I(ep)].interrupt_started ||
> + status == usb_redir_success) {
> return;
> }
>
> - dev->endpoint[EP2I(ep)].interrupt_error =
> - interrupt_receiving_status->status;
> if (interrupt_receiving_status->status == usb_redir_stall) {
> DPRINTF("interrupt receiving stopped by peer ep %02X\n", ep);
> dev->endpoint[EP2I(ep)].interrupt_started = 0;
> + status = usb_redir_ioerror;
> }
> + bufp_alloc(dev, NULL, 0, status, ep);
> }
>
> static void usbredir_bulk_streams_status(void *priv, uint64_t id,
> @@ -1833,7 +1827,7 @@ static const VMStateDescription usbredir_ep_vmstate = {
> VMSTATE_UINT8(iso_started, struct endp_data),
> VMSTATE_UINT8(iso_error, struct endp_data),
> VMSTATE_UINT8(interrupt_started, struct endp_data),
> - VMSTATE_UINT8(interrupt_error, struct endp_data),
> + VMSTATE_UINT8(zero, struct endp_data), /* Was interrupt_error */
> VMSTATE_UINT8(bufpq_prefilled, struct endp_data),
> VMSTATE_UINT8(bufpq_dropping_packets, struct endp_data),
> {
>
next prev parent reply other threads:[~2012-11-07 9:51 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 [this message]
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 ` [Qemu-devel] [PATCH 5/8] ehci: Lower timer freq when there are no iso packets in the periodic schedule Hans de Goede
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=509A2F19.3020007@redhat.com \
--to=pbonzini@redhat.com \
--cc=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).