From patchwork Fri Oct 14 04:26:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 682122 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3swF1P64Qvz9s9N for ; Fri, 14 Oct 2016 15:27:05 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3swF1P52PHzDt4p for ; Fri, 14 Oct 2016 15:27:05 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3swDzn3ldRzDt2t for ; Fri, 14 Oct 2016 15:25:41 +1100 (AEDT) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u9E4NinU057145 for ; Fri, 14 Oct 2016 00:25:39 -0400 Received: from e23smtp07.au.ibm.com (e23smtp07.au.ibm.com [202.81.31.140]) by mx0a-001b2d01.pphosted.com with ESMTP id 262jts2kbf-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 14 Oct 2016 00:25:39 -0400 Received: from localhost by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 14 Oct 2016 14:25:37 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp07.au.ibm.com (202.81.31.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 14 Oct 2016 14:25:34 +1000 Received: from d23relay08.au.ibm.com (d23relay08.au.ibm.com [9.185.71.33]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 23AFD2BB0059 for ; Fri, 14 Oct 2016 15:25:34 +1100 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay08.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u9E4PYxe18284684 for ; Fri, 14 Oct 2016 15:25:34 +1100 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u9E4PXW2020154 for ; Fri, 14 Oct 2016 15:25:33 +1100 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u9E4PX9f020151; Fri, 14 Oct 2016 15:25:33 +1100 Received: from bran.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) by ozlabs.au.ibm.com (Postfix) with ESMTP id 4256DA0138; Fri, 14 Oct 2016 15:25:33 +1100 (AEDT) Received: from gwshan (shangw.ozlabs.ibm.com [10.61.2.199]) by bran.ozlabs.ibm.com (Postfix) with ESMTP id 3BEA0E3C59; Fri, 14 Oct 2016 15:25:33 +1100 (AEDT) Received: by gwshan (Postfix, from userid 1000) id CCFF49424E6; Fri, 14 Oct 2016 15:26:18 +1100 (AEDT) From: Gavin Shan To: skiboot@lists.ozlabs.org Date: Fri, 14 Oct 2016 15:26:04 +1100 X-Mailer: git-send-email 2.1.0 In-Reply-To: <1476419167-16688-1-git-send-email-gwshan@linux.vnet.ibm.com> References: <1476419167-16688-1-git-send-email-gwshan@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16101404-0044-0000-0000-000001EEB8AA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16101404-0045-0000-0000-000005BEDA12 Message-Id: <1476419167-16688-7-git-send-email-gwshan@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-10-14_01:, , 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-1609300000 definitions=main-1610140077 Subject: [Skiboot] [PATCH v3 6/9] core/pci: Reserve PCI buses for RC's slot X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andrew.donnellan@au1.ibm.com MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" When RC's downstream link is down, we need reserve spare PCI buses if it has an associated PCI hotplug slot. Otherwise, the adapter behind it can't be probed successfully in PCI hot add scenario. This reserves all available buses (to 255) for RC's hotplug slot when its downstream is down so that PCI adapter can be hot added to the slot afterwards. Cc: stable # 5.3.0+ Signed-off-by: Gavin Shan --- core/pci.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/core/pci.c b/core/pci.c index 0c93fd9..08e0ed1 100644 --- a/core/pci.c +++ b/core/pci.c @@ -558,9 +558,10 @@ uint8_t pci_scan_bus(struct phb *phb, uint8_t bus, uint8_t max_bus, struct list_head *list, struct pci_device *parent, bool scan_downstream) { - struct pci_device *pd = NULL; + struct pci_device *pd = NULL, *rc = NULL; uint8_t dev, fn, next_bus, max_sub, save_max; uint32_t scan_map; + bool use_max; /* Decide what to scan */ scan_map = parent ? parent->scan_map : phb->scan_map; @@ -576,6 +577,10 @@ uint8_t pci_scan_bus(struct phb *phb, uint8_t bus, uint8_t max_bus, if (!pd) continue; + /* Record RC when its downstream link is down */ + if (!scan_downstream && dev == 0 && !rc) + rc = pd; + /* XXX Handle ARI */ if (!pd->is_multifunction) continue; @@ -586,6 +591,20 @@ uint8_t pci_scan_bus(struct phb *phb, uint8_t bus, uint8_t max_bus, } } + /* Reserve all possible buses if RC's downstream link is down + * if PCI hotplug is supported. + */ + if (rc && rc->slot && rc->slot->pluggable) { + next_bus = phb->ops->choose_bus(phb, rc, bus + 1, + &max_bus, &use_max); + rc->secondary_bus = next_bus; + rc->subordinate_bus = max_bus; + pci_cfg_write8(phb, rc->bdfn, PCI_CFG_SECONDARY_BUS, + rc->secondary_bus); + pci_cfg_write8(phb, rc->bdfn, PCI_CFG_SUBORDINATE_BUS, + rc->subordinate_bus); + } + /* * We only scan downstream if instructed to do so by the * caller. Typically we avoid the scan when we know the @@ -605,7 +624,7 @@ uint8_t pci_scan_bus(struct phb *phb, uint8_t bus, uint8_t max_bus, /* Scan down bridges */ list_for_each(list, pd, link) { - bool use_max, do_scan; + bool do_scan; if (!pd->is_bridge) continue;