From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: Gavin Shan <gwshan@linux.vnet.ibm.com>, linuxppc-dev@lists.ozlabs.org
Cc: bhelgaas@google.com, linux-pci@vger.kernel.org
Subject: Re: [PATCH v4 14/21] powerpc/powernv: Functions to get/reset PCI slot status
Date: Sun, 10 May 2015 00:44:45 +1000 [thread overview]
Message-ID: <554E1D5D.4000309@ozlabs.ru> (raw)
In-Reply-To: <1430460188-31343-15-git-send-email-gwshan@linux.vnet.ibm.com>
On 05/01/2015 04:03 PM, Gavin Shan wrote:
> 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 <gwshan@linux.vnet.ibm.com>
> ---
> 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 <linux/pci.h>
> #include <misc/cxl.h>
>
> +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))
I got a question about the style (i.e. I do not mean the patch is wrong :) )
Everywhere else you use int64_t or s64 for the value returned by OPAL but
not with opal_check_point(). And you would compare it to OPAL_SUCCESS
rather than plain zero. What does opal_check_token() return when succeeded?
1, -1,...? OPAL_SUCCESS means here an error, right?
> + 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)
> {
>
--
Alexey
next prev parent reply other threads:[~2015-05-09 14:44 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-01 6:02 [PATCH v4 00/21] PowerPC/PowerNV: PCI Slot Management Gavin Shan
2015-05-01 6:02 ` [PATCH v4 01/21] pci: Add pcibios_setup_bridge() Gavin Shan
2015-05-07 22:12 ` Bjorn Helgaas
2015-05-11 1:59 ` Gavin Shan
2015-05-01 6:02 ` [PATCH v4 02/21] powerpc/powernv: Enable M64 on P7IOC Gavin Shan
2015-05-09 0:18 ` Alexey Kardashevskiy
2015-05-11 4:37 ` Gavin Shan
2015-05-01 6:02 ` [PATCH v4 03/21] powerpc/powernv: M64 support improvement Gavin Shan
2015-05-09 10:24 ` Alexey Kardashevskiy
2015-05-11 4:47 ` Gavin Shan
2015-05-01 6:02 ` [PATCH v4 04/21] powerpc/powernv: Improve IO and M32 mapping Gavin Shan
2015-05-09 10:53 ` Alexey Kardashevskiy
2015-05-11 4:52 ` Gavin Shan
2015-05-01 6:02 ` [PATCH v4 05/21] powerpc/powernv: Improve DMA32 segment assignment Gavin Shan
2015-05-01 6:02 ` [PATCH v4 06/21] powerpc/powernv: Create PEs dynamically Gavin Shan
2015-05-09 11:43 ` Alexey Kardashevskiy
2015-05-11 4:55 ` Gavin Shan
2015-05-01 6:02 ` [PATCH v4 07/21] powerpc/powernv: Release " Gavin Shan
2015-05-09 12:43 ` Alexey Kardashevskiy
2015-05-11 6:25 ` Gavin Shan
2015-05-11 7:02 ` Alexey Kardashevskiy
2015-05-12 0:03 ` Gavin Shan
2015-05-12 0:53 ` Alexey Kardashevskiy
2015-05-12 1:25 ` Gavin Shan
2015-05-01 6:02 ` [PATCH v4 08/21] powerpc/powernv: Drop pnv_ioda_setup_dev_PE() Gavin Shan
2015-05-09 12:45 ` Alexey Kardashevskiy
2015-05-01 6:02 ` [PATCH v4 09/21] powerpc/powernv: Use PCI slot reset infrastructure Gavin Shan
2015-05-09 13:41 ` Alexey Kardashevskiy
2015-05-11 6:45 ` Gavin Shan
2015-05-11 7:16 ` Alexey Kardashevskiy
2015-05-01 6:02 ` [PATCH v4 10/21] powerpc/powernv: Fundamental reset for PCI bus reset Gavin Shan
2015-05-09 14:12 ` Alexey Kardashevskiy
2015-05-11 6:47 ` Gavin Shan
2015-05-11 7:17 ` Alexey Kardashevskiy
2015-05-12 0:04 ` Gavin Shan
2015-05-01 6:02 ` [PATCH v4 11/21] powerpc/pci: Don't scan empty slot Gavin Shan
2015-05-01 6:02 ` [PATCH v4 12/21] powerpc/pci: Move pcibios_find_pci_bus() around Gavin Shan
2015-05-01 6:03 ` [PATCH v4 13/21] powerpc/powernv: Introduce pnv_pci_poll() Gavin Shan
2015-05-09 14:30 ` Alexey Kardashevskiy
2015-05-11 7:19 ` Gavin Shan
2015-05-01 6:03 ` [PATCH v4 14/21] powerpc/powernv: Functions to get/reset PCI slot status Gavin Shan
2015-05-09 14:44 ` Alexey Kardashevskiy [this message]
2015-05-01 6:03 ` [PATCH v4 15/21] powerpc/pci: Delay creating pci_dn Gavin Shan
2015-05-09 14:55 ` Alexey Kardashevskiy
2015-05-11 7:21 ` Gavin Shan
2015-05-01 6:03 ` [PATCH v4 16/21] powerpc/pci: Create eeh_dev while " Gavin Shan
2015-05-09 15:08 ` Alexey Kardashevskiy
2015-05-11 7:24 ` Gavin Shan
2015-05-01 6:03 ` [PATCH v4 17/21] powerpc/pci: Export traverse_pci_device_nodes() Gavin Shan
2015-05-01 6:03 ` [PATCH v4 18/21] powerpc/pci: Update bridge windows on PCI plugging Gavin Shan
2015-05-01 6:03 ` [PATCH v4 19/21] drivers/of: Support adding sub-tree Gavin Shan
2015-05-01 12:54 ` Rob Herring
2015-05-01 15:22 ` Benjamin Herrenschmidt
2015-05-01 18:46 ` Rob Herring
2015-05-01 22:57 ` Benjamin Herrenschmidt
2015-05-01 23:29 ` Benjamin Herrenschmidt
2015-05-02 2:48 ` Benjamin Herrenschmidt
2015-05-04 1:30 ` Gavin Shan
2015-05-04 4:51 ` Benjamin Herrenschmidt
2015-05-04 0:23 ` Gavin Shan
2015-05-04 16:41 ` Pantelis Antoniou
2015-05-04 21:14 ` Benjamin Herrenschmidt
2015-05-13 23:35 ` Benjamin Herrenschmidt
2015-05-14 0:18 ` Rob Herring
2015-05-14 0:54 ` Benjamin Herrenschmidt
2015-05-14 6:23 ` Pantelis Antoniou
2015-05-14 6:46 ` Benjamin Herrenschmidt
2015-05-14 7:04 ` Pantelis Antoniou
2015-05-14 7:14 ` Benjamin Herrenschmidt
2015-05-14 7:19 ` Pantelis Antoniou
2015-05-14 7:25 ` Benjamin Herrenschmidt
2015-05-14 7:29 ` Benjamin Herrenschmidt
2015-05-14 7:34 ` Pantelis Antoniou
2015-05-14 7:47 ` Benjamin Herrenschmidt
2015-05-14 11:02 ` Pantelis Antoniou
2015-05-14 23:25 ` Benjamin Herrenschmidt
2015-06-07 7:54 ` Grant Likely
2015-06-08 20:57 ` Benjamin Herrenschmidt
2015-06-08 21:34 ` Grant Likely
2015-06-10 6:55 ` Gavin Shan
2015-05-03 23:28 ` Gavin Shan
2015-05-15 1:27 ` Gavin Shan
2015-05-01 6:03 ` [PATCH v4 20/21] powerpc/powernv: Select OF_DYNAMIC Gavin Shan
2015-05-01 6:03 ` [PATCH v4 21/21] pci/hotplug: PowerPC PowerNV PCI hotplug driver Gavin Shan
2015-05-09 15:54 ` Alexey Kardashevskiy
2015-05-11 7:38 ` Gavin Shan
2015-05-08 23:59 ` [PATCH v4 00/21] PowerPC/PowerNV: PCI Slot Management Alexey Kardashevskiy
2015-05-11 7:40 ` Gavin Shan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=554E1D5D.4000309@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=bhelgaas@google.com \
--cc=gwshan@linux.vnet.ibm.com \
--cc=linux-pci@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).