From nobody Wed Nov 5 09:06:19 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.zohomail.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 1499748255492184.6284115708246; Mon, 10 Jul 2017 21:44:15 -0700 (PDT) Received: from localhost ([::1]:44130 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUn1y-0006le-AM for importer@patchew.org; Tue, 11 Jul 2017 00:44:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUmxP-0002MA-GH for qemu-devel@nongnu.org; Tue, 11 Jul 2017 00:39:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUmxO-0007VJ-FY for qemu-devel@nongnu.org; Tue, 11 Jul 2017 00:39:31 -0400 Received: from ozlabs.org ([103.22.144.67]:48909) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dUmxO-0007TS-4D; Tue, 11 Jul 2017 00:39:30 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3x68Vy3z31z9t2H; Tue, 11 Jul 2017 14:39:21 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1499747962; bh=uJz4jFbJXuYzzGWUQG30STgY9NjvuOX9zYyx8gmLtj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BY5e5gjEe0fJ24bNH8s+07DRCAobuzhewQSXdzdPAfusbTngIFzj8s0IEi42cOF6M APRjahUHchieZwvUAqUOTvZsMIognR1WxyAmNx9anvXO34TqvoEJkViacHZjWpBg7o KfmF2/2d3p7Ccyo14G/hpD/fj9vaNjUbmseWXB7Y= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 11 Jul 2017 14:39:10 +1000 Message-Id: <20170711043917.1757-11-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170711043917.1757-1-david@gibson.dropbear.id.au> References: <20170711043917.1757-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 10/17] spapr: Use unplug_request for PCI hot unplug 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, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, surajjs@au1.ibm.com, aik@ozlabs.ru, sbobroff@au1.ibm.com, groug@kaod.org, agraf@suse.de, 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" AIUI, ->unplug_request in the HotplugHandler is used for "soft" unplug, where acknowledgement from the guest is required before completing the unplug, whereas ->unplug is used for "hard" unplug where qemu unilaterally removes the device, and the guest just has to cope with its sudden absence. For spapr we (correctly) use ->unplug_request for CPU and memory hot unplug but we use ->unplug for PCI. While I think it might be possible to support "hard" PCI unplug within the PAPR model, that's not how it actually works now. Although it's called from ->unplug, the PCI unplug path will usually just mark the device for removal, with completion of the unplug delayed until userspace responds to the unplug notification. If the guest doesn't respond as expected, that could delay the unplug completion arbitrarily long. To reflect that, change the PCI unplug path to be called from ->unplug_request. We also rename spapr_phb_hot_plug_child() and spapr_phb_hot_unplug_child() to spapr_pci_plug() and spapr_pci_unplug_request() to more obviously reflect the callbacks they're implementing. Signed-off-by: David Gibson Reviewed-by: Laurent Vivier Reviewed-by: Greg Kurz --- hw/ppc/spapr_pci.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 49c8db8..cc1588d 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1388,8 +1388,8 @@ static uint32_t spapr_phb_get_pci_drc_index(sPAPRPHBS= tate *phb, return spapr_drc_index(drc); } =20 -static void spapr_phb_hot_plug_child(HotplugHandler *plug_handler, - DeviceState *plugged_dev, Error **err= p) +static void spapr_pci_plug(HotplugHandler *plug_handler, + DeviceState *plugged_dev, Error **errp) { sPAPRPHBState *phb =3D SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler)); PCIDevice *pdev =3D PCI_DEVICE(plugged_dev); @@ -1469,8 +1469,8 @@ out: } } =20 -static void spapr_phb_hot_unplug_child(HotplugHandler *plug_handler, - DeviceState *plugged_dev, Error **e= rrp) +static void spapr_pci_unplug_request(HotplugHandler *plug_handler, + DeviceState *plugged_dev, Error **err= p) { sPAPRPHBState *phb =3D SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler)); PCIDevice *pdev =3D PCI_DEVICE(plugged_dev); @@ -1485,6 +1485,7 @@ static void spapr_phb_hot_unplug_child(HotplugHandler= *plug_handler, } =20 g_assert(drc); + g_assert(drc->dev =3D=3D plugged_dev); =20 drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); if (!drck->release_pending(drc)) { @@ -1972,8 +1973,8 @@ static void spapr_phb_class_init(ObjectClass *klass, = void *data) /* Supported by TYPE_SPAPR_MACHINE */ dc->user_creatable =3D true; set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); - hp->plug =3D spapr_phb_hot_plug_child; - hp->unplug =3D spapr_phb_hot_unplug_child; + hp->plug =3D spapr_pci_plug; + hp->unplug_request =3D spapr_pci_unplug_request; } =20 static const TypeInfo spapr_phb_info =3D { --=20 2.9.4