From nobody Mon Feb 9 23:02:39 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 1498819916288206.1751362990277; Fri, 30 Jun 2017 03:51:56 -0700 (PDT) Received: from localhost ([::1]:43661 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQtWj-0004Pb-Tg for importer@patchew.org; Fri, 30 Jun 2017 06:51:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQtRn-000053-Qz for qemu-devel@nongnu.org; Fri, 30 Jun 2017 06:46:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQtRm-0007yC-0y for qemu-devel@nongnu.org; Fri, 30 Jun 2017 06:46:47 -0400 Received: from ozlabs.org ([103.22.144.67]:45941) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQtRl-0007wA-LU; Fri, 30 Jun 2017 06:46:45 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wzY9p1pb4z9t2J; 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=a3quTNUuQxREf0U2/aiH3ORiSsgcTcnOhwzBo/r6zQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=edFUSN5IQB1qOxTuKmY0UJ5nZ27V2FWdxuaZjRdVbzgTbZ4x1D08F2FK7dXCWBAjB J4H1SZPvAbgMBPiFc2mNdm2H1lekmf0B6K46D9W9zISQR3SBKIMFZKvEZSYXsHoFub 6HmRDyzNxHIj00yYWaP9bd8uLxQu384CyjCYRMAU= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 30 Jun 2017 20:46:29 +1000 Message-Id: <20170630104632.27942-19-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: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 18/21] spapr: Split DRC release from DRC detach 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" spapr_drc_detach() is called when qemu generic code requests a device be unplugged. It makes a number of tests, which could well delay further action until later, before actually detach the device from the DRC. This splits out the part which actually removes the device from the DRC into spapr_drc_release(). This will be useful for further cleanups. Signed-off-by: David Gibson Reviewed-by: Greg Kurz Reviewed-by: Michael Roth --- hw/ppc/spapr_drc.c | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 21f5bf1..8a2b8f5 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -315,29 +315,8 @@ void spapr_drc_attach(sPAPRDRConnector *drc, DeviceSta= te *d, void *fdt, NULL, 0, NULL); } =20 -void spapr_drc_detach(sPAPRDRConnector *drc, DeviceState *d, Error **errp) +static void spapr_drc_release(sPAPRDRConnector *drc) { - trace_spapr_drc_detach(spapr_drc_index(drc)); - - if (drc->isolation_state !=3D SPAPR_DR_ISOLATION_STATE_ISOLATED) { - trace_spapr_drc_awaiting_isolated(spapr_drc_index(drc)); - drc->awaiting_release =3D true; - return; - } - - if (spapr_drc_type(drc) !=3D SPAPR_DR_CONNECTOR_TYPE_PCI && - drc->allocation_state !=3D SPAPR_DR_ALLOCATION_STATE_UNUSABLE) { - trace_spapr_drc_awaiting_unusable(spapr_drc_index(drc)); - drc->awaiting_release =3D true; - return; - } - - if (drc->awaiting_allocation) { - drc->awaiting_release =3D true; - trace_spapr_drc_awaiting_allocation(spapr_drc_index(drc)); - return; - } - drc->dr_indicator =3D SPAPR_DR_INDICATOR_INACTIVE; =20 /* Calling release callbacks based on spapr_drc_type(drc). */ @@ -365,6 +344,32 @@ void spapr_drc_detach(sPAPRDRConnector *drc, DeviceSta= te *d, Error **errp) drc->dev =3D NULL; } =20 +void spapr_drc_detach(sPAPRDRConnector *drc, DeviceState *d, Error **errp) +{ + trace_spapr_drc_detach(spapr_drc_index(drc)); + + if (drc->isolation_state !=3D SPAPR_DR_ISOLATION_STATE_ISOLATED) { + trace_spapr_drc_awaiting_isolated(spapr_drc_index(drc)); + drc->awaiting_release =3D true; + return; + } + + if (spapr_drc_type(drc) !=3D SPAPR_DR_CONNECTOR_TYPE_PCI && + drc->allocation_state !=3D SPAPR_DR_ALLOCATION_STATE_UNUSABLE) { + trace_spapr_drc_awaiting_unusable(spapr_drc_index(drc)); + drc->awaiting_release =3D true; + return; + } + + if (drc->awaiting_allocation) { + drc->awaiting_release =3D true; + trace_spapr_drc_awaiting_allocation(spapr_drc_index(drc)); + return; + } + + spapr_drc_release(drc); +} + static bool release_pending(sPAPRDRConnector *drc) { return drc->awaiting_release; --=20 2.9.4