From patchwork Fri Jun 10 05:03:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 633512 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rQqsN5dhvz9sD3 for ; Fri, 10 Jun 2016 15:06:48 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3rQqsN4mbbzDqNj for ; Fri, 10 Jun 2016 15:06:48 +1000 (AEST) 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 3rQqqt53jYzDqP9 for ; Fri, 10 Jun 2016 15:05:30 +1000 (AEST) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u5A53oqG052277 for ; Fri, 10 Jun 2016 01:05:29 -0400 Received: from e23smtp08.au.ibm.com (e23smtp08.au.ibm.com [202.81.31.141]) by mx0a-001b2d01.pphosted.com with ESMTP id 23fm5xu17u-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 10 Jun 2016 01:05:29 -0400 Received: from localhost by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 10 Jun 2016 15:05:26 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp08.au.ibm.com (202.81.31.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 10 Jun 2016 15:05:23 +1000 X-IBM-Helo: d23dlp01.au.ibm.com X-IBM-MailFrom: gwshan@linux.vnet.ibm.com X-IBM-RcptTo: skiboot@lists.ozlabs.org Received: from d23relay09.au.ibm.com (d23relay09.au.ibm.com [9.185.63.181]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 4A3CF2CE8060 for ; Fri, 10 Jun 2016 15:05:18 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u5A557iR3408152 for ; Fri, 10 Jun 2016 15:05:07 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u5A54mnK024462 for ; Fri, 10 Jun 2016 15:04:48 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u5A54m7k024456; Fri, 10 Jun 2016 15:04:48 +1000 Received: from bran.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) by ozlabs.au.ibm.com (Postfix) with ESMTP id 7A528A01AD; Fri, 10 Jun 2016 15:03:57 +1000 (AEST) Received: from gwshan (shangw.ozlabs.ibm.com [10.61.2.199]) by bran.ozlabs.ibm.com (Postfix) with ESMTP id 78257E3B1A; Fri, 10 Jun 2016 15:03:57 +1000 (AEST) Received: by gwshan (Postfix, from userid 1000) id 5C54A942CA3; Fri, 10 Jun 2016 15:03:57 +1000 (AEST) From: Gavin Shan To: skiboot@lists.ozlabs.org Date: Fri, 10 Jun 2016 15:03:39 +1000 X-Mailer: git-send-email 2.1.0 In-Reply-To: <1465535032-26749-1-git-send-email-gwshan@linux.vnet.ibm.com> References: <1465535032-26749-1-git-send-email-gwshan@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16061005-0048-0000-0000-000001904994 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16061005-0049-0000-0000-000045E8DBCE Message-Id: <1465535032-26749-11-git-send-email-gwshan@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-06-10_04:, , 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-1606100058 Subject: [Skiboot] [PATCH v12 10/23] core/pci: Extend pci_walk_dev() for PCI slot X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair@popple.id.au MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Currently, pci_walk_dev() iterates all PCI devices behind the specified PHB. This extends the function to allow iteration on PCI devices behind the specified PCI slot so that it can be used by PCI hotplug logic in the subsequent patches. Signed-off-by: Gavin Shan Reviewed-by: Russell Currey --- core/pci.c | 12 ++++++++---- hw/npu.c | 4 ++-- include/pci.h | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/core/pci.c b/core/pci.c index 3d4f639..64b9189 100644 --- a/core/pci.c +++ b/core/pci.c @@ -797,9 +797,9 @@ static void pci_scan_phb(void *data) pci_scan(phb, 0, 0xff, &phb->devices, NULL, has_link); /* Configure MPS (Max Payload Size) for PCIe domain */ - pci_walk_dev(phb, pci_get_mps, &mps); + pci_walk_dev(phb, NULL, pci_get_mps, &mps); phb->mps = mps; - pci_walk_dev(phb, pci_configure_mps, NULL); + pci_walk_dev(phb, NULL, pci_configure_mps, NULL); } int64_t pci_register_phb(struct phb *phb, int opal_id) @@ -1581,11 +1581,15 @@ static struct pci_device *__pci_walk_dev(struct phb *phb, } struct pci_device *pci_walk_dev(struct phb *phb, + struct pci_device *pd, int (*cb)(struct phb *, struct pci_device *, void *), void *userdata) { + if (pd) + return __pci_walk_dev(phb, &pd->children, cb, userdata); + return __pci_walk_dev(phb, &phb->devices, cb, userdata); } @@ -1605,7 +1609,7 @@ static int __pci_find_dev(struct phb *phb, struct pci_device *pci_find_dev(struct phb *phb, uint16_t bdfn) { - return pci_walk_dev(phb, __pci_find_dev, &bdfn); + return pci_walk_dev(phb, NULL, __pci_find_dev, &bdfn); } static int __pci_restore_bridge_buses(struct phb *phb, @@ -1626,7 +1630,7 @@ static int __pci_restore_bridge_buses(struct phb *phb, void pci_restore_bridge_buses(struct phb *phb) { - pci_walk_dev(phb, __pci_restore_bridge_buses, NULL); + pci_walk_dev(phb, NULL, __pci_restore_bridge_buses, NULL); } struct pci_cfg_reg_filter *pci_find_cfg_reg_filter(struct pci_device *pd, diff --git a/hw/npu.c b/hw/npu.c index a8f9f06..f57d34d 100644 --- a/hw/npu.c +++ b/hw/npu.c @@ -541,7 +541,7 @@ static void npu_dev_bind_pci_dev(struct npu_dev *dev) if (!phb) continue; - dev->pd = pci_walk_dev(phb, __npu_dev_bind_pci_dev, dev); + dev->pd = pci_walk_dev(phb, NULL, __npu_dev_bind_pci_dev, dev); if (dev->pd) { dev->phb = phb; /* Found the device, set the bit in config space */ @@ -618,7 +618,7 @@ static int npu_dn_fixup(struct phb *phb, static void npu_phb_final_fixup(struct phb *phb) { - pci_walk_dev(phb, npu_dn_fixup, NULL); + pci_walk_dev(phb, NULL, npu_dn_fixup, NULL); } static void npu_ioda_init(struct npu *p) diff --git a/include/pci.h b/include/pci.h index bd966ba..1039f10 100644 --- a/include/pci.h +++ b/include/pci.h @@ -524,6 +524,7 @@ extern int64_t pci_find_ecap(struct phb *phb, uint16_t bdfn, uint16_t cap, uint8_t *version); extern void pci_device_init(struct phb *phb, struct pci_device *pd); extern struct pci_device *pci_walk_dev(struct phb *phb, + struct pci_device *pd, int (*cb)(struct phb *, struct pci_device *, void *),