All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] ocxl: Cleanup AFU interrupt allocation
@ 2020-04-02 15:43 Frederic Barrat
  2020-04-02 15:43 ` [PATCH 1/4] scsi: cxlflash: Access interrupt trigger page from xive directly Frederic Barrat
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Frederic Barrat @ 2020-04-02 15:43 UTC (permalink / raw)
  To: linuxppc-dev, clg, christophe_lombard, ajd, ukrishn, mrochs; +Cc: haren, groug

Short series to cleanup AFU interrupt allocation for opencapi.
Current code was using its own allocation service, calling opal
directly to get the trigger page. This is not needed and we can use
xive to achieve the same thing. The only caveat is that the trigger
page address is only valid after the interrupt has been mapped, but
that is not a problem with the way the code is using it.
No functional change.

Frederic Barrat (4):
  scsi: cxlflash: Access interrupt trigger page from xive directly
  ocxl: Access interrupt trigger page from xive directly
  ocxl: Don't return trigger page when allocating an interrupt
  ocxl: Remove custom service to allocate interrupts

 arch/powerpc/include/asm/pnv-ocxl.h   |  3 ---
 arch/powerpc/platforms/powernv/ocxl.c | 30 ---------------------------
 drivers/misc/ocxl/Kconfig             |  2 +-
 drivers/misc/ocxl/afu_irq.c           | 12 ++++++-----
 drivers/misc/ocxl/link.c              | 15 +++++++-------
 drivers/scsi/cxlflash/ocxl_hw.c       | 20 +++++++-----------
 drivers/scsi/cxlflash/ocxl_hw.h       |  1 -
 include/misc/ocxl.h                   | 10 ++-------
 8 files changed, 25 insertions(+), 68 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/4] scsi: cxlflash: Access interrupt trigger page from xive directly
  2020-04-02 15:43 [PATCH 0/4] ocxl: Cleanup AFU interrupt allocation Frederic Barrat
@ 2020-04-02 15:43 ` Frederic Barrat
  2020-04-02 23:19   ` Matthew R. Ochs
  2020-04-02 15:43 ` [PATCH 2/4] ocxl: " Frederic Barrat
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 14+ messages in thread
From: Frederic Barrat @ 2020-04-02 15:43 UTC (permalink / raw)
  To: linuxppc-dev, clg, christophe_lombard, ajd, ukrishn, mrochs; +Cc: haren, groug

xive is already mapping the trigger page in kernel space and it can be
accessed through standard APIs, so let's reuse it and simplify the code.

Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
---
 drivers/scsi/cxlflash/ocxl_hw.c | 17 +++++++----------
 drivers/scsi/cxlflash/ocxl_hw.h |  1 -
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c
index 7018cd802569..59452850f71c 100644
--- a/drivers/scsi/cxlflash/ocxl_hw.c
+++ b/drivers/scsi/cxlflash/ocxl_hw.c
@@ -15,7 +15,8 @@
 #include <linux/pseudo_fs.h>
 #include <linux/poll.h>
 #include <linux/sched/signal.h>
-
+#include <linux/interrupt.h>
+#include <asm/xive.h>
 #include <misc/ocxl.h>
 
 #include <uapi/misc/cxl.h>
@@ -180,7 +181,7 @@ static int afu_map_irq(u64 flags, struct ocxlflash_context *ctx, int num,
 	struct ocxl_hw_afu *afu = ctx->hw_afu;
 	struct device *dev = afu->dev;
 	struct ocxlflash_irqs *irq;
-	void __iomem *vtrig;
+	struct xive_irq_data *xd;
 	u32 virq;
 	int rc = 0;
 
@@ -204,15 +205,14 @@ static int afu_map_irq(u64 flags, struct ocxlflash_context *ctx, int num,
 		goto err1;
 	}
 
-	vtrig = ioremap(irq->ptrig, PAGE_SIZE);
-	if (unlikely(!vtrig)) {
-		dev_err(dev, "%s: Trigger page mapping failed\n", __func__);
-		rc = -ENOMEM;
+	xd = irq_get_handler_data(virq);
+	if (unlikely(!xd)) {
+		dev_err(dev, "%s: Can't get interrupt data\n", __func__);
 		goto err2;
 	}
 
 	irq->virq = virq;
-	irq->vtrig = vtrig;
+	irq->vtrig = xd->trig_mmio;
 out:
 	return rc;
 err2:
@@ -259,8 +259,6 @@ static void afu_unmap_irq(u64 flags, struct ocxlflash_context *ctx, int num,
 	}
 
 	irq = &ctx->irqs[num];
-	if (irq->vtrig)
-		iounmap(irq->vtrig);
 
 	if (irq_find_mapping(NULL, irq->hwirq)) {
 		free_irq(irq->virq, cookie);
@@ -648,7 +646,6 @@ static int alloc_afu_irqs(struct ocxlflash_context *ctx, int num)
 		}
 
 		irqs[i].hwirq = hwirq;
-		irqs[i].ptrig = addr;
 	}
 
 	ctx->irqs = irqs;
diff --git a/drivers/scsi/cxlflash/ocxl_hw.h b/drivers/scsi/cxlflash/ocxl_hw.h
index fc6ad4f985de..f2fe88816bea 100644
--- a/drivers/scsi/cxlflash/ocxl_hw.h
+++ b/drivers/scsi/cxlflash/ocxl_hw.h
@@ -13,7 +13,6 @@
 struct ocxlflash_irqs {
 	int hwirq;
 	u32 virq;
-	u64 ptrig;
 	void __iomem *vtrig;
 };
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/4] ocxl: Access interrupt trigger page from xive directly
  2020-04-02 15:43 [PATCH 0/4] ocxl: Cleanup AFU interrupt allocation Frederic Barrat
  2020-04-02 15:43 ` [PATCH 1/4] scsi: cxlflash: Access interrupt trigger page from xive directly Frederic Barrat
@ 2020-04-02 15:43 ` Frederic Barrat
  2020-04-03  5:55   ` Cédric Le Goater
                     ` (2 more replies)
  2020-04-02 15:43 ` [PATCH 3/4] ocxl: Don't return trigger page when allocating an interrupt Frederic Barrat
  2020-04-02 15:43 ` [PATCH 4/4] ocxl: Remove custom service to allocate interrupts Frederic Barrat
  3 siblings, 3 replies; 14+ messages in thread
From: Frederic Barrat @ 2020-04-02 15:43 UTC (permalink / raw)
  To: linuxppc-dev, clg, christophe_lombard, ajd, ukrishn, mrochs; +Cc: haren, groug

We can access the trigger page through standard APIs so let's use it
and avoid saving it when allocating the interrupt. It will also allow
to simplify allocation in a later patch.

Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
---
 drivers/misc/ocxl/afu_irq.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/ocxl/afu_irq.c b/drivers/misc/ocxl/afu_irq.c
index 70f8f1c3929d..b30ec0ef7be7 100644
--- a/drivers/misc/ocxl/afu_irq.c
+++ b/drivers/misc/ocxl/afu_irq.c
@@ -2,6 +2,7 @@
 // Copyright 2017 IBM Corp.
 #include <linux/interrupt.h>
 #include <asm/pnv-ocxl.h>
+#include <asm/xive.h>
 #include "ocxl_internal.h"
 #include "trace.h"
 
@@ -196,13 +197,16 @@ void ocxl_afu_irq_free_all(struct ocxl_context *ctx)
 
 u64 ocxl_afu_irq_get_addr(struct ocxl_context *ctx, int irq_id)
 {
+	struct xive_irq_data *xd;
 	struct afu_irq *irq;
 	u64 addr = 0;
 
 	mutex_lock(&ctx->irq_lock);
 	irq = idr_find(&ctx->irq_idr, irq_id);
-	if (irq)
-		addr = irq->trigger_page;
+	if (irq) {
+		xd = irq_get_handler_data(irq->virq);
+		addr = xd ? xd->trig_page : 0;
+	}
 	mutex_unlock(&ctx->irq_lock);
 	return addr;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/4] ocxl: Don't return trigger page when allocating an interrupt
  2020-04-02 15:43 [PATCH 0/4] ocxl: Cleanup AFU interrupt allocation Frederic Barrat
  2020-04-02 15:43 ` [PATCH 1/4] scsi: cxlflash: Access interrupt trigger page from xive directly Frederic Barrat
  2020-04-02 15:43 ` [PATCH 2/4] ocxl: " Frederic Barrat
@ 2020-04-02 15:43 ` Frederic Barrat
  2020-04-03  5:56   ` Cédric Le Goater
  2020-04-03  9:25   ` Greg Kurz
  2020-04-02 15:43 ` [PATCH 4/4] ocxl: Remove custom service to allocate interrupts Frederic Barrat
  3 siblings, 2 replies; 14+ messages in thread
From: Frederic Barrat @ 2020-04-02 15:43 UTC (permalink / raw)
  To: linuxppc-dev, clg, christophe_lombard, ajd, ukrishn, mrochs; +Cc: haren, groug

Existing users of ocxl_link_irq_alloc() have been converted to obtain
the trigger page of an interrupt through xive directly, we therefore
have no need to return the trigger page when allocating an interrupt.

It also allows ocxl to use the xive native interface to allocate
interrupts, instead of its custom service.

Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
---
 drivers/misc/ocxl/Kconfig       |  2 +-
 drivers/misc/ocxl/afu_irq.c     |  4 +---
 drivers/misc/ocxl/link.c        | 15 +++++++--------
 drivers/scsi/cxlflash/ocxl_hw.c |  3 +--
 include/misc/ocxl.h             | 10 ++--------
 5 files changed, 12 insertions(+), 22 deletions(-)

diff --git a/drivers/misc/ocxl/Kconfig b/drivers/misc/ocxl/Kconfig
index 2d2266c1439e..e65773f5cf59 100644
--- a/drivers/misc/ocxl/Kconfig
+++ b/drivers/misc/ocxl/Kconfig
@@ -9,7 +9,7 @@ config OCXL_BASE
 
 config OCXL
 	tristate "OpenCAPI coherent accelerator support"
-	depends on PPC_POWERNV && PCI && EEH
+	depends on PPC_POWERNV && PCI && EEH && PPC_XIVE_NATIVE
 	select OCXL_BASE
 	select HOTPLUG_PCI_POWERNV
 	default m
diff --git a/drivers/misc/ocxl/afu_irq.c b/drivers/misc/ocxl/afu_irq.c
index b30ec0ef7be7..ecdcfae025b7 100644
--- a/drivers/misc/ocxl/afu_irq.c
+++ b/drivers/misc/ocxl/afu_irq.c
@@ -11,7 +11,6 @@ struct afu_irq {
 	int hw_irq;
 	unsigned int virq;
 	char *name;
-	u64 trigger_page;
 	irqreturn_t (*handler)(void *private);
 	void (*free_private)(void *private);
 	void *private;
@@ -125,8 +124,7 @@ int ocxl_afu_irq_alloc(struct ocxl_context *ctx, int *irq_id)
 		goto err_unlock;
 	}
 
-	rc = ocxl_link_irq_alloc(ctx->afu->fn->link, &irq->hw_irq,
-				&irq->trigger_page);
+	rc = ocxl_link_irq_alloc(ctx->afu->fn->link, &irq->hw_irq);
 	if (rc)
 		goto err_idr;
 
diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c
index 58d111afd9f6..fd73d3bc0eb6 100644
--- a/drivers/misc/ocxl/link.c
+++ b/drivers/misc/ocxl/link.c
@@ -6,6 +6,7 @@
 #include <linux/mmu_context.h>
 #include <asm/copro.h>
 #include <asm/pnv-ocxl.h>
+#include <asm/xive.h>
 #include <misc/ocxl.h>
 #include "ocxl_internal.h"
 #include "trace.h"
@@ -682,23 +683,21 @@ int ocxl_link_remove_pe(void *link_handle, int pasid)
 }
 EXPORT_SYMBOL_GPL(ocxl_link_remove_pe);
 
-int ocxl_link_irq_alloc(void *link_handle, int *hw_irq, u64 *trigger_addr)
+int ocxl_link_irq_alloc(void *link_handle, int *hw_irq)
 {
 	struct ocxl_link *link = (struct ocxl_link *) link_handle;
-	int rc, irq;
-	u64 addr;
+	int irq;
 
 	if (atomic_dec_if_positive(&link->irq_available) < 0)
 		return -ENOSPC;
 
-	rc = pnv_ocxl_alloc_xive_irq(&irq, &addr);
-	if (rc) {
+	irq = xive_native_alloc_irq();
+	if (!irq) {
 		atomic_inc(&link->irq_available);
-		return rc;
+		return -ENXIO;
 	}
 
 	*hw_irq = irq;
-	*trigger_addr = addr;
 	return 0;
 }
 EXPORT_SYMBOL_GPL(ocxl_link_irq_alloc);
@@ -707,7 +706,7 @@ void ocxl_link_free_irq(void *link_handle, int hw_irq)
 {
 	struct ocxl_link *link = (struct ocxl_link *) link_handle;
 
-	pnv_ocxl_free_xive_irq(hw_irq);
+	xive_native_free_irq(hw_irq);
 	atomic_inc(&link->irq_available);
 }
 EXPORT_SYMBOL_GPL(ocxl_link_free_irq);
diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c
index 59452850f71c..03bff0cae658 100644
--- a/drivers/scsi/cxlflash/ocxl_hw.c
+++ b/drivers/scsi/cxlflash/ocxl_hw.c
@@ -613,7 +613,6 @@ static int alloc_afu_irqs(struct ocxlflash_context *ctx, int num)
 	struct ocxl_hw_afu *afu = ctx->hw_afu;
 	struct device *dev = afu->dev;
 	struct ocxlflash_irqs *irqs;
-	u64 addr;
 	int rc = 0;
 	int hwirq;
 	int i;
@@ -638,7 +637,7 @@ static int alloc_afu_irqs(struct ocxlflash_context *ctx, int num)
 	}
 
 	for (i = 0; i < num; i++) {
-		rc = ocxl_link_irq_alloc(afu->link_token, &hwirq, &addr);
+		rc = ocxl_link_irq_alloc(afu->link_token, &hwirq);
 		if (unlikely(rc)) {
 			dev_err(dev, "%s: ocxl_link_irq_alloc failed rc=%d\n",
 				__func__, rc);
diff --git a/include/misc/ocxl.h b/include/misc/ocxl.h
index 06dd5839e438..a2868adec22f 100644
--- a/include/misc/ocxl.h
+++ b/include/misc/ocxl.h
@@ -480,14 +480,8 @@ int ocxl_link_remove_pe(void *link_handle, int pasid);
  * Allocate an AFU interrupt associated to the link.
  *
  * 'hw_irq' is the hardware interrupt number
- * 'obj_handle' is the 64-bit object handle to be passed to the AFU to
- * trigger the interrupt.
- * On P9, 'obj_handle' is an address, which, if written, triggers the
- * interrupt. It is an MMIO address which needs to be remapped (one
- * page).
- */
-int ocxl_link_irq_alloc(void *link_handle, int *hw_irq,
-			u64 *obj_handle);
+ */
+int ocxl_link_irq_alloc(void *link_handle, int *hw_irq);
 
 /*
  * Free a previously allocated AFU interrupt
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/4] ocxl: Remove custom service to allocate interrupts
  2020-04-02 15:43 [PATCH 0/4] ocxl: Cleanup AFU interrupt allocation Frederic Barrat
                   ` (2 preceding siblings ...)
  2020-04-02 15:43 ` [PATCH 3/4] ocxl: Don't return trigger page when allocating an interrupt Frederic Barrat
@ 2020-04-02 15:43 ` Frederic Barrat
  2020-04-03  5:56   ` Cédric Le Goater
  2020-04-03  9:27   ` Greg Kurz
  3 siblings, 2 replies; 14+ messages in thread
From: Frederic Barrat @ 2020-04-02 15:43 UTC (permalink / raw)
  To: linuxppc-dev, clg, christophe_lombard, ajd, ukrishn, mrochs; +Cc: haren, groug

We now allocate interrupts through xive directly.

Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
---
 arch/powerpc/include/asm/pnv-ocxl.h   |  3 ---
 arch/powerpc/platforms/powernv/ocxl.c | 30 ---------------------------
 2 files changed, 33 deletions(-)

diff --git a/arch/powerpc/include/asm/pnv-ocxl.h b/arch/powerpc/include/asm/pnv-ocxl.h
index 7de82647e761..e90650328c9c 100644
--- a/arch/powerpc/include/asm/pnv-ocxl.h
+++ b/arch/powerpc/include/asm/pnv-ocxl.h
@@ -30,7 +30,4 @@ extern int pnv_ocxl_spa_setup(struct pci_dev *dev, void *spa_mem, int PE_mask,
 extern void pnv_ocxl_spa_release(void *platform_data);
 extern int pnv_ocxl_spa_remove_pe_from_cache(void *platform_data, int pe_handle);
 
-extern int pnv_ocxl_alloc_xive_irq(u32 *irq, u64 *trigger_addr);
-extern void pnv_ocxl_free_xive_irq(u32 irq);
-
 #endif /* _ASM_PNV_OCXL_H */
diff --git a/arch/powerpc/platforms/powernv/ocxl.c b/arch/powerpc/platforms/powernv/ocxl.c
index 8c65aacda9c8..ecdad219d704 100644
--- a/arch/powerpc/platforms/powernv/ocxl.c
+++ b/arch/powerpc/platforms/powernv/ocxl.c
@@ -2,7 +2,6 @@
 // Copyright 2017 IBM Corp.
 #include <asm/pnv-ocxl.h>
 #include <asm/opal.h>
-#include <asm/xive.h>
 #include <misc/ocxl-config.h>
 #include "pci.h"
 
@@ -484,32 +483,3 @@ int pnv_ocxl_spa_remove_pe_from_cache(void *platform_data, int pe_handle)
 	return rc;
 }
 EXPORT_SYMBOL_GPL(pnv_ocxl_spa_remove_pe_from_cache);
-
-int pnv_ocxl_alloc_xive_irq(u32 *irq, u64 *trigger_addr)
-{
-	__be64 flags, trigger_page;
-	s64 rc;
-	u32 hwirq;
-
-	hwirq = xive_native_alloc_irq();
-	if (!hwirq)
-		return -ENOENT;
-
-	rc = opal_xive_get_irq_info(hwirq, &flags, NULL, &trigger_page, NULL,
-				NULL);
-	if (rc || !trigger_page) {
-		xive_native_free_irq(hwirq);
-		return -ENOENT;
-	}
-	*irq = hwirq;
-	*trigger_addr = be64_to_cpu(trigger_page);
-	return 0;
-
-}
-EXPORT_SYMBOL_GPL(pnv_ocxl_alloc_xive_irq);
-
-void pnv_ocxl_free_xive_irq(u32 irq)
-{
-	xive_native_free_irq(irq);
-}
-EXPORT_SYMBOL_GPL(pnv_ocxl_free_xive_irq);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] scsi: cxlflash: Access interrupt trigger page from xive directly
  2020-04-02 15:43 ` [PATCH 1/4] scsi: cxlflash: Access interrupt trigger page from xive directly Frederic Barrat
@ 2020-04-02 23:19   ` Matthew R. Ochs
  2020-04-03 11:19     ` Cédric Le Goater
  0 siblings, 1 reply; 14+ messages in thread
From: Matthew R. Ochs @ 2020-04-02 23:19 UTC (permalink / raw)
  To: Frederic Barrat
  Cc: ukrishn, ajd, haren, groug, clg, linuxppc-dev, christophe_lombard

On Thu, Apr 02, 2020 at 05:43:49PM +0200, Frederic Barrat wrote:
> xive is already mapping the trigger page in kernel space and it can be
> accessed through standard APIs, so let's reuse it and simplify the code.
> 
> Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
> ---
>  drivers/scsi/cxlflash/ocxl_hw.c | 17 +++++++----------
>  drivers/scsi/cxlflash/ocxl_hw.h |  1 -
>  2 files changed, 7 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c
> index 7018cd802569..59452850f71c 100644
> --- a/drivers/scsi/cxlflash/ocxl_hw.c
> +++ b/drivers/scsi/cxlflash/ocxl_hw.c
> @@ -15,7 +15,8 @@
>  #include <linux/pseudo_fs.h>
>  #include <linux/poll.h>
>  #include <linux/sched/signal.h>
> -
> +#include <linux/interrupt.h>
> +#include <asm/xive.h>
>  #include <misc/ocxl.h>
>  
>  #include <uapi/misc/cxl.h>
> @@ -180,7 +181,7 @@ static int afu_map_irq(u64 flags, struct ocxlflash_context *ctx, int num,
>  	struct ocxl_hw_afu *afu = ctx->hw_afu;
>  	struct device *dev = afu->dev;
>  	struct ocxlflash_irqs *irq;
> -	void __iomem *vtrig;
> +	struct xive_irq_data *xd;
>  	u32 virq;
>  	int rc = 0;
>  
> @@ -204,15 +205,14 @@ static int afu_map_irq(u64 flags, struct ocxlflash_context *ctx, int num,
>  		goto err1;
>  	}
>  
> -	vtrig = ioremap(irq->ptrig, PAGE_SIZE);
> -	if (unlikely(!vtrig)) {
> -		dev_err(dev, "%s: Trigger page mapping failed\n", __func__);
> -		rc = -ENOMEM;
> +	xd = irq_get_handler_data(virq);
> +	if (unlikely(!xd)) {
> +		dev_err(dev, "%s: Can't get interrupt data\n", __func__);

The removal of setting the return code injects a bug should this error leg
ever be encountered. So we should either keep the rc statement e.g. -EINVAL,
-ENXIO, -ENODEV, etc., or remove this error leg. I lean towards keeping the
statement.

>  		goto err2;
>  	}
>  
>  	irq->virq = virq;
> -	irq->vtrig = vtrig;
> +	irq->vtrig = xd->trig_mmio;
>  out:
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/4] ocxl: Access interrupt trigger page from xive directly
  2020-04-02 15:43 ` [PATCH 2/4] ocxl: " Frederic Barrat
@ 2020-04-03  5:55   ` Cédric Le Goater
  2020-04-03  6:36   ` Andrew Donnellan
  2020-04-03  9:17   ` Greg Kurz
  2 siblings, 0 replies; 14+ messages in thread
From: Cédric Le Goater @ 2020-04-03  5:55 UTC (permalink / raw)
  To: Frederic Barrat, linuxppc-dev, christophe_lombard, ajd, ukrishn, mrochs
  Cc: haren, groug

On 4/2/20 5:43 PM, Frederic Barrat wrote:
> We can access the trigger page through standard APIs so let's use it
> and avoid saving it when allocating the interrupt. It will also allow
> to simplify allocation in a later patch.
> 
> Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>


Reviewed-by: Cédric Le Goater <clg@kaod.org>

> ---
>  drivers/misc/ocxl/afu_irq.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/ocxl/afu_irq.c b/drivers/misc/ocxl/afu_irq.c
> index 70f8f1c3929d..b30ec0ef7be7 100644
> --- a/drivers/misc/ocxl/afu_irq.c
> +++ b/drivers/misc/ocxl/afu_irq.c
> @@ -2,6 +2,7 @@
>  // Copyright 2017 IBM Corp.
>  #include <linux/interrupt.h>
>  #include <asm/pnv-ocxl.h>
> +#include <asm/xive.h>
>  #include "ocxl_internal.h"
>  #include "trace.h"
>  
> @@ -196,13 +197,16 @@ void ocxl_afu_irq_free_all(struct ocxl_context *ctx)
>  
>  u64 ocxl_afu_irq_get_addr(struct ocxl_context *ctx, int irq_id)
>  {
> +	struct xive_irq_data *xd;
>  	struct afu_irq *irq;
>  	u64 addr = 0;
>  
>  	mutex_lock(&ctx->irq_lock);
>  	irq = idr_find(&ctx->irq_idr, irq_id);
> -	if (irq)
> -		addr = irq->trigger_page;
> +	if (irq) {
> +		xd = irq_get_handler_data(irq->virq);
> +		addr = xd ? xd->trig_page : 0;
> +	}
>  	mutex_unlock(&ctx->irq_lock);
>  	return addr;
>  }
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/4] ocxl: Don't return trigger page when allocating an interrupt
  2020-04-02 15:43 ` [PATCH 3/4] ocxl: Don't return trigger page when allocating an interrupt Frederic Barrat
@ 2020-04-03  5:56   ` Cédric Le Goater
  2020-04-03  9:25   ` Greg Kurz
  1 sibling, 0 replies; 14+ messages in thread
From: Cédric Le Goater @ 2020-04-03  5:56 UTC (permalink / raw)
  To: Frederic Barrat, linuxppc-dev, christophe_lombard, ajd, ukrishn, mrochs
  Cc: haren, groug

On 4/2/20 5:43 PM, Frederic Barrat wrote:
> Existing users of ocxl_link_irq_alloc() have been converted to obtain
> the trigger page of an interrupt through xive directly, we therefore
> have no need to return the trigger page when allocating an interrupt.
> 
> It also allows ocxl to use the xive native interface to allocate
> interrupts, instead of its custom service.
> 
> Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>

Reviewed-by: Cédric Le Goater <clg@kaod.org>


> ---
>  drivers/misc/ocxl/Kconfig       |  2 +-
>  drivers/misc/ocxl/afu_irq.c     |  4 +---
>  drivers/misc/ocxl/link.c        | 15 +++++++--------
>  drivers/scsi/cxlflash/ocxl_hw.c |  3 +--
>  include/misc/ocxl.h             | 10 ++--------
>  5 files changed, 12 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/misc/ocxl/Kconfig b/drivers/misc/ocxl/Kconfig
> index 2d2266c1439e..e65773f5cf59 100644
> --- a/drivers/misc/ocxl/Kconfig
> +++ b/drivers/misc/ocxl/Kconfig
> @@ -9,7 +9,7 @@ config OCXL_BASE
>  
>  config OCXL
>  	tristate "OpenCAPI coherent accelerator support"
> -	depends on PPC_POWERNV && PCI && EEH
> +	depends on PPC_POWERNV && PCI && EEH && PPC_XIVE_NATIVE
>  	select OCXL_BASE
>  	select HOTPLUG_PCI_POWERNV
>  	default m
> diff --git a/drivers/misc/ocxl/afu_irq.c b/drivers/misc/ocxl/afu_irq.c
> index b30ec0ef7be7..ecdcfae025b7 100644
> --- a/drivers/misc/ocxl/afu_irq.c
> +++ b/drivers/misc/ocxl/afu_irq.c
> @@ -11,7 +11,6 @@ struct afu_irq {
>  	int hw_irq;
>  	unsigned int virq;
>  	char *name;
> -	u64 trigger_page;
>  	irqreturn_t (*handler)(void *private);
>  	void (*free_private)(void *private);
>  	void *private;
> @@ -125,8 +124,7 @@ int ocxl_afu_irq_alloc(struct ocxl_context *ctx, int *irq_id)
>  		goto err_unlock;
>  	}
>  
> -	rc = ocxl_link_irq_alloc(ctx->afu->fn->link, &irq->hw_irq,
> -				&irq->trigger_page);
> +	rc = ocxl_link_irq_alloc(ctx->afu->fn->link, &irq->hw_irq);
>  	if (rc)
>  		goto err_idr;
>  
> diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c
> index 58d111afd9f6..fd73d3bc0eb6 100644
> --- a/drivers/misc/ocxl/link.c
> +++ b/drivers/misc/ocxl/link.c
> @@ -6,6 +6,7 @@
>  #include <linux/mmu_context.h>
>  #include <asm/copro.h>
>  #include <asm/pnv-ocxl.h>
> +#include <asm/xive.h>
>  #include <misc/ocxl.h>
>  #include "ocxl_internal.h"
>  #include "trace.h"
> @@ -682,23 +683,21 @@ int ocxl_link_remove_pe(void *link_handle, int pasid)
>  }
>  EXPORT_SYMBOL_GPL(ocxl_link_remove_pe);
>  
> -int ocxl_link_irq_alloc(void *link_handle, int *hw_irq, u64 *trigger_addr)
> +int ocxl_link_irq_alloc(void *link_handle, int *hw_irq)
>  {
>  	struct ocxl_link *link = (struct ocxl_link *) link_handle;
> -	int rc, irq;
> -	u64 addr;
> +	int irq;
>  
>  	if (atomic_dec_if_positive(&link->irq_available) < 0)
>  		return -ENOSPC;
>  
> -	rc = pnv_ocxl_alloc_xive_irq(&irq, &addr);
> -	if (rc) {
> +	irq = xive_native_alloc_irq();
> +	if (!irq) {
>  		atomic_inc(&link->irq_available);
> -		return rc;
> +		return -ENXIO;
>  	}
>  
>  	*hw_irq = irq;
> -	*trigger_addr = addr;
>  	return 0;
>  }
>  EXPORT_SYMBOL_GPL(ocxl_link_irq_alloc);
> @@ -707,7 +706,7 @@ void ocxl_link_free_irq(void *link_handle, int hw_irq)
>  {
>  	struct ocxl_link *link = (struct ocxl_link *) link_handle;
>  
> -	pnv_ocxl_free_xive_irq(hw_irq);
> +	xive_native_free_irq(hw_irq);
>  	atomic_inc(&link->irq_available);
>  }
>  EXPORT_SYMBOL_GPL(ocxl_link_free_irq);
> diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c
> index 59452850f71c..03bff0cae658 100644
> --- a/drivers/scsi/cxlflash/ocxl_hw.c
> +++ b/drivers/scsi/cxlflash/ocxl_hw.c
> @@ -613,7 +613,6 @@ static int alloc_afu_irqs(struct ocxlflash_context *ctx, int num)
>  	struct ocxl_hw_afu *afu = ctx->hw_afu;
>  	struct device *dev = afu->dev;
>  	struct ocxlflash_irqs *irqs;
> -	u64 addr;
>  	int rc = 0;
>  	int hwirq;
>  	int i;
> @@ -638,7 +637,7 @@ static int alloc_afu_irqs(struct ocxlflash_context *ctx, int num)
>  	}
>  
>  	for (i = 0; i < num; i++) {
> -		rc = ocxl_link_irq_alloc(afu->link_token, &hwirq, &addr);
> +		rc = ocxl_link_irq_alloc(afu->link_token, &hwirq);
>  		if (unlikely(rc)) {
>  			dev_err(dev, "%s: ocxl_link_irq_alloc failed rc=%d\n",
>  				__func__, rc);
> diff --git a/include/misc/ocxl.h b/include/misc/ocxl.h
> index 06dd5839e438..a2868adec22f 100644
> --- a/include/misc/ocxl.h
> +++ b/include/misc/ocxl.h
> @@ -480,14 +480,8 @@ int ocxl_link_remove_pe(void *link_handle, int pasid);
>   * Allocate an AFU interrupt associated to the link.
>   *
>   * 'hw_irq' is the hardware interrupt number
> - * 'obj_handle' is the 64-bit object handle to be passed to the AFU to
> - * trigger the interrupt.
> - * On P9, 'obj_handle' is an address, which, if written, triggers the
> - * interrupt. It is an MMIO address which needs to be remapped (one
> - * page).
> - */
> -int ocxl_link_irq_alloc(void *link_handle, int *hw_irq,
> -			u64 *obj_handle);
> + */
> +int ocxl_link_irq_alloc(void *link_handle, int *hw_irq);
>  
>  /*
>   * Free a previously allocated AFU interrupt
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/4] ocxl: Remove custom service to allocate interrupts
  2020-04-02 15:43 ` [PATCH 4/4] ocxl: Remove custom service to allocate interrupts Frederic Barrat
@ 2020-04-03  5:56   ` Cédric Le Goater
  2020-04-03  9:27   ` Greg Kurz
  1 sibling, 0 replies; 14+ messages in thread
From: Cédric Le Goater @ 2020-04-03  5:56 UTC (permalink / raw)
  To: Frederic Barrat, linuxppc-dev, christophe_lombard, ajd, ukrishn, mrochs
  Cc: haren, groug

On 4/2/20 5:43 PM, Frederic Barrat wrote:
> We now allocate interrupts through xive directly.
> 
> Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>


Reviewed-by: Cédric Le Goater <clg@kaod.org>

> ---
>  arch/powerpc/include/asm/pnv-ocxl.h   |  3 ---
>  arch/powerpc/platforms/powernv/ocxl.c | 30 ---------------------------
>  2 files changed, 33 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/pnv-ocxl.h b/arch/powerpc/include/asm/pnv-ocxl.h
> index 7de82647e761..e90650328c9c 100644
> --- a/arch/powerpc/include/asm/pnv-ocxl.h
> +++ b/arch/powerpc/include/asm/pnv-ocxl.h
> @@ -30,7 +30,4 @@ extern int pnv_ocxl_spa_setup(struct pci_dev *dev, void *spa_mem, int PE_mask,
>  extern void pnv_ocxl_spa_release(void *platform_data);
>  extern int pnv_ocxl_spa_remove_pe_from_cache(void *platform_data, int pe_handle);
>  
> -extern int pnv_ocxl_alloc_xive_irq(u32 *irq, u64 *trigger_addr);
> -extern void pnv_ocxl_free_xive_irq(u32 irq);
> -
>  #endif /* _ASM_PNV_OCXL_H */
> diff --git a/arch/powerpc/platforms/powernv/ocxl.c b/arch/powerpc/platforms/powernv/ocxl.c
> index 8c65aacda9c8..ecdad219d704 100644
> --- a/arch/powerpc/platforms/powernv/ocxl.c
> +++ b/arch/powerpc/platforms/powernv/ocxl.c
> @@ -2,7 +2,6 @@
>  // Copyright 2017 IBM Corp.
>  #include <asm/pnv-ocxl.h>
>  #include <asm/opal.h>
> -#include <asm/xive.h>
>  #include <misc/ocxl-config.h>
>  #include "pci.h"
>  
> @@ -484,32 +483,3 @@ int pnv_ocxl_spa_remove_pe_from_cache(void *platform_data, int pe_handle)
>  	return rc;
>  }
>  EXPORT_SYMBOL_GPL(pnv_ocxl_spa_remove_pe_from_cache);
> -
> -int pnv_ocxl_alloc_xive_irq(u32 *irq, u64 *trigger_addr)
> -{
> -	__be64 flags, trigger_page;
> -	s64 rc;
> -	u32 hwirq;
> -
> -	hwirq = xive_native_alloc_irq();
> -	if (!hwirq)
> -		return -ENOENT;
> -
> -	rc = opal_xive_get_irq_info(hwirq, &flags, NULL, &trigger_page, NULL,
> -				NULL);
> -	if (rc || !trigger_page) {
> -		xive_native_free_irq(hwirq);
> -		return -ENOENT;
> -	}
> -	*irq = hwirq;
> -	*trigger_addr = be64_to_cpu(trigger_page);
> -	return 0;
> -
> -}
> -EXPORT_SYMBOL_GPL(pnv_ocxl_alloc_xive_irq);
> -
> -void pnv_ocxl_free_xive_irq(u32 irq)
> -{
> -	xive_native_free_irq(irq);
> -}
> -EXPORT_SYMBOL_GPL(pnv_ocxl_free_xive_irq);
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/4] ocxl: Access interrupt trigger page from xive directly
  2020-04-02 15:43 ` [PATCH 2/4] ocxl: " Frederic Barrat
  2020-04-03  5:55   ` Cédric Le Goater
@ 2020-04-03  6:36   ` Andrew Donnellan
  2020-04-03  9:17   ` Greg Kurz
  2 siblings, 0 replies; 14+ messages in thread
From: Andrew Donnellan @ 2020-04-03  6:36 UTC (permalink / raw)
  To: Frederic Barrat, linuxppc-dev, clg, christophe_lombard, ukrishn, mrochs
  Cc: haren, groug

On 3/4/20 2:43 am, Frederic Barrat wrote:
> We can access the trigger page through standard APIs so let's use it
> and avoid saving it when allocating the interrupt. It will also allow
> to simplify allocation in a later patch.
> 
> Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>

I don't see any obvious issues.

Acked-by: Andrew Donnellan <ajd@linux.ibm.com>

-- 
Andrew Donnellan              OzLabs, ADL Canberra
ajd@linux.ibm.com             IBM Australia Limited


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/4] ocxl: Access interrupt trigger page from xive directly
  2020-04-02 15:43 ` [PATCH 2/4] ocxl: " Frederic Barrat
  2020-04-03  5:55   ` Cédric Le Goater
  2020-04-03  6:36   ` Andrew Donnellan
@ 2020-04-03  9:17   ` Greg Kurz
  2 siblings, 0 replies; 14+ messages in thread
From: Greg Kurz @ 2020-04-03  9:17 UTC (permalink / raw)
  To: Frederic Barrat
  Cc: ukrishn, ajd, haren, clg, linuxppc-dev, christophe_lombard, mrochs

On Thu,  2 Apr 2020 17:43:50 +0200
Frederic Barrat <fbarrat@linux.ibm.com> wrote:

> We can access the trigger page through standard APIs so let's use it
> and avoid saving it when allocating the interrupt. It will also allow
> to simplify allocation in a later patch.
> 
> Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
> ---

Reviewed-by: Greg Kurz <groug@kaod.org>

>  drivers/misc/ocxl/afu_irq.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/ocxl/afu_irq.c b/drivers/misc/ocxl/afu_irq.c
> index 70f8f1c3929d..b30ec0ef7be7 100644
> --- a/drivers/misc/ocxl/afu_irq.c
> +++ b/drivers/misc/ocxl/afu_irq.c
> @@ -2,6 +2,7 @@
>  // Copyright 2017 IBM Corp.
>  #include <linux/interrupt.h>
>  #include <asm/pnv-ocxl.h>
> +#include <asm/xive.h>
>  #include "ocxl_internal.h"
>  #include "trace.h"
>  
> @@ -196,13 +197,16 @@ void ocxl_afu_irq_free_all(struct ocxl_context *ctx)
>  
>  u64 ocxl_afu_irq_get_addr(struct ocxl_context *ctx, int irq_id)
>  {
> +	struct xive_irq_data *xd;
>  	struct afu_irq *irq;
>  	u64 addr = 0;
>  
>  	mutex_lock(&ctx->irq_lock);
>  	irq = idr_find(&ctx->irq_idr, irq_id);
> -	if (irq)
> -		addr = irq->trigger_page;
> +	if (irq) {
> +		xd = irq_get_handler_data(irq->virq);
> +		addr = xd ? xd->trig_page : 0;
> +	}
>  	mutex_unlock(&ctx->irq_lock);
>  	return addr;
>  }


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/4] ocxl: Don't return trigger page when allocating an interrupt
  2020-04-02 15:43 ` [PATCH 3/4] ocxl: Don't return trigger page when allocating an interrupt Frederic Barrat
  2020-04-03  5:56   ` Cédric Le Goater
@ 2020-04-03  9:25   ` Greg Kurz
  1 sibling, 0 replies; 14+ messages in thread
From: Greg Kurz @ 2020-04-03  9:25 UTC (permalink / raw)
  To: Frederic Barrat
  Cc: ukrishn, ajd, haren, clg, linuxppc-dev, christophe_lombard, mrochs

On Thu,  2 Apr 2020 17:43:51 +0200
Frederic Barrat <fbarrat@linux.ibm.com> wrote:

> Existing users of ocxl_link_irq_alloc() have been converted to obtain
> the trigger page of an interrupt through xive directly, we therefore
> have no need to return the trigger page when allocating an interrupt.
> 
> It also allows ocxl to use the xive native interface to allocate
> interrupts, instead of its custom service.
> 
> Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
> ---

Reviewed-by: Greg Kurz <groug@kaod.org>

>  drivers/misc/ocxl/Kconfig       |  2 +-
>  drivers/misc/ocxl/afu_irq.c     |  4 +---
>  drivers/misc/ocxl/link.c        | 15 +++++++--------
>  drivers/scsi/cxlflash/ocxl_hw.c |  3 +--
>  include/misc/ocxl.h             | 10 ++--------
>  5 files changed, 12 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/misc/ocxl/Kconfig b/drivers/misc/ocxl/Kconfig
> index 2d2266c1439e..e65773f5cf59 100644
> --- a/drivers/misc/ocxl/Kconfig
> +++ b/drivers/misc/ocxl/Kconfig
> @@ -9,7 +9,7 @@ config OCXL_BASE
>  
>  config OCXL
>  	tristate "OpenCAPI coherent accelerator support"
> -	depends on PPC_POWERNV && PCI && EEH
> +	depends on PPC_POWERNV && PCI && EEH && PPC_XIVE_NATIVE
>  	select OCXL_BASE
>  	select HOTPLUG_PCI_POWERNV
>  	default m
> diff --git a/drivers/misc/ocxl/afu_irq.c b/drivers/misc/ocxl/afu_irq.c
> index b30ec0ef7be7..ecdcfae025b7 100644
> --- a/drivers/misc/ocxl/afu_irq.c
> +++ b/drivers/misc/ocxl/afu_irq.c
> @@ -11,7 +11,6 @@ struct afu_irq {
>  	int hw_irq;
>  	unsigned int virq;
>  	char *name;
> -	u64 trigger_page;
>  	irqreturn_t (*handler)(void *private);
>  	void (*free_private)(void *private);
>  	void *private;
> @@ -125,8 +124,7 @@ int ocxl_afu_irq_alloc(struct ocxl_context *ctx, int *irq_id)
>  		goto err_unlock;
>  	}
>  
> -	rc = ocxl_link_irq_alloc(ctx->afu->fn->link, &irq->hw_irq,
> -				&irq->trigger_page);
> +	rc = ocxl_link_irq_alloc(ctx->afu->fn->link, &irq->hw_irq);
>  	if (rc)
>  		goto err_idr;
>  
> diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c
> index 58d111afd9f6..fd73d3bc0eb6 100644
> --- a/drivers/misc/ocxl/link.c
> +++ b/drivers/misc/ocxl/link.c
> @@ -6,6 +6,7 @@
>  #include <linux/mmu_context.h>
>  #include <asm/copro.h>
>  #include <asm/pnv-ocxl.h>
> +#include <asm/xive.h>
>  #include <misc/ocxl.h>
>  #include "ocxl_internal.h"
>  #include "trace.h"
> @@ -682,23 +683,21 @@ int ocxl_link_remove_pe(void *link_handle, int pasid)
>  }
>  EXPORT_SYMBOL_GPL(ocxl_link_remove_pe);
>  
> -int ocxl_link_irq_alloc(void *link_handle, int *hw_irq, u64 *trigger_addr)
> +int ocxl_link_irq_alloc(void *link_handle, int *hw_irq)
>  {
>  	struct ocxl_link *link = (struct ocxl_link *) link_handle;
> -	int rc, irq;
> -	u64 addr;
> +	int irq;
>  
>  	if (atomic_dec_if_positive(&link->irq_available) < 0)
>  		return -ENOSPC;
>  
> -	rc = pnv_ocxl_alloc_xive_irq(&irq, &addr);
> -	if (rc) {
> +	irq = xive_native_alloc_irq();
> +	if (!irq) {
>  		atomic_inc(&link->irq_available);
> -		return rc;
> +		return -ENXIO;
>  	}
>  
>  	*hw_irq = irq;
> -	*trigger_addr = addr;
>  	return 0;
>  }
>  EXPORT_SYMBOL_GPL(ocxl_link_irq_alloc);
> @@ -707,7 +706,7 @@ void ocxl_link_free_irq(void *link_handle, int hw_irq)
>  {
>  	struct ocxl_link *link = (struct ocxl_link *) link_handle;
>  
> -	pnv_ocxl_free_xive_irq(hw_irq);
> +	xive_native_free_irq(hw_irq);
>  	atomic_inc(&link->irq_available);
>  }
>  EXPORT_SYMBOL_GPL(ocxl_link_free_irq);
> diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c
> index 59452850f71c..03bff0cae658 100644
> --- a/drivers/scsi/cxlflash/ocxl_hw.c
> +++ b/drivers/scsi/cxlflash/ocxl_hw.c
> @@ -613,7 +613,6 @@ static int alloc_afu_irqs(struct ocxlflash_context *ctx, int num)
>  	struct ocxl_hw_afu *afu = ctx->hw_afu;
>  	struct device *dev = afu->dev;
>  	struct ocxlflash_irqs *irqs;
> -	u64 addr;
>  	int rc = 0;
>  	int hwirq;
>  	int i;
> @@ -638,7 +637,7 @@ static int alloc_afu_irqs(struct ocxlflash_context *ctx, int num)
>  	}
>  
>  	for (i = 0; i < num; i++) {
> -		rc = ocxl_link_irq_alloc(afu->link_token, &hwirq, &addr);
> +		rc = ocxl_link_irq_alloc(afu->link_token, &hwirq);
>  		if (unlikely(rc)) {
>  			dev_err(dev, "%s: ocxl_link_irq_alloc failed rc=%d\n",
>  				__func__, rc);
> diff --git a/include/misc/ocxl.h b/include/misc/ocxl.h
> index 06dd5839e438..a2868adec22f 100644
> --- a/include/misc/ocxl.h
> +++ b/include/misc/ocxl.h
> @@ -480,14 +480,8 @@ int ocxl_link_remove_pe(void *link_handle, int pasid);
>   * Allocate an AFU interrupt associated to the link.
>   *
>   * 'hw_irq' is the hardware interrupt number
> - * 'obj_handle' is the 64-bit object handle to be passed to the AFU to
> - * trigger the interrupt.
> - * On P9, 'obj_handle' is an address, which, if written, triggers the
> - * interrupt. It is an MMIO address which needs to be remapped (one
> - * page).
> - */
> -int ocxl_link_irq_alloc(void *link_handle, int *hw_irq,
> -			u64 *obj_handle);
> + */
> +int ocxl_link_irq_alloc(void *link_handle, int *hw_irq);
>  
>  /*
>   * Free a previously allocated AFU interrupt


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/4] ocxl: Remove custom service to allocate interrupts
  2020-04-02 15:43 ` [PATCH 4/4] ocxl: Remove custom service to allocate interrupts Frederic Barrat
  2020-04-03  5:56   ` Cédric Le Goater
@ 2020-04-03  9:27   ` Greg Kurz
  1 sibling, 0 replies; 14+ messages in thread
From: Greg Kurz @ 2020-04-03  9:27 UTC (permalink / raw)
  To: Frederic Barrat
  Cc: ukrishn, ajd, haren, clg, linuxppc-dev, christophe_lombard, mrochs

On Thu,  2 Apr 2020 17:43:52 +0200
Frederic Barrat <fbarrat@linux.ibm.com> wrote:

> We now allocate interrupts through xive directly.
> 
> Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
> ---
>  arch/powerpc/include/asm/pnv-ocxl.h   |  3 ---
>  arch/powerpc/platforms/powernv/ocxl.c | 30 ---------------------------

Nice diffstat :)

Reviewed-by: Greg Kurz <groug@kaod.org>

>  2 files changed, 33 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/pnv-ocxl.h b/arch/powerpc/include/asm/pnv-ocxl.h
> index 7de82647e761..e90650328c9c 100644
> --- a/arch/powerpc/include/asm/pnv-ocxl.h
> +++ b/arch/powerpc/include/asm/pnv-ocxl.h
> @@ -30,7 +30,4 @@ extern int pnv_ocxl_spa_setup(struct pci_dev *dev, void *spa_mem, int PE_mask,
>  extern void pnv_ocxl_spa_release(void *platform_data);
>  extern int pnv_ocxl_spa_remove_pe_from_cache(void *platform_data, int pe_handle);
>  
> -extern int pnv_ocxl_alloc_xive_irq(u32 *irq, u64 *trigger_addr);
> -extern void pnv_ocxl_free_xive_irq(u32 irq);
> -
>  #endif /* _ASM_PNV_OCXL_H */
> diff --git a/arch/powerpc/platforms/powernv/ocxl.c b/arch/powerpc/platforms/powernv/ocxl.c
> index 8c65aacda9c8..ecdad219d704 100644
> --- a/arch/powerpc/platforms/powernv/ocxl.c
> +++ b/arch/powerpc/platforms/powernv/ocxl.c
> @@ -2,7 +2,6 @@
>  // Copyright 2017 IBM Corp.
>  #include <asm/pnv-ocxl.h>
>  #include <asm/opal.h>
> -#include <asm/xive.h>
>  #include <misc/ocxl-config.h>
>  #include "pci.h"
>  
> @@ -484,32 +483,3 @@ int pnv_ocxl_spa_remove_pe_from_cache(void *platform_data, int pe_handle)
>  	return rc;
>  }
>  EXPORT_SYMBOL_GPL(pnv_ocxl_spa_remove_pe_from_cache);
> -
> -int pnv_ocxl_alloc_xive_irq(u32 *irq, u64 *trigger_addr)
> -{
> -	__be64 flags, trigger_page;
> -	s64 rc;
> -	u32 hwirq;
> -
> -	hwirq = xive_native_alloc_irq();
> -	if (!hwirq)
> -		return -ENOENT;
> -
> -	rc = opal_xive_get_irq_info(hwirq, &flags, NULL, &trigger_page, NULL,
> -				NULL);
> -	if (rc || !trigger_page) {
> -		xive_native_free_irq(hwirq);
> -		return -ENOENT;
> -	}
> -	*irq = hwirq;
> -	*trigger_addr = be64_to_cpu(trigger_page);
> -	return 0;
> -
> -}
> -EXPORT_SYMBOL_GPL(pnv_ocxl_alloc_xive_irq);
> -
> -void pnv_ocxl_free_xive_irq(u32 irq)
> -{
> -	xive_native_free_irq(irq);
> -}
> -EXPORT_SYMBOL_GPL(pnv_ocxl_free_xive_irq);


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] scsi: cxlflash: Access interrupt trigger page from xive directly
  2020-04-02 23:19   ` Matthew R. Ochs
@ 2020-04-03 11:19     ` Cédric Le Goater
  0 siblings, 0 replies; 14+ messages in thread
From: Cédric Le Goater @ 2020-04-03 11:19 UTC (permalink / raw)
  To: Matthew R. Ochs, Frederic Barrat
  Cc: ukrishn, ajd, haren, groug, linuxppc-dev, christophe_lombard

On 4/3/20 1:19 AM, Matthew R. Ochs wrote:
> On Thu, Apr 02, 2020 at 05:43:49PM +0200, Frederic Barrat wrote:
>> xive is already mapping the trigger page in kernel space and it can be
>> accessed through standard APIs, so let's reuse it and simplify the code.
>>
>> Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
>> ---
>>  drivers/scsi/cxlflash/ocxl_hw.c | 17 +++++++----------
>>  drivers/scsi/cxlflash/ocxl_hw.h |  1 -
>>  2 files changed, 7 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c
>> index 7018cd802569..59452850f71c 100644
>> --- a/drivers/scsi/cxlflash/ocxl_hw.c
>> +++ b/drivers/scsi/cxlflash/ocxl_hw.c
>> @@ -15,7 +15,8 @@
>>  #include <linux/pseudo_fs.h>
>>  #include <linux/poll.h>
>>  #include <linux/sched/signal.h>
>> -
>> +#include <linux/interrupt.h>
>> +#include <asm/xive.h>
>>  #include <misc/ocxl.h>
>>  
>>  #include <uapi/misc/cxl.h>
>> @@ -180,7 +181,7 @@ static int afu_map_irq(u64 flags, struct ocxlflash_context *ctx, int num,
>>  	struct ocxl_hw_afu *afu = ctx->hw_afu;
>>  	struct device *dev = afu->dev;
>>  	struct ocxlflash_irqs *irq;
>> -	void __iomem *vtrig;
>> +	struct xive_irq_data *xd;
>>  	u32 virq;
>>  	int rc = 0;
>>  
>> @@ -204,15 +205,14 @@ static int afu_map_irq(u64 flags, struct ocxlflash_context *ctx, int num,
>>  		goto err1;
>>  	}
>>  
>> -	vtrig = ioremap(irq->ptrig, PAGE_SIZE);
>> -	if (unlikely(!vtrig)) {
>> -		dev_err(dev, "%s: Trigger page mapping failed\n", __func__);
>> -		rc = -ENOMEM;
>> +	xd = irq_get_handler_data(virq);
>> +	if (unlikely(!xd)) {
>> +		dev_err(dev, "%s: Can't get interrupt data\n", __func__);
> 
> The removal of setting the return code injects a bug should this error leg
> ever be encountered. So we should either keep the rc statement e.g. -EINVAL,
> -ENXIO, -ENODEV, etc., or remove this error leg. I lean towards keeping the
> statement.

I like ENXIO for XIVE matters. 

C. 

>>  		goto err2;
>>  	}
>>  
>>  	irq->virq = virq;
>> -	irq->vtrig = vtrig;
>> +	irq->vtrig = xd->trig_mmio;
>>  out:
>>


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-04-03 11:24 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-02 15:43 [PATCH 0/4] ocxl: Cleanup AFU interrupt allocation Frederic Barrat
2020-04-02 15:43 ` [PATCH 1/4] scsi: cxlflash: Access interrupt trigger page from xive directly Frederic Barrat
2020-04-02 23:19   ` Matthew R. Ochs
2020-04-03 11:19     ` Cédric Le Goater
2020-04-02 15:43 ` [PATCH 2/4] ocxl: " Frederic Barrat
2020-04-03  5:55   ` Cédric Le Goater
2020-04-03  6:36   ` Andrew Donnellan
2020-04-03  9:17   ` Greg Kurz
2020-04-02 15:43 ` [PATCH 3/4] ocxl: Don't return trigger page when allocating an interrupt Frederic Barrat
2020-04-03  5:56   ` Cédric Le Goater
2020-04-03  9:25   ` Greg Kurz
2020-04-02 15:43 ` [PATCH 4/4] ocxl: Remove custom service to allocate interrupts Frederic Barrat
2020-04-03  5:56   ` Cédric Le Goater
2020-04-03  9:27   ` Greg Kurz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.