From patchwork Thu Nov 15 19:24:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 151248 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7407690ljp; Thu, 15 Nov 2018 11:35:22 -0800 (PST) X-Google-Smtp-Source: AJdET5d86uSO7+JfhGeQDJq8W5uOYi3x62Bg5m+hiV/ZyFSR13OLrLoM8QPD2etifJMuRamc9pJ1 X-Received: by 2002:aed:2f65:: with SMTP id l92mr7381833qtd.109.1542310522237; Thu, 15 Nov 2018 11:35:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542310522; cv=none; d=google.com; s=arc-20160816; b=iP9ly85o7zwcY8mt0GcZzMHu1KHJhFLyZKz7XP5pPwbb7BS8qO+K8sWmTuazB6bqnx 53f7qxW4eSfNA70PbK45iH/3GupSLPTT+leatJvDOZFAzkUUBGlTgZyyWdKdaU4/oXAs 5Dqqk9O0wGHFa6FP3pjABnqU7BSEjuln1f9KhVGmE8AZVJspbux2TjAAEEbB2P1j4/Ci MXeVS65KlM0S03t0/FhB1O/wumeUGtv+O+4LjVM3sOXt6XL5RWvg4gfEtqqHfIITwB4d VhnPpUHWb8znL/5ZTloADBd0X8O6tgjvusnXOxMfijnml/CkdHE+JFv3ZWs+RTcKUFqx i2iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=STEFnmERwmM/Z9Wu9lJP1GkrtR9zGW2Cs18899DJPak=; b=gb0MKxddLfcpwYpBd4tqfXWffZmfv9uEE7nX0TxSAOOQfzkKSPq5UfVYfeRZBQlQsk T7K35omRqo7tPZCqoS33uP0rCwAu2tiZzqzBOIT65rYOXWS6eTsJIVEDzWFGFWVIIuIw DUFzb65/PLRej5PGgv/t7V+Vwzrm3tMQRfo6pKsk/FsE8QGSHa29dn/seOTGRPXc7wiO TdBoq+4HjvzBQhUwQ9p6R1Obs3ioMnVlxB35MR0ycQdppiHctrGfKs/tQpD7Nnuuu+6w zaW8d2aeHc02Tgp6abafz6e04sL3guC7c0BP0TYnQ8/+4PE3F3v5GtBon3gQHqsV1pPd bUlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=dMn+24wC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w58si8189380qtb.24.2018.11.15.11.35.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 15 Nov 2018 11:35:22 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=dMn+24wC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:40471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNNQ9-0002Nb-IW for patch@linaro.org; Thu, 15 Nov 2018 14:35:21 -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) 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-Received: by 2002:aca:d886:: with SMTP id p128-v6mr4410342oig.346.1542309898212; 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) 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.17.1 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 = { */ static const VMStateDescription vmstate_acpi = { .name = "piix4_pm", - .version_id = 3, + .version_id = 4, .minimum_version_id = 3, .minimum_version_id_old = 1, .load_state_old = acpi_load_old, @@ -320,6 +320,7 @@ static const VMStateDescription vmstate_acpi = { 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" @@ -450,6 +451,36 @@ static const MemoryRegionOps pm_smbus_ops = { .endianness = DEVICE_LITTLE_ENDIAN, }; +static bool pm_smbus_vmstate_needed(void *opaque) +{ + MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine()); + + return !mc->smbus_no_migration_support; +} + +const VMStateDescription pmsmb_vmstate = { + .name = "pmsmb", + .version_id = 1, + .minimum_version_id = 1, + .needed = pm_smbus_vmstate_needed, + .fields = (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 = 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 { static const VMStateDescription vmstate_ich9_smbus = { .name = "ich9_smb", - .version_id = 1, + .version_id = 2, .minimum_version_id = 1, .fields = (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 { void pm_smbus_init(DeviceState *parent, PMSMBus *smb, bool force_aux_blk); +extern const VMStateDescription pmsmb_vmstate; + #endif /* PM_SMBUS_H */