* [Qemu-devel] [PATCH 0/2] usb-serial: only check speed once at realize time
@ 2014-09-19 7:25 arei.gonglei
2014-09-19 7:25 ` [Qemu-devel] [PATCH 1/2] usb-bus: introduce a wrapper function to check speed arei.gonglei
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: arei.gonglei @ 2014-09-19 7:25 UTC (permalink / raw)
To: qemu-devel
Cc: weidong.huang, luonengjun, peter.huangpeng, armbru, Gonglei,
kraxel, pbonzini
From: Gonglei <arei.gonglei@huawei.com>
This patch series based on
[PATCH v3 00/19] usb: convert device init to realize
As Paolo's comments:
usb port speed check could be extracted to a separate
function usb_check_attach, that is called just once at realize time,
even if !s->cs->be_open.
Please review, Thanks. :)
Gonglei (2):
usb-bus: introduce a wrapper function to check speed
usb-serial: only check speed once at realize time
hw/usb/bus.c | 14 +++++++++++++-
hw/usb/dev-serial.c | 16 +++++++++-------
include/hw/usb.h | 1 +
3 files changed, 23 insertions(+), 8 deletions(-)
--
1.7.12.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 1/2] usb-bus: introduce a wrapper function to check speed
2014-09-19 7:25 [Qemu-devel] [PATCH 0/2] usb-serial: only check speed once at realize time arei.gonglei
@ 2014-09-19 7:25 ` arei.gonglei
2014-09-19 7:25 ` [Qemu-devel] [PATCH 2/2] usb-serial: only check speed once at realize time arei.gonglei
2014-09-19 8:08 ` [Qemu-devel] [PATCH 0/2] " Paolo Bonzini
2 siblings, 0 replies; 6+ messages in thread
From: arei.gonglei @ 2014-09-19 7:25 UTC (permalink / raw)
To: qemu-devel
Cc: weidong.huang, luonengjun, peter.huangpeng, armbru, Gonglei,
kraxel, pbonzini
From: Gonglei <arei.gonglei@huawei.com>
In this way, we can check speed directly, don't need
call usb_device_attach(), which has other conditions,
such as checking the chardev is open.
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
hw/usb/bus.c | 14 +++++++++++++-
include/hw/usb.h | 1 +
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index b375293..da1eba9 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -478,7 +478,7 @@ static void usb_mask_to_str(char *dest, size_t size,
}
}
-void usb_device_attach(USBDevice *dev, Error **errp)
+void usb_check_attach(USBDevice *dev, Error **errp)
{
USBBus *bus = usb_bus_from_device(dev);
USBPort *port = dev->port;
@@ -499,6 +499,18 @@ void usb_device_attach(USBDevice *dev, Error **errp)
bus->qbus.name, port->path, portspeed);
return;
}
+}
+
+void usb_device_attach(USBDevice *dev, Error **errp)
+{
+ USBPort *port = dev->port;
+ Error *local_err = NULL;
+
+ usb_check_attach(dev, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
dev->attached++;
usb_attach(port);
diff --git a/include/hw/usb.h b/include/hw/usb.h
index 8ffbba2..b20b959 100644
--- a/include/hw/usb.h
+++ b/include/hw/usb.h
@@ -553,6 +553,7 @@ void usb_release_port(USBDevice *dev);
void usb_device_attach(USBDevice *dev, Error **errp);
int usb_device_detach(USBDevice *dev);
int usb_device_delete_addr(int busnr, int addr);
+void usb_check_attach(USBDevice *dev, Error **errp);
static inline USBBus *usb_bus_from_device(USBDevice *d)
{
--
1.7.12.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 2/2] usb-serial: only check speed once at realize time
2014-09-19 7:25 [Qemu-devel] [PATCH 0/2] usb-serial: only check speed once at realize time arei.gonglei
2014-09-19 7:25 ` [Qemu-devel] [PATCH 1/2] usb-bus: introduce a wrapper function to check speed arei.gonglei
@ 2014-09-19 7:25 ` arei.gonglei
2014-09-19 8:08 ` [Qemu-devel] [PATCH 0/2] " Paolo Bonzini
2 siblings, 0 replies; 6+ messages in thread
From: arei.gonglei @ 2014-09-19 7:25 UTC (permalink / raw)
To: qemu-devel
Cc: weidong.huang, luonengjun, peter.huangpeng, armbru, Gonglei,
kraxel, pbonzini
From: Gonglei <arei.gonglei@huawei.com>
Whatever the chardev is open or not, we should assure
the speed is matched each other. So, call usb_check_attach()
check speed. And then pass &error_abort at all calls to
usb_device_attach().
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
hw/usb/dev-serial.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
index 3784f4a..1cee450 100644
--- a/hw/usb/dev-serial.c
+++ b/hw/usb/dev-serial.c
@@ -451,7 +451,6 @@ static void usb_serial_read(void *opaque, const uint8_t *buf, int size)
static void usb_serial_event(void *opaque, int event)
{
USBSerialState *s = opaque;
- Error *local_err = NULL;
switch (event) {
case CHR_EVENT_BREAK:
@@ -461,11 +460,7 @@ static void usb_serial_event(void *opaque, int event)
break;
case CHR_EVENT_OPENED:
if (!s->dev.attached) {
- usb_device_attach(&s->dev, &local_err);
- if (local_err) {
- qerror_report_err(local_err);
- error_free(local_err);
- }
+ usb_device_attach(&s->dev, &error_abort);
}
break;
case CHR_EVENT_CLOSED:
@@ -479,6 +474,7 @@ static void usb_serial_event(void *opaque, int event)
static void usb_serial_realize(USBDevice *dev, Error **errp)
{
USBSerialState *s = DO_UPCAST(USBSerialState, dev, dev);
+ Error *local_err = NULL;
usb_desc_create_serial(dev);
usb_desc_init(dev);
@@ -489,12 +485,18 @@ static void usb_serial_realize(USBDevice *dev, Error **errp)
return;
}
+ usb_check_attach(dev, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
+
qemu_chr_add_handlers(s->cs, usb_serial_can_read, usb_serial_read,
usb_serial_event, s);
usb_serial_handle_reset(dev);
if (s->cs->be_open && !dev->attached) {
- usb_device_attach(dev, errp);
+ usb_device_attach(dev, &error_abort);
}
}
--
1.7.12.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] usb-serial: only check speed once at realize time
2014-09-19 7:25 [Qemu-devel] [PATCH 0/2] usb-serial: only check speed once at realize time arei.gonglei
2014-09-19 7:25 ` [Qemu-devel] [PATCH 1/2] usb-bus: introduce a wrapper function to check speed arei.gonglei
2014-09-19 7:25 ` [Qemu-devel] [PATCH 2/2] usb-serial: only check speed once at realize time arei.gonglei
@ 2014-09-19 8:08 ` Paolo Bonzini
2014-09-19 8:12 ` Gonglei (Arei)
2014-09-23 10:59 ` Gonglei (Arei)
2 siblings, 2 replies; 6+ messages in thread
From: Paolo Bonzini @ 2014-09-19 8:08 UTC (permalink / raw)
To: arei.gonglei, qemu-devel
Cc: luonengjun, kraxel, weidong.huang, peter.huangpeng, armbru
Il 19/09/2014 09:25, arei.gonglei@huawei.com ha scritto:
> From: Gonglei <arei.gonglei@huawei.com>
>
> This patch series based on
> [PATCH v3 00/19] usb: convert device init to realize
>
> As Paolo's comments:
>
> usb port speed check could be extracted to a separate
> function usb_check_attach, that is called just once at realize time,
> even if !s->cs->be_open.
>
> Please review, Thanks. :)
>
> Gonglei (2):
> usb-bus: introduce a wrapper function to check speed
> usb-serial: only check speed once at realize time
>
> hw/usb/bus.c | 14 +++++++++++++-
> hw/usb/dev-serial.c | 16 +++++++++-------
> include/hw/usb.h | 1 +
> 3 files changed, 23 insertions(+), 8 deletions(-)
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] usb-serial: only check speed once at realize time
2014-09-19 8:08 ` [Qemu-devel] [PATCH 0/2] " Paolo Bonzini
@ 2014-09-19 8:12 ` Gonglei (Arei)
2014-09-23 10:59 ` Gonglei (Arei)
1 sibling, 0 replies; 6+ messages in thread
From: Gonglei (Arei) @ 2014-09-19 8:12 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel@nongnu.org
Cc: Luonengjun, kraxel@redhat.com, Huangweidong (C),
Huangpeng (Peter), armbru@redhat.com
> Il 19/09/2014 09:25, arei.gonglei@huawei.com ha scritto:
> > From: Gonglei <arei.gonglei@huawei.com>
> >
> > This patch series based on
> > [PATCH v3 00/19] usb: convert device init to realize
> >
> > As Paolo's comments:
> >
> > usb port speed check could be extracted to a separate
> > function usb_check_attach, that is called just once at realize time,
> > even if !s->cs->be_open.
> >
> > Please review, Thanks. :)
> >
> > Gonglei (2):
> > usb-bus: introduce a wrapper function to check speed
> > usb-serial: only check speed once at realize time
> >
> > hw/usb/bus.c | 14 +++++++++++++-
> > hw/usb/dev-serial.c | 16 +++++++++-------
> > include/hw/usb.h | 1 +
> > 3 files changed, 23 insertions(+), 8 deletions(-)
> >
>
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Thanks !
Best regards,
-Gonglei
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] usb-serial: only check speed once at realize time
2014-09-19 8:08 ` [Qemu-devel] [PATCH 0/2] " Paolo Bonzini
2014-09-19 8:12 ` Gonglei (Arei)
@ 2014-09-23 10:59 ` Gonglei (Arei)
1 sibling, 0 replies; 6+ messages in thread
From: Gonglei (Arei) @ 2014-09-23 10:59 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel@nongnu.org
Cc: Luonengjun, kraxel@redhat.com, Huangweidong (C),
Huangpeng (Peter), armbru@redhat.com
And this one :) Thanks!
Best regards,
-Gonglei
> -----Original Message-----
> From: Paolo Bonzini [mailto:paolo.bonzini@gmail.com] On Behalf Of Paolo
> Bonzini
> Sent: Friday, September 19, 2014 4:08 PM
> To: Gonglei (Arei); qemu-devel@nongnu.org
> Cc: Huangweidong (C); Luonengjun; Huangpeng (Peter); armbru@redhat.com;
> kraxel@redhat.com
> Subject: Re: [PATCH 0/2] usb-serial: only check speed once at realize time
>
> Il 19/09/2014 09:25, arei.gonglei@huawei.com ha scritto:
> > From: Gonglei <arei.gonglei@huawei.com>
> >
> > This patch series based on
> > [PATCH v3 00/19] usb: convert device init to realize
> >
> > As Paolo's comments:
> >
> > usb port speed check could be extracted to a separate
> > function usb_check_attach, that is called just once at realize time,
> > even if !s->cs->be_open.
> >
> > Please review, Thanks. :)
> >
> > Gonglei (2):
> > usb-bus: introduce a wrapper function to check speed
> > usb-serial: only check speed once at realize time
> >
> > hw/usb/bus.c | 14 +++++++++++++-
> > hw/usb/dev-serial.c | 16 +++++++++-------
> > include/hw/usb.h | 1 +
> > 3 files changed, 23 insertions(+), 8 deletions(-)
> >
>
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-09-23 11:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-19 7:25 [Qemu-devel] [PATCH 0/2] usb-serial: only check speed once at realize time arei.gonglei
2014-09-19 7:25 ` [Qemu-devel] [PATCH 1/2] usb-bus: introduce a wrapper function to check speed arei.gonglei
2014-09-19 7:25 ` [Qemu-devel] [PATCH 2/2] usb-serial: only check speed once at realize time arei.gonglei
2014-09-19 8:08 ` [Qemu-devel] [PATCH 0/2] " Paolo Bonzini
2014-09-19 8:12 ` Gonglei (Arei)
2014-09-23 10:59 ` Gonglei (Arei)
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).