From patchwork Fri Jul 8 23:19:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyrel Datwyler X-Patchwork-Id: 9221897 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E75626089D for ; Fri, 8 Jul 2016 23:20:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D507228636 for ; Fri, 8 Jul 2016 23:20:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C526228639; Fri, 8 Jul 2016 23:20:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97B9628636 for ; Fri, 8 Jul 2016 23:20:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756287AbcGHXT7 (ORCPT ); Fri, 8 Jul 2016 19:19:59 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:43720 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756172AbcGHXT6 (ORCPT ); Fri, 8 Jul 2016 19:19:58 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u68NJI0I100253 for ; Fri, 8 Jul 2016 19:19:57 -0400 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0a-001b2d01.pphosted.com with ESMTP id 2415xpddqr-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 08 Jul 2016 19:19:57 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 8 Jul 2016 17:19:56 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 8 Jul 2016 17:19:53 -0600 X-IBM-Helo: d03dlp01.boulder.ibm.com X-IBM-MailFrom: tyreld@linux.vnet.ibm.com Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id A9ED31FF0046; Fri, 8 Jul 2016 17:19:36 -0600 (MDT) Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u68NJr4L61472852; Fri, 8 Jul 2016 16:19:53 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2ED83C6014; Fri, 8 Jul 2016 17:19:53 -0600 (MDT) Received: from Ubuntu-16.04-LTS (unknown [9.40.192.81]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id 9008BC6016; Fri, 8 Jul 2016 17:19:52 -0600 (MDT) From: Tyrel Datwyler To: linux-pci@vger.kernel.org Cc: bhelgaas@google.com, mpe@ellerman.id.au, benh@kernel.crashing.org, nfont@linux.vnet.ibm.com, mdroth@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Tyrel Datwyler Subject: [PATCH] rpaphp: fix slot registration for multiple slots under a PHB Date: Fri, 8 Jul 2016 18:19:47 -0500 X-Mailer: git-send-email 2.7.4 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16070823-0024-0000-0000-00001411D786 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16070823-0025-0000-0000-00004286EB5C Message-Id: <1468019987-1733-1-git-send-email-tyreld@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-07-08_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1607080231 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP PowerVM seems to only ever provide a single hotplug slot per PHB. The under lying slot hotplug registration code assumed multiple slots, but the actual implementation is broken for multiple slots. This went unnoticed for years due to the nature of PowerVM as mentioned previously. Under qemu/kvm the hotplug slot model aligns more with x86 where multiple slots are presented under a single PHB. As seen in the following each additional slot after the first fails to register due to each slot always being compared against the first child node of the PHB in the device tree. [ 6.492291] rpaphp: RPA HOT Plug PCI Controller Driver version: 0.1 [ 6.492569] rpaphp: Slot [Slot 0] registered [ 6.492577] rpaphp: pci_hp_register failed with error -16 [ 6.493082] rpaphp: pci_hp_register failed with error -16 [ 6.493138] rpaphp: pci_hp_register failed with error -16 [ 6.493161] rpaphp: pci_hp_register failed with error -16 The registration logic is fixed so that each slot is compared against the existing child devices of the PHB in the device tree to determine present slots vs empty slots. [ 38.481750] rpaphp: RPA HOT Plug PCI Controller Driver version: 0.1 [ 38.482004] rpaphp: Slot [C0] registered [ 38.482127] rpaphp: Slot [C1] registered [ 38.482241] rpaphp: Slot [C2] registered [ 38.482356] rpaphp: Slot [C3] registered [ 38.482495] rpaphp: Slot [C4] registered Signed-off-by: Tyrel Datwyler --- drivers/pci/hotplug/rpaphp_slot.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c index 6937c72..c90fa8d 100644 --- a/drivers/pci/hotplug/rpaphp_slot.c +++ b/drivers/pci/hotplug/rpaphp_slot.c @@ -117,8 +117,10 @@ EXPORT_SYMBOL_GPL(rpaphp_deregister_slot); int rpaphp_register_slot(struct slot *slot) { struct hotplug_slot *php_slot = slot->hotplug_slot; + struct device_node *child; + u32 my_index; int retval; - int slotno; + int slotno = -1; dbg("%s registering slot:path[%s] index[%x], name[%s] pdomain[%x] type[%d]\n", __func__, slot->dn->full_name, slot->index, slot->name, @@ -130,10 +132,15 @@ int rpaphp_register_slot(struct slot *slot) return -EAGAIN; } - if (slot->dn->child) - slotno = PCI_SLOT(PCI_DN(slot->dn->child)->devfn); - else - slotno = -1; + for_each_child_of_node(slot->dn, child) { + retval = of_property_read_u32(child, "my,ibm-drc-index", &my_index); + if (my_index == slot->index) { + slotno = PCI_SLOT(PCI_DN(child)->devfn); + of_node_put(child); + break; + } + } + retval = pci_hp_register(php_slot, slot->bus, slotno, slot->name); if (retval) { err("pci_hp_register failed with error %d\n", retval);