From patchwork Mon Mar 21 17:28:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 64123 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1545661lbc; Mon, 21 Mar 2016 10:41:51 -0700 (PDT) X-Received: by 10.140.228.68 with SMTP id y65mr44399653qhb.78.1458582111064; Mon, 21 Mar 2016 10:41:51 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o10si24894454qhb.108.2016.03.21.10.41.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 21 Mar 2016 10:41:51 -0700 (PDT) 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; 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]:59330 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai3pu-0006DR-Fv for patch@linaro.org; Mon, 21 Mar 2016 13:41:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52173) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai3eJ-0002i8-55 for qemu-devel@nongnu.org; Mon, 21 Mar 2016 13:29:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ai3eE-0001ES-8Y for qemu-devel@nongnu.org; Mon, 21 Mar 2016 13:29:50 -0400 Received: from e32.co.us.ibm.com ([32.97.110.150]:60295) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai3eE-0001Dv-2C for qemu-devel@nongnu.org; Mon, 21 Mar 2016 13:29:46 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 21 Mar 2016 11:29:45 -0600 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 21 Mar 2016 11:29:42 -0600 X-IBM-Helo: d03dlp02.boulder.ibm.com X-IBM-MailFrom: mdroth@linux.vnet.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org;qemu-stable@nongnu.org Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 0F39E3E40047; Mon, 21 Mar 2016 11:29:41 -0600 (MDT) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u2LHTeOm31653972; Mon, 21 Mar 2016 10:29:40 -0700 Received: from d03av01.boulder.ibm.com (localhost [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u2LHTeUZ009269; Mon, 21 Mar 2016 11:29:40 -0600 Received: from localhost ([9.80.111.41]) by d03av01.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u2LHTdad009245; Mon, 21 Mar 2016 11:29:40 -0600 From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 21 Mar 2016 12:28:29 -0500 Message-Id: <1458581313-19045-32-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1458581313-19045-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1458581313-19045-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16032117-0005-0000-0000-00001F2D4102 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 32.97.110.150 Cc: Michael Roth , Alexandre DERUMIER , qemu-stable@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc=20Mar=C3=AD?= , Laszlo Ersek Subject: [Qemu-devel] [PATCH 31/35] fw_cfg: unbreak migration compatibility for 2.4 and earlier machines X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Laszlo Ersek When I reviewed Marc's fw_cfg DMA patches, I completely missed that the way we set dma_enabled would break migration. Gerd explained the right way (see reference below): dma_enabled should be set to true by default, and only true->false transitions should be possible: - when the user requests that with -global fw_cfg_mem.dma_enabled=off or -global fw_cfg_io.dma_enabled=off as appropriate for the platform, - when HW_COMPAT_2_4 dictates it, - when board code initializes fw_cfg without requesting DMA support. Cc: Marc MarĂ­ Cc: Gerd Hoffmann Cc: Alexandre DERUMIER Cc: qemu-stable@nongnu.org Ref: http://thread.gmane.org/gmane.comp.emulators.qemu/390272/focus=391042 Ref: https://bugs.launchpad.net/qemu/+bug/1536487 Suggested-by: Gerd Hoffmann Signed-off-by: Laszlo Ersek Message-id: 1455823860-22268-1-git-send-email-lersek@redhat.com Signed-off-by: Gerd Hoffmann (cherry picked from commit e6915b5f3a874a467a9a65f7ec1d6ef8d251a51a) Conflicts: include/hw/compat.h * remove cosmetic dep on c9c0afbb Signed-off-by: Michael Roth --- hw/nvram/fw_cfg.c | 20 ++++++++++++-------- include/hw/compat.h | 8 ++++++++ 2 files changed, 20 insertions(+), 8 deletions(-) -- 1.9.1 diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 117809b..5a03b5d 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -782,17 +782,19 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase, DeviceState *dev; FWCfgState *s; uint32_t version = FW_CFG_VERSION; - bool dma_enabled = dma_iobase && dma_as; + bool dma_requested = dma_iobase && dma_as; dev = qdev_create(NULL, TYPE_FW_CFG_IO); qdev_prop_set_uint32(dev, "iobase", iobase); qdev_prop_set_uint32(dev, "dma_iobase", dma_iobase); - qdev_prop_set_bit(dev, "dma_enabled", dma_enabled); + if (!dma_requested) { + qdev_prop_set_bit(dev, "dma_enabled", false); + } fw_cfg_init1(dev); s = FW_CFG(dev); - if (dma_enabled) { + if (s->dma_enabled) { /* 64 bits for the address field */ s->dma_as = dma_as; s->dma_addr = 0; @@ -818,11 +820,13 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, SysBusDevice *sbd; FWCfgState *s; uint32_t version = FW_CFG_VERSION; - bool dma_enabled = dma_addr && dma_as; + bool dma_requested = dma_addr && dma_as; dev = qdev_create(NULL, TYPE_FW_CFG_MEM); qdev_prop_set_uint32(dev, "data_width", data_width); - qdev_prop_set_bit(dev, "dma_enabled", dma_enabled); + if (!dma_requested) { + qdev_prop_set_bit(dev, "dma_enabled", false); + } fw_cfg_init1(dev); @@ -832,7 +836,7 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, s = FW_CFG(dev); - if (dma_enabled) { + if (s->dma_enabled) { s->dma_as = dma_as; s->dma_addr = 0; sysbus_mmio_map(sbd, 2, dma_addr); @@ -877,7 +881,7 @@ static Property fw_cfg_io_properties[] = { DEFINE_PROP_UINT32("iobase", FWCfgIoState, iobase, -1), DEFINE_PROP_UINT32("dma_iobase", FWCfgIoState, dma_iobase, -1), DEFINE_PROP_BOOL("dma_enabled", FWCfgIoState, parent_obj.dma_enabled, - false), + true), DEFINE_PROP_END_OF_LIST(), }; @@ -917,7 +921,7 @@ static const TypeInfo fw_cfg_io_info = { static Property fw_cfg_mem_properties[] = { DEFINE_PROP_UINT32("data_width", FWCfgMemState, data_width, -1), DEFINE_PROP_BOOL("dma_enabled", FWCfgMemState, parent_obj.dma_enabled, - false), + true), DEFINE_PROP_END_OF_LIST(), }; diff --git a/include/hw/compat.h b/include/hw/compat.h index d0b1c4f..b7973db 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -18,6 +18,14 @@ .driver = "virtio-pci",\ .property = "migrate-extra",\ .value = "off",\ + },{\ + .driver = "fw_cfg_mem",\ + .property = "dma_enabled",\ + .value = "off",\ + },{\ + .driver = "fw_cfg_io",\ + .property = "dma_enabled",\ + .value = "off",\ }, #define HW_COMPAT_2_3 \