From patchwork Fri May 1 06:03:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 6308401 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E9BA2BEEE5 for ; Fri, 1 May 2015 06:04:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DF04A203ED for ; Fri, 1 May 2015 06:04:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B929B203E9 for ; Fri, 1 May 2015 06:04:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753344AbbEAGEn (ORCPT ); Fri, 1 May 2015 02:04:43 -0400 Received: from e23smtp02.au.ibm.com ([202.81.31.144]:41593 "EHLO e23smtp02.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750935AbbEAGEh (ORCPT ); Fri, 1 May 2015 02:04:37 -0400 Received: from /spool/local by e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 1 May 2015 16:04:35 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp02.au.ibm.com (202.81.31.208) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 1 May 2015 16:04:34 +1000 Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 1C5EA2BB0040 for ; Fri, 1 May 2015 16:04:34 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t4164Pl320119676 for ; Fri, 1 May 2015 16:04:34 +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 t41640vI000860 for ; Fri, 1 May 2015 16:04:00 +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 t416409Z000498; Fri, 1 May 2015 16:04:00 +1000 Received: from bran.ozlabs.ibm.com (haven.au.ibm.com [9.192.253.15]) by ozlabs.au.ibm.com (Postfix) with ESMTP id B4976A03E3; Fri, 1 May 2015 16:03:18 +1000 (AEST) Received: from gwshan (shangw.ozlabs.ibm.com [10.61.2.199]) by bran.ozlabs.ibm.com (Postfix) with ESMTP id DC39916AA05; Fri, 1 May 2015 16:03:17 +1000 (AEST) Received: by gwshan (Postfix, from userid 1000) id 9DA099421F2; Fri, 1 May 2015 16:03:17 +1000 (AEST) From: Gavin Shan To: linuxppc-dev@lists.ozlabs.org Cc: linux-pci@vger.kernel.org, benh@kernel.crashing.org, bhelgaas@google.com, Gavin Shan Subject: [PATCH v4 14/21] powerpc/powernv: Functions to get/reset PCI slot status Date: Fri, 1 May 2015 16:03:01 +1000 Message-Id: <1430460188-31343-15-git-send-email-gwshan@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1430460188-31343-1-git-send-email-gwshan@linux.vnet.ibm.com> References: <1430460188-31343-1-git-send-email-gwshan@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15050106-0005-0000-0000-000001B9559D Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The patch exports 3 functions, which base on corresponding OPAL APIs to get or set PCI slot status. Those functions are going to be used by PCI hotplug module in subsequent patches: pnv_pci_get_presence_status() opal_pci_get_presence_status() pnv_pci_get_power_status() opal_pci_get_power_status() pnv_pci_set_power_status() opal_pci_set_power_status() Besides, the patch also exports pnv_pci_hotplug_notifier() to allow registering PCI hotplug notifier, which will be used to receive PCI hotplug message from skiboot firmware. Signed-off-by: Gavin Shan --- arch/powerpc/include/asm/opal-api.h | 7 +++- arch/powerpc/include/asm/opal.h | 3 ++ arch/powerpc/include/asm/pnv-pci.h | 5 +++ arch/powerpc/platforms/powernv/opal-wrappers.S | 3 ++ arch/powerpc/platforms/powernv/pci.c | 45 ++++++++++++++++++++++++++ 5 files changed, 62 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/opal-api.h b/arch/powerpc/include/asm/opal-api.h index 0321a90..29b407d 100644 --- a/arch/powerpc/include/asm/opal-api.h +++ b/arch/powerpc/include/asm/opal-api.h @@ -153,7 +153,10 @@ #define OPAL_FLASH_READ 110 #define OPAL_FLASH_WRITE 111 #define OPAL_FLASH_ERASE 112 -#define OPAL_LAST 112 +#define OPAL_PCI_GET_PRESENCE_STATUS 116 +#define OPAL_PCI_GET_POWER_STATUS 117 +#define OPAL_PCI_SET_POWER_STATUS 118 +#define OPAL_LAST 118 /* Device tree flags */ @@ -352,6 +355,8 @@ enum opal_msg_type { OPAL_MSG_SHUTDOWN, /* params[0] = 1 reboot, 0 shutdown */ OPAL_MSG_HMI_EVT, OPAL_MSG_DPO, + OPAL_MSG_PRD, + OPAL_MSG_PCI_HOTPLUG, OPAL_MSG_TYPE_MAX, }; diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h index 6d467df..a0eb206 100644 --- a/arch/powerpc/include/asm/opal.h +++ b/arch/powerpc/include/asm/opal.h @@ -200,6 +200,9 @@ int64_t opal_flash_write(uint64_t id, uint64_t offset, uint64_t buf, uint64_t size, uint64_t token); int64_t opal_flash_erase(uint64_t id, uint64_t offset, uint64_t size, uint64_t token); +int64_t opal_pci_get_presence_status(uint64_t id, uint8_t *status); +int64_t opal_pci_get_power_status(uint64_t id, uint8_t *status); +int64_t opal_pci_set_power_status(uint64_t id, uint8_t status); /* Internal functions */ extern int early_init_dt_scan_opal(unsigned long node, const char *uname, diff --git a/arch/powerpc/include/asm/pnv-pci.h b/arch/powerpc/include/asm/pnv-pci.h index f9b4982..50d92a4 100644 --- a/arch/powerpc/include/asm/pnv-pci.h +++ b/arch/powerpc/include/asm/pnv-pci.h @@ -13,6 +13,11 @@ #include #include +extern int pnv_pci_get_presence_status(uint64_t id, uint8_t *status); +extern int pnv_pci_get_power_status(uint64_t id, uint8_t *status); +extern int pnv_pci_set_power_status(uint64_t id, uint8_t status); +extern int pnv_pci_hotplug_notifier(struct notifier_block *nb, bool enable); + int pnv_phb_to_cxl_mode(struct pci_dev *dev, uint64_t mode); int pnv_cxl_ioda_msi_setup(struct pci_dev *dev, unsigned int hwirq, unsigned int virq); diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S b/arch/powerpc/platforms/powernv/opal-wrappers.S index a7ade94..aa95dcb 100644 --- a/arch/powerpc/platforms/powernv/opal-wrappers.S +++ b/arch/powerpc/platforms/powernv/opal-wrappers.S @@ -295,3 +295,6 @@ OPAL_CALL(opal_i2c_request, OPAL_I2C_REQUEST); OPAL_CALL(opal_flash_read, OPAL_FLASH_READ); OPAL_CALL(opal_flash_write, OPAL_FLASH_WRITE); OPAL_CALL(opal_flash_erase, OPAL_FLASH_ERASE); +OPAL_CALL(opal_pci_get_presence_status, OPAL_PCI_GET_PRESENCE_STATUS); +OPAL_CALL(opal_pci_get_power_status, OPAL_PCI_GET_POWER_STATUS); +OPAL_CALL(opal_pci_set_power_status, OPAL_PCI_SET_POWER_STATUS); diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c index a2da9a3..60e6d65 100644 --- a/arch/powerpc/platforms/powernv/pci.c +++ b/arch/powerpc/platforms/powernv/pci.c @@ -60,6 +60,51 @@ int pnv_pci_poll(uint64_t id, int64_t rval, uint8_t *pval) return rval ? -EIO : 0; } +int pnv_pci_get_presence_status(uint64_t id, uint8_t *status) +{ + long rc; + + if (!opal_check_token(OPAL_PCI_GET_PRESENCE_STATUS)) + return -ENXIO; + + rc = opal_pci_get_presence_status(id, status); + return pnv_pci_poll(id, rc, status); +} +EXPORT_SYMBOL_GPL(pnv_pci_get_presence_status); + +int pnv_pci_get_power_status(uint64_t id, uint8_t *status) +{ + long rc; + + if (!opal_check_token(OPAL_PCI_GET_POWER_STATUS)) + return -ENXIO; + + rc = opal_pci_get_power_status(id, status); + return pnv_pci_poll(id, rc, status); +} +EXPORT_SYMBOL_GPL(pnv_pci_get_power_status); + +int pnv_pci_set_power_status(uint64_t id, uint8_t status) +{ + long rc; + + if (!opal_check_token(OPAL_PCI_SET_POWER_STATUS)) + return -ENXIO; + + rc = opal_pci_set_power_status(id, status); + return pnv_pci_poll(id, rc, NULL); +} +EXPORT_SYMBOL_GPL(pnv_pci_set_power_status); + +int pnv_pci_hotplug_notifier(struct notifier_block *nb, bool enable) +{ + if (enable) + return opal_message_notifier_register(OPAL_MSG_PCI_HOTPLUG, nb); + + return opal_message_notifier_unregister(OPAL_MSG_PCI_HOTPLUG, nb); +} +EXPORT_SYMBOL_GPL(pnv_pci_hotplug_notifier); + #ifdef CONFIG_PCI_MSI static int pnv_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) {