All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/5] Fixes 20190402 patches
@ 2019-04-02  6:46 Gerd Hoffmann
  2019-04-02  6:46 ` [Qemu-devel] [PULL 1/5] Revert "audio: fix pc speaker init" Gerd Hoffmann
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2019-04-02  6:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

The following changes since commit 230ce19814ecc6bff8edac3b5b86e7c82f422c6c:

  Merge remote-tracking branch 'remotes/rth/tags/pull-axp-20190325' into staging (2019-03-29 19:29:00 +0000)

are available in the Git repository at:

  git://git.kraxel.org/qemu tags/fixes-20190402-pull-request

for you to fetch changes up to be1092afa07794e5247eb504095fb5f2ae421ec6:

  audio: fix audio timer rate conversion bug (2019-04-02 07:50:49 +0200)

----------------------------------------------------------------
fixes for 4.0 (audio, usb),

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

Bandan Das (2):
  usb-mtp: fix return status of delete
  usb-mtp: remove usb_mtp_object_free_one

Gerd Hoffmann (1):
  Revert "audio: fix pc speaker init"

Peter Maydell (1):
  hw/usb/bus.c: Handle "no speed matched" case in usb_mask_to_str()

Volker Rümelin (1):
  audio: fix audio timer rate conversion bug

 audio/audio.c        |  2 +-
 audio/audio_legacy.c |  6 ++++
 hw/audio/pcspk.c     | 36 ++++++++++++---------
 hw/usb/bus.c         |  4 +++
 hw/usb/dev-mtp.c     | 76 +++++++++++++++++++++-----------------------
 5 files changed, 68 insertions(+), 56 deletions(-)

-- 
2.18.1

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

* [Qemu-devel] [PULL 1/5] Revert "audio: fix pc speaker init"
  2019-04-02  6:46 [Qemu-devel] [PULL 0/5] Fixes 20190402 patches Gerd Hoffmann
@ 2019-04-02  6:46 ` Gerd Hoffmann
  2019-04-02  6:46 ` [Qemu-devel] [PULL 2/5] hw/usb/bus.c: Handle "no speed matched" case in usb_mask_to_str() Gerd Hoffmann
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2019-04-02  6:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

This reverts commit bd56d378842c238c8901536c06c20a4a51ee9761.

Turned out it isn't that simple as the device needs the pit object link.
So "-device isa-pcspk" isn't going wo work anyway.  We are in freeze, so
just reverting the thing is the best way to handle this for now, trying
to come up with something better can be done in the 4.1 devel cycle.

Also add a comment noting the object link.

Reported-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20190328071121.21147-1-kraxel@redhat.com
---
 hw/audio/pcspk.c | 36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
index fdbb4b6e9923..9c7fd74aeba7 100644
--- a/hw/audio/pcspk.c
+++ b/hw/audio/pcspk.c
@@ -57,6 +57,7 @@ typedef struct {
 } PCSpkState;
 
 static const char *s_spk = "pcspk";
+static PCSpkState *pcspk_state;
 
 static inline void generate_samples(PCSpkState *s)
 {
@@ -110,6 +111,22 @@ static void pcspk_callback(void *opaque, int free)
     }
 }
 
+static int pcspk_audio_init(ISABus *bus)
+{
+    PCSpkState *s = pcspk_state;
+    struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUDIO_FORMAT_U8, 0};
+
+    AUD_register_card(s_spk, &s->card);
+
+    s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as);
+    if (!s->voice) {
+        AUD_log(s_spk, "Could not open voice\n");
+        return -1;
+    }
+
+    return 0;
+}
+
 static uint64_t pcspk_io_read(void *opaque, hwaddr addr,
                               unsigned size)
 {
@@ -162,20 +179,12 @@ static void pcspk_initfn(Object *obj)
 
 static void pcspk_realizefn(DeviceState *dev, Error **errp)
 {
-    struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUDIO_FORMAT_U8, 0};
     ISADevice *isadev = ISA_DEVICE(dev);
     PCSpkState *s = PC_SPEAKER(dev);
 
     isa_register_ioport(isadev, &s->ioport, s->iobase);
 
-    AUD_register_card(s_spk, &s->card);
-
-    s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as);
-    if (!s->voice) {
-        error_setg(errp, "Initializing audio voice failed");
-        AUD_remove_card(&s->card);
-        return;
-    }
+    pcspk_state = s;
 }
 
 static bool migrate_needed(void *opaque)
@@ -212,6 +221,9 @@ static void pcspk_class_initfn(ObjectClass *klass, void *data)
     set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
     dc->vmsd = &vmstate_spk;
     dc->props = pcspk_properties;
+    /* Reason: realize sets global pcspk_state */
+    /* Reason: pit object link */
+    dc->user_creatable = false;
 }
 
 static const TypeInfo pcspk_info = {
@@ -222,12 +234,6 @@ static const TypeInfo pcspk_info = {
     .class_init     = pcspk_class_initfn,
 };
 
-static int pcspk_audio_init(ISABus *bus)
-{
-    isa_create_simple(bus, TYPE_PC_SPEAKER);
-    return 0;
-}
-
 static void pcspk_register(void)
 {
     type_register_static(&pcspk_info);
-- 
2.18.1

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

* [Qemu-devel] [PULL 2/5] hw/usb/bus.c: Handle "no speed matched" case in usb_mask_to_str()
  2019-04-02  6:46 [Qemu-devel] [PULL 0/5] Fixes 20190402 patches Gerd Hoffmann
  2019-04-02  6:46 ` [Qemu-devel] [PULL 1/5] Revert "audio: fix pc speaker init" Gerd Hoffmann
@ 2019-04-02  6:46 ` Gerd Hoffmann
  2019-04-02  6:46 ` [Qemu-devel] [PULL 3/5] usb-mtp: fix return status of delete Gerd Hoffmann
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2019-04-02  6:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Peter Maydell

From: Peter Maydell <peter.maydell@linaro.org>

In usb_mask_to_str() we convert a mask of USB speeds into
a human-readable string (like "full+high") for use in
tracing and error messages. However the conversion code
doesn't do anything to the string buffer if the passed in
speedmask doesn't match any of the recognized speeds,
which means that the tracing and error messages will
end up with random garbage in them. This can happen if
we're doing USB device passthrough.

Handle the "unrecognized speed" case by using the
string "unknown".

Fixes: https://bugs.launchpad.net/qemu/+bug/1603785
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20190328133503.6490-1-peter.maydell@linaro.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/bus.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 6fffab7bfa44..9a74dc956010 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -500,6 +500,10 @@ static void usb_mask_to_str(char *dest, size_t size,
                             speeds[i].name);
         }
     }
+
+    if (pos == 0) {
+        snprintf(dest, size, "unknown");
+    }
 }
 
 void usb_check_attach(USBDevice *dev, Error **errp)
-- 
2.18.1

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

* [Qemu-devel] [PULL 3/5] usb-mtp: fix return status of delete
  2019-04-02  6:46 [Qemu-devel] [PULL 0/5] Fixes 20190402 patches Gerd Hoffmann
  2019-04-02  6:46 ` [Qemu-devel] [PULL 1/5] Revert "audio: fix pc speaker init" Gerd Hoffmann
  2019-04-02  6:46 ` [Qemu-devel] [PULL 2/5] hw/usb/bus.c: Handle "no speed matched" case in usb_mask_to_str() Gerd Hoffmann
@ 2019-04-02  6:46 ` Gerd Hoffmann
  2019-04-02  6:46 ` [Qemu-devel] [PULL 4/5] usb-mtp: remove usb_mtp_object_free_one Gerd Hoffmann
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2019-04-02  6:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Bandan Das

From: Bandan Das <bsd@redhat.com>

Spotted by Coverity: CID 1399414

mtp delete allows the return status of delete succeeded,
partial_delete or readonly - when none of the objects could be
deleted. Give more meaningful names to return values of the
delete function.

Some initiators recurse over the objects themselves. In that case,
only READ_ONLY can be returned.

Signed-off-by: Bandan Das <bsd@redhat.com>
Message-Id: <20190401211712.19012-2-bsd@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/dev-mtp.c | 62 ++++++++++++++++++++++++++----------------------
 1 file changed, 34 insertions(+), 28 deletions(-)

diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 06e376bcd211..91b820baafd8 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -1135,11 +1135,19 @@ static MTPData *usb_mtp_get_object_prop_value(MTPState *s, MTPControl *c,
     return d;
 }
 
-/* Return correct return code for a delete event */
+/*
+ * Return values when object @o is deleted.
+ * If at least one of the deletions succeeded,
+ * DELETE_SUCCESS is set and if at least one
+ * of the deletions failed, DELETE_FAILURE is
+ * set. Both bits being set (DELETE_PARTIAL)
+ * signifies a  RES_PARTIAL_DELETE being sent
+ * back to the initiator.
+ */
 enum {
-    ALL_DELETE,
-    PARTIAL_DELETE,
-    READ_ONLY,
+    DELETE_SUCCESS = (1 << 0),
+    DELETE_FAILURE = (1 << 1),
+    DELETE_PARTIAL = (DELETE_FAILURE | DELETE_SUCCESS),
 };
 
 /* Assumes that children, if any, have been already freed */
@@ -1155,8 +1163,7 @@ static void usb_mtp_object_free_one(MTPState *s, MTPObject *o)
 static int usb_mtp_deletefn(MTPState *s, MTPObject *o, uint32_t trans)
 {
     MTPObject *iter, *iter2;
-    bool partial_delete = false;
-    bool success = false;
+    int ret = 0;
 
     /*
      * TODO: Add support for Protection Status
@@ -1165,34 +1172,28 @@ static int usb_mtp_deletefn(MTPState *s, MTPObject *o, uint32_t trans)
     QLIST_FOREACH(iter, &o->children, list) {
         if (iter->format == FMT_ASSOCIATION) {
             QLIST_FOREACH(iter2, &iter->children, list) {
-                usb_mtp_deletefn(s, iter2, trans);
+                ret |= usb_mtp_deletefn(s, iter2, trans);
             }
         }
     }
 
     if (o->format == FMT_UNDEFINED_OBJECT) {
         if (remove(o->path)) {
-            partial_delete = true;
+            ret |= DELETE_FAILURE;
         } else {
             usb_mtp_object_free_one(s, o);
-            success = true;
+            ret |= DELETE_SUCCESS;
         }
     } else if (o->format == FMT_ASSOCIATION) {
         if (rmdir(o->path)) {
-            partial_delete = true;
+            ret |= DELETE_FAILURE;
         } else {
             usb_mtp_object_free_one(s, o);
-            success = true;
+            ret |= DELETE_SUCCESS;
         }
     }
 
-    if (success && partial_delete) {
-        return PARTIAL_DELETE;
-    }
-    if (!success && partial_delete) {
-        return READ_ONLY;
-    }
-    return ALL_DELETE;
+    return ret;
 }
 
 static void usb_mtp_object_delete(MTPState *s, uint32_t handle,
@@ -1226,19 +1227,24 @@ static void usb_mtp_object_delete(MTPState *s, uint32_t handle,
     }
 
     ret = usb_mtp_deletefn(s, o, trans);
-    if (ret == PARTIAL_DELETE) {
-        usb_mtp_queue_result(s, RES_PARTIAL_DELETE,
-                             trans, 0, 0, 0, 0);
-        return;
-    } else if (ret == READ_ONLY) {
-        usb_mtp_queue_result(s, RES_STORE_READ_ONLY, trans,
-                             0, 0, 0, 0);
-        return;
-    } else {
+    switch (ret) {
+    case DELETE_SUCCESS:
         usb_mtp_queue_result(s, RES_OK, trans,
                              0, 0, 0, 0);
-        return;
+        break;
+    case DELETE_FAILURE:
+        usb_mtp_queue_result(s, RES_PARTIAL_DELETE,
+                             trans, 0, 0, 0, 0);
+        break;
+    case DELETE_PARTIAL:
+        usb_mtp_queue_result(s, RES_PARTIAL_DELETE,
+                             trans, 0, 0, 0, 0);
+        break;
+    default:
+        g_assert_not_reached();
     }
+
+    return;
 }
 
 static void usb_mtp_command(MTPState *s, MTPControl *c)
-- 
2.18.1

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

* [Qemu-devel] [PULL 4/5] usb-mtp: remove usb_mtp_object_free_one
  2019-04-02  6:46 [Qemu-devel] [PULL 0/5] Fixes 20190402 patches Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2019-04-02  6:46 ` [Qemu-devel] [PULL 3/5] usb-mtp: fix return status of delete Gerd Hoffmann
@ 2019-04-02  6:46 ` Gerd Hoffmann
  2019-04-02  6:46 ` [Qemu-devel] [PULL 5/5] audio: fix audio timer rate conversion bug Gerd Hoffmann
  2019-04-02  8:33 ` [Qemu-devel] [PULL 0/5] Fixes 20190402 patches Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2019-04-02  6:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Bandan Das

From: Bandan Das <bsd@redhat.com>

This function is used in the delete path only and can
be replaced by a call to usb_mtp_object_free.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Bandan Das <bsd@redhat.com>
Message-Id: <20190401211712.19012-3-bsd@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/dev-mtp.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 91b820baafd8..4dc1317e2e49 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -1150,16 +1150,6 @@ enum {
     DELETE_PARTIAL = (DELETE_FAILURE | DELETE_SUCCESS),
 };
 
-/* Assumes that children, if any, have been already freed */
-static void usb_mtp_object_free_one(MTPState *s, MTPObject *o)
-{
-    assert(o->nchildren == 0);
-    QTAILQ_REMOVE(&s->objects, o, next);
-    g_free(o->name);
-    g_free(o->path);
-    g_free(o);
-}
-
 static int usb_mtp_deletefn(MTPState *s, MTPObject *o, uint32_t trans)
 {
     MTPObject *iter, *iter2;
@@ -1181,14 +1171,14 @@ static int usb_mtp_deletefn(MTPState *s, MTPObject *o, uint32_t trans)
         if (remove(o->path)) {
             ret |= DELETE_FAILURE;
         } else {
-            usb_mtp_object_free_one(s, o);
+            usb_mtp_object_free(s, o);
             ret |= DELETE_SUCCESS;
         }
     } else if (o->format == FMT_ASSOCIATION) {
         if (rmdir(o->path)) {
             ret |= DELETE_FAILURE;
         } else {
-            usb_mtp_object_free_one(s, o);
+            usb_mtp_object_free(s, o);
             ret |= DELETE_SUCCESS;
         }
     }
-- 
2.18.1

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

* [Qemu-devel] [PULL 5/5] audio: fix audio timer rate conversion bug
  2019-04-02  6:46 [Qemu-devel] [PULL 0/5] Fixes 20190402 patches Gerd Hoffmann
                   ` (3 preceding siblings ...)
  2019-04-02  6:46 ` [Qemu-devel] [PULL 4/5] usb-mtp: remove usb_mtp_object_free_one Gerd Hoffmann
@ 2019-04-02  6:46 ` Gerd Hoffmann
  2019-04-02  8:33 ` [Qemu-devel] [PULL 0/5] Fixes 20190402 patches Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2019-04-02  6:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Volker Rümelin

From: Volker Rümelin <vr_qemu@t-online.de>

Currently the default audio timer frequency is 10000Hz instead of
a period of 10000us. Also the audiodev timer-period property gets
converted like a frequency. Only handling of the legacy
QEMU_AUDIO_TIMER_PERIOD environment variable is correct because
it's actually a frequency.

With this patch the property timer-period is really a timer period
and QEMU_AUDIO_TIMER_PERIOD remains a frequency.

Fixes: 71830221fb "-audiodev command line option basic implementation."
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Reviewed-by: Zoltán Kővágó <DirtY.iCE.hu@gmail.com>
Message-id: 90b95e4f-39ef-2b01-da6a-857ebaee1ec5@t-online.de
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 audio/audio.c        | 2 +-
 audio/audio_legacy.c | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/audio/audio.c b/audio/audio.c
index 5fd9a58a808f..2040762feff1 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1471,7 +1471,7 @@ static int audio_init(Audiodev *dev)
     if (dev->timer_period <= 0) {
         s->period_ticks = 1;
     } else {
-        s->period_ticks = NANOSECONDS_PER_SECOND / dev->timer_period;
+        s->period_ticks = dev->timer_period * SCALE_US;
     }
 
     e = qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s);
diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c
index 6d140119d98a..2fd58cb8ef25 100644
--- a/audio/audio_legacy.c
+++ b/audio/audio_legacy.c
@@ -26,6 +26,7 @@
 #include "audio_int.h"
 #include "qemu-common.h"
 #include "qemu/cutils.h"
+#include "qemu/timer.h"
 #include "qapi/error.h"
 #include "qapi/qapi-visit-audio.h"
 #include "qapi/visitor-impl.h"
@@ -338,8 +339,13 @@ static AudiodevListEntry *legacy_opt(const char *drvname)
     handle_per_direction(audio_get_pdo_in(e->dev), "QEMU_AUDIO_ADC_");
     handle_per_direction(audio_get_pdo_out(e->dev), "QEMU_AUDIO_DAC_");
 
+    /* Original description: Timer period in HZ (0 - use lowest possible) */
     get_int("QEMU_AUDIO_TIMER_PERIOD",
             &e->dev->timer_period, &e->dev->has_timer_period);
+    if (e->dev->has_timer_period && e->dev->timer_period) {
+        e->dev->timer_period = NANOSECONDS_PER_SECOND / 1000 /
+                               e->dev->timer_period;
+    }
 
     switch (e->dev->driver) {
     case AUDIODEV_DRIVER_ALSA:
-- 
2.18.1

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

* Re: [Qemu-devel] [PULL 0/5] Fixes 20190402 patches
  2019-04-02  6:46 [Qemu-devel] [PULL 0/5] Fixes 20190402 patches Gerd Hoffmann
                   ` (4 preceding siblings ...)
  2019-04-02  6:46 ` [Qemu-devel] [PULL 5/5] audio: fix audio timer rate conversion bug Gerd Hoffmann
@ 2019-04-02  8:33 ` Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2019-04-02  8:33 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: QEMU Developers

On Tue, 2 Apr 2019 at 14:07, Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> The following changes since commit 230ce19814ecc6bff8edac3b5b86e7c82f422c6c:
>
>   Merge remote-tracking branch 'remotes/rth/tags/pull-axp-20190325' into staging (2019-03-29 19:29:00 +0000)
>
> are available in the Git repository at:
>
>   git://git.kraxel.org/qemu tags/fixes-20190402-pull-request
>
> for you to fetch changes up to be1092afa07794e5247eb504095fb5f2ae421ec6:
>
>   audio: fix audio timer rate conversion bug (2019-04-02 07:50:49 +0200)
>
> ----------------------------------------------------------------
> fixes for 4.0 (audio, usb),
>
> ----------------------------------------------------------------

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.0
for any user-visible changes.

-- PMM

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

end of thread, other threads:[~2019-04-02  8:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-02  6:46 [Qemu-devel] [PULL 0/5] Fixes 20190402 patches Gerd Hoffmann
2019-04-02  6:46 ` [Qemu-devel] [PULL 1/5] Revert "audio: fix pc speaker init" Gerd Hoffmann
2019-04-02  6:46 ` [Qemu-devel] [PULL 2/5] hw/usb/bus.c: Handle "no speed matched" case in usb_mask_to_str() Gerd Hoffmann
2019-04-02  6:46 ` [Qemu-devel] [PULL 3/5] usb-mtp: fix return status of delete Gerd Hoffmann
2019-04-02  6:46 ` [Qemu-devel] [PULL 4/5] usb-mtp: remove usb_mtp_object_free_one Gerd Hoffmann
2019-04-02  6:46 ` [Qemu-devel] [PULL 5/5] audio: fix audio timer rate conversion bug Gerd Hoffmann
2019-04-02  8:33 ` [Qemu-devel] [PULL 0/5] Fixes 20190402 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.