From nobody Thu Nov 6 10:15:20 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1540376797823636.6883862334786; Wed, 24 Oct 2018 03:26:37 -0700 (PDT) Received: from localhost ([::1]:47323 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFGN2-00024W-Kj for importer@patchew.org; Wed, 24 Oct 2018 06:26:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFGHL-0005Am-Pl for qemu-devel@nongnu.org; Wed, 24 Oct 2018 06:20:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gFGHK-0000ha-U3 for qemu-devel@nongnu.org; Wed, 24 Oct 2018 06:20:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37548) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gFGHK-0000hS-MP; Wed, 24 Oct 2018 06:20:42 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 01A883001DD6; Wed, 24 Oct 2018 10:20:42 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-178.ams2.redhat.com [10.36.117.178]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47E945C1B2; Wed, 24 Oct 2018 10:20:15 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 24 Oct 2018 12:19:29 +0200 Message-Id: <20181024101930.20674-7-david@redhat.com> In-Reply-To: <20181024101930.20674-1-david@redhat.com> References: <20181024101930.20674-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 24 Oct 2018 10:20:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 6/7] pci/shpc: route unplug via the hotplug handler 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: Eduardo Habkost , "Michael S . Tsirkin" , David Hildenbrand , Alexander Graf , "Dr . David Alan Gilbert" , qemu-ppc@nongnu.org, Igor Mammedov , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Preparation for multi-stage hotplug handlers. Signed-off-by: David Hildenbrand --- hw/pci-bridge/pci_bridge_dev.c | 14 ++++++++++++++ hw/pci-bridge/pcie_pci_bridge.c | 14 ++++++++++++++ hw/pci/shpc.c | 11 ++++++++++- include/hw/pci/shpc.h | 2 ++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/hw/pci-bridge/pci_bridge_dev.c b/hw/pci-bridge/pci_bridge_dev.c index 2362dcbc64..978ab2a896 100644 --- a/hw/pci-bridge/pci_bridge_dev.c +++ b/hw/pci-bridge/pci_bridge_dev.c @@ -225,6 +225,19 @@ static void pci_bridge_dev_hotplug_cb(HotplugHandler *= hotplug_dev, shpc_device_hotplug_cb(hotplug_dev, dev, errp); } =20 +static void pci_bridge_dev_hot_unplug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + PCIDevice *pci_hotplug_dev =3D PCI_DEVICE(hotplug_dev); + + if (!shpc_present(pci_hotplug_dev)) { + error_setg(errp, "standard hotplug controller has been disabled fo= r " + "this %s", TYPE_PCI_BRIDGE_DEV); + return; + } + shpc_device_hot_unplug_cb(hotplug_dev, dev, errp); +} + static void pci_bridge_dev_hot_unplug_request_cb(HotplugHandler *hotplug_d= ev, DeviceState *dev, Error **errp) @@ -259,6 +272,7 @@ static void pci_bridge_dev_class_init(ObjectClass *klas= s, void *data) set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); hc->pre_plug =3D pci_bridge_dev_pre_plug_cb; hc->plug =3D pci_bridge_dev_hotplug_cb; + hc->unplug =3D pci_bridge_dev_hot_unplug_cb; hc->unplug_request =3D pci_bridge_dev_hot_unplug_request_cb; } =20 diff --git a/hw/pci-bridge/pcie_pci_bridge.c b/hw/pci-bridge/pcie_pci_bridg= e.c index cde8af0a4e..6ca711210e 100644 --- a/hw/pci-bridge/pcie_pci_bridge.c +++ b/hw/pci-bridge/pcie_pci_bridge.c @@ -156,6 +156,19 @@ static void pcie_pci_bridge_hotplug_cb(HotplugHandler = *hotplug_dev, shpc_device_hotplug_cb(hotplug_dev, dev, errp); } =20 +static void pcie_pci_bridge_hot_unplug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + PCIDevice *pci_hotplug_dev =3D PCI_DEVICE(hotplug_dev); + + if (!shpc_present(pci_hotplug_dev)) { + error_setg(errp, "standard hotplug controller has been disabled fo= r " + "this %s", TYPE_PCIE_PCI_BRIDGE_DEV); + return; + } + shpc_device_hot_unplug_cb(hotplug_dev, dev, errp); +} + static void pcie_pci_bridge_hot_unplug_request_cb(HotplugHandler *hotplug_= dev, DeviceState *dev, Error **errp) @@ -188,6 +201,7 @@ static void pcie_pci_bridge_class_init(ObjectClass *kla= ss, void *data) set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); hc->pre_plug =3D pcie_pci_bridge_pre_plug_cb; hc->plug =3D pcie_pci_bridge_hotplug_cb; + hc->unplug =3D pcie_pci_bridge_hot_unplug_cb; hc->unplug_request =3D pcie_pci_bridge_hot_unplug_request_cb; } =20 diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c index 1caf4a7ee9..591f5189c5 100644 --- a/hw/pci/shpc.c +++ b/hw/pci/shpc.c @@ -238,6 +238,7 @@ static void shpc_invalid_command(SHPCDevice *shpc) =20 static void shpc_free_devices_in_slot(SHPCDevice *shpc, int slot) { + HotplugHandler *hotplug_ctrl; int devfn; int pci_slot =3D SHPC_IDX_TO_PCI(slot); for (devfn =3D PCI_DEVFN(pci_slot, 0); @@ -245,7 +246,9 @@ static void shpc_free_devices_in_slot(SHPCDevice *shpc,= int slot) ++devfn) { PCIDevice *affected_dev =3D shpc->sec_bus->devices[devfn]; if (affected_dev) { - object_unparent(OBJECT(affected_dev)); + hotplug_ctrl =3D qdev_get_hotplug_handler(DEVICE(affected_dev)= ); + hotplug_handler_unplug(hotplug_ctrl, DEVICE(affected_dev), + &error_abort); } } } @@ -541,6 +544,12 @@ void shpc_device_hotplug_cb(HotplugHandler *hotplug_de= v, DeviceState *dev, shpc_interrupt_update(pci_hotplug_dev); } =20 +void shpc_device_hot_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *d= ev, + Error **errp) +{ + object_unparent(OBJECT(dev)); +} + void shpc_device_hot_unplug_request_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { diff --git a/include/hw/pci/shpc.h b/include/hw/pci/shpc.h index 82eacf8e96..40c5ac9bfe 100644 --- a/include/hw/pci/shpc.h +++ b/include/hw/pci/shpc.h @@ -49,6 +49,8 @@ void shpc_device_pre_plug_cb(HotplugHandler *hotplug_dev,= DeviceState *dev, Error **errp); void shpc_device_hotplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); +void shpc_device_hot_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *d= ev, + Error **errp); void shpc_device_hot_unplug_request_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); =20 --=20 2.17.2