public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: Isaku Yamahata <yamahata@valinux.co.jp>
Cc: qemu-devel@nongnu.org, avi@redhat.com, mtosatti@redhat.com,
	kvm@vger.kernel.org
Subject: Re: [PATCH] acpi_piix4: fix save/load of PIIX4PMState
Date: Tue, 19 Apr 2011 14:33:46 +0200	[thread overview]
Message-ID: <m3sjteh13p.fsf@neno.mitica> (raw)
In-Reply-To: <20110419074221.GE27268@valinux.co.jp> (Isaku Yamahata's message of "Tue, 19 Apr 2011 16:42:21 +0900")

Isaku Yamahata <yamahata@valinux.co.jp> wrote:
>> shouldn't last one still be uint16_t?
>
> It results in an error by type_check_pointer.

You are right.  We are just lying.  Will think about how to fix this
properly (basically move the whole thing to a uint8_t array, and work
from there.

>> I guess that on ich9, GPE becomes one array, do you have that code handy
>> somewhere, just to see what you want to do?
>
> I attached acpi_ich9.c.
> For the full source tree please see the thread of q35 patchset.
> http://lists.nongnu.org/archive/html/qemu-devel/2011-03/msg01656.html
>
> You may want to see only struct ACPIGFP and vmstate_ich9_pm.

Thanks.

>
>> I think that best thing to do at this point is just to revert this whole
>> patch.  We are creating a new type for uint8_t, that becomes a pointer.
>> We are not sending the length of that array, so we need to add a new
>> version/subsection when we add ICH9 anyways.
>> 
>> Seeing what you want to do would help me trying to figure out the best
>> vmstate aproach.
>
> What I want to do eventually is to implement ACPI GPE logic generally,
> to replace the current acpi_piix4's which was very specific to piix4,
> and to implement ich9 GPE with new GPE code.
> Thus we can avoid code/logic duplication of ACPI GPE between piix4 and
> ich9.
> struct ACPIGPE is used for both piix4 and ich9 with different
> initialization parameter.

Do you mean

> According to the ACPI spec, GPE register length is hw specific.
> In fact PIIX4 has 4 bytes length gpe
> (Before patch PIIX4 GPE implementation used uint16_t sts + uint16_t en
> which is very hw-specific. With the patch they became
> uint8_t* sts + uint8_t *en which are dynamically allocated).
> ICH9 has 8 bytes length gpe. (newer chipsets tend to have longer
> GPE length as they support more and more events)
>
> Regarding to save/load, what I want to do is to save/load
> the dynamically allocated array whose size is determined dynamically,
> but the size is chip-constant.
>
> struct ACPIGPE {
>     uint32_t blk;
>     uint8_t len;        <<<<< this is determined by chip.
>                         <<<<< 4 for piix4
>                         <<<<< 8 for ich9
>
>     uint8_t *sts;       <<<<< ACPI GPE status register
>                         <<<< uint8_t array whose size is determined
>                         <<<< dynamically
>                         <<<< 2 bytes for piix4
>                         <<<< 4 bytes for ich9
>
>     uint8_t *en;        <<<< ACPI GPE enable register
>                         <<<< uint8_t array whose size is determined
>                         <<<< dynamically
>                         <<<< 2 bytes for piix4
>                         <<<< 4 bytes for ich9
> };
>
> In order to keep the save/load compatibility of piix4(big endian uint16_t),
> I had to add ugly hack as above.
> If you don't like it, only acpi_piix4 part should be reverted.

I am on vacation Thrusday & Friday, but will try to do something for
this.  Things would be easiare if we change that struct to something
like:

struct ACPIGPE {
       unti32_t blk;
       uint8_t len;
       uint8_t data[8]; /* We can change struct to bigger values when we
                           implement new chipsets */
       uint8_t *sts; /* pointer to previous array);
       uint8_t *en;  /* another pointer to previous array */
}

my problem here is that you have a len field that means we have 2 arrays
of len/2 each.  That is very difficult to describe (althought possible).
This other way, we just separate the logical interface and how things
are stored.  as an added bonos, we remove two allocations.

Later, Juan.

  reply	other threads:[~2011-04-19 12:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-18 14:01 [PATCH] acpi_piix4: fix save/load of PIIX4PMState Isaku Yamahata
2011-04-18 16:26 ` Juan Quintela
2011-04-19  7:42   ` Isaku Yamahata
2011-04-19 12:33     ` Juan Quintela [this message]
2011-04-19 13:22       ` Isaku Yamahata

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=m3sjteh13p.fsf@neno.mitica \
    --to=quintela@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yamahata@valinux.co.jp \
    /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