From patchwork Mon Jan 28 17:54:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 156845 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3729218jaa; Mon, 28 Jan 2019 10:14:16 -0800 (PST) X-Google-Smtp-Source: ALg8bN7HsB/iD5p/7iOxUGb2faIc5Q0cD4p7y3WP3jFDQkdFu0NWnwhy4LeNla2YIIwtLFFnsM+Y X-Received: by 2002:a05:6000:108d:: with SMTP id y13mr21863712wrw.135.1548699256097; Mon, 28 Jan 2019 10:14:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548699256; cv=none; d=google.com; s=arc-20160816; b=ZwiRNR6rS/vzabKF0vW6YFEw3HMbA7Md9Le2+Kja00wsxcsb2kKgVHB/2/tdSnAiHf FEVt8ddmzuzv4a7TcmXCsLVFvIcEwEO49BdL1xbbt64omDt6Zua3PLLkv2KrQD60HaTs qfCjUR/ILUTwkXP6PhGcrf2fluGm4J15NEYVt/HtOGe2OCR6CeG5EDABLqOw0hZiy+Hb f3TXVovWYiKHuyVNAVfvQPZUtzuc0Re4vWpvp1UZ9Qb316PzfrPe5u7Sd5OWxlx35RWu dChfBMSOBpwkxA0K/K9xDAeSYSQxDoABQdb4DJbE70KbbJiHUeElfNuiNlfF2W1LN0WV 5wzg== 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=Ysp9jG7buWT7lrGZ69hqgy8eTQ886skoQ080vnSGPR8=; b=erGmCgyQ/kD7GJjcUeHYnV4O9rIz5lFeKqHkOGd2xWWE5vajzW5drRI5x99biFyh+F 9UiuyARoqxUk0QwGPOr+PU+61zt1IRBd8tOhR7cWsxbQEGOBAxqzaaOb7kdNXYgiPs0H 11cx0P/AqFsi4YgBwATvB+JsAoquV+rPCxH0NiEfahooZWf0FQjUEidYLth2yl0Jxlqt keeHVcChlFlrmFYYq3lnTdLMVbgEvVvFYwjx2ey80qr2+UrJN5evtMBVeeKsE4HOZObM AG4ePSSc9/xklgfIYVMOV4Aq08WsXsTxSgzCqTbHeERIeE6bWlYhfJaTNLKyVI5O0/HW 5SHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Qm5vVuXh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p25si96896wmh.85.2019.01.28.10.14.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 28 Jan 2019 10:14:16 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Qm5vVuXh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([127.0.0.1]:36376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goBQE-0005IQ-Si for patch@linaro.org; Mon, 28 Jan 2019 13:14:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37380) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goBEH-0003dP-0f for qemu-devel@nongnu.org; Mon, 28 Jan 2019 13:01:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goB7v-0005Yr-Rj for qemu-devel@nongnu.org; Mon, 28 Jan 2019 12:55:31 -0500 Received: from mail-io1-xd42.google.com ([2607:f8b0:4864:20::d42]:34310) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1goB7u-0005YJ-Nv for qemu-devel@nongnu.org; Mon, 28 Jan 2019 12:55:18 -0500 Received: by mail-io1-xd42.google.com with SMTP id b16so14263903ior.1 for ; Mon, 28 Jan 2019 09:55:18 -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=Ysp9jG7buWT7lrGZ69hqgy8eTQ886skoQ080vnSGPR8=; b=Qm5vVuXhxnwPOb8UNNJWQdyu5W90zDfdpcTBy9u8TYfosqaZrXbYWOTtY2ZIulKyCJ mw36DfFs1lmb4FW0FpJFXd3CNNJT1NJ+cl6tYFjItk/jnDiCOGXxJzR6b8hbGMjhDyLX o8tbFkl/2Mk6LUonKSPKGcBg6ROybUrokpm7DzsEIKqPBn+W/4346P4ToGIoAH1o/8VU 9RqpHKEBJQkJc2tQ9Bz/WHOUVjssuEKQKHXOXrZJsoxLWyWGRy/OHMzKr2mmWI+HqyM+ njZ6vX1yFLpTzMyhPqG5kC+v3rtD74rArENe6bIvz2QjfEcBDJuHWoxzE2v2++lxeSvW 0x0w== 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=Ysp9jG7buWT7lrGZ69hqgy8eTQ886skoQ080vnSGPR8=; b=XQYHCgltcxIiUEA41LT5DLOx0fxVngrqnynGz8YRDzCRxG35rsRHSrHCS9LmgZwAng /OhPkX8ibDplZ+o/sZCBqw18HCVdBHPVZAVh40ao3WZ8nnoJnYreB7BBiTIMjwWS3917 zaW9Y6zOpjKRKRUn0E3nJ+Ny1f4lEWueLVC8CmUtmTnSWtQHKsyDZpNZG4fpDIgF8xDx mZJ0qh1kfJLboLFrWj138zLG2v1Z6x1AQyqHBAWo+Z5k/sGzKHcHFA3rVwhRzrF1pWT+ 2cqIQWnmWxXbpJn0K+f1Jt4ol2S/9wh60ISLizh8e694EpOq6fB7dnQFV+HB40YkxPwW xgtA== X-Gm-Message-State: AHQUAubGOINJZZrfyK6BieSEW+Nblb2iQnOlDY65V0qVJqG9QdhpMs95 KxXqQy/Jvrfmqt7c7BG9ZQ== X-Received: by 2002:a6b:92d6:: with SMTP id u205mr14190202iod.221.1548698118012; Mon, 28 Jan 2019 09:55:18 -0800 (PST) Received: from serve.minyard.net ([47.184.128.64]) by smtp.gmail.com with ESMTPSA id t70sm50994ita.17.2019.01.28.09.55.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 09:55:16 -0800 (PST) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:c8f8:7971:e432:a838]) by serve.minyard.net (Postfix) with ESMTPA id 9318EFC9; Mon, 28 Jan 2019 11:55:12 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 7E75530115F; Mon, 28 Jan 2019 11:55:09 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org, "Dr . David Alan Gilbert" Date: Mon, 28 Jan 2019 11:54:52 -0600 Message-Id: <20190128175458.27255-14-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190128175458.27255-1-minyard@acm.org> References: <20190128175458.27255-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::d42 Subject: [Qemu-devel] [PATCH v4 13/19] 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: Peter Maydell , Paolo Bonzini , Corey Minyard , Corey Minyard , "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 Reviewed-by: Dr. David Alan Gilbert --- hw/acpi/piix4.c | 7 +++++++ hw/i2c/pm_smbus.c | 31 +++++++++++++++++++++++++++++++ hw/i2c/smbus_ich9.c | 10 +++++++++- include/hw/i2c/pm_smbus.h | 9 +++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 88f9a9ec09..7f8efe9997 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -302,6 +302,11 @@ static const VMStateDescription vmstate_cpuhp_state = { } }; +static bool piix4_vmstate_need_smbus(void *opaque, int version_id) +{ + return pm_smbus_vmstate_needed(); +} + /* qemu-kvm 1.2 uses version 3 but advertised as 2 * To support incoming qemu-kvm 1.2 migration, change version_id * and minimum_version_id to 2 below (which breaks migration from @@ -321,6 +326,8 @@ 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_TEST(smb, PIIX4PMState, piix4_vmstate_need_smbus, 3, + 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 81d2a425ec..e48544f909 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" @@ -453,6 +454,36 @@ static const MemoryRegionOps pm_smbus_ops = { .endianness = DEVICE_LITTLE_ENDIAN, }; +bool pm_smbus_vmstate_needed(void) +{ + 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, + .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_UINT8(smb_blkdata, 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..7b24be8256 100644 --- a/hw/i2c/smbus_ich9.c +++ b/hw/i2c/smbus_ich9.c @@ -43,12 +43,20 @@ typedef struct ICH9SMBState { PMSMBus smb; } ICH9SMBState; +static bool ich9_vmstate_need_smbus(void *opaque, int version_id) +{ + return pm_smbus_vmstate_needed(); +} + static const VMStateDescription vmstate_ich9_smbus = { .name = "ich9_smb", .version_id = 1, .minimum_version_id = 1, .fields = (VMStateField[]) { - VMSTATE_PCI_DEVICE(dev, struct ICH9SMBState), + VMSTATE_PCI_DEVICE(dev, ICH9SMBState), + VMSTATE_BOOL_TEST(irq_enabled, ICH9SMBState, ich9_vmstate_need_smbus), + VMSTATE_STRUCT_TEST(smb, ICH9SMBState, ich9_vmstate_need_smbus, 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 7bcca97672..fb55c44444 100644 --- a/include/hw/i2c/pm_smbus.h +++ b/include/hw/i2c/pm_smbus.h @@ -43,4 +43,13 @@ typedef struct PMSMBus { void pm_smbus_init(DeviceState *parent, PMSMBus *smb, bool force_aux_blk); +/* + * For backwards compatibility on migration, older versions don't have + * working migration for pm_smbus, this lets us ignore the migrations + * for older machine versions. + */ +bool pm_smbus_vmstate_needed(void); + +extern const VMStateDescription pmsmb_vmstate; + #endif /* PM_SMBUS_H */