From nobody Tue Feb 10 05:41:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498820078304711.2371550659595; Fri, 30 Jun 2017 03:54:38 -0700 (PDT) Received: from localhost ([::1]:43669 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQtZN-000788-1D for importer@patchew.org; Fri, 30 Jun 2017 06:54:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQtRp-00006m-CR for qemu-devel@nongnu.org; Fri, 30 Jun 2017 06:46:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQtRm-0007z6-Mz for qemu-devel@nongnu.org; Fri, 30 Jun 2017 06:46:49 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:43223) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQtRm-0007w2-6K; Fri, 30 Jun 2017 06:46:46 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wzY9p0K91z9t24; Fri, 30 Jun 2017 20:46:37 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1498819598; bh=G8mEko8WYp/9aCfexTpJypG6u+/YtUANCvhGOpnxYN8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LSgdolGoTwCRvvKrSQ5ONLaqtJ5CdOMSedJm03HxPbTemNO/V8MeqnP0kAAX7mp5T XmQZCpOyQrbjPpa6HMbHzNHeGqaVr10oaVPLHvtRUnZuZJAVU6QrJoQWC+kpnCf4VE LKAnGINnVVlbaGpUOh+CpNRFZyKdjYGJsAMjqlr8= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 30 Jun 2017 20:46:30 +1000 Message-Id: <20170630104632.27942-20-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170630104632.27942-1-david@gibson.dropbear.id.au> References: <20170630104632.27942-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 19/21] spapr: Make DRC reset force DRC into known state 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: lvivier@redhat.com, thuth@redhat.com, qemu-devel@nongnu.org, sursingh@redhat.com, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.org, sbobroff@redhat.com, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The reset handler for DRCs attempts several state transitions which are subject to various checks and restrictions. But at reset time we know there is no guest, so we can ignore most of the usual sequencing rules and just set the DRC back to a known state. In fact, it's safer to do so. The existing code also has several redundant checks for drc->awaiting_release inside a block which has already tested that. This patch removes those and sets the DRC to a fixed initial state based only on whether a device is currently plugged or not. With DRCs correctly reset to a state based on device presence, we don't need to force state transitions as cold plugged devices are processed. This allows us to remove all the callers of the set_*_state() methods from outside spapr_drc.c. Signed-off-by: David Gibson Reviewed-by: Greg Kurz Reviewed-by: Michael Roth --- hw/ppc/spapr.c | 15 --------------- hw/ppc/spapr_drc.c | 35 ++++++++++++++++------------------- 2 files changed, 16 insertions(+), 34 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 3c12af0..0ee9fac 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2636,12 +2636,6 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_= t addr_start, uint64_t size, =20 spapr_drc_attach(drc, dev, fdt, fdt_offset, !dev->hotplugged, errp= ); addr +=3D SPAPR_MEMORY_BLOCK_SIZE; - if (!dev->hotplugged) { - sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(d= rc); - /* guests expect coldplugged LMBs to be pre-allocated */ - drck->set_allocation_state(drc, SPAPR_DR_ALLOCATION_STATE_USAB= LE); - drck->set_isolation_state(drc, SPAPR_DR_ISOLATION_STATE_UNISOL= ATED); - } } /* send hotplug notification to the * guest only in case of hotplugged memory @@ -3009,15 +3003,6 @@ static void spapr_core_plug(HotplugHandler *hotplug_= dev, DeviceState *dev, * of hotplugged CPUs. */ spapr_hotplug_req_add_by_index(drc); - } else { - /* - * Set the right DRC states for cold plugged CPU. - */ - if (drc) { - sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(d= rc); - drck->set_allocation_state(drc, SPAPR_DR_ALLOCATION_STATE_USAB= LE); - drck->set_isolation_state(drc, SPAPR_DR_ISOLATION_STATE_UNISOL= ATED); - } } core_slot->cpu =3D OBJECT(dev); =20 diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 8a2b8f5..9a2511f 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -378,7 +378,6 @@ static bool release_pending(sPAPRDRConnector *drc) static void reset(DeviceState *d) { sPAPRDRConnector *drc =3D SPAPR_DR_CONNECTOR(d); - sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); =20 trace_spapr_drc_reset(spapr_drc_index(drc)); =20 @@ -386,27 +385,25 @@ static void reset(DeviceState *d) drc->ccs =3D NULL; =20 /* immediately upon reset we can safely assume DRCs whose devices - * are pending removal can be safely removed, and that they will - * subsequently be left in an ISOLATED state. move the DRC to this - * state in these cases (which will in turn complete any pending - * device removals) + * are pending removal can be safely removed. */ if (drc->awaiting_release) { - drck->set_isolation_state(drc, SPAPR_DR_ISOLATION_STATE_ISOLATED); - /* generally this should also finalize the removal, but if the dev= ice - * hasn't yet been configured we normally defer removal under the - * assumption that this transition is taking place as part of devi= ce - * configuration. so check if we're still waiting after this, and - * force removal if we are - */ - if (drc->awaiting_release) { - spapr_drc_detach(drc, DEVICE(drc->dev), NULL); - } + spapr_drc_release(drc); + } + + drc->awaiting_allocation =3D false; =20 - /* non-PCI devices may be awaiting a transition to UNUSABLE */ - if (spapr_drc_type(drc) !=3D SPAPR_DR_CONNECTOR_TYPE_PCI && - drc->awaiting_release) { - drck->set_allocation_state(drc, SPAPR_DR_ALLOCATION_STATE_UNUS= ABLE); + if (drc->dev) { + /* A device present at reset is coldplugged */ + drc->isolation_state =3D SPAPR_DR_ISOLATION_STATE_UNISOLATED; + if (spapr_drc_type(drc) !=3D SPAPR_DR_CONNECTOR_TYPE_PCI) { + drc->allocation_state =3D SPAPR_DR_ALLOCATION_STATE_USABLE; + } + } else { + /* Otherwise device is absent, but might be hotplugged */ + drc->isolation_state =3D SPAPR_DR_ISOLATION_STATE_ISOLATED; + if (spapr_drc_type(drc) !=3D SPAPR_DR_CONNECTOR_TYPE_PCI) { + drc->allocation_state =3D SPAPR_DR_ALLOCATION_STATE_UNUSABLE; } } } --=20 2.9.4