qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: malc <av1474@comtv.ru>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH 00/20] Port audio to vmstate
Date: Fri, 23 Oct 2009 14:26:31 +0200	[thread overview]
Message-ID: <m3vdi6b8js.fsf@neno.mitica> (raw)
In-Reply-To: <Pine.LNX.4.64.0910230036300.2584@linmac.oyster.ru> (malc's message of "Fri, 23 Oct 2009 00:44:13 +0400 (MSD)")

malc <av1474@comtv.ru> wrote:
> On Thu, 22 Oct 2009, Juan Quintela wrote:
>

Hi

>> - es1370: the best working with migration.
>> - adlib: I am not able to get sound out of it on any recent Fedora :(
>
> It's an FM chip, trying to play PCM with it just not gonna fly.

That could expain it :)

>>   I disabled dma_running before loading state.  malc can you take a look here?

> Can you please elaborate on what is exactly the problem.

What we have here:

On save_state, we save a state field:
    val = s->dma_running; qemu_put_be32s (f, &val);

Now on load state, we read it to one local variable:
    qemu_get_be32s (f, &dma_running);

My understanding of the code here is that you should never assign
directly s->dma_running, that you should set/clean it through
  cs_reset_voices()
(setting this value has _side-effects_

So far so good.

Now, the whole point of vmstate is:
- state is described declaratively
- and load/save are "kind" of inverse functions. One save
  the value of one field to the state, and the other takes the value
  from the state and put it back in the field.
- Later (post_load), we do any side-effect that we need to do with the
  new loaded state.

Here we can't do this.  How would I do it in any other driver, i.e. (no
audio).  Easy, you just declare dma_running_vmstate in the state, and
in post_load(), you just call cs_reset_voices depending on that value.

You already ruled out that solution on ac97.  Didn't even try here.

No problem, I just read it on s->dma_running(), and on post_load I do:

if (s->dma_running && (s->dregs[Interface_Configuration] & PEN)) {
      s->dma_running = 0;
      cs_reset_voices (s, s->dregs[FS_And_Playback_Data_Format]);
}

And call it a day :).

But then I thought of what happens if you call loadvm from the monitor
while s->dma_running = 1.

And decided that the proper thing to do is to do:

in pre_load()
 - we set dma_running to 0 if if it 1, but do it like in
   cs_reset_voices()

        if (s->dma_running) {
            DMA_release_DREQ (s->dma);
            AUD_set_active_out (s->voice, 0);
        }
        s->dma_running = 0;

And now, in post_load, we know that s->dma_runing is what was comes from
migration, and we can set it to this value.  Do you think that my
explanation is clear?

Discussing this with Anthony on irc, he thinks that dma_running is the
same that  (s->dregs[Interface_Configuration] & PEN), and that we could
remove it from the state, but I am not sure, nad decided not to go that
route (because I am not sure, not because it is not the same.  I don't know).

>> - ac97: from Anthony sugestion, remove the use of active array, it can be
>>         recalculated.  All my testing (muted, not muted, ..., shows that
>>         transmited array is the same one than the recalculated one).
>
> Good.
>
>>   ac97 don't work always with migration.
>> 
>> How did I test:
>> - start a linux guest
>> - inside there play a song (ogg123 foo.ogg)
>> - in the middle of the song do savevm foo
>> - later restart qemu with -loadvm foo option
>> 
>> What did I expect?:
>> - I expected after ending the loadvm to hear the contination of the song.
>> 
>> Actual results:
>> - es1370: the one working better
>> - sb16: lots of underruns, very low sound quality.
>> - ac97: mixed results.  The 1st 5-10 seconds always sound perfect
>>    Then, between 10 and 30 seconds, sometimes it lots syncs and start playing at
>>    full speed, basiaclly no sound ouput. No sound after this is ever generated.
>>    If it is able to generate sound for 30-40 seconds, then sound works correctly.
>>   I tried to debug this, enabled all the audio DEBUG*, but I didn't find what is
>>   happening.
>>   Notice that this happens when I launch from the same savevm image.  Some times
>>   it works well, some times it stops working at 5 seconds, sometimes it stops
>>   working at 10 seconds, and so on.
>>   My theory is that we are not saving all the state that we need, but I have been
>>   unable to found anything obviosu here.  malc, do you have any suggestion?
>
> a. See how it behaves when you use OSS on the guest instead
>    (might need clocking=48000 module parameter)
>
> b. http://mpxplay.sourceforge.net/ is the DOS player which knows about
>    i810 audio, see how it fares there
>> 
>> This took a lot because the ac97 testing, I thouguht the ac97
>> problems were due to my changes.  It just happened that the 1st time
>> that I loaded without my changes it just worked :( Problem can be
>> reproduced as easily without any of my changes.  More work needs to
>> be done to be sure that ac97 migrates correctly, but that is
>> independent of this patch :)
>> 
>
> I don't like vmstate, but if you are dead bent on adding it to audio,
> knock yourself out, IO_READ/WRITE_PROTO will stay. Can't help with
> migration, GUS/Adlib are better tested with DOS and as for cs4231a i
> don't quite understand what you are asking.

ok, will integrate the vmstate changes, and leave the
IO_READ/WRITE_PROTO until there are consensous about that :)

Later, Juan.

  reply	other threads:[~2009-10-23 12:26 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-22 14:36 [Qemu-devel] [PATCH 00/20] Port audio to vmstate Juan Quintela
2009-10-22 14:36 ` [Qemu-devel] [PATCH 01/20] audio: fix compilation of DEBUG_PLIVE Juan Quintela
2009-10-22 14:36 ` [Qemu-devel] [PATCH 02/20] audio: port to vmstate Juan Quintela
2009-10-22 14:36 ` [Qemu-devel] [PATCH 03/20] sb16: remove IO_READ_PROTO Juan Quintela
2009-10-22 20:32   ` malc
2009-10-22 20:41     ` Anthony Liguori
2009-10-22 14:36 ` [Qemu-devel] [PATCH 04/20] sb16: remove IO_WRITE_PROTO Juan Quintela
2009-10-22 20:32   ` malc
2009-10-22 14:36 ` [Qemu-devel] [PATCH 05/20] sb16: port to vmstate Juan Quintela
2009-10-22 14:36 ` [Qemu-devel] [PATCH 06/20] es1370: remove IO_READ_PROTO Juan Quintela
2009-10-22 20:33   ` malc
2009-10-22 14:36 ` [Qemu-devel] [PATCH 07/20] es1370: remove IO_WRITE_PROTO Juan Quintela
2009-10-22 20:33   ` malc
2009-10-22 14:36 ` [Qemu-devel] [PATCH 08/20] es1370: port to vmstate Juan Quintela
2009-10-22 14:36 ` [Qemu-devel] [PATCH 09/20] adlib: remove IO_READ_PROTO Juan Quintela
2009-10-22 20:34   ` malc
2009-10-22 14:36 ` [Qemu-devel] [PATCH 10/20] adlib: remove IO_WRITE_PROTO Juan Quintela
2009-10-22 20:34   ` malc
2009-10-22 14:36 ` [Qemu-devel] [PATCH 11/20] c4231a: remove IO_READ_PROTO Juan Quintela
2009-10-22 20:34   ` malc
2009-10-22 14:36 ` [Qemu-devel] [PATCH 12/20] c4231a: remove IO_WRITE_PROTO Juan Quintela
2009-10-22 20:35   ` malc
2009-10-22 14:36 ` [Qemu-devel] [PATCH 13/20] c4231a: port to vmstate Juan Quintela
2009-10-22 14:36 ` [Qemu-devel] [PATCH 14/20] gus: remove IO_READ_PROTO Juan Quintela
2009-10-22 20:35   ` malc
2009-10-22 14:36 ` [Qemu-devel] [PATCH 15/20] gus: remove IO_WRITE_PROTO Juan Quintela
2009-10-22 20:35   ` malc
2009-10-22 14:36 ` [Qemu-devel] [PATCH 16/20] gus: port to vmstate Juan Quintela
2009-10-22 14:36 ` [Qemu-devel] [PATCH 17/20] ac97: sizeof returns unsigned long Juan Quintela
2009-10-22 14:36 ` [Qemu-devel] [PATCH 18/20] ac97: recalculate active after loadvm Juan Quintela
2009-10-22 14:36 ` [Qemu-devel] [PATCH 19/20] ac97: up savevm version and remove active from state Juan Quintela
2009-10-22 14:36 ` [Qemu-devel] [PATCH 20/20] ac97: port to vmstate Juan Quintela
2009-10-22 20:44 ` [Qemu-devel] [PATCH 00/20] Port audio " malc
2009-10-23 12:26   ` Juan Quintela [this message]
2009-10-23 12:41     ` [Qemu-devel] " malc

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=m3vdi6b8js.fsf@neno.mitica \
    --to=quintela@redhat.com \
    --cc=av1474@comtv.ru \
    --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 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).