From nobody Thu Nov 6 18:07:55 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542310460773899.1013109495206; Thu, 15 Nov 2018 11:34:20 -0800 (PST) Received: from localhost ([::1]:40471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNNP9-0002Nb-D5 for importer@patchew.org; Thu, 15 Nov 2018 14:34:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNNGJ-0003Wh-AB for qemu-devel@nongnu.org; Thu, 15 Nov 2018 14:25:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNNG9-00082G-SJ for qemu-devel@nongnu.org; Thu, 15 Nov 2018 14:25:11 -0500 Received: from mail-oi1-x244.google.com ([2607:f8b0:4864:20::244]:40074) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gNNG7-00080d-PF for qemu-devel@nongnu.org; Thu, 15 Nov 2018 14:25:00 -0500 Received: by mail-oi1-x244.google.com with SMTP id u130-v6so17704906oie.7 for ; Thu, 15 Nov 2018 11:24:58 -0800 (PST) Received: from serve.minyard.net ([47.184.128.64]) by smtp.gmail.com with ESMTPSA id h54sm15902486otf.59.2018.11.15.11.24.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 11:24:55 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 3947E1D62; Thu, 15 Nov 2018 13:24:51 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id CEB1F301469; Thu, 15 Nov 2018 13:24:48 -0600 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=STEFnmERwmM/Z9Wu9lJP1GkrtR9zGW2Cs18899DJPak=; b=dMn+24wCpn8Txlau6mr5GxlM7hYjzWorZuJ5p1FsCRS1Wy7gHddfL5o1mSOpQTl22y REW591vS8KpXDLmldya/4rpwW59VFPcqtinZpveUgRheOGPB/aBLGnuxFGrGJDf6nLpE gydAIXts1JZRiOycRdgZq5XycBkbMW+AzBghipeU/aDnglrScl1lqNIDh6/CZs7rrnot foMzpa0dzBFF9wAfv3v9t0zR6pJBJaMzS6ywmApZ5YrwkNHchCYkJl7F0EZNiHfso8Q4 yVgbcXbK+uHHUtNgqaLGoVTzZnNqz4mrKXUkTeUI9aMyHyesks1lW6GXgG85zfQPWP5K /4Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=STEFnmERwmM/Z9Wu9lJP1GkrtR9zGW2Cs18899DJPak=; b=T0FW6o/BWmcrZZ2SIRjChs3/+QRQ7rj/AzdkudG216N+wGRWkbWOnePo6KOoeWbWiA EKSLHWEfRhD3l3vBh7yZCNsSV8vPehb3CHwToEHOCgaMH09OQnmAplyunfUOVRy+N66+ WZZXTfNIIT9vy+xFUVOw3buvwz51FZYM2CoCAk8oes9Mw3/DsP+kB2fCn4vLHD1uKJA2 1kPqoJkXCM9LyhJohwJe/vTIVRyQ4EifLpVqa00DuQrIbOg023TBSh8X2OoqQS7xwvB1 /45lkLZKekoq8cLf9+BzpYYT6pHwRfLEWWUcmpXMjZv1CrB+Fp5gXLFJpgD78Gj0ZNfK /Wqw== X-Gm-Message-State: AGRZ1gKmpt8fkgHB8AwY/rNOARZx5Tu/Z/FbDtUo8OwqL0X9GCssFYFZ NM0CMh9gcepq+MS9PBgIZA== X-Google-Smtp-Source: AJdET5fWLwE3AwZ4EFLPUcvXBwVHguyonQo9kZBZCR4eGvk7s0j4+VD35UNjeOolo9aJB06ITJ6ExA== X-Received: by 2002:aca:d886:: with SMTP id p128-v6mr4410342oig.346.1542309898212; Thu, 15 Nov 2018 11:24:58 -0800 (PST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 15 Nov 2018 13:24:41 -0600 Message-Id: <20181115192446.17187-8-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181115192446.17187-1-minyard@acm.org> References: <20181115192446.17187-1-minyard@acm.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::244 Subject: [Qemu-devel] [PATCH v2 07/12] i2c:pm_smbus: Fix state transfer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Corey Minyard , "Dr . David Alan Gilbert" , minyard@acm.org, "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Corey Minyard Transfer the state information for the SMBus registers and internal data so it will work on a VM transfer. Signed-off-by: Corey Minyard Cc: Michael S. Tsirkin Cc: Paolo Bonzini Cc: Dr. David Alan Gilbert --- hw/acpi/piix4.c | 3 ++- hw/i2c/pm_smbus.c | 31 +++++++++++++++++++++++++++++++ hw/i2c/smbus_ich9.c | 6 ++++-- include/hw/i2c/pm_smbus.h | 2 ++ 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index e330f24c71..313305f5a0 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -309,7 +309,7 @@ static const VMStateDescription vmstate_cpuhp_state =3D= { */ static const VMStateDescription vmstate_acpi =3D { .name =3D "piix4_pm", - .version_id =3D 3, + .version_id =3D 4, .minimum_version_id =3D 3, .minimum_version_id_old =3D 1, .load_state_old =3D acpi_load_old, @@ -320,6 +320,7 @@ static const VMStateDescription vmstate_acpi =3D { VMSTATE_UINT16(ar.pm1.evt.en, PIIX4PMState), VMSTATE_UINT16(ar.pm1.cnt.cnt, PIIX4PMState), VMSTATE_STRUCT(apm, PIIX4PMState, 0, vmstate_apm, APMState), + VMSTATE_STRUCT(smb, PIIX4PMState, 4, pmsmb_vmstate, PMSMBus), VMSTATE_TIMER_PTR(ar.tmr.timer, PIIX4PMState), VMSTATE_INT64(ar.tmr.overflow_time, PIIX4PMState), VMSTATE_STRUCT(ar.gpe, PIIX4PMState, 2, vmstate_gpe, ACPIGPE), diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c index 8793113c25..75907e1c22 100644 --- a/hw/i2c/pm_smbus.c +++ b/hw/i2c/pm_smbus.c @@ -19,6 +19,7 @@ */ #include "qemu/osdep.h" #include "hw/hw.h" +#include "hw/boards.h" #include "hw/i2c/pm_smbus.h" #include "hw/i2c/smbus_master.h" =20 @@ -450,6 +451,36 @@ static const MemoryRegionOps pm_smbus_ops =3D { .endianness =3D DEVICE_LITTLE_ENDIAN, }; =20 +static bool pm_smbus_vmstate_needed(void *opaque) +{ + MachineClass *mc =3D MACHINE_GET_CLASS(qdev_get_machine()); + + return !mc->smbus_no_migration_support; +} + +const VMStateDescription pmsmb_vmstate =3D { + .name =3D "pmsmb", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D pm_smbus_vmstate_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8(smb_stat, PMSMBus), + VMSTATE_UINT8(smb_ctl, PMSMBus), + VMSTATE_UINT8(smb_cmd, PMSMBus), + VMSTATE_UINT8(smb_addr, PMSMBus), + VMSTATE_UINT8(smb_data0, PMSMBus), + VMSTATE_UINT8(smb_data1, PMSMBus), + VMSTATE_UINT32(smb_index, PMSMBus), + VMSTATE_UINT8_ARRAY(smb_data, PMSMBus, PM_SMBUS_MAX_MSG_SIZE), + VMSTATE_UINT8(smb_auxctl, PMSMBus), + VMSTATE_BOOL(i2c_enable, PMSMBus), + VMSTATE_BOOL(op_done, PMSMBus), + VMSTATE_BOOL(in_i2c_block_read, PMSMBus), + VMSTATE_BOOL(start_transaction_on_status_read, PMSMBus), + VMSTATE_END_OF_LIST() + } +}; + void pm_smbus_init(DeviceState *parent, PMSMBus *smb, bool force_aux_blk) { smb->op_done =3D true; diff --git a/hw/i2c/smbus_ich9.c b/hw/i2c/smbus_ich9.c index e6d8d28194..c9b7482a54 100644 --- a/hw/i2c/smbus_ich9.c +++ b/hw/i2c/smbus_ich9.c @@ -45,10 +45,12 @@ typedef struct ICH9SMBState { =20 static const VMStateDescription vmstate_ich9_smbus =3D { .name =3D "ich9_smb", - .version_id =3D 1, + .version_id =3D 2, .minimum_version_id =3D 1, .fields =3D (VMStateField[]) { - VMSTATE_PCI_DEVICE(dev, struct ICH9SMBState), + VMSTATE_PCI_DEVICE(dev, ICH9SMBState), + VMSTATE_BOOL_V(irq_enabled, ICH9SMBState, 2), + VMSTATE_STRUCT(smb, ICH9SMBState, 2, pmsmb_vmstate, PMSMBus), VMSTATE_END_OF_LIST() } }; diff --git a/include/hw/i2c/pm_smbus.h b/include/hw/i2c/pm_smbus.h index 7bcca97672..5075fc64fa 100644 --- a/include/hw/i2c/pm_smbus.h +++ b/include/hw/i2c/pm_smbus.h @@ -43,4 +43,6 @@ typedef struct PMSMBus { =20 void pm_smbus_init(DeviceState *parent, PMSMBus *smb, bool force_aux_blk); =20 +extern const VMStateDescription pmsmb_vmstate; + #endif /* PM_SMBUS_H */ --=20 2.17.1