From: Peter Crosthwaite <peter.crosthwaite@petalogix.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
i.mitsyanko@samsung.com, Juan Quintela <quintela@redhat.com>,
stefanha@gmail.com, qemu-devel@nongnu.org, paul@codesourcery.com,
edgar.iglesias@gmail.com, john.williams@petalogix.com
Subject: Re: [Qemu-devel] [PATCH v5 02/15] ssi: Added VMSD stub
Date: Fri, 10 Aug 2012 14:19:48 +1000 [thread overview]
Message-ID: <1344572388.14961.32.camel@PetaLogix-ws2> (raw)
In-Reply-To: <CAFEAcA--JOghgzu-y1PtZb++djEK2x2oPA9EFm32ORKObCBeuA@mail.gmail.com>
On Mon, 2012-08-06 at 10:13 +0100, Peter Maydell wrote:
> On 6 August 2012 03:16, Peter A. G. Crosthwaite
> <peter.crosthwaite@petalogix.com> wrote:
> > Added VMSD stub for SSI slaves. Fields may be added to this VMSD for generic
> > SSI slave state (e.g. the CS line state).
>
> This is more me being confused about how this should work than a
> review comment, but it seems a bit odd that we have a hierarchy
> Device->SSI->ADS7846[etc], where the VMState for the ADS7846
> includes a field for the SSI VMState, but the SSI VMState doesn't
> include a field for the Device VMState.
>
> What you've done here matches how i2c works currently, but I've
> just cc'd Anthony and Juan to check whether there's a better way
> of doing it.
>
So VMSD is handled by casting to TYPE_DEVICE and populating dc->vmsd.
This is only going to work for one layer of heirachy. But, I notice a
few device models here and there just call vmstate_register() directly.
Question is, can we call vmstate_register() from the object init
function for SSI_SLAVE, seperately? This would mean that a single
TYPE_DEVICE object is going to get two vmsds instead of one. The
original, and one for SSI_SLAVE (which has the cs state). Sound legit?
Any implementation details and pitfalls to be aware of?
Would be nice to get rid of this change pattern applied to all the
existing SSI devices.
Regards,
Peter
>
> > Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>
> > ---
> > hw/ads7846.c | 1 +
> > hw/max111x.c | 1 +
> > hw/spitz.c | 2 ++
> > hw/ssi.c | 10 ++++++++++
> > hw/ssi.h | 10 ++++++++++
> > hw/stellaris.c | 1 +
> > hw/z2.c | 1 +
> > 7 files changed, 26 insertions(+), 0 deletions(-)
> >
> > diff --git a/hw/ads7846.c b/hw/ads7846.c
> > index 41c7f10..6a523f6 100644
> > --- a/hw/ads7846.c
> > +++ b/hw/ads7846.c
> > @@ -124,6 +124,7 @@ static const VMStateDescription vmstate_ads7846 = {
> > .minimum_version_id_old = 0,
> > .post_load = ads7856_post_load,
> > .fields = (VMStateField[]) {
> > + VMSTATE_SSI_SLAVE(ssidev, ADS7846State),
> > VMSTATE_INT32_ARRAY(input, ADS7846State, 8),
> > VMSTATE_INT32(noise, ADS7846State),
> > VMSTATE_INT32(cycle, ADS7846State),
> > diff --git a/hw/max111x.c b/hw/max111x.c
> > index 706d89f..948fd97 100644
> > --- a/hw/max111x.c
> > +++ b/hw/max111x.c
> > @@ -103,6 +103,7 @@ static const VMStateDescription vmstate_max111x = {
> > .minimum_version_id = 0,
> > .minimum_version_id_old = 0,
> > .fields = (VMStateField[]) {
> > + VMSTATE_SSI_SLAVE(ssidev, MAX111xState),
> > VMSTATE_UINT8(tb1, MAX111xState),
> > VMSTATE_UINT8(rb2, MAX111xState),
> > VMSTATE_UINT8(rb3, MAX111xState),
> > diff --git a/hw/spitz.c b/hw/spitz.c
> > index 20e7835..f5d502d 100644
> > --- a/hw/spitz.c
> > +++ b/hw/spitz.c
> > @@ -1087,6 +1087,7 @@ static const VMStateDescription vmstate_corgi_ssp_regs = {
> > .minimum_version_id = 1,
> > .minimum_version_id_old = 1,
> > .fields = (VMStateField []) {
> > + VMSTATE_SSI_SLAVE(ssidev, CorgiSSPState),
> > VMSTATE_UINT32_ARRAY(enable, CorgiSSPState, 3),
> > VMSTATE_END_OF_LIST(),
> > }
> > @@ -1115,6 +1116,7 @@ static const VMStateDescription vmstate_spitz_lcdtg_regs = {
> > .minimum_version_id = 1,
> > .minimum_version_id_old = 1,
> > .fields = (VMStateField []) {
> > + VMSTATE_SSI_SLAVE(ssidev, SpitzLCDTG),
> > VMSTATE_UINT32(bl_intensity, SpitzLCDTG),
> > VMSTATE_UINT32(bl_power, SpitzLCDTG),
> > VMSTATE_END_OF_LIST(),
> > diff --git a/hw/ssi.c b/hw/ssi.c
> > index 35d0a04..2db88fc 100644
> > --- a/hw/ssi.c
> > +++ b/hw/ssi.c
> > @@ -80,6 +80,16 @@ uint32_t ssi_transfer(SSIBus *bus, uint32_t val)
> > return r;
> > }
> >
> > +const VMStateDescription vmstate_ssi_slave = {
> > + .name = "SSISlave",
> > + .version_id = 1,
> > + .minimum_version_id = 1,
> > + .minimum_version_id_old = 1,
> > + .fields = (VMStateField[]) {
> > + VMSTATE_END_OF_LIST()
> > + }
> > +};
> > +
> > static void ssi_slave_register_types(void)
> > {
> > type_register_static(&ssi_bus_info);
> > diff --git a/hw/ssi.h b/hw/ssi.h
> > index 06657d7..975f9fb 100644
> > --- a/hw/ssi.h
> > +++ b/hw/ssi.h
> > @@ -38,6 +38,16 @@ struct SSISlave {
> > #define SSI_SLAVE_FROM_QDEV(dev) DO_UPCAST(SSISlave, qdev, dev)
> > #define FROM_SSI_SLAVE(type, dev) DO_UPCAST(type, ssidev, dev)
> >
> > +extern const VMStateDescription vmstate_ssi_slave;
> > +
> > +#define VMSTATE_SSI_SLAVE(_field, _state) { \
> > + .name = (stringify(_field)), \
> > + .size = sizeof(SSISlave), \
> > + .vmsd = &vmstate_ssi_slave, \
> > + .flags = VMS_STRUCT, \
> > + .offset = vmstate_offset_value(_state, _field, SSISlave), \
> > +}
> > +
> > DeviceState *ssi_create_slave(SSIBus *bus, const char *name);
> >
> > /* Master interface. */
> > diff --git a/hw/stellaris.c b/hw/stellaris.c
> > index 562fbbf..4d26857 100644
> > --- a/hw/stellaris.c
> > +++ b/hw/stellaris.c
> > @@ -1188,6 +1188,7 @@ static const VMStateDescription vmstate_stellaris_ssi_bus = {
> > .minimum_version_id = 1,
> > .minimum_version_id_old = 1,
> > .fields = (VMStateField[]) {
> > + VMSTATE_SSI_SLAVE(ssidev, stellaris_ssi_bus_state),
> > VMSTATE_INT32(current_dev, stellaris_ssi_bus_state),
> > VMSTATE_END_OF_LIST()
> > }
> > diff --git a/hw/z2.c b/hw/z2.c
> > index 289cee9..721aaf1 100644
> > --- a/hw/z2.c
> > +++ b/hw/z2.c
> > @@ -165,6 +165,7 @@ static VMStateDescription vmstate_zipit_lcd_state = {
> > .minimum_version_id = 1,
> > .minimum_version_id_old = 1,
> > .fields = (VMStateField[]) {
> > + VMSTATE_SSI_SLAVE(ssidev, ZipitLCD),
> > VMSTATE_INT32(selected, ZipitLCD),
> > VMSTATE_INT32(enabled, ZipitLCD),
> > VMSTATE_BUFFER(buf, ZipitLCD),
> > --
> > 1.7.0.4
> >
>
>
> -- PMM
next prev parent reply other threads:[~2012-08-10 4:21 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-06 2:16 [Qemu-devel] [PATCH v5 00/15] Ehnahced SSI bus support + M25P80 SPI flash + Xilinx SPI controller Peter A. G. Crosthwaite
2012-08-06 2:16 ` [Qemu-devel] [PATCH v5 01/15] ssi: Support for multiple attached devices Peter A. G. Crosthwaite
2012-08-06 2:16 ` [Qemu-devel] [PATCH v5 02/15] ssi: Added VMSD stub Peter A. G. Crosthwaite
2012-08-06 9:13 ` Peter Maydell
2012-08-06 9:15 ` Peter Maydell
2012-08-10 4:19 ` Peter Crosthwaite [this message]
2012-08-06 2:16 ` [Qemu-devel] [PATCH v5 03/15] ssi: Implemented CS behaviour Peter A. G. Crosthwaite
2012-08-06 9:25 ` Peter Maydell
2012-08-07 5:17 ` Peter Crosthwaite
2012-08-06 2:16 ` [Qemu-devel] [PATCH v5 04/15] ssi: Added create_slave_no_init() Peter A. G. Crosthwaite
2012-08-06 9:29 ` Peter Maydell
2012-08-07 0:04 ` Peter Crosthwaite
2012-08-06 2:16 ` [Qemu-devel] [PATCH v5 05/15] qdev: allow multiple qdev_init_gpio_in() calls Peter A. G. Crosthwaite
2012-08-06 9:38 ` Peter Maydell
2012-08-07 0:12 ` Peter Crosthwaite
2012-08-07 8:03 ` Peter Maydell
2012-08-06 2:16 ` [Qemu-devel] [PATCH v5 06/15] hw/stellaris: Removed gpio_out init array Peter A. G. Crosthwaite
2012-08-06 2:16 ` [Qemu-devel] [PATCH v5 07/15] stellaris: Removed SSI mux Peter A. G. Crosthwaite
2012-08-06 2:16 ` [Qemu-devel] [PATCH v5 08/15] ssd0323: abort() instead of exit(1) on error Peter A. G. Crosthwaite
2012-08-06 9:41 ` Peter Maydell
2012-08-10 23:31 ` Peter Crosthwaite
2012-08-11 19:01 ` Peter Maydell
2012-08-06 2:16 ` [Qemu-devel] [PATCH v5 09/15] hw: Added generic FIFO API Peter A. G. Crosthwaite
2012-08-06 9:40 ` Igor Mitsyanko
2012-08-06 9:48 ` Peter Maydell
2012-08-06 12:42 ` Igor Mitsyanko
2012-08-07 6:05 ` Peter Crosthwaite
2012-08-06 9:52 ` Igor Mitsyanko
2012-08-07 6:10 ` Peter Crosthwaite
2012-08-07 6:28 ` Igor Mitsyanko
2012-08-07 6:42 ` Peter Crosthwaite
2012-08-06 2:16 ` [Qemu-devel] [PATCH v5 10/15] m25p80: Initial implementation of SPI flash device Peter A. G. Crosthwaite
2012-08-06 2:16 ` [Qemu-devel] [PATCH v5 11/15] xilinx_spi: Initial impl. of Xilinx SPI controller Peter A. G. Crosthwaite
2012-08-06 2:16 ` [Qemu-devel] [PATCH v5 12/15] petalogix-ml605: added SPI controller with n25q128 Peter A. G. Crosthwaite
2012-08-06 9:50 ` Peter Maydell
2012-08-07 5:24 ` Peter Crosthwaite
2012-08-06 2:16 ` [Qemu-devel] [PATCH v5 13/15] xilinx_spips: Xilinx Zynq SPI cntrlr device model Peter A. G. Crosthwaite
2012-08-06 2:16 ` [Qemu-devel] [PATCH v5 14/15] xilinx_zynq: Added SPI controllers + flashes Peter A. G. Crosthwaite
2012-08-06 2:16 ` [Qemu-devel] [PATCH v5 15/15] MAINTAINERS: Added maintainerships for SSI Peter A. G. Crosthwaite
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=1344572388.14961.32.camel@PetaLogix-ws2 \
--to=peter.crosthwaite@petalogix.com \
--cc=aliguori@us.ibm.com \
--cc=edgar.iglesias@gmail.com \
--cc=i.mitsyanko@samsung.com \
--cc=john.williams@petalogix.com \
--cc=paul@codesourcery.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=stefanha@gmail.com \
/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).