From patchwork Tue May 5 08:53:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikunj A Dadhania X-Patchwork-Id: 467953 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D399914099F for ; Tue, 5 May 2015 18:59:28 +1000 (AEST) Received: from localhost ([::1]:37595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpYhL-0003QL-33 for incoming@patchwork.ozlabs.org; Tue, 05 May 2015 04:59:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34343) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpYdI-0004hb-IQ for qemu-devel@nongnu.org; Tue, 05 May 2015 04:55:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YpYdE-00084t-AL for qemu-devel@nongnu.org; Tue, 05 May 2015 04:55:16 -0400 Received: from e23smtp04.au.ibm.com ([202.81.31.146]:39371) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpYdD-00084I-GE for qemu-devel@nongnu.org; Tue, 05 May 2015 04:55:12 -0400 Received: from /spool/local by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 5 May 2015 18:55:08 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp04.au.ibm.com (202.81.31.210) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 5 May 2015 18:55:06 +1000 Received: from d23relay08.au.ibm.com (d23relay08.au.ibm.com [9.185.71.33]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id B583F2CE8040; Tue, 5 May 2015 18:55:05 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay08.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t458svlK31654012; Tue, 5 May 2015 18:55:05 +1000 Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t458sXe5018465; Tue, 5 May 2015 18:54:33 +1000 Received: from abhimanyu.in.ibm.com (abhimanyu.in.ibm.com [9.124.35.239]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t458sLOp017866; Tue, 5 May 2015 18:54:31 +1000 From: Nikunj A Dadhania To: qemu-devel@nongnu.org, david@gibson.dropbear.id.au Date: Tue, 5 May 2015 14:23:55 +0530 Message-Id: <1430816036-26408-6-git-send-email-nikunj@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1430816036-26408-1-git-send-email-nikunj@linux.vnet.ibm.com> References: <1430816036-26408-1-git-send-email-nikunj@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15050508-0013-0000-0000-0000013532A8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 202.81.31.146 Cc: aik@ozlabs.ru, qemu-ppc@nongnu.org, agraf@suse.de, nikunj@linux.vnet.ibm.com, mdroth@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH v3 5/6] spapr_pci: fix boot-time device tree fields for pci hotplug X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Michael Roth We need to set the proper drc_index values in ibm,my-drc-index fields in order to allow a PCI device that was present at boot-time to be unplugged. Previously SLOF handles this, but with QEMU handling the DT we need to do it there as well. This patch slightly changes how SLOF handled it in the past, which was to allows add an ibm,my-drc-index value based on PCI slot/devices topology. Now we only add it when the slot supports hotplug and has a DR connector, which is more inline with PAPR. Signed-off-by: Michael Roth Signed-off-by: Nikunj A Dadhania --- hw/ppc/spapr_pci.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 103284a..cbd5661 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -951,7 +951,9 @@ static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset, _FDT(fdt_setprop(fdt, offset, "ibm,loc-code", drc_name, strlen(drc_name))); } - _FDT(fdt_setprop_cell(fdt, offset, "ibm,my-drc-index", drc_index)); + if (drc_index) { + _FDT(fdt_setprop_cell(fdt, offset, "ibm,my-drc-index", drc_index)); + } _FDT(fdt_setprop_cell(fdt, offset, "#address-cells", RESOURCE_CELLS_ADDRESS)); @@ -1483,6 +1485,20 @@ PCIHostState *spapr_create_phb(sPAPREnvironment *spapr, int index) return PCI_HOST_BRIDGE(dev); } +static uint32_t spapr_phb_get_pci_drc_index(sPAPRPHBState *phb, + PCIDevice *pdev) +{ + sPAPRDRConnector *drc = spapr_phb_get_pci_drc(phb, pdev); + sPAPRDRConnectorClass *drck; + + if (!drc) { + return 0; + } + + drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); + return drck->get_index(drc); +} + typedef struct sPAPRFDT { void *fdt; int node_off; @@ -1499,6 +1515,7 @@ static void spapr_populate_pci_devices_dt(PCIBus *bus, PCIDevice *pdev, int func = PCI_FUNC(pdev->devfn); char nodename[512]; sPAPRFDT s_fdt; + uint32_t drc_index = spapr_phb_get_pci_drc_index(p->sphb, pdev); if (func) { sprintf(nodename, "pci@%d,%d", slot, func); @@ -1506,7 +1523,7 @@ static void spapr_populate_pci_devices_dt(PCIBus *bus, PCIDevice *pdev, sprintf(nodename, "pci@%d", slot); } offset = fdt_add_subnode(p->fdt, p->node_off, nodename); - ret = spapr_populate_pci_child_dt(pdev, p->fdt, offset, p->index, 0, NULL); + ret = spapr_populate_pci_child_dt(pdev, p->fdt, offset, p->index, drc_index, NULL); g_assert(!ret); if ((pci_default_read_config(pdev, PCI_HEADER_TYPE, 1) !=