From patchwork Fri May 20 06:32:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 624333 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 3r9yqw3MH3z9t3g for ; Fri, 20 May 2016 16:35:56 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3r9yqw2T2FzDqZ2 for ; Fri, 20 May 2016 16:35:56 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e23smtp05.au.ibm.com (e23smtp05.au.ibm.com [202.81.31.147]) (using TLSv1.2 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3r9ynb630RzDqF4 for ; Fri, 20 May 2016 16:33:55 +1000 (AEST) Received: from localhost by e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 May 2016 16:33:55 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp05.au.ibm.com (202.81.31.211) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 20 May 2016 16:33:52 +1000 X-IBM-Helo: d23dlp02.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 d23dlp02.au.ibm.com (Postfix) with ESMTP id CEF852BB005C for ; Fri, 20 May 2016 16:33:51 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u4K6XhHq57344022 for ; Fri, 20 May 2016 16:33:51 +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 u4K6XJtl014395 for ; Fri, 20 May 2016 16:33:19 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u4K6XIl5013698; Fri, 20 May 2016 16:33:18 +1000 Received: from bran.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) by ozlabs.au.ibm.com (Postfix) with ESMTP id 4AD80A03B4; Fri, 20 May 2016 16:32:32 +1000 (AEST) Received: from gwshan (shangw.ozlabs.ibm.com [10.61.2.199]) by bran.ozlabs.ibm.com (Postfix) with ESMTP id 54117E3A8D; Fri, 20 May 2016 16:32:32 +1000 (AEST) Received: by gwshan (Postfix, from userid 1000) id 30366942543; Fri, 20 May 2016 16:32:32 +1000 (AEST) From: Gavin Shan To: skiboot@lists.ozlabs.org Date: Fri, 20 May 2016 16:32:14 +1000 Message-Id: <1463725945-12916-13-git-send-email-gwshan@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1463725945-12916-1-git-send-email-gwshan@linux.vnet.ibm.com> References: <1463725945-12916-1-git-send-email-gwshan@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16052006-0017-0000-0000-000004AA6899 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused Subject: [Skiboot] [PATCH v11 12/23] core/pci: Return value for struct phb_ops::device_init 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" This adds @data argument and "int" return value for struct phb_ops:: device_init() so that it can be called in pci_walk_dev() directly to reinitialize the PCI devices behind the specified slot in subsequent patches. Signed-off-by: Gavin Shan --- core/pci.c | 2 +- hw/p7ioc-phb.c | 12 ++++++++++-- hw/phb3.c | 12 ++++++++++-- include/pci.h | 3 ++- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/core/pci.c b/core/pci.c index 2c63f99..91e45f3 100644 --- a/core/pci.c +++ b/core/pci.c @@ -255,7 +255,7 @@ static struct pci_device *pci_scan_one(struct phb *phb, struct pci_device *paren * Call PHB hook */ if (phb->ops->device_init) - phb->ops->device_init(phb, pd); + phb->ops->device_init(phb, pd, NULL); return pd; fail: diff --git a/hw/p7ioc-phb.c b/hw/p7ioc-phb.c index 4d02dd2..f750ec8 100644 --- a/hw/p7ioc-phb.c +++ b/hw/p7ioc-phb.c @@ -2180,7 +2180,9 @@ static void p7ioc_endpoint_init(struct phb *phb, pci_cfg_write32(phb, bdfn, aercap + PCIECAP_AER_CAPCTL, val32); } -static void p7ioc_device_init(struct phb *phb, struct pci_device *dev) +static int p7ioc_device_init(struct phb *phb, + struct pci_device *dev, + void *data __unused) { int ecap = 0; int aercap = 0; @@ -2209,6 +2211,8 @@ static void p7ioc_device_init(struct phb *phb, struct pci_device *dev) p7ioc_switch_port_init(phb, dev, ecap, aercap); else p7ioc_endpoint_init(phb, dev, ecap, aercap); + + return 0; } static int64_t p7ioc_pci_reinit(struct phb *phb, @@ -2216,6 +2220,7 @@ static int64_t p7ioc_pci_reinit(struct phb *phb, { struct pci_device *pd; uint16_t bdfn = data; + int ret; if (scope != OPAL_REINIT_PCI_DEV) return OPAL_PARAMETER; @@ -2224,7 +2229,10 @@ static int64_t p7ioc_pci_reinit(struct phb *phb, if (!pd) return OPAL_PARAMETER; - p7ioc_device_init(phb, pd); + ret = p7ioc_device_init(phb, pd, NULL); + if (ret) + return OPAL_HARDWARE; + return OPAL_SUCCESS; } diff --git a/hw/phb3.c b/hw/phb3.c index 83935b8..1baa7ad 100644 --- a/hw/phb3.c +++ b/hw/phb3.c @@ -536,7 +536,9 @@ static void phb3_check_device_quirks(struct phb *phb, struct pci_device *dev) } } -static void phb3_device_init(struct phb *phb, struct pci_device *dev) +static int phb3_device_init(struct phb *phb, + struct pci_device *dev, + void *data __unused) { int ecap = 0; int aercap = 0; @@ -568,12 +570,15 @@ static void phb3_device_init(struct phb *phb, struct pci_device *dev) phb3_switch_port_init(phb, dev, ecap, aercap); else phb3_endpoint_init(phb, dev, ecap, aercap); + + return 0; } static int64_t phb3_pci_reinit(struct phb *phb, uint64_t scope, uint64_t data) { struct pci_device *pd; uint16_t bdfn = data; + int ret; if (scope != OPAL_REINIT_PCI_DEV) return OPAL_PARAMETER; @@ -582,7 +587,10 @@ static int64_t phb3_pci_reinit(struct phb *phb, uint64_t scope, uint64_t data) if (!pd) return OPAL_PARAMETER; - phb3_device_init(phb, pd); + ret = phb3_device_init(phb, pd, NULL); + if (ret) + return OPAL_HARDWARE; + return OPAL_SUCCESS; } diff --git a/include/pci.h b/include/pci.h index 5c30d6c..3481ed4 100644 --- a/include/pci.h +++ b/include/pci.h @@ -267,7 +267,8 @@ struct phb_ops { * and before probing further. It can alter things like scan_map * for bridge ports etc... */ - void (*device_init)(struct phb *phb, struct pci_device *device); + int (*device_init)(struct phb *phb, struct pci_device *device, + void *data); /* PHB final fixup is called after PCI probing is completed */ void (*phb_final_fixup)(struct phb *phb);