qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/3] usb: Halt ep queue en cancel pending packets on a packet error
Date: Fri, 17 Aug 2012 12:30:31 +0200	[thread overview]
Message-ID: <502E1D47.9090801@redhat.com> (raw)
In-Reply-To: <1345196357-6076-1-git-send-email-hdegoede@redhat.com>

  Hi,

> Note this patch only touches the ehci and uhci controller changes, since AFAIK
> no other controllers actually queue up multiple transfer. If I'm wrong on this
> other controllers need to be updated too!

xhci does it too (although it is hard to test as xhci can happily submit
256k transfers where ehci and uhci have to use a bunch of smaller
packets instead).

Some minor nits below (the other two patches look good):

> +    /* Submitting a new packet clears halt */
> +    p->ep->halted = false;

check that the queue is empty when halted is set (i.e. enforce cancel on
error) ?

> +
>      if (QTAILQ_EMPTY(&p->ep->queue) || p->ep->pipeline) {
>          ret = usb_process_one(p);
>          if (ret == USB_RET_ASYNC) {
>              usb_packet_set_state(p, USB_PACKET_ASYNC);
>              QTAILQ_INSERT_TAIL(&p->ep->queue, p, queue);
>          } else {
> +            /*
> +             * When pipelining is enabled usb-devices must always return async,
> +             * otherwise packets can complete out of order!
> +             */
> +            assert(!p->ep->pipeline);

Strictly speaking returning something != async is fine for the first
package in the queue, but I guess in practice this doesn't matter as
enabling pipelining doesn't make sense unless you actually go async.

>              p->result = ret;
>              usb_packet_set_state(p, USB_PACKET_COMPLETE);
>          }
> @@ -402,6 +410,20 @@ int usb_handle_packet(USBDevice *dev, USBPacket *p)
>  /* Notify the controller that an async packet is complete.  This should only
>     be called for packets previously deferred by returning USB_RET_ASYNC from
>     handle_packet. */

That comments should be ...

> +static void __usb_packet_complete(USBDevice *dev, USBPacket *p)
> +{
> +    USBEndpoint *ep = p->ep;
> +
> +    assert(p->result != USB_RET_ASYNC && p->result != USB_RET_NAK);
> +
> +    if (p->result < 0) {
> +        ep->halted = true;
> +    }
> +    usb_packet_set_state(p, USB_PACKET_COMPLETE);
> +    QTAILQ_REMOVE(&ep->queue, p, queue);
> +    dev->port->ops->complete(dev->port, p);
> +}
> +

... here, where the function for the external users is.

>  void usb_packet_complete(USBDevice *dev, USBPacket *p)
>  {

cheers,
  Gerd

  parent reply	other threads:[~2012-08-17 10:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-17  9:39 [Qemu-devel] [PATCH 1/3] usb: Halt ep queue en cancel pending packets on a packet error Hans de Goede
2012-08-17  9:39 ` [Qemu-devel] [PATCH 2/3] usb: controllers do not need to check for babble themselves Hans de Goede
2012-08-17  9:39 ` [Qemu-devel] [PATCH 3/3] ehci: simplify ehci_state_executing Hans de Goede
2012-08-17 10:30 ` Gerd Hoffmann [this message]
2012-08-17 13:10   ` [Qemu-devel] [PATCH 1/3] usb: Halt ep queue en cancel pending packets on a packet error Hans de Goede
2012-08-17 17:03 ` Andreas Färber
2012-08-18  9:06   ` Hans de Goede

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=502E1D47.9090801@redhat.com \
    --to=kraxel@redhat.com \
    --cc=hdegoede@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).