From patchwork Wed Feb 20 13:59:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 158833 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5085030jaa; Wed, 20 Feb 2019 07:57:43 -0800 (PST) X-Google-Smtp-Source: AHgI3IaKLbozEfG71A+xyCFjaoMeJeoBRHNueqE8avc7mAFY9kinaEC1HzCndyuM66x4QCdWGCGU X-Received: by 2002:a25:32c9:: with SMTP id y192mr29500937yby.244.1550678263527; Wed, 20 Feb 2019 07:57:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550678263; cv=none; d=google.com; s=arc-20160816; b=Ol+vJ/iLZ+tLgieImQnOYT+Fze2xk6KAxgR8D00InT3grRnFcgssTSTPX+3F/eI5Sn dXbhwQombC92rjzb74oa7CpnV2okunJRxM56SIUYKl02H93KFBhL/ZXY1VmBMrr4HsdD Cp6AWvdwXpF5IR43PCBJ9kI+jTQ5ykRrBuC2D6YqLjr6GVMju+Np7OS9EANP71H9dEj5 VX2U0reX17DCLe+It2p4vmoGUnja4DO4khSPh2BxEESgwvgqAdAz5mfPbhY27NtMy8uO d8yMAGrjbz0WZFwH0uFxZQTBet542X5fV6nVct2fRKfbeM9RNXtc64TuW4q9PtHDZvue M9+g== 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=HrLP0g1P/fNxo2j1ZygwD6qK3qkV3Nnnx13TqSXpsn5lpNPwsF/N9aKxLh4vrvO/+0 21BPFMQcKJR95Hdm2kHtFGaf8DyuiB8SX165x8swiAvoRSLxceqBQiPvJxvUXB6EDHUx SeE2pTIhPpDyZe048zURKvWK/1N8R6NxXxIODrUIlT1opa6SBmfL3Qx7T8Kw6grBduHF VHbMYU3EVFfC0JKPf2lM12h3h1z9MZzrrdO5FzsgU281ipqCyGVHKCe/jvjtzbtDTFkp Kw7r+gyPWZGdnIBLIU5nwInTx3T+lt0LXca/3cVS9Di3pL1ufVy2rFdlNkuAuA05//cQ gSrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Ot7Q8PKB; 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 q17si11344752ybp.368.2019.02.20.07.57.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 20 Feb 2019 07:57:43 -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=Ot7Q8PKB; 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]:41431 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwUFi-0001Ts-TK for patch@linaro.org; Wed, 20 Feb 2019 10:57:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwTwH-0002KT-Kv for qemu-devel@nongnu.org; Wed, 20 Feb 2019 10:37:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwTvv-000634-0T for qemu-devel@nongnu.org; Wed, 20 Feb 2019 10:37:27 -0500 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]:37318) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwTvq-0004yZ-Ub for qemu-devel@nongnu.org; Wed, 20 Feb 2019 10:37:14 -0500 Received: by mail-ot1-x343.google.com with SMTP id b3so40817683otp.4 for ; Wed, 20 Feb 2019 07:35:25 -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=Ot7Q8PKB6jEyjcT/kYdT3DXO9sInl/d71s7CEB0HMrunS/jjhxfyL6zaNGpRBgJt36 xFRefp8AXLbCVYnJ9Bfk/BriXw7ihp+rfm+uuX/p69tlgfe5lGyDtudMzNcTnM13+KdX Kplc0LeYQhl6z7+Kqm/RpXdlivjTY1a1ahuF8wT4EQ/51p8fTdHmL2Ttwsx54vtXsjKq WfQ+EVfKnt4cpr6Lw6reCe205pEdVSUKG5+3gFx+vzPZDRRlmXvniiDIhITOoMXa5069 UpxfuGufSMO0oH3ASr+x52ey7uHoYeBaZC9ZtoIhS2tRsijhiF0dT97d/kiX7s70tFcP hImA== 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=sJBDKMAdUf33yVQ26DkJw0fGuCjS9d+JLoKKGiQ4PbuMq9bwfiwAiES8PC6kXwaGS6 kSgZB0xs0uYoQPHBI4c4o4WbCz86XUXF43xP6uX7tAV8hZzE8O77qBzytZYgMitORll7 qSCTUeQE1IXWY2n3bPow+cplcyNgwtAOyWrkgTt8A+18NOxWe2glgRvginMmPvnKb52n b6rVsCkM0jSAYQLg+Y+uGzu/IYaXjcQ5E68owXosUNlJwxyxGnkU3FlJ9aonOe/gC4j6 GBZvrr0hJMsLOSOdmPxEIGomhR/270WrCF6HpDMtqC7S3Abw7uFjbo5stCyDEim+Gnjv OM8Q== X-Gm-Message-State: AHQUAuZY/JuEUfms45ZsQC63oMPqFsryKxssL02bUHHC34Fqg+JfyTPW kuwGNNI5yr6a0AXsKzBq/fSd4Wmo4Q== X-Received: by 2002:aca:ad8f:: with SMTP id w137mr6171599oie.12.1550671216937; Wed, 20 Feb 2019 06:00:16 -0800 (PST) Received: from serve.minyard.net ([47.184.128.64]) by smtp.gmail.com with ESMTPSA id i9sm1561125oth.13.2019.02.20.06.00.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Feb 2019 06:00:12 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 2D09D1808F8; Wed, 20 Feb 2019 14:00:10 +0000 (UTC) Received: by t430.minyard.net (Postfix, from userid 1000) id E9279302A6C; Wed, 20 Feb 2019 08:00:09 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2019 07:59:50 -0600 Message-Id: <20190220135956.22589-14-minyard@acm.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190220135956.22589-1-minyard@acm.org> References: <20190220135956.22589-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::343 Subject: [Qemu-devel] [PATCH 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 , Corey Minyard , Corey Minyard , "Michael S . Tsirkin" , "Dr . David Alan Gilbert" , 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 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 */