From patchwork Thu Dec 7 21:46:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 10101151 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DD2CC60329 for ; Thu, 7 Dec 2017 21:53:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF5F8284B9 for ; Thu, 7 Dec 2017 21:53:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C43F928734; Thu, 7 Dec 2017 21:53:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8A7C9284B9 for ; Thu, 7 Dec 2017 21:53:00 +0000 (UTC) Received: from localhost ([::1]:34530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN46F-0001qD-N2 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Dec 2017 16:52:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN401-00041G-Cv for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN400-0006OP-8L for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:33 -0500 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:42451) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eN400-0006Mp-1i for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:46:32 -0500 Received: by mail-pg0-x244.google.com with SMTP id e14so5385658pgr.9 for ; Thu, 07 Dec 2017 13:46:31 -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=jpmK1Igkm3NFGVKTiC4/qQJV3D4/E8c+EEW3KID+uZQ=; b=HcPhFbPUXF5lC1Covv19MvacrUpvuywwDs04akFru/rwMBHpHKpHMCjVIIA44rOFV1 s6b9HDwYAgGClQLRB2k/4M/KcVxTMQ35Q3XAKnC/9r+qajWHMar8nTnJMdaPU94uhsFF RLfFsBISK1Oajl2Cickly0GflUyz7yAxNzHoOj337FdJl4RbFjr9F+NieTRTRLdK3i8e hH/8523nvciyX2ALAThWZkURByhHpAqhWZtBmPtCH7Xq3tG9mUSeqUaCFooSciuuCytH KeE4yfBEVh9X2jaBQFn2EUjUy8EWzJkIaT5G+0m6HSqh1zbO/tT8pGh5s1d0jQdYWZvi fKNQ== 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=jpmK1Igkm3NFGVKTiC4/qQJV3D4/E8c+EEW3KID+uZQ=; b=RU7bBe39uwT74RXkHfezX93JOK60nrMy3EOXI+Qn0EeM4nUgTECoXGOSlYB2Qt61gM 0jb3JnqDjiIB8oQhZNyADMg37Tzy/TYGQ5CkGAKa9yhZPiUcrrpScBa3/oFY1vK0MqKK gD7iSvn8UQn5dTCC1wY7CGwdrQKNzg+Nze8h7ozSOabXRz6xFWTxl3hdsrgTTGQVKCJD rXI/NpGAlt+TyUEW248GMXyeJFtEEmwj0oGeBohuX3qEPLMbe75VK/U0MdRc7cM5bcw+ p1Up9oVeK0QnC90/6OZAEEe9b6dhVnC0s4RZqoyw8r31qQSOeYGXBXADbSpr3+z8npwZ xijA== X-Gm-Message-State: AJaThX5YT7KRFTJEZI+6ibOi32y7dOU+VMu0F6kO/AUOT0oXoZaOfYRY UBTZXF8i6tElPXhkZIztRw== X-Google-Smtp-Source: AGs4zMZh1ynE9eEyFoIuGBGh31zviaUoAM0/gREkInkX8C1/8ryeBi6WXYTfMS4gj+LsH9H5B9WtNg== X-Received: by 10.99.120.131 with SMTP id t125mr26147999pgc.83.1512683190991; Thu, 07 Dec 2017 13:46:30 -0800 (PST) Received: from serve.minyard.net ([47.184.168.85]) by smtp.gmail.com with ESMTPSA id u19sm10223959pfh.89.2017.12.07.13.46.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 13:46:29 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 3195FCF0; Thu, 7 Dec 2017 15:46:25 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 2A2EB302366; Thu, 7 Dec 2017 15:46:23 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 7 Dec 2017 15:46:12 -0600 Message-Id: <1512683181-8420-6-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512683181-8420-1-git-send-email-minyard@acm.org> References: <1512683181-8420-1-git-send-email-minyard@acm.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH 05/14] 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: Corey Minyard , Paolo Bonzini , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- hw/acpi/piix4.c | 1 + hw/i2c/pm_smbus.c | 19 +++++++++++++++++++ hw/i2c/smbus_ich9.c | 3 ++- include/hw/i2c/pm_smbus.h | 2 ++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index a0fb1ce..18c1ffa 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -321,6 +321,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, 1, 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 686d411..eb2df4d 100644 --- a/hw/i2c/pm_smbus.c +++ b/hw/i2c/pm_smbus.c @@ -370,6 +370,25 @@ static const MemoryRegionOps pm_smbus_ops = { .endianness = DEVICE_LITTLE_ENDIAN, }; +const VMStateDescription pmsmb_vmstate = { + .name = "pmsmb", + .version_id = 1, + .minimum_version_id = 1, + .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_VBUFFER_UINT32(smb_data, PMSMBus, 1, NULL, smb_index), + VMSTATE_UINT8(smb_auxctl, PMSMBus), + VMSTATE_BOOL(i2c_enable, PMSMBus), + VMSTATE_BOOL(op_done, PMSMBus), + VMSTATE_END_OF_LIST() + } +}; + void pm_smbus_init(DeviceState *parent, PMSMBus *smb) { smb->op_done = true; diff --git a/hw/i2c/smbus_ich9.c b/hw/i2c/smbus_ich9.c index 59e165a..706b9ec 100644 --- a/hw/i2c/smbus_ich9.c +++ b/hw/i2c/smbus_ich9.c @@ -49,7 +49,8 @@ static const VMStateDescription vmstate_ich9_smbus = { .version_id = 1, .minimum_version_id = 1, .fields = (VMStateField[]) { - VMSTATE_PCI_DEVICE(dev, struct ICH9SMBState), + VMSTATE_PCI_DEVICE(dev, ICH9SMBState), + VMSTATE_STRUCT(smb, ICH9SMBState, 1, pmsmb_vmstate, PMSMBus), VMSTATE_END_OF_LIST() } }; diff --git a/include/hw/i2c/pm_smbus.h b/include/hw/i2c/pm_smbus.h index 99d5489..b1e1970 100644 --- a/include/hw/i2c/pm_smbus.h +++ b/include/hw/i2c/pm_smbus.h @@ -33,4 +33,6 @@ typedef struct PMSMBus { void pm_smbus_init(DeviceState *parent, PMSMBus *smb); +extern const VMStateDescription pmsmb_vmstate; + #endif /* PM_SMBUS_H */