qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] audio/hda: drop atomics
@ 2018-06-27 11:19 Gerd Hoffmann
  2018-06-27 16:15 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 4+ messages in thread
From: Gerd Hoffmann @ 2018-06-27 11:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Doesn't build on 32bit clang.  And because we run under qemu mutex
anyway they are not needed.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/audio/hda-codec.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c
index 8a8214de74..a4e24b919d 100644
--- a/hw/audio/hda-codec.c
+++ b/hw/audio/hda-codec.c
@@ -18,7 +18,6 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu/atomic.h"
 #include "hw/hw.h"
 #include "hw/pci/pci.h"
 #include "intel-hda.h"
@@ -212,7 +211,7 @@ static inline void hda_timer_sync_adjust(HDAAudioStream *st, int64_t target_pos)
     }
 
     trace_hda_audio_adjust(st->node->name, target_pos);
-    atomic_fetch_add(&st->buft_start, corr);
+    st->buft_start += corr;
 }
 
 static void hda_audio_input_timer(void *opaque)
@@ -221,9 +220,9 @@ static void hda_audio_input_timer(void *opaque)
 
     int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
 
-    int64_t buft_start = atomic_fetch_add(&st->buft_start, 0);
-    int64_t wpos = atomic_fetch_add(&st->wpos, 0);
-    int64_t rpos = atomic_fetch_add(&st->rpos, 0);
+    int64_t buft_start = st->buft_start;
+    int64_t wpos = st->wpos;
+    int64_t rpos = st->rpos;
 
     int64_t wanted_rpos = hda_bytes_per_second(st) * (now - buft_start)
                           / NANOSECONDS_PER_SECOND;
@@ -245,7 +244,7 @@ static void hda_audio_input_timer(void *opaque)
         }
         rpos += chunk;
         to_transfer -= chunk;
-        atomic_fetch_add(&st->rpos, chunk);
+        st->rpos += chunk;
     }
 
 out_timer:
@@ -259,8 +258,8 @@ static void hda_audio_input_cb(void *opaque, int avail)
 {
     HDAAudioStream *st = opaque;
 
-    int64_t wpos = atomic_fetch_add(&st->wpos, 0);
-    int64_t rpos = atomic_fetch_add(&st->rpos, 0);
+    int64_t wpos = st->wpos;
+    int64_t rpos = st->rpos;
 
     int64_t to_transfer = audio_MIN(B_SIZE - (wpos - rpos), avail);
 
@@ -272,7 +271,7 @@ static void hda_audio_input_cb(void *opaque, int avail)
         uint32_t read = AUD_read(st->voice.in, st->buf + start, chunk);
         wpos += read;
         to_transfer -= read;
-        atomic_fetch_add(&st->wpos, read);
+        st->wpos += read;
         if (chunk != read) {
             break;
         }
@@ -285,9 +284,9 @@ static void hda_audio_output_timer(void *opaque)
 
     int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
 
-    int64_t buft_start = atomic_fetch_add(&st->buft_start, 0);
-    int64_t wpos = atomic_fetch_add(&st->wpos, 0);
-    int64_t rpos = atomic_fetch_add(&st->rpos, 0);
+    int64_t buft_start = st->buft_start;
+    int64_t wpos = st->wpos;
+    int64_t rpos = st->rpos;
 
     int64_t wanted_wpos = hda_bytes_per_second(st) * (now - buft_start)
                           / NANOSECONDS_PER_SECOND;
@@ -309,7 +308,7 @@ static void hda_audio_output_timer(void *opaque)
         }
         wpos += chunk;
         to_transfer -= chunk;
-        atomic_fetch_add(&st->wpos, chunk);
+        st->wpos += chunk;
     }
 
 out_timer:
@@ -323,8 +322,8 @@ static void hda_audio_output_cb(void *opaque, int avail)
 {
     HDAAudioStream *st = opaque;
 
-    int64_t wpos = atomic_fetch_add(&st->wpos, 0);
-    int64_t rpos = atomic_fetch_add(&st->rpos, 0);
+    int64_t wpos = st->wpos;
+    int64_t rpos = st->rpos;
 
     int64_t to_transfer = audio_MIN(wpos - rpos, avail);
 
@@ -345,7 +344,7 @@ static void hda_audio_output_cb(void *opaque, int avail)
         uint32_t written = AUD_write(st->voice.out, st->buf + start, chunk);
         rpos += written;
         to_transfer -= written;
-        atomic_fetch_add(&st->rpos, written);
+        st->rpos += written;
         if (chunk != written) {
             break;
         }
-- 
2.9.3

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

* Re: [Qemu-devel] [PATCH] audio/hda: drop atomics
  2018-06-27 11:19 [Qemu-devel] [PATCH] audio/hda: drop atomics Gerd Hoffmann
@ 2018-06-27 16:15 ` Philippe Mathieu-Daudé
  2018-06-29 17:49   ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-27 16:15 UTC (permalink / raw)
  To: Gerd Hoffmann, Richard Henderson; +Cc: qemu-devel

On 06/27/2018 08:19 AM, Gerd Hoffmann wrote:
> Doesn't build on 32bit clang.  And because we run under qemu mutex
> anyway they are not needed.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  hw/audio/hda-codec.c | 31 +++++++++++++++----------------
>  1 file changed, 15 insertions(+), 16 deletions(-)
> 
> diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c
> index 8a8214de74..a4e24b919d 100644
> --- a/hw/audio/hda-codec.c
> +++ b/hw/audio/hda-codec.c
> @@ -18,7 +18,6 @@
>   */
>  
>  #include "qemu/osdep.h"
> -#include "qemu/atomic.h"
>  #include "hw/hw.h"
>  #include "hw/pci/pci.h"
>  #include "intel-hda.h"
> @@ -212,7 +211,7 @@ static inline void hda_timer_sync_adjust(HDAAudioStream *st, int64_t target_pos)
>      }
>  
>      trace_hda_audio_adjust(st->node->name, target_pos);
> -    atomic_fetch_add(&st->buft_start, corr);
> +    st->buft_start += corr;
>  }
>  
>  static void hda_audio_input_timer(void *opaque)
> @@ -221,9 +220,9 @@ static void hda_audio_input_timer(void *opaque)
>  
>      int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
>  
> -    int64_t buft_start = atomic_fetch_add(&st->buft_start, 0);
> -    int64_t wpos = atomic_fetch_add(&st->wpos, 0);
> -    int64_t rpos = atomic_fetch_add(&st->rpos, 0);
> +    int64_t buft_start = st->buft_start;
> +    int64_t wpos = st->wpos;
> +    int64_t rpos = st->rpos;
>  
>      int64_t wanted_rpos = hda_bytes_per_second(st) * (now - buft_start)
>                            / NANOSECONDS_PER_SECOND;
> @@ -245,7 +244,7 @@ static void hda_audio_input_timer(void *opaque)
>          }
>          rpos += chunk;
>          to_transfer -= chunk;
> -        atomic_fetch_add(&st->rpos, chunk);
> +        st->rpos += chunk;
>      }
>  
>  out_timer:
> @@ -259,8 +258,8 @@ static void hda_audio_input_cb(void *opaque, int avail)
>  {
>      HDAAudioStream *st = opaque;
>  
> -    int64_t wpos = atomic_fetch_add(&st->wpos, 0);
> -    int64_t rpos = atomic_fetch_add(&st->rpos, 0);
> +    int64_t wpos = st->wpos;
> +    int64_t rpos = st->rpos;
>  
>      int64_t to_transfer = audio_MIN(B_SIZE - (wpos - rpos), avail);
>  
> @@ -272,7 +271,7 @@ static void hda_audio_input_cb(void *opaque, int avail)
>          uint32_t read = AUD_read(st->voice.in, st->buf + start, chunk);
>          wpos += read;
>          to_transfer -= read;
> -        atomic_fetch_add(&st->wpos, read);
> +        st->wpos += read;
>          if (chunk != read) {
>              break;
>          }
> @@ -285,9 +284,9 @@ static void hda_audio_output_timer(void *opaque)
>  
>      int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
>  
> -    int64_t buft_start = atomic_fetch_add(&st->buft_start, 0);
> -    int64_t wpos = atomic_fetch_add(&st->wpos, 0);
> -    int64_t rpos = atomic_fetch_add(&st->rpos, 0);
> +    int64_t buft_start = st->buft_start;
> +    int64_t wpos = st->wpos;
> +    int64_t rpos = st->rpos;
>  
>      int64_t wanted_wpos = hda_bytes_per_second(st) * (now - buft_start)
>                            / NANOSECONDS_PER_SECOND;
> @@ -309,7 +308,7 @@ static void hda_audio_output_timer(void *opaque)
>          }
>          wpos += chunk;
>          to_transfer -= chunk;
> -        atomic_fetch_add(&st->wpos, chunk);
> +        st->wpos += chunk;
>      }
>  
>  out_timer:
> @@ -323,8 +322,8 @@ static void hda_audio_output_cb(void *opaque, int avail)
>  {
>      HDAAudioStream *st = opaque;
>  
> -    int64_t wpos = atomic_fetch_add(&st->wpos, 0);
> -    int64_t rpos = atomic_fetch_add(&st->rpos, 0);
> +    int64_t wpos = st->wpos;
> +    int64_t rpos = st->rpos;
>  
>      int64_t to_transfer = audio_MIN(wpos - rpos, avail);
>  
> @@ -345,7 +344,7 @@ static void hda_audio_output_cb(void *opaque, int avail)
>          uint32_t written = AUD_write(st->voice.out, st->buf + start, chunk);
>          rpos += written;
>          to_transfer -= written;
> -        atomic_fetch_add(&st->rpos, written);
> +        st->rpos += written;
>          if (chunk != written) {
>              break;
>          }
> 

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

* Re: [Qemu-devel] [PATCH] audio/hda: drop atomics
  2018-06-27 16:15 ` Philippe Mathieu-Daudé
@ 2018-06-29 17:49   ` Philippe Mathieu-Daudé
  2018-07-02 10:52     ` Peter Maydell
  0 siblings, 1 reply; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-06-29 17:49 UTC (permalink / raw)
  To: Gerd Hoffmann, Richard Henderson, Max Reitz, Peter Maydell
  Cc: qemu-devel, Martin Schrodt

On 06/27/2018 01:15 PM, Philippe Mathieu-Daudé wrote:
> On 06/27/2018 08:19 AM, Gerd Hoffmann wrote:
>> Doesn't build on 32bit clang.  And because we run under qemu mutex
>> anyway they are not needed.
>>
>> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> 
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Applying this patch as build fix on master would fix the mips/mipsel
host builds (also clang -m32 reported by Max). But there's no hurry.

> 
>> ---
>>  hw/audio/hda-codec.c | 31 +++++++++++++++----------------
>>  1 file changed, 15 insertions(+), 16 deletions(-)
>>
>> diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c
>> index 8a8214de74..a4e24b919d 100644
>> --- a/hw/audio/hda-codec.c
>> +++ b/hw/audio/hda-codec.c
>> @@ -18,7 +18,6 @@
>>   */
>>  
>>  #include "qemu/osdep.h"
>> -#include "qemu/atomic.h"
>>  #include "hw/hw.h"
>>  #include "hw/pci/pci.h"
>>  #include "intel-hda.h"
>> @@ -212,7 +211,7 @@ static inline void hda_timer_sync_adjust(HDAAudioStream *st, int64_t target_pos)
>>      }
>>  
>>      trace_hda_audio_adjust(st->node->name, target_pos);
>> -    atomic_fetch_add(&st->buft_start, corr);
>> +    st->buft_start += corr;
>>  }
>>  
>>  static void hda_audio_input_timer(void *opaque)
>> @@ -221,9 +220,9 @@ static void hda_audio_input_timer(void *opaque)
>>  
>>      int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
>>  
>> -    int64_t buft_start = atomic_fetch_add(&st->buft_start, 0);
>> -    int64_t wpos = atomic_fetch_add(&st->wpos, 0);
>> -    int64_t rpos = atomic_fetch_add(&st->rpos, 0);
>> +    int64_t buft_start = st->buft_start;
>> +    int64_t wpos = st->wpos;
>> +    int64_t rpos = st->rpos;
>>  
>>      int64_t wanted_rpos = hda_bytes_per_second(st) * (now - buft_start)
>>                            / NANOSECONDS_PER_SECOND;
>> @@ -245,7 +244,7 @@ static void hda_audio_input_timer(void *opaque)
>>          }
>>          rpos += chunk;
>>          to_transfer -= chunk;
>> -        atomic_fetch_add(&st->rpos, chunk);
>> +        st->rpos += chunk;
>>      }
>>  
>>  out_timer:
>> @@ -259,8 +258,8 @@ static void hda_audio_input_cb(void *opaque, int avail)
>>  {
>>      HDAAudioStream *st = opaque;
>>  
>> -    int64_t wpos = atomic_fetch_add(&st->wpos, 0);
>> -    int64_t rpos = atomic_fetch_add(&st->rpos, 0);
>> +    int64_t wpos = st->wpos;
>> +    int64_t rpos = st->rpos;
>>  
>>      int64_t to_transfer = audio_MIN(B_SIZE - (wpos - rpos), avail);
>>  
>> @@ -272,7 +271,7 @@ static void hda_audio_input_cb(void *opaque, int avail)
>>          uint32_t read = AUD_read(st->voice.in, st->buf + start, chunk);
>>          wpos += read;
>>          to_transfer -= read;
>> -        atomic_fetch_add(&st->wpos, read);
>> +        st->wpos += read;
>>          if (chunk != read) {
>>              break;
>>          }
>> @@ -285,9 +284,9 @@ static void hda_audio_output_timer(void *opaque)
>>  
>>      int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
>>  
>> -    int64_t buft_start = atomic_fetch_add(&st->buft_start, 0);
>> -    int64_t wpos = atomic_fetch_add(&st->wpos, 0);
>> -    int64_t rpos = atomic_fetch_add(&st->rpos, 0);
>> +    int64_t buft_start = st->buft_start;
>> +    int64_t wpos = st->wpos;
>> +    int64_t rpos = st->rpos;
>>  
>>      int64_t wanted_wpos = hda_bytes_per_second(st) * (now - buft_start)
>>                            / NANOSECONDS_PER_SECOND;
>> @@ -309,7 +308,7 @@ static void hda_audio_output_timer(void *opaque)
>>          }
>>          wpos += chunk;
>>          to_transfer -= chunk;
>> -        atomic_fetch_add(&st->wpos, chunk);
>> +        st->wpos += chunk;
>>      }
>>  
>>  out_timer:
>> @@ -323,8 +322,8 @@ static void hda_audio_output_cb(void *opaque, int avail)
>>  {
>>      HDAAudioStream *st = opaque;
>>  
>> -    int64_t wpos = atomic_fetch_add(&st->wpos, 0);
>> -    int64_t rpos = atomic_fetch_add(&st->rpos, 0);
>> +    int64_t wpos = st->wpos;
>> +    int64_t rpos = st->rpos;
>>  
>>      int64_t to_transfer = audio_MIN(wpos - rpos, avail);
>>  
>> @@ -345,7 +344,7 @@ static void hda_audio_output_cb(void *opaque, int avail)
>>          uint32_t written = AUD_write(st->voice.out, st->buf + start, chunk);
>>          rpos += written;
>>          to_transfer -= written;
>> -        atomic_fetch_add(&st->rpos, written);
>> +        st->rpos += written;
>>          if (chunk != written) {
>>              break;
>>          }
>>

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

* Re: [Qemu-devel] [PATCH] audio/hda: drop atomics
  2018-06-29 17:49   ` Philippe Mathieu-Daudé
@ 2018-07-02 10:52     ` Peter Maydell
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2018-07-02 10:52 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Gerd Hoffmann, Richard Henderson, Max Reitz, QEMU Developers,
	Martin Schrodt

On 29 June 2018 at 18:49, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> On 06/27/2018 01:15 PM, Philippe Mathieu-Daudé wrote:
>> On 06/27/2018 08:19 AM, Gerd Hoffmann wrote:
>>> Doesn't build on 32bit clang.  And because we run under qemu mutex
>>> anyway they are not needed.
>>>
>>> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
>>
>> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> Applying this patch as build fix on master would fix the mips/mipsel
> host builds (also clang -m32 reported by Max). But there's no hurry.

Thanks; applied to master as a build fix.

-- PMM

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

end of thread, other threads:[~2018-07-02 10:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-27 11:19 [Qemu-devel] [PATCH] audio/hda: drop atomics Gerd Hoffmann
2018-06-27 16:15 ` Philippe Mathieu-Daudé
2018-06-29 17:49   ` Philippe Mathieu-Daudé
2018-07-02 10:52     ` Peter Maydell

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).