From patchwork Thu Dec 1 04:44:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 701337 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tTlDL07mFz9t0v for ; Thu, 1 Dec 2016 15:48:50 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="ObK6aJxz"; dkim-atps=neutral Received: from localhost ([::1]:48096 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCJId-0006xn-C9 for incoming@patchwork.ozlabs.org; Wed, 30 Nov 2016 23:48:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCJEu-0004HI-Sj for qemu-devel@nongnu.org; Wed, 30 Nov 2016 23:44:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCJEt-0002A1-SR for qemu-devel@nongnu.org; Wed, 30 Nov 2016 23:44:56 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:60653) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cCJEs-00024b-QD; Wed, 30 Nov 2016 23:44:55 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3tTl7f258Xz9t1B; Thu, 1 Dec 2016 15:44:46 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1480567486; bh=H/W7IlISCHxcD1T/BujOlH48+bSYkKZ+6TTg/Urs4EQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ObK6aJxzMHxUpcyMwpL04/H6FTSrUHggGeeWizFIUfDVdpyFp6uUUZ/EHcC5XhcbN wcMkQv74VOKENcgr7i77VvMHjznKXmjJ6bz6VeWTNNV+s98qmldikeB/N3wIKudbS7 o04qio2h2ris8BmbeCUUgm2GR1eaCI62y1TV0MVY= From: David Gibson To: stefanha@redhat.com, peter.maydell@linaro.org Date: Thu, 1 Dec 2016 15:44:41 +1100 Message-Id: <20161201044441.14365-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161201044441.14365-1-david@gibson.dropbear.id.au> References: <20161201044441.14365-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 1/1] spapr: fix default DRC state for coldplugged LMBs 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: mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, agraf@suse.de, qemu-ppc@nongnu.org, Bharata B Rao , Greg Kurz , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Michael Roth Currently we set the initial isolation/allocation state for DRCs associated with coldplugged LMBs to ISOLATED/UNUSABLE, respectively, under the assumption that the guest will move this state to UNISOLATED/USABLE. In fact, this is only the case for LMBs added via hotplug. For coldplugged LMBs, the guest actually assumes the initial state to be UNISOLATED/USABLE. In practice, this only becomes an issue when we attempt to unplug one of these LMBs, where the guest kernel will issue an rtas-get-sensor-state call to check that the corresponding DRC is in an USABLE state before it will release the LMB back to QEMU. If the returned state is otherwise, the guest will assume no further action is needed, which bypasses the QEMU-side cleanup that occurs during the USABLE->UNUSABLE transition. This results in LMBs and their corresponding pc-dimm devices to stick around indefinitely. This patch fixes the issue by manually setting DRCs associated with cold-plugged LMBs to UNISOLATED/ALLOCATED, but leaving the hotplug state untouched. As it turns out, this is analogous to the handling for cold-plugged CPUs in spapr_core_plug(). Cc: qemu-ppc@nongnu.org Cc: David Gibson Cc: Bharata B Rao Cc: Greg Kurz Signed-off-by: Michael Roth Signed-off-by: David Gibson --- hw/ppc/spapr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index c3269c7..208ef7b 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2290,6 +2290,11 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t size, drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); drck->attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, errp); addr += SPAPR_MEMORY_BLOCK_SIZE; + if (!dev->hotplugged) { + /* guests expect coldplugged LMBs to be pre-allocated */ + drck->set_allocation_state(drc, SPAPR_DR_ALLOCATION_STATE_USABLE); + drck->set_isolation_state(drc, SPAPR_DR_ISOLATION_STATE_UNISOLATED); + } } /* send hotplug notification to the * guest only in case of hotplugged memory