From nobody Wed Nov 5 17:24:53 2025 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 1496898669998829.2744968389534; Wed, 7 Jun 2017 22:11:09 -0700 (PDT) Received: from localhost ([::1]:47360 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIpiu-0007Y2-MR for importer@patchew.org; Thu, 08 Jun 2017 01:11:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIphV-0006X4-14 for qemu-devel@nongnu.org; Thu, 08 Jun 2017 01:09:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIphQ-0008OD-Bg for qemu-devel@nongnu.org; Thu, 08 Jun 2017 01:09:40 -0400 Received: from ozlabs.org ([103.22.144.67]:41911) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dIphQ-0008NO-03; Thu, 08 Jun 2017 01:09:36 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wjtl15ryQz9s89; Thu, 8 Jun 2017 15:09:33 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496898573; bh=swPlbR0Kq7hiO7WecekrxW/oS2aPgvDs/4xQtr0yxI8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FiWLMy5W8w8prbmB5qJIwAotN41Aex6leIlXJmEd8NrnaSlqwSAgQ+Y9JxAk+0As/ gW6IH9cfcw4foK/rVrREcxl6DkIugXXSAah1+mHwZ3ciTzfYbkXq96uANcKNLF00OC J/j9BGTi0/oIFoe5fKEZaDi0Fgf8sjOIPx4uJM9Y= From: David Gibson To: mdroth@linux.vnet.ibm.com Date: Thu, 8 Jun 2017 15:09:27 +1000 Message-Id: <20170608050930.2613-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170608050930.2613-1-david@gibson.dropbear.id.au> References: <20170608050930.2613-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] [PATCH 3/6] 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: sursingh@redhat.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, bharata@linux.vnet.ibm.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 --- hw/ppc/spapr_drc.c | 54 ++++++++++++++++++++++++++++++--------------------= ---- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index afd68f4..dc4ac77 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -326,31 +326,9 @@ 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) -{ - 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) { - if (!drc->awaiting_allocation_skippable) { - drc->awaiting_release =3D true; - trace_spapr_drc_awaiting_allocation(spapr_drc_index(drc)); - return; - } - } =20 +static void spapr_drc_release(sPAPRDRConnector *drc) +{ drc->dr_indicator =3D SPAPR_DR_INDICATOR_INACTIVE; =20 /* Calling release callbacks based on spapr_drc_type(drc). */ @@ -379,6 +357,34 @@ 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) { + if (!drc->awaiting_allocation_skippable) { + 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