Message ID | 20200403153838.29224-2-fbarrat@linux.ibm.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 1e89da5ef9c28c673e86048c89ef9495618d987d |
Headers | show |
Series | ocxl: Cleanup AFU interrupt allocation | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/apply_patch | success | Successfully applied on branch powerpc/merge (d0c12846a3a24cd6d68b608c866712bc7e471634) |
snowpatch_ozlabs/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 59 lines checked |
snowpatch_ozlabs/needsstable | success | Patch has no Fixes tags |
On 4/3/20 5:38 PM, 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> Reviewed-by: Cédric Le Goater <clg@kaod.org> Thanks, C. > --- > Changelog: > v2: Define rc = -ENXIO on the error path (Matt) > > > drivers/scsi/cxlflash/ocxl_hw.c | 18 ++++++++---------- > drivers/scsi/cxlflash/ocxl_hw.h | 1 - > 2 files changed, 8 insertions(+), 11 deletions(-) > > diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c > index 7018cd802569..d6eec434a607 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,15 @@ 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__); > + rc = -ENXIO; > goto err2; > } > > irq->virq = virq; > - irq->vtrig = vtrig; > + irq->vtrig = xd->trig_mmio; > out: > return rc; > err2: > @@ -259,8 +260,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 +647,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; > }; > >
On Fri, Apr 03, 2020 at 05:38:35PM +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> Looks good! Acked-by: Matthew R. Ochs <mrochs@linux.ibm.com> > --- > Changelog: > v2: Define rc = -ENXIO on the error path (Matt) > > > drivers/scsi/cxlflash/ocxl_hw.c | 18 ++++++++---------- > drivers/scsi/cxlflash/ocxl_hw.h | 1 - > 2 files changed, 8 insertions(+), 11 deletions(-) > > diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c > index 7018cd802569..d6eec434a607 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,15 @@ 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__); > + rc = -ENXIO; > goto err2; > } > > irq->virq = virq; > - irq->vtrig = vtrig; > + irq->vtrig = xd->trig_mmio; > out: > return rc; > err2: > @@ -259,8 +260,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 +647,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 >
diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c index 7018cd802569..d6eec434a607 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,15 @@ 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__); + rc = -ENXIO; goto err2; } irq->virq = virq; - irq->vtrig = vtrig; + irq->vtrig = xd->trig_mmio; out: return rc; err2: @@ -259,8 +260,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 +647,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; };
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> --- Changelog: v2: Define rc = -ENXIO on the error path (Matt) drivers/scsi/cxlflash/ocxl_hw.c | 18 ++++++++---------- drivers/scsi/cxlflash/ocxl_hw.h | 1 - 2 files changed, 8 insertions(+), 11 deletions(-)