From: Hans de Goede <hdegoede@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 15/22] usb: Add packet combining functions
Date: Tue, 30 Oct 2012 14:23:39 +0100 [thread overview]
Message-ID: <508FD4DB.7000900@redhat.com> (raw)
In-Reply-To: <5088E259.1080206@redhat.com>
Hi,
On 10/25/2012 08:55 AM, Gerd Hoffmann wrote:
> On 10/24/12 18:14, Hans de Goede wrote:
>> + /*
>> + * Process / cancel combined packets, called from
>> + * usb_ep_combine_input_packets() / usb_combined_packet_cancel().
>> + * Only called for devices which call these functions themselves.
>> + */
>> + int (*handle_combined_data)(USBDevice *dev, USBPacket *p);
>> + void (*cancel_combined_packet)(USBDevice *dev, USBPacket *p);
>
> I still think these should get a USBCombinedPacket not a USBPacket.
I just rebased my tree's USB bits to your usb.68 pull req, and then
tried to make this change, and then I realized again why at least
handle_combined_data is not getting a USBCombinedPacket as argument.
The call sequence goes like this:
1) hcd calls usb_handle_packet
2) usb_handle_packet calls devices handle_data (through process_one)
3) device's handle_data sees this is for a input ep on which it is
doing input pipelining, returns USB_RET_ADD_TO_QUEUE
4) hcd calls usb_device_flush_ep_queue
5) usb_device_flush_ep_queue calls usb_ep_combine_input_packets
6) usb_ep_combine_input_packets either ends up with a combined
packet, or with a single regular packet to send to
the device
Currently usb_ep_combine_input_packets calls the device's
handle_combined_data method in both cases, and that can distinguish
between the 2 scenarios by checking the passed in USBPacket's
combined field.
I did things this way, even though it may seem more logical for
usb_ep_combine_input_packets to call the device's "regular"
handle_data method in case no combining is done for a packet,
so it is submitting a single regular packet, but in that case
we would end up at step 3) again, and the device's handle_data
will again return USB_RET_ADD_TO_QUEUE which is not what we want.
This is why handle_combined_data takes a USBPacket, and then checks
USBPacket->combined to see what to do, rather then taking a
USBCombinedPacket, as usb_ep_combine_input_packets simply does
not always have a combined packet to pass.
Alternatives to allow handle_combined_data to take a
USBCombinedPacket, would be:
1) Some flag to the device's handle_data method to indicate
it should *really* process the packet and not return
USB_RET_ADD_TO_QUEUE
2) Always make Uc allocate a USBCombinedPacket,
even when the entire transfer consists of only a single
packet, note that this in essence means an unnecessary
malloc + free call per such packet, and for example with
(redirected) usb-mass-storage one can expect each scsi
sense phase transfer to be only a single packet large,
and for smaller reads the data phase packets as well!
IMHO either alternative is worse then simply passing
a USBPacket to handle_combined_data, and let the
device's handle_combined_data figure out what to do
based on USBPacket->combined. Note that if it were
to take a USBCombinedPacket, it would end up getting
back to the USBPacket itself through
USBCombinedPacket->first anyways to get info from there
such as the packet id.
Regards,
Hans
next prev parent reply other threads:[~2012-10-30 13:22 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-24 16:13 [Qemu-devel] usb: input-pipelining + speedups v3 Hans de Goede
2012-10-24 16:13 ` [Qemu-devel] [PATCH 01/22] uhci: Properly unmap packets on cancel / invalid pid Hans de Goede
2012-10-24 16:13 ` [Qemu-devel] [PATCH 02/22] uhci: Move checks to continue queuing to uhci_fill_queue() Hans de Goede
2012-10-24 16:13 ` [Qemu-devel] [PATCH 03/22] ehci: Get rid of packet tbytes field Hans de Goede
2012-10-24 16:14 ` [Qemu-devel] [PATCH 04/22] ehci: Set int flag on a short input packet Hans de Goede
2012-10-24 16:14 ` [Qemu-devel] [PATCH 05/22] ehci: Improve latency of interrupt delivery and async schedule scanning Hans de Goede
2012-10-24 16:14 ` [Qemu-devel] [PATCH 06/22] ehci: Speed up the timer of raising int from the async schedule Hans de Goede
2012-10-24 16:14 ` [Qemu-devel] [PATCH 07/22] ehci: Detect going in circles when filling the queue Hans de Goede
2012-10-24 16:14 ` [Qemu-devel] [PATCH 08/22] ehci: Retry to fill the queue while waiting for td completion Hans de Goede
2012-10-24 16:14 ` [Qemu-devel] [PATCH 09/22] xhci: Add a xhci_ep_nuke_one_xfer helper function Hans de Goede
2012-10-24 16:14 ` [Qemu-devel] [PATCH 10/22] usb: Rename __usb_packet_complete to usb_packet_complete_one Hans de Goede
2012-10-24 16:14 ` [Qemu-devel] [PATCH 11/22] usb: Add USB_RET_ADD_TO_QUEUE packet result code Hans de Goede
2012-10-24 16:14 ` [Qemu-devel] [PATCH 12/22] usb: Move clearing of queue on halt to the core Hans de Goede
2012-10-24 16:14 ` [Qemu-devel] [PATCH 13/22] usb: Move short-not-ok handling " Hans de Goede
2012-10-24 16:14 ` [Qemu-devel] [PATCH 14/22] usb: Add an int_req flag to USBPacket Hans de Goede
2012-10-24 16:14 ` [Qemu-devel] [PATCH 15/22] usb: Add packet combining functions Hans de Goede
2012-10-25 6:55 ` Gerd Hoffmann
2012-10-30 13:23 ` Hans de Goede [this message]
2012-10-30 13:25 ` Hans de Goede
2012-10-30 13:38 ` Hans de Goede
2012-10-24 16:14 ` [Qemu-devel] [PATCH 16/22] combined-packet: Add a workaround for Linux usbfs + live migration Hans de Goede
2012-10-24 16:14 ` [Qemu-devel] [PATCH 17/22] usb-redir: Add support for 32 bits bulk packet length Hans de Goede
2012-10-24 16:14 ` [Qemu-devel] [PATCH 18/22] usb-redir: Add support for input pipelining Hans de Goede
2012-10-24 16:14 ` [Qemu-devel] [PATCH 19/22] usb-redir: Add an usbredir_setup_usb_eps() helper function Hans de Goede
2012-10-24 16:14 ` [Qemu-devel] [PATCH 20/22] usb-redir: Use reject rather the disconnect on bad ep info Hans de Goede
2012-10-24 16:14 ` [Qemu-devel] [PATCH 21/22] usb-redir: Allow to attach USB 2.0 devices to 1.1 host controller Hans de Goede
2012-10-24 16:14 ` [Qemu-devel] [PATCH 22/22] usb-redir: Allow redirecting super speed devices to high speed controllers Hans de Goede
2012-10-25 7:13 ` [Qemu-devel] usb: input-pipelining + speedups v3 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=508FD4DB.7000900@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).