]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
UBUNTU: SAUCE: cxlflash: Register for translation errors
authorUma Krishnan <ukrishn@linux.vnet.ibm.com>
Tue, 13 Feb 2018 23:25:18 +0000 (17:25 -0600)
committerSeth Forshee <seth.forshee@canonical.com>
Tue, 27 Mar 2018 19:10:09 +0000 (14:10 -0500)
BugLink: http://bugs.launchpad.net/bugs/1752672
While enabling a context on the link, a predefined callback can be
registered with the OCXL provider services to be notified on translation
errors. These errors can in turn be passed back to the user on a read
operation.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
drivers/scsi/cxlflash/ocxl_hw.c
drivers/scsi/cxlflash/ocxl_hw.h

index d707e4c827519a51bc5bbbc72aeece9d0440516e..9356672dd50811e11cafdbc7ccc6a30462590494 100644 (file)
@@ -334,6 +334,25 @@ static u64 ocxlflash_get_irq_objhndl(void *ctx_cookie, int irq)
        return (__force u64)ctx->irqs[irq].vtrig;
 }
 
+/**
+ * ocxlflash_xsl_fault() - callback when translation error is triggered
+ * @data:      Private data provided at callback registration, the context.
+ * @addr:      Address that triggered the error.
+ * @dsisr:     Value of dsisr register.
+ */
+static void ocxlflash_xsl_fault(void *data, u64 addr, u64 dsisr)
+{
+       struct ocxlflash_context *ctx = data;
+
+       spin_lock(&ctx->slock);
+       ctx->fault_addr = addr;
+       ctx->fault_dsisr = dsisr;
+       ctx->pending_fault = true;
+       spin_unlock(&ctx->slock);
+
+       wake_up_all(&ctx->wq);
+}
+
 /**
  * start_context() - local routine to start a context
  * @ctx:       Adapter context to be started.
@@ -378,7 +397,8 @@ static int start_context(struct ocxlflash_context *ctx)
                mm = current->mm;
        }
 
-       rc = ocxl_link_add_pe(link_token, ctx->pe, pid, 0, 0, mm, NULL, NULL);
+       rc = ocxl_link_add_pe(link_token, ctx->pe, pid, 0, 0, mm,
+                             ocxlflash_xsl_fault, ctx);
        if (unlikely(rc)) {
                dev_err(dev, "%s: ocxl_link_add_pe failed rc=%d\n",
                        __func__, rc);
@@ -512,6 +532,7 @@ static void *ocxlflash_dev_context_init(struct pci_dev *pdev, void *afu_cookie)
        ctx->hw_afu = afu;
        ctx->irq_bitmap = 0;
        ctx->pending_irq = false;
+       ctx->pending_fault = false;
 out:
        return ctx;
 err2:
@@ -957,7 +978,7 @@ err1:
  */
 static inline bool ctx_event_pending(struct ocxlflash_context *ctx)
 {
-       if (ctx->pending_irq)
+       if (ctx->pending_irq || ctx->pending_fault)
                return true;
 
        return false;
@@ -1062,6 +1083,12 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
                event.irq.irq = bit + 1;
                if (bitmap_empty(&ctx->irq_bitmap, ctx->num_irqs))
                        ctx->pending_irq = false;
+       } else if (ctx->pending_fault) {
+               event.header.size += sizeof(struct cxl_event_data_storage);
+               event.header.type = CXL_EVENT_DATA_STORAGE;
+               event.fault.addr = ctx->fault_addr;
+               event.fault.dsisr = ctx->fault_dsisr;
+               ctx->pending_fault = false;
        }
 
        spin_unlock_irqrestore(&ctx->slock, lock_flags);
index a4f3b9072ce6a2e7c095503fb7f4b2ef9b7d5d25..eb1c24afeae3a72f72b17b923e3d935b1c28ea38 100644 (file)
@@ -69,4 +69,8 @@ struct ocxlflash_context {
        int num_irqs;                   /* Number of interrupts */
        bool pending_irq;               /* Pending interrupt on the context */
        ulong irq_bitmap;               /* Bits indicating pending irq num */
+
+       u64 fault_addr;                 /* Address that triggered the fault */
+       u64 fault_dsisr;                /* Value of dsisr register at fault */
+       bool pending_fault;             /* Pending translation fault */
 };