From patchwork Tue Jan 9 14:01:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 123969 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4056094qgn; Tue, 9 Jan 2018 06:02:00 -0800 (PST) X-Google-Smtp-Source: ACJfBovngQ0qs/F4aZCrEWgpRlMf5/kEndS2UhlzN7PWcrduBiA08gmLYEb6RoXumyciOuuOAm1k X-Received: by 10.98.55.5 with SMTP id e5mr13729188pfa.173.1515506519775; Tue, 09 Jan 2018 06:01:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515506519; cv=none; d=google.com; s=arc-20160816; b=RBXGnCftXq5bgZNhcbMsr6IDrXZtqeyAxiMYW1aReVcGDU4rPu1T/omRjCHZvfIQmv U/BZuKwEQbwlXqW+yfkBPsFoJTDk4xYE9ycQwPvbj0MHmlCW979HuIFd15DH4cnvy6Cq 0U8HqSL8QafNEh7HH8PXvodyG3vhzQJ7I1NEIvqSbYzxR8InnrbFfyMcdwcocMF/60lX vTBG9/9wZudB+5Y4aJHhcYDBMryC1Pcc8bjRynaKvx3PxZrSvwmF8An92yg2A0uWTZ52 ZIVuK8WgmgJqjORRvXM6lM2PFqUZCq5UsAH2W6h6ZpAzW/dfIH62SwvnUrbh40umrGrS u5kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Ngh+zFvgxOPwUdKWF/Yp2pTDs524HEcljXaX6jfQyqM=; b=qTiQsTcN8umziQXuUU0LBQlen9V6bVSkFFqz1xnPqvYPe4b6BF26sQN+TwWI7FbC3Z Xchh6x11E3HXNeI8691OZp1jI4sNbWu8g/MK0dlGD9+cjlSHyZHCXGHg7/VgEQ4s/NXm wIgzh6thzfN9B6WCzgONpJcz2a45P9ptODoSsMqhRX3PIg4vBQjem3pYbCteQ/8DioVq k35NmjSsfCZF2OoQBl4w//ohb5109HvZksCy6XHmlGdnIUvS9pXw1fe+/kDb8FrL561u g1LdITy7LK5ygljT2Q9hl+8QAL3wvBRFNA3TrgVmm6fxLhaU10/y6QxVs38vM77XycTc AAbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id h4si10416798pln.668.2018.01.09.06.01.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jan 2018 06:01:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1eYuTT-0003eB-5y; Tue, 09 Jan 2018 14:01:55 +0000 From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: patches@linaro.org, qemu-stable@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 1/4] hw/sd/pl181: Reset SD card on controller reset Date: Tue, 9 Jan 2018 14:01:50 +0000 Message-Id: <1515506513-31961-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515506513-31961-1-git-send-email-peter.maydell@linaro.org> References: <1515506513-31961-1-git-send-email-peter.maydell@linaro.org> Since pl181 is still using the legacy SD card API, the SD card created by sd_init() is not plugged into any bus. This means that the controller has to reset it manually. Failing to do this mostly didn't affect the guest since the guest typically does a programmed SD card reset as part of its SD controller driver initialization, but meant that migration failed because it's only in sd_reset() that we set up the wpgrps_size field. Cc: qemu-stable@nongnu.org Fixes: https://bugs.launchpad.net/qemu/+bug/1739378 Signed-off-by: Peter Maydell --- hw/sd/pl181.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.7.4 diff --git a/hw/sd/pl181.c b/hw/sd/pl181.c index 55c8098..3ba1f7d 100644 --- a/hw/sd/pl181.c +++ b/hw/sd/pl181.c @@ -480,6 +480,10 @@ static void pl181_reset(DeviceState *d) /* We can assume our GPIO outputs have been wired up now */ sd_set_cb(s->card, s->cardstatus[0], s->cardstatus[1]); + /* Since we're still using the legacy SD API the card is not plugged + * into any bus, and we must reset it manually. + */ + device_reset(DEVICE(s->card)); } static void pl181_init(Object *obj) From patchwork Tue Jan 9 14:01:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 123967 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4056026qgn; Tue, 9 Jan 2018 06:01:57 -0800 (PST) X-Google-Smtp-Source: ACJfBouV2a1xIDC73eIswWWJjHV6w93q7hxPi8l1/1RfmT+6ouH7PBjdX/QFa9iQWg6QRY6s/+CN X-Received: by 10.46.101.90 with SMTP id z87mr9190790ljb.112.1515506517101; Tue, 09 Jan 2018 06:01:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515506517; cv=none; d=google.com; s=arc-20160816; b=GiIAFrTfSEH796rXQUpjKAcoJHAL9i7dUD2BRAfu+zDT2QRWfiTIcWBobJuHPKVP5j PVK1jqiz9DeGqrtxzK8+3UOxisnmzYhveYutznUvR8JPdKb5caChscLU38JY+cqd0QyG TwIPbAhRm3AWOh7jl2WWzqzzqFiz/Qu6w58iMXWpWtF2AawerQ1uUvA1aw2xJ1xTMK62 0srTspdUWEBDP9dv/N0UdV3XkpAznSsmpsVCtQO51AtvIts9AKYFOxkRs6AHJL/dFnE3 sMj0H1hI2tiEZ/E7VovjtkP9Xar+jGGUXTxjXb1OYF6x9ZauhTte0w0AMv1cedHTn6Lb /+Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=e8D3c+rvhcxq/fooYISPPiT34fPHUsEnaEB+nUHnzr4=; b=hcmUuFILqfECGZ1l8P7ndDmwaLlU9tk/6sHKy1A5Ld33wOTtJT/T1BoNFHSQMCDKMd 88NNuYUseRdxNyNRLaI0/4EGJl0KMwIC7H9Ye9+9dWBz82Vu+8p58CvpZRapyA+ez7xm B4KypAO2Lzh7RhQKmJuUjFD8TvBAgsO5P77ZlwI0UWJ7ttUbWd58ztb847tLPir1a2YY hsdSBuZoHeMmW9GK1vF7kdE/wTGSe3yUx3XtnyjuR30qNO6I7FRU4AWYXWrjUDsBBI9f jxFruj3ZXPnbxng+kI2pBGXWVc0Iv5oazp68yVu22ckm06ifCIy3j6SUd8tItCZfyMxO 3Wrg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id 28si5643704ljz.386.2018.01.09.06.01.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jan 2018 06:01:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1eYuTT-0003eT-S4; Tue, 09 Jan 2018 14:01:55 +0000 From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: patches@linaro.org, qemu-stable@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 2/4] hw/sd/milkymist-memcard: Reset SD card on controller reset Date: Tue, 9 Jan 2018 14:01:51 +0000 Message-Id: <1515506513-31961-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515506513-31961-1-git-send-email-peter.maydell@linaro.org> References: <1515506513-31961-1-git-send-email-peter.maydell@linaro.org> Since pl181 is still using the legacy SD card API, the SD card created by sd_init() is not plugged into any bus. This means that the controller has to reset it manually. Failing to do this mostly didn't affect the guest since the guest typically does a programmed SD card reset as part of its SD controller driver initialization, but meant that migration failed because it's only in sd_reset() that we set up the wpgrps_size field. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell --- hw/sd/milkymist-memcard.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.7.4 diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c index 4008c81..341da88 100644 --- a/hw/sd/milkymist-memcard.c +++ b/hw/sd/milkymist-memcard.c @@ -248,6 +248,10 @@ static void milkymist_memcard_reset(DeviceState *d) for (i = 0; i < R_MAX; i++) { s->regs[i] = 0; } + /* Since we're still using the legacy SD API the card is not plugged + * into any bus, and we must reset it manually. + */ + device_reset(DEVICE(s->card)); } static int milkymist_memcard_init(SysBusDevice *dev) From patchwork Tue Jan 9 14:01:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 123966 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4056022qgn; Tue, 9 Jan 2018 06:01:57 -0800 (PST) X-Google-Smtp-Source: ACJfBotlYrB8rXIoPYhpoRaPKpxyA4OFWjGS1OTzZPiuKSQGKaxSGVrr04ifFLsIslIEq4dYrWHg X-Received: by 10.28.238.6 with SMTP id m6mr12947365wmh.97.1515506517125; Tue, 09 Jan 2018 06:01:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515506517; cv=none; d=google.com; s=arc-20160816; b=qmDy+m60NloiUtU16yaqIIPwJ5DziFpLmuHnELdWPrayJ5fhOe8ITLveDbg9stKnSa SFmQxkn7jNa+wfTLuPQ0lSGIC1idG4zIttGlwrZuL6bWA8jS3SCQ0KHU65INOHXRVFbB 3L4a/3YuLngF87qYZ7NiASOiYNTQQWMaDVmoVXcYqhaGYGDOW8GdPd0H9pTcc1LnlLg9 nrhCNnoQCvUUko7BJiOWmFtcFdzjuImtfkIPFkBlpS7qjyftL6PzQej+NxWskQHQk1N0 N/kZYHlJkGu3FwEFUD3LNC84asmF+Sh6slEfoz7uz03ZQ+4iByOMHE8zf/8H7JDpaM6L kLrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=yzVSrDm5d995q4LMUQVlMIeJos7qXSJWNS9RNe95x94=; b=Kgal7rYsavJ/F+5K28lkQM00m9DmmtdWRguGM0w2fBffF6yDohINsXIiFkZXi5nC1u V4MHc4Ao7a0gKBBgIGvM6FpAot+u9xh3ijauXfbw/aF6LJzBg2UGQJqNsLc8o+tXd6F6 hWwaKl3B2g/6Q3RVv7SwvzPr9Z5oEw16IN2G/I74uX8MBxarg5Wtz0ccI/c//ETwlvUJ WcjWuRnsQHaEVUnAw+G4jphGP9JHdEVnStQ4+S9s/VqiBEiLjvTGiX1W3UxCET+ByOhL 3AgIXwIIcneLrg+2X/RmoW2X0ukViWRoNoQMEAaLXZzq8i6/NrzwL9QPPWsx0g4PSsjb va2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id y44si2481830wrd.521.2018.01.09.06.01.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jan 2018 06:01:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1eYuTU-0003ek-JW; Tue, 09 Jan 2018 14:01:56 +0000 From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: patches@linaro.org, qemu-stable@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 3/4] hw/sd/ssi-sd: Reset SD card on controller reset Date: Tue, 9 Jan 2018 14:01:52 +0000 Message-Id: <1515506513-31961-4-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515506513-31961-1-git-send-email-peter.maydell@linaro.org> References: <1515506513-31961-1-git-send-email-peter.maydell@linaro.org> Since ssi-sd is still using the legacy SD card API, the SD card created by sd_init() is not plugged into any bus. This means that the controller has to reset it manually. Failing to do this mostly didn't affect the guest since the guest typically does a programmed SD card reset as part of its SD controller driver initialization, but meant that migration failed because it's only in sd_reset() that we set up the wpgrps_size field. In the case of sd-ssi, we have to implement an entire reset function since there wasn't one previously, and that requires a QOM cast macro that got omitted when this device was QOMified. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell --- hw/sd/ssi-sd.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c index 24001dc..30d2a87 100644 --- a/hw/sd/ssi-sd.c +++ b/hw/sd/ssi-sd.c @@ -50,6 +50,9 @@ typedef struct { SDState *sd; } ssi_sd_state; +#define TYPE_SSI_SD "ssi-sd" +#define SSI_SD(obj) OBJECT_CHECK(ssi_sd_state, (obj), TYPE_SSI_SD) + /* State word bits. */ #define SSI_SDR_LOCKED 0x0001 #define SSI_SDR_WP_ERASE 0x0002 @@ -251,6 +254,24 @@ static void ssi_sd_realize(SSISlave *d, Error **errp) } } +static void ssi_sd_reset(DeviceState *dev) +{ + ssi_sd_state *s = SSI_SD(dev); + + s->mode = SSI_SD_CMD; + s->cmd = 0; + memset(s->cmdarg, 0, sizeof(s->cmdarg)); + memset(s->response, 0, sizeof(s->response)); + s->arglen = 0; + s->response_pos = 0; + s->stopping = 0; + + /* Since we're still using the legacy SD API the card is not plugged + * into any bus, and we must reset it manually. + */ + device_reset(DEVICE(s->sd)); +} + static void ssi_sd_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -260,10 +281,11 @@ static void ssi_sd_class_init(ObjectClass *klass, void *data) k->transfer = ssi_sd_transfer; k->cs_polarity = SSI_CS_LOW; dc->vmsd = &vmstate_ssi_sd; + dc->reset = ssi_sd_reset; } static const TypeInfo ssi_sd_info = { - .name = "ssi-sd", + .name = TYPE_SSI_SD, .parent = TYPE_SSI_SLAVE, .instance_size = sizeof(ssi_sd_state), .class_init = ssi_sd_class_init, From patchwork Tue Jan 9 14:01:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 123968 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4056046qgn; Tue, 9 Jan 2018 06:01:58 -0800 (PST) X-Google-Smtp-Source: ACJfBovPo6AveIKHTROM3HT7fMW2k760pK17/F/u9nvTAhQZ0nG5dC5Gr7/brvmens7rdILsRsih X-Received: by 10.223.189.16 with SMTP id j16mr13084805wrh.52.1515506518080; Tue, 09 Jan 2018 06:01:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515506518; cv=none; d=google.com; s=arc-20160816; b=q1t9d88VOEW9hL1l31r8GUEDHVrE8iDKIoTy6RYu6uDVxC6dAc/H7F+GhWM1GAALBR xdf1RSkSPzqBvwucgZjhPxD8ll4UgIVQNDbnd16fB4WTHE6I19yZajMYoeJ9Ju8AUDqe kD2fo0vrrlzpSFZ1UtV+GxO6OcKAqySLMpsb+CNhPEJGIgg/dDYK6JVl+NfpHVkK2Cnu m7KJx2NoPQD+1BcTchwNJ9Y0S4skkAtJSGoWwKbuzmn06GohircySAS6n4eZRLZi/F6/ WI07/ed0XONFaS/TE7bJv7cx4DEwjs8YyTfp+dcBS8vPTaxMM3tNh62Rhc8mUi8c0H6R Qw9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=J1ldDW2V7oPKtznNt7RCOwJyIeTQj2tkcROExEUA6RE=; b=BIqCOZt8WOnL4Ve9NlAKe4M95oHo9GlBprAo2Y9hKOv213P/Q668kkaOhQ6A5sN4Oy 6t4eDRWn/VoPQbS/jgY8e3Td+B81o+tCTVAq8YzQynUEOmBtxyh4PVbRsDqgs5Q40GE9 ySIltRkNFV2lxGXjUL6W0FPaK8nwRUpcZMJ992I5XvSMZE/DODms3cDKMV/Y74Au8OhL YAU+XdmVQCFzQdGKwOAtRR9xsyDNysDN7phNbzEd0MiK3fOcpjsZcdHUn3fdWYFdgzKZ fpQrHG9+PR6DnLIudIPHFgOcLJjgxyrOpEgoRd/wKnZ+kIXC+e+MqSlqy36Pa+k0W2QS Z44Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id m70si9413420wma.241.2018.01.09.06.01.57 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jan 2018 06:01:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1eYuTV-0003f0-C0; Tue, 09 Jan 2018 14:01:57 +0000 From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: patches@linaro.org, qemu-stable@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 4/4] hw/sd/omap_mmc: Reset SD card on controller reset Date: Tue, 9 Jan 2018 14:01:53 +0000 Message-Id: <1515506513-31961-5-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515506513-31961-1-git-send-email-peter.maydell@linaro.org> References: <1515506513-31961-1-git-send-email-peter.maydell@linaro.org> Since omap_mmc is still using the legacy SD card API, the SD card created by sd_init() is not plugged into any bus. This means that the controller has to reset it manually. Failing to do this mostly didn't affect the guest since the guest typically does a programmed SD card reset as part of its SD controller driver initialization, but would mean that migration fails because it's only in sd_reset() that we set up the wpgrps_size field. Signed-off-by: Peter Maydell --- This one isn't cc-stable because the OMAP boards don't support migration at all anyway, being un-QOMified. --- hw/sd/omap_mmc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/hw/sd/omap_mmc.c b/hw/sd/omap_mmc.c index e934cd3..5b47cad 100644 --- a/hw/sd/omap_mmc.c +++ b/hw/sd/omap_mmc.c @@ -305,6 +305,12 @@ void omap_mmc_reset(struct omap_mmc_s *host) host->cdet_enable = 0; qemu_set_irq(host->coverswitch, host->cdet_state); host->clkdiv = 0; + + /* Since we're still using the legacy SD API the card is not plugged + * into any bus, and we must reset it manually. When omap_mmc is + * QOMified this must move into the QOM reset function. + */ + device_reset(DEVICE(host->card)); } static uint64_t omap_mmc_read(void *opaque, hwaddr offset, @@ -587,8 +593,6 @@ struct omap_mmc_s *omap_mmc_init(hwaddr base, s->lines = 1; /* TODO: needs to be settable per-board */ s->rev = 1; - omap_mmc_reset(s); - memory_region_init_io(&s->iomem, NULL, &omap_mmc_ops, s, "omap.mmc", 0x800); memory_region_add_subregion(sysmem, base, &s->iomem); @@ -598,6 +602,8 @@ struct omap_mmc_s *omap_mmc_init(hwaddr base, exit(1); } + omap_mmc_reset(s); + return s; } @@ -613,8 +619,6 @@ struct omap_mmc_s *omap2_mmc_init(struct omap_target_agent_s *ta, s->lines = 4; s->rev = 2; - omap_mmc_reset(s); - memory_region_init_io(&s->iomem, NULL, &omap_mmc_ops, s, "omap.mmc", omap_l4_region_size(ta, 0)); omap_l4_attach(ta, 0, &s->iomem); @@ -628,6 +632,8 @@ struct omap_mmc_s *omap2_mmc_init(struct omap_target_agent_s *ta, s->cdet = qemu_allocate_irq(omap_mmc_cover_cb, s, 0); sd_set_cb(s->card, NULL, s->cdet); + omap_mmc_reset(s); + return s; }