From: Jan Kiszka <jan.kiszka@siemens.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: qemu-devel <qemu-devel@nongnu.org>, Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2] usb-redir: Allow to attach USB 2.0 devices to 1.1 host controller
Date: Mon, 08 Oct 2012 19:36:38 +0200 [thread overview]
Message-ID: <50730F26.6020109@siemens.com> (raw)
In-Reply-To: <505D84F3.3070106@web.de>
On 2012-09-22 11:29, Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> This follows the logic of host-linux: If a 2.0 device has no ISO
> endpoint and no interrupt endpoint with a packet size > 64, we can
> attach it also to an 1.1 host controller. In case the redir server does
> not report endpoint sizes, play safe and remove the 1.1 compatibility as
> well. Moreover, if we detect a conflicting change in the configuration
> after the device was already attached, it will be disconnected
> immediately.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>
> Changes in v2:
> - fix incompatibility marking via introduction of compatible_speedmask
> - disconnect device if incompatibility is detected when already
> attached
>
> hw/usb/redirect.c | 24 +++++++++++++++++++++++-
> 1 files changed, 23 insertions(+), 1 deletions(-)
>
> diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
> index b10241a..2099ea4 100644
> --- a/hw/usb/redirect.c
> +++ b/hw/usb/redirect.c
> @@ -105,6 +105,7 @@ struct USBRedirDevice {
> struct usb_redir_interface_info_header interface_info;
> struct usbredirfilter_rule *filter_rules;
> int filter_rules_count;
> + int compatible_speedmask;
> };
>
> static void usbredir_hello(void *priv, struct usb_redir_hello_header *h);
> @@ -1037,6 +1038,9 @@ static int usbredir_initfn(USBDevice *udev)
> /* We'll do the attach once we receive the speed from the usb-host */
> udev->auto_attach = 0;
>
> + /* Will be cleared during setup when we find conflicts */
> + dev->compatible_speedmask = USB_SPEED_MASK_FULL;
> +
> /* Let the backend know we are ready */
> qemu_chr_fe_open(dev->cs);
> qemu_chr_add_handlers(dev->cs, usbredir_chardev_can_read,
> @@ -1177,10 +1181,12 @@ static void usbredir_device_connect(void *priv,
> case usb_redir_speed_low:
> speed = "low speed";
> dev->dev.speed = USB_SPEED_LOW;
> + dev->dev.speedmask = 0;
> break;
> case usb_redir_speed_full:
> speed = "full speed";
> dev->dev.speed = USB_SPEED_FULL;
> + dev->dev.speedmask = 0;
> break;
> case usb_redir_speed_high:
> speed = "high speed";
> @@ -1189,6 +1195,7 @@ static void usbredir_device_connect(void *priv,
> case usb_redir_speed_super:
> speed = "super speed";
> dev->dev.speed = USB_SPEED_SUPER;
> + dev->dev.speedmask = 0;
> break;
> default:
> speed = "unknown speed";
> @@ -1210,7 +1217,7 @@ static void usbredir_device_connect(void *priv,
> device_connect->device_class);
> }
>
> - dev->dev.speedmask = (1 << dev->dev.speed);
> + dev->dev.speedmask = (1 << dev->dev.speed) | dev->compatible_speedmask;
> dev->device_info = *device_connect;
>
> if (usbredir_check_filter(dev)) {
> @@ -1271,6 +1278,14 @@ static void usbredir_interface_info(void *priv,
> }
> }
>
> +static void usbredir_mark_fullspeed_incompatible(USBRedirDevice *dev)
> +{
> + dev->compatible_speedmask &= ~USB_SPEED_MASK_FULL;
> + if (dev->dev.attached && dev->dev.port->dev->speed == USB_SPEED_FULL) {
> + usbredir_device_disconnect(dev);
> + }
> +}
> +
> static void usbredir_ep_info(void *priv,
> struct usb_redir_ep_info_header *ep_info)
> {
> @@ -1286,7 +1301,14 @@ static void usbredir_ep_info(void *priv,
> case usb_redir_type_invalid:
> break;
> case usb_redir_type_iso:
> + usbredir_mark_fullspeed_incompatible(dev);
> + /* Fall through */
> case usb_redir_type_interrupt:
> + if (!usbredirparser_peer_has_cap(dev->parser,
> + usb_redir_cap_ep_info_max_packet_size) ||
> + ep_info->max_packet_size[i] > 64) {
> + usbredir_mark_fullspeed_incompatible(dev);
> + }
> if (dev->endpoint[i].interval == 0) {
> ERROR("Received 0 interval for isoc or irq endpoint\n");
> usbredir_device_disconnect(dev);
>
Any comments? Or already queued somewhere?
Jan
--
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2012-10-08 17:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-15 16:27 [Qemu-devel] [PATCH] usb-redir: Allow to attach USB 2.0 devices to 1.1 host controller Jan Kiszka
2012-09-17 9:08 ` Hans de Goede
2012-09-17 9:18 ` Jan Kiszka
2012-09-17 14:24 ` Hans de Goede
2012-09-17 16:22 ` Jan Kiszka
2012-09-18 9:41 ` Hans de Goede
2012-09-21 11:49 ` Jan Kiszka
2012-09-21 12:21 ` Hans de Goede
2012-09-21 12:25 ` Jan Kiszka
2012-09-18 21:18 ` Anthony Liguori
2012-09-19 9:20 ` Hans de Goede
2012-09-22 9:29 ` [Qemu-devel] [PATCH v2] " Jan Kiszka
2012-10-08 17:36 ` Jan Kiszka [this message]
2012-10-08 23:05 ` [Qemu-devel] [v2] " Hans de Goede
2012-10-09 8:38 ` Hans de Goede
2012-10-09 8:40 ` Gerd Hoffmann
2012-10-09 10:05 ` 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=50730F26.6020109@siemens.com \
--to=jan.kiszka@siemens.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.