linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
To: Ian Munsie <imunsie@au1.ibm.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Michael Neuling <mikey@neuling.org>,
	Andrew Donnellan <andrew.donnellan@au1.ibm.com>,
	linuxppc-dev@lists.ozlabs.org, Huy Nguyen <huyn@mellanox.com>
Subject: Re: [PATCH 10/14] cxl: Add support for interrupts on the Mellanox CX4
Date: Wed, 6 Jul 2016 20:41:42 +0200	[thread overview]
Message-ID: <577D50E6.4080204@linux.vnet.ibm.com> (raw)
In-Reply-To: <1467638532-9250-11-git-send-email-imunsie@au.ibm.com>



Le 04/07/2016 15:22, Ian Munsie a écrit :
> From: Ian Munsie <imunsie@au1.ibm.com>
>
> The Mellanox CX4 in cxl mode uses a hybrid interrupt model, where
> interrupts are routed from the networking hardware to the XSL using the
> MSIX table, and from there will be transformed back into an MSIX
> interrupt using the cxl style interrupts (i.e. using IVTE entries and
> ranges to map a PE and AFU interrupt number to an MSIX address).
>
> We want to hide the implementation details of cxl interrupts as much as
> possible. To this end, we use a special version of the MSI setup &
> teardown routines in the PHB while in cxl mode to allocate the cxl
> interrupts and configure the IVTE entries in the process element.
>
> This function does not configure the MSIX table - the CX4 card uses a
> custom format in that table and it would not be appropriate to fill that
> out in generic code. The rest of the functionality is similar to the
> "Full MSI-X mode" described in the CAIA, and this could be easily
> extended to support other adapters that use that mode in the future.
>
> The interrupts will be associated with the default context. If the
> maximum number of interrupts per context has been limited (e.g. by the
> mlx5 driver), it will automatically allocate additional kernel contexts
> to associate extra interrupts as required. These contexts will be
> started using the same WED that was used to start the default context.
>
> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
> ---
>   arch/powerpc/platforms/powernv/pci-cxl.c  | 84 +++++++++++++++++++++++++++++++
>   arch/powerpc/platforms/powernv/pci-ioda.c |  4 ++
>   arch/powerpc/platforms/powernv/pci.h      |  2 +
>   drivers/misc/cxl/api.c                    | 71 ++++++++++++++++++++++++++
>   drivers/misc/cxl/base.c                   | 31 ++++++++++++
>   drivers/misc/cxl/cxl.h                    |  4 ++
>   drivers/misc/cxl/main.c                   |  2 +
>   include/misc/cxl-base.h                   |  4 ++
>   8 files changed, 202 insertions(+)
>
> diff --git a/arch/powerpc/platforms/powernv/pci-cxl.c b/arch/powerpc/platforms/powernv/pci-cxl.c
> index 2f386f5..1559ca2 100644
> --- a/arch/powerpc/platforms/powernv/pci-cxl.c
> +++ b/arch/powerpc/platforms/powernv/pci-cxl.c
> @@ -8,6 +8,7 @@
>    */
>
>   #include <linux/module.h>
> +#include <linux/msi.h>
>   #include <asm/pci-bridge.h>
>   #include <asm/pnv-pci.h>
>   #include <asm/opal.h>
> @@ -273,3 +274,86 @@ void pnv_cxl_disable_device(struct pci_dev *dev)
>   	cxl_pci_disable_device(dev);
>   	cxl_afu_put(afu);
>   }
> +
> +/*
> + * This is a special version of pnv_setup_msi_irqs for cards in cxl mode. This
> + * function handles setting up the IVTE entries for the XSL to use.
> + *
> + * We are currently not filling out the MSIX table, since the only currently
> + * supported adapter (CX4) uses a custom MSIX table format in cxl mode and it
> + * is up to their driver to fill that out. In the future we may fill out the
> + * MSIX table (and change the IVTE entries to be an index to the MSIX table)
> + * for adapters implementing the Full MSI-X mode described in the CAIA.
> + */
> +int pnv_cxl_cx4_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
> +{
> +	struct pci_controller *hose = pci_bus_to_host(pdev->bus);
> +	struct pnv_phb *phb = hose->private_data;
> +	struct msi_desc *entry;
> +	struct cxl_context *ctx = NULL;
> +	unsigned int virq;
> +	int hwirq;
> +	int afu_irq = 0;
> +	int rc;
> +
> +	if (WARN_ON(!phb) || !phb->msi_bmp.bitmap)
> +		return -ENODEV;
> +
> +	if (pdev->no_64bit_msi && !phb->msi32_support)
> +		return -ENODEV;
> +
> +	rc = cxl_cx4_setup_msi_irqs(pdev, nvec, type);
> +	if (rc)
> +		return rc;
> +
> +	for_each_pci_msi_entry(entry, pdev) {
> +		if (!entry->msi_attrib.is_64 && !phb->msi32_support) {
> +			pr_warn("%s: Supports only 64-bit MSIs\n",
> +				pci_name(pdev));
> +			return -ENXIO;
> +		}
> +
> +		hwirq = cxl_next_msi_hwirq(pdev, &ctx, &afu_irq);
> +		if (WARN_ON(hwirq < 0))
> +			return hwirq;

I think we want:
	if (WARN_ON(hwirq <= 0))
cxl_find_afu_irq() returns 0 if doesn't find the irq, which is not 
supposed to happen here.

   Fred

  reply	other threads:[~2016-07-06 18:41 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-04 13:21 powerpc / cxl: Add support for the Mellanox CX4 in cxl mode Ian Munsie
2016-07-04 13:21 ` [PATCH 01/14] powerpc/powernv: Split cxl code out into a separate file Ian Munsie
2016-07-06  3:44   ` Andrew Donnellan
2016-07-06 16:27   ` Frederic Barrat
2016-07-04 13:22 ` [PATCH 02/14] cxl: Add cxl_slot_is_supported API Ian Munsie
2016-07-06  2:02   ` Andrew Donnellan
2016-07-06 16:36   ` Frederic Barrat
2016-07-04 13:22 ` [PATCH 03/14] cxl: Enable bus mastering for devices using CAPP DMA mode Ian Munsie
2016-07-06  4:04   ` Andrew Donnellan
2016-07-06 16:37   ` Frederic Barrat
2016-07-04 13:22 ` [PATCH 04/14] cxl: Move cxl_afu_get / cxl_afu_put to base Ian Munsie
2016-07-05  2:10   ` Andrew Donnellan
2016-07-06 16:45   ` Frederic Barrat
2016-07-04 13:22 ` [PATCH 05/14] cxl: Allow a default context to be associated with an external pci_dev Ian Munsie
2016-07-06 16:51   ` Frederic Barrat
2016-07-04 13:22 ` [PATCH 06/14] powerpc/powernv: Add support for the cxl kernel api on the real phb Ian Munsie
2016-07-06 17:38   ` Frederic Barrat
2016-07-07  6:28     ` Ian Munsie
2016-07-04 13:22 ` [PATCH 07/14] cxl: Add support for using the kernel API with a real PHB Ian Munsie
2016-07-06 17:39   ` Frederic Barrat
2016-07-06 18:30   ` Frederic Barrat
2016-07-07  6:32     ` Ian Munsie
2016-07-04 13:22 ` [PATCH 08/14] cxl: Add kernel APIs to get & set the max irqs per context Ian Munsie
2016-07-06 18:11   ` Frederic Barrat
2016-07-07  6:00     ` Ian Munsie
2016-07-04 13:22 ` [PATCH 09/14] cxl: Add preliminary workaround for CX4 interrupt limitation Ian Munsie
2016-07-06 18:34   ` Frederic Barrat
2016-07-04 13:22 ` [PATCH 10/14] cxl: Add support for interrupts on the Mellanox CX4 Ian Munsie
2016-07-06 18:41   ` Frederic Barrat [this message]
2016-07-07  6:03     ` Ian Munsie
2016-07-04 13:22 ` [PATCH 11/14] cxl: Workaround PE=0 hardware limitation in " Ian Munsie
2016-07-06  4:42   ` Andrew Donnellan
2016-07-06 18:42   ` Frederic Barrat
2016-07-04 13:22 ` [PATCH 12/14] PCI/hotplug: pnv_php: export symbols and move struct types needed by cxl Ian Munsie
2016-07-05  0:03   ` Gavin Shan
2016-07-05  1:08     ` Andrew Donnellan
2016-07-04 13:22 ` [PATCH 13/14] PCI/hotplug: pnv_php: handle OPAL_PCI_SLOT_OFFLINE power state Ian Munsie
2016-07-04 13:22 ` [PATCH 14/14] cxl: Add cxl_check_and_switch_mode() API to switch bi-modal cards Ian Munsie
2016-07-06  3:55   ` Andrew Donnellan
2016-07-06 18:51   ` Frederic Barrat
2016-07-07  1:18     ` Andrew Donnellan
2016-07-07  6:26       ` Ian Munsie
2016-07-07  6:44         ` Andrew Donnellan
2016-07-07  8:15           ` Andrew Donnellan
2016-07-11  9:19             ` Ian Munsie
2016-07-12  1:20               ` Andrew Donnellan

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=577D50E6.4080204@linux.vnet.ibm.com \
    --to=fbarrat@linux.vnet.ibm.com \
    --cc=andrew.donnellan@au1.ibm.com \
    --cc=huyn@mellanox.com \
    --cc=imunsie@au1.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mikey@neuling.org \
    --cc=mpe@ellerman.id.au \
    /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).