All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/5] Usb 20181001 patches
@ 2018-10-01  9:28 Gerd Hoffmann
  2018-10-01  9:28 ` [Qemu-devel] [PULL 1/5] usb-mtp: fix error conditions for write operation Gerd Hoffmann
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2018-10-01  9:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

The following changes since commit 07f426c35eddd79388a23d11cb278600d7e3831d:

  Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20180926' into staging (2018-09-28 18:56:09 +0100)

are available in the git repository at:

  git://git.kraxel.org/qemu tags/usb-20181001-pull-request

for you to fetch changes up to a60f39a4681b369bdcc78a9d1a1067d4a6bb8736:

  ohci: set effectively usb frame rate to 1kHz (2018-10-01 10:49:54 +0200)

----------------------------------------------------------------
usb: fixes for mtp, hub and ohci.

----------------------------------------------------------------

Bandan (2):
  usb-mtp: fix error conditions for write operation
  doc: replace x-root with rootdir for usb-mtp

Bandan Das (1):
  usb-mtp: reset ObjectInfo dataset size on cleanup

Gerd Hoffmann (1):
  usb-hub: clear suspend on detach

Miguel GAIO (1):
  ohci: set effectively usb frame rate to 1kHz

 hw/usb/dev-hub.c          | 4 ++++
 hw/usb/dev-mtp.c          | 9 ++++++---
 hw/usb/hcd-ohci.c         | 6 +++++-
 qemu-doc.texi             | 2 +-
 scripts/device-crash-test | 2 +-
 5 files changed, 17 insertions(+), 6 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PULL 1/5] usb-mtp: fix error conditions for write operation
  2018-10-01  9:28 [Qemu-devel] [PULL 0/5] Usb 20181001 patches Gerd Hoffmann
@ 2018-10-01  9:28 ` Gerd Hoffmann
  2018-10-01  9:28 ` [Qemu-devel] [PULL 2/5] doc: replace x-root with rootdir for usb-mtp Gerd Hoffmann
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2018-10-01  9:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Bandan

From: Bandan <bsd@redhat.com>

Return STORE_FULL if we can't write all the bytes but
return incomplete transfer if data received is less then
what was specified in the metadata. Also, use d->offset
as the file size which is valid for all file sizes.

Signed-off-by: Bandan <bsd@redhat.com>
Message-id: 20180907220851.9658-2-bsd@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/dev-mtp.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 3fdc4b0da1..15edf3bb82 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -1665,13 +1665,14 @@ static void usb_mtp_write_data(MTPState *s)
             goto success;
         }
 
-        rc = write_retry(d->fd, d->data, s->dataset.size);
-        if (!rc) {
+        rc = write_retry(d->fd, d->data, d->offset);
+        if (rc != d->offset) {
             usb_mtp_queue_result(s, RES_STORE_FULL, d->trans,
                                  0, 0, 0, 0);
             goto done;
             }
-        if (rc != s->dataset.size) {
+        /* Only for < 4G file sizes */
+        if (s->dataset.size != 0xFFFFFFFF && rc != s->dataset.size) {
             usb_mtp_queue_result(s, RES_INCOMPLETE_TRANSFER, d->trans,
                                  0, 0, 0, 0);
             goto done;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PULL 2/5] doc: replace x-root with rootdir for usb-mtp
  2018-10-01  9:28 [Qemu-devel] [PULL 0/5] Usb 20181001 patches Gerd Hoffmann
  2018-10-01  9:28 ` [Qemu-devel] [PULL 1/5] usb-mtp: fix error conditions for write operation Gerd Hoffmann
@ 2018-10-01  9:28 ` Gerd Hoffmann
  2018-10-01  9:28 ` [Qemu-devel] [PULL 3/5] usb-mtp: reset ObjectInfo dataset size on cleanup Gerd Hoffmann
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2018-10-01  9:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Bandan

From: Bandan <bsd@redhat.com>

Signed-off-by: Bandan <bsd@redhat.com>
Message-id: 20180907220851.9658-3-bsd@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 qemu-doc.texi             | 2 +-
 scripts/device-crash-test | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/qemu-doc.texi b/qemu-doc.texi
index 7bd449f398..f7ad1dfe4b 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -943,7 +943,7 @@ for details
 Bulk-only transport storage device, see
 @url{https://git.qemu.org/?p=qemu.git;a=blob_plain;f=docs/usb-storage.txt,usb-storage.txt}
 for details here, too
-@item usb-mtp,x-root=@var{dir}
+@item usb-mtp,rootdir=@var{dir}
 Media transfer protocol device, using @var{dir} as root of the file tree
 that is presented to the guest.
 @item usb-host,hostbus=@var{bus},hostaddr=@var{addr}
diff --git a/scripts/device-crash-test b/scripts/device-crash-test
index e6c233e9bf..7045594bd4 100755
--- a/scripts/device-crash-test
+++ b/scripts/device-crash-test
@@ -125,7 +125,7 @@ ERROR_WHITELIST = [
     {'device':'tpm-tis', 'expected':True},                 # tpm_tis: backend driver with id (null) could not be found
     {'device':'unimplemented-device', 'expected':True},    # property 'size' not specified or zero
     {'device':'usb-braille', 'expected':True},             # Property chardev is required
-    {'device':'usb-mtp', 'expected':True},                 # x-root property must be configured
+    {'device':'usb-mtp', 'expected':True},                 # rootdir property must be configured
     {'device':'usb-redir', 'expected':True},               # Parameter 'chardev' is missing
     {'device':'usb-serial', 'expected':True},              # Property chardev is required
     {'device':'usb-storage', 'expected':True},             # drive property not set
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PULL 3/5] usb-mtp: reset ObjectInfo dataset size on cleanup
  2018-10-01  9:28 [Qemu-devel] [PULL 0/5] Usb 20181001 patches Gerd Hoffmann
  2018-10-01  9:28 ` [Qemu-devel] [PULL 1/5] usb-mtp: fix error conditions for write operation Gerd Hoffmann
  2018-10-01  9:28 ` [Qemu-devel] [PULL 2/5] doc: replace x-root with rootdir for usb-mtp Gerd Hoffmann
@ 2018-10-01  9:28 ` Gerd Hoffmann
  2018-10-01  9:28 ` [Qemu-devel] [PULL 4/5] usb-hub: clear suspend on detach Gerd Hoffmann
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2018-10-01  9:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Bandan Das

From: Bandan Das <bsd@redhat.com>

Stale values in this field may result in qemu
expecting more data on the next operation

Signed-off-by: Bandan Das <bsd@redhat.com>
Message-id: 20180907220851.9658-4-bsd@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/dev-mtp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 15edf3bb82..00a3691bae 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -1568,6 +1568,7 @@ static void usb_mtp_handle_control(USBDevice *dev, USBPacket *p,
             if (s->write_pending) {
                 g_free(s->dataset.filename);
                 s->write_pending = false;
+                s->dataset.size = 0;
             }
             usb_mtp_data_free(s->data_out);
             s->data_out = NULL;
@@ -1693,6 +1694,7 @@ done:
     }
 free:
     g_free(s->dataset.filename);
+    s->dataset.size = 0;
     g_free(path);
     s->write_pending = false;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PULL 4/5] usb-hub: clear suspend on detach
  2018-10-01  9:28 [Qemu-devel] [PULL 0/5] Usb 20181001 patches Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2018-10-01  9:28 ` [Qemu-devel] [PULL 3/5] usb-mtp: reset ObjectInfo dataset size on cleanup Gerd Hoffmann
@ 2018-10-01  9:28 ` Gerd Hoffmann
  2018-10-01  9:28 ` [Qemu-devel] [PULL 5/5] ohci: set effectively usb frame rate to 1kHz Gerd Hoffmann
  2018-10-01 14:44 ` [Qemu-devel] [PULL 0/5] Usb 20181001 patches Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2018-10-01  9:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20180912114012.6034-1-kraxel@redhat.com
---
 hw/usb/dev-hub.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c
index 5d9743ef93..dc368179d1 100644
--- a/hw/usb/dev-hub.c
+++ b/hw/usb/dev-hub.c
@@ -191,6 +191,10 @@ static void usb_hub_detach(USBPort *port1)
         port->wPortStatus &= ~PORT_STAT_ENABLE;
         port->wPortChange |= PORT_STAT_C_ENABLE;
     }
+    if (port->wPortStatus & PORT_STAT_SUSPEND) {
+        port->wPortStatus &= ~PORT_STAT_SUSPEND;
+        port->wPortChange |= PORT_STAT_C_SUSPEND;
+    }
     usb_wakeup(s->intr, 0);
 }
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PULL 5/5] ohci: set effectively usb frame rate to 1kHz
  2018-10-01  9:28 [Qemu-devel] [PULL 0/5] Usb 20181001 patches Gerd Hoffmann
                   ` (3 preceding siblings ...)
  2018-10-01  9:28 ` [Qemu-devel] [PULL 4/5] usb-hub: clear suspend on detach Gerd Hoffmann
@ 2018-10-01  9:28 ` Gerd Hoffmann
  2018-10-01 14:44 ` [Qemu-devel] [PULL 0/5] Usb 20181001 patches Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2018-10-01  9:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Miguel GAIO

From: Miguel GAIO <mgaio35@gmail.com>

USB frame rate is slightly lower than 1kHz: ie. ~950Hz.
Thus usb-audio device is not able to perform a simple audio playback
without underruns on audio backend.
eg. "-device pci-ohci,id=ohci -device usb-audio,bus=ohci.0" vs PulseAudio
backend. more than 50 underruns are observed per second.

Update ohci_sof_time computation, using QEMU_CLOCK_VIRTUAL in
ohci_usb_start(), and increment by usb_frame_time in ohci_sof()
makes USB frame rate close to 1kHz.
This way, no audio underrun are observed during audio playback.

Signed-off-by: Miguel GAIO <mgaio35@gmail.com>
Message-Id: <20180927151936.3647-1-mgaio35@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/hcd-ohci.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 98da5f0f04..66656a1133 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1253,12 +1253,12 @@ static int ohci_service_ed_list(OHCIState *ohci, uint32_t head, int completion)
 /* set a timer for EOF */
 static void ohci_eof_timer(OHCIState *ohci)
 {
-    ohci->sof_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
     timer_mod(ohci->eof_timer, ohci->sof_time + usb_frame_time);
 }
 /* Set a timer for EOF and generate a SOF event */
 static void ohci_sof(OHCIState *ohci)
 {
+    ohci->sof_time += usb_frame_time;
     ohci_eof_timer(ohci);
     ohci_set_interrupt(ohci, OHCI_INTR_SF);
 }
@@ -1362,6 +1362,7 @@ static int ohci_bus_start(OHCIState *ohci)
      * can meet some race conditions
      */
 
+    ohci->sof_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
     ohci_eof_timer(ohci);
 
     return 1;
@@ -1476,6 +1477,9 @@ static uint32_t ohci_get_frame_remaining(OHCIState *ohci)
      * set already.
      */
     tks = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - ohci->sof_time;
+    if (tks < 0) {
+        tks = 0;
+    }
 
     /* avoid muldiv if possible */
     if (tks >= usb_frame_time)
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PULL 0/5] Usb 20181001 patches
  2018-10-01  9:28 [Qemu-devel] [PULL 0/5] Usb 20181001 patches Gerd Hoffmann
                   ` (4 preceding siblings ...)
  2018-10-01  9:28 ` [Qemu-devel] [PULL 5/5] ohci: set effectively usb frame rate to 1kHz Gerd Hoffmann
@ 2018-10-01 14:44 ` Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2018-10-01 14:44 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: QEMU Developers

On 1 October 2018 at 10:28, Gerd Hoffmann <kraxel@redhat.com> wrote:
> The following changes since commit 07f426c35eddd79388a23d11cb278600d7e3831d:
>
>   Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20180926' into staging (2018-09-28 18:56:09 +0100)
>
> are available in the git repository at:
>
>   git://git.kraxel.org/qemu tags/usb-20181001-pull-request
>
> for you to fetch changes up to a60f39a4681b369bdcc78a9d1a1067d4a6bb8736:
>
>   ohci: set effectively usb frame rate to 1kHz (2018-10-01 10:49:54 +0200)
>
> ----------------------------------------------------------------
> usb: fixes for mtp, hub and ohci.
>
Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-10-01 14:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-01  9:28 [Qemu-devel] [PULL 0/5] Usb 20181001 patches Gerd Hoffmann
2018-10-01  9:28 ` [Qemu-devel] [PULL 1/5] usb-mtp: fix error conditions for write operation Gerd Hoffmann
2018-10-01  9:28 ` [Qemu-devel] [PULL 2/5] doc: replace x-root with rootdir for usb-mtp Gerd Hoffmann
2018-10-01  9:28 ` [Qemu-devel] [PULL 3/5] usb-mtp: reset ObjectInfo dataset size on cleanup Gerd Hoffmann
2018-10-01  9:28 ` [Qemu-devel] [PULL 4/5] usb-hub: clear suspend on detach Gerd Hoffmann
2018-10-01  9:28 ` [Qemu-devel] [PULL 5/5] ohci: set effectively usb frame rate to 1kHz Gerd Hoffmann
2018-10-01 14:44 ` [Qemu-devel] [PULL 0/5] Usb 20181001 patches Peter Maydell

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.