From: Miles Glenn <milesg@linux.ibm.com>
To: Caleb Schlossin <calebs@linux.ibm.com>, qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org, npiggin@gmail.com, adityag@linux.ibm.com,
alistair@alistair23.me, kowal@linux.ibm.com,
chalapathi.v@linux.ibm.com, angeloj@linux.ibm.com
Subject: Re: [PATCH 6/6] hw/ppc: pnv_chiptod.c add vmstate support
Date: Fri, 12 Dec 2025 11:28:07 -0600 [thread overview]
Message-ID: <c9a2ae0e412009867643881e24c6dd2e82a6ffbc.camel@linux.ibm.com> (raw)
In-Reply-To: <20251211220926.2865972-7-calebs@linux.ibm.com>
Reviewed-by: Glenn Miles <milesg@linux.ibm.com>
On Thu, 2025-12-11 at 16:09 -0600, Caleb Schlossin wrote:
> - Added pre_save and post_load methods to handle slave_pc_target and tod_state
>
> Signed-off-by: Angelo Jaramillo <angeloj@linux.ibm.com>
> Signed-off-by: Caleb Schlossin <calebs@linux.ibm.com>
> ---
> hw/ppc/pnv_chiptod.c | 38 ++++++++++++++++++++++++++++++++++++
> include/hw/ppc/pnv_chiptod.h | 2 ++
> 2 files changed, 40 insertions(+)
>
> diff --git a/hw/ppc/pnv_chiptod.c b/hw/ppc/pnv_chiptod.c
> index f887a18cde..9dc5942ca0 100644
> --- a/hw/ppc/pnv_chiptod.c
> +++ b/hw/ppc/pnv_chiptod.c
> @@ -37,6 +37,7 @@
> #include "hw/ppc/pnv_core.h"
> #include "hw/ppc/pnv_xscom.h"
> #include "hw/ppc/pnv_chiptod.h"
> +#include "migration/vmstate.h"
> #include "trace.h"
>
> #include <libfdt.h>
> @@ -341,6 +342,8 @@ static void pnv_chiptod_xscom_write(void *opaque, hwaddr addr,
> " TOD_TX_TTYPE_CTRL_REG val 0x%" PRIx64
> " invalid slave address\n", val);
> }
> + /* Write slave_pc_target to a uint64_t variable for vmstate support. */
> + chiptod->tx_ttype_ctrl = val;
> break;
> case TOD_ERROR_REG:
> chiptod->tod_error &= ~val;
> @@ -613,6 +616,40 @@ static void pnv_chiptod_unrealize(DeviceState *dev)
> qemu_unregister_reset(pnv_chiptod_reset, chiptod);
> }
>
> +static int vmstate_pnv_chiptod_pre_save(void *opaque)
> +{
> + PnvChipTOD *chiptod = PNV_CHIPTOD(opaque);
> + chiptod->tod_state_val = (uint8_t)chiptod->tod_state;
> + return 0;
> +}
> +
> +static int vmstate_pnv_chiptod_post_load(void *opaque)
> +{
> + PnvChipTOD *chiptod = PNV_CHIPTOD(opaque);
> + if (chiptod->tx_ttype_ctrl != 0) {
> + pnv_chiptod_xscom_write(chiptod, TOD_TX_TTYPE_CTRL_REG << 3,
> + chiptod->tx_ttype_ctrl, 8);
> + }
> + chiptod->tod_state = (enum tod_state)chiptod->tod_state_val;
> + return 0;
> +}
> +
> +static const VMStateDescription pnv_chiptod_vmstate = {
> + .name = TYPE_PNV_CHIPTOD,
> + .version_id = 1,
> + .pre_save = vmstate_pnv_chiptod_pre_save,
> + .pre_load = vmstate_pnv_chiptod_post_load,
> + .fields = (const VMStateField[]) {
> + VMSTATE_BOOL(primary, PnvChipTOD),
> + VMSTATE_BOOL(secondary, PnvChipTOD),
> + VMSTATE_UINT64(tod_error, PnvChipTOD),
> + VMSTATE_UINT64(pss_mss_ctrl_reg, PnvChipTOD),
> + VMSTATE_UINT64(tx_ttype_ctrl, PnvChipTOD),
> + VMSTATE_UINT8(tod_state_val, PnvChipTOD),
> + VMSTATE_END_OF_LIST(),
> + },
> +};
> +
> static void pnv_chiptod_class_init(ObjectClass *klass, const void *data)
> {
> DeviceClass *dc = DEVICE_CLASS(klass);
> @@ -621,6 +658,7 @@ static void pnv_chiptod_class_init(ObjectClass *klass, const void *data)
> dc->unrealize = pnv_chiptod_unrealize;
> dc->desc = "PowerNV ChipTOD Controller";
> dc->user_creatable = false;
> + dc->vmsd = &pnv_chiptod_vmstate;
> }
>
> static const TypeInfo pnv_chiptod_type_info = {
> diff --git a/include/hw/ppc/pnv_chiptod.h b/include/hw/ppc/pnv_chiptod.h
> index 466b06560a..3e5e3b02b2 100644
> --- a/include/hw/ppc/pnv_chiptod.h
> +++ b/include/hw/ppc/pnv_chiptod.h
> @@ -41,6 +41,8 @@ struct PnvChipTOD {
> uint64_t tod_error;
> uint64_t pss_mss_ctrl_reg;
> PnvCore *slave_pc_target;
> + uint64_t tx_ttype_ctrl;
> + uint8_t tod_state_val;
> };
>
> struct PnvChipTODClass {
prev parent reply other threads:[~2025-12-12 17:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-11 22:09 [PATCH 0/6] hw/ppc: Snapshot support for several ppc devices Caleb Schlossin
2025-12-11 22:09 ` [PATCH 1/6] hw/ppc: Add VMSTATE information for LPC model Caleb Schlossin
2025-12-12 17:12 ` Miles Glenn
2025-12-11 22:09 ` [PATCH 2/6] hw/ppc: Add pnv_spi vmstate support Caleb Schlossin
2025-12-12 17:29 ` Miles Glenn
2025-12-11 22:09 ` [PATCH 3/6] hw/ppc: Add pnv_i2c " Caleb Schlossin
2025-12-12 17:16 ` Miles Glenn
2025-12-11 22:09 ` [PATCH 4/6] hw/ppc: pnv_adu.c added " Caleb Schlossin
2025-12-12 17:17 ` Miles Glenn
2025-12-11 22:09 ` [PATCH 5/6] hw/ppc: pnv_core.c add " Caleb Schlossin
2025-12-12 17:23 ` Miles Glenn
2025-12-11 22:09 ` [PATCH 6/6] hw/ppc: pnv_chiptod.c " Caleb Schlossin
2025-12-12 17:28 ` Miles Glenn [this message]
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=c9a2ae0e412009867643881e24c6dd2e82a6ffbc.camel@linux.ibm.com \
--to=milesg@linux.ibm.com \
--cc=adityag@linux.ibm.com \
--cc=alistair@alistair23.me \
--cc=angeloj@linux.ibm.com \
--cc=calebs@linux.ibm.com \
--cc=chalapathi.v@linux.ibm.com \
--cc=kowal@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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).