From patchwork Thu Feb 28 18:17:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 159413 Delivered-To: patch@linaro.org Received: by 2002:ac9:18c7:0:0:0:0:0 with SMTP id i7csp980345oce; Thu, 28 Feb 2019 10:25:02 -0800 (PST) X-Google-Smtp-Source: APXvYqy4dWKKSh5tvaSCwclltq7K+E53D7O6TYocqx+q6kCRAYQ6rssNrwTRw5/+0KUkRII7t35D X-Received: by 2002:a0d:c544:: with SMTP id h65mr266214ywd.35.1551378302601; Thu, 28 Feb 2019 10:25:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551378302; cv=none; d=google.com; s=arc-20160816; b=AEOm9op/bU/mRrRWFIQGyA/ZbBnMm2i0vMUkhE52EXcH7xuQeoIcESGzxc6S5mAzV8 VXO1XEQ1rjf417bQQuzCrduzP1BSr7Bdd/guT1Sp3Pv+U6cci7Fm+BscC88U2BzCB22M GPNzmIfVHcb5MEyX6xxBVBMvkeFuHzb9X6bgRYRA3g0xUAvW8niA02arXBqjrt72fHFk dDq5eFVzITzhEm9stbMkkqmf3REM/GPctvDdzXdIawQIEX5FqL3bl1m5GH5fXNxIJhME w86FmZquRwWauYtgWNH46K4+7P7cXzG6l8LUPZFLWjQlzewPnkXpEyopG9BE1/7DI9jH 8MYg== 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=3UFlQ3shD3IizolfVnuZXQqGFynAqm90AKBUEoy7fD0=; b=06HlMODaZ2pUyW4I2v5VUY/5FDPPHrVDhvOw9BLxVo6TOxfB5/xLC9Q3wvkEfbs/NY ddFIFuOmeIpDvOz2DR5kfRkJW6yEpqnEwbmRZbyrXxDwA4aRu0EYqFCUeP7GcoyoQKFi GwfgPWI428QCYkpwTmhdGk0+OFsV3ZJI0sOCzlpygfSlfINP65OWtv31214tyqpzlkU9 FOjxagugnqQBs6AslEKuNHymSkOq3qtJsLHGvCfmCc1uViw+6v0n+JBfri1W/6cKGrQY q4FkJe7qoQACloPau9DQpdakJzbmUZ/1NOSiBp6jwQ9F0+3oeYRgqB79/ijKM4Zbikd2 iThw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=bqBhCTeJ; 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 f132si11496937ywc.198.2019.02.28.10.25.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 28 Feb 2019 10:25:02 -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=bqBhCTeJ; 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]:44578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzQMg-0005c1-2c for patch@linaro.org; Thu, 28 Feb 2019 13:25:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzQFo-0000aG-Ic for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:18:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzQFc-0002Mg-Ts for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:17:56 -0500 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]:33637) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzQFY-0002DA-CO for qemu-devel@nongnu.org; Thu, 28 Feb 2019 13:17:42 -0500 Received: by mail-ot1-x32c.google.com with SMTP id q24so18585007otk.0 for ; Thu, 28 Feb 2019 10:17:28 -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=3UFlQ3shD3IizolfVnuZXQqGFynAqm90AKBUEoy7fD0=; b=bqBhCTeJN/Q0wiLB7dyPHL6HCEVcVI98YoB7ozyffW3psFEhkXFKun4G417PCU1Z0F h0Pyz8ypZqWrs64bK6wbueAW7PhrGTlq+ApAcEjV1x+22rFCDu5zuOqjVllnp1Zc35WH SQBnLOCzjXriipX1hk8fqrKAnJMob3HGFfUAErzDJRRqr0SEC/CbcDnSJMfkE1MSGztC 3K9OkGi61wh+0802xBkUfjg8VnHu0PckYB0u26rXr2DbjFZHhYKcLcYIsx5OKN4mo+rK a6XXQXlfDx+JcAVWimSgymiqwU4PZvpWgmdXlYJKccjgIiNKCHyR0gCXYyoefiG8eny1 Edwg== 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=3UFlQ3shD3IizolfVnuZXQqGFynAqm90AKBUEoy7fD0=; b=jjO9qSM+OJosFxr3+8jg4qb1vZUT9J2eOATsUVg/eij0AQ+cps5EPZfYLVgnabn+8c GkxC5OAtL7YEY9ZcHVfjTHeBuWrjXMqF6+7NuV+U1F1aOCTSf58ZtecGL+Y5U7kOaw6o zviAkOs9UPsy6QTSEtclH7SjHavCKqcT+OmUxJy9xy9C1yPniqQzsfA7VthD6PlhF38O st1UCecNTI7Q1vHz6xQU19o2aWDL2FBLlNxKwWNeExxamYPb+ET2m4v4e0BSB4D+59yI ye3dJvUOqvjR7NDimxwbFa8UU1AUKi4rQ5a/cDfzkFotzO2FJvO1efgXMuaoZ8m3PrcN QKfQ== X-Gm-Message-State: APjAAAXPo3IOYBUn19tV5V9n5e4hCDO0V7P3GytN9VK+cq+q2loWyHnz VR8Ct7ImRzEIrsmZ2MNhvg== X-Received: by 2002:a9d:5509:: with SMTP id l9mr649608oth.200.1551377847281; Thu, 28 Feb 2019 10:17:27 -0800 (PST) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id g80sm7691137otg.38.2019.02.28.10.17.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 10:17:25 -0800 (PST) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:b89e:c7bf:12ab:ad14]) by serve.minyard.net (Postfix) with ESMTPA id 6845E1808FD; Thu, 28 Feb 2019 18:17:14 +0000 (UTC) Received: by t430.minyard.net (Postfix, from userid 1000) id 573CD3028CF; Thu, 28 Feb 2019 12:17:14 -0600 (CST) From: minyard@acm.org To: Peter Maydell Date: Thu, 28 Feb 2019 12:17:04 -0600 Message-Id: <20190228181710.2477-14-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190228181710.2477-1-minyard@acm.org> References: <20190228181710.2477-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::32c Subject: [Qemu-devel] [PULL 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: Corey Minyard , minyard@acm.org, "Michael S . Tsirkin" , "Dr . David Alan Gilbert" , QEMU Developers , Paolo Bonzini 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 df8c0db909..8fd25a5926 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 */