summaryrefslogtreecommitdiff
path: root/drivers/scsi/cxlflash
diff options
context:
space:
mode:
authorUma Krishnan <ukrishn@linux.vnet.ibm.com>2018-03-26 11:32:48 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2018-04-18 19:32:48 -0400
commit6b938ac91017d9375bda42251f559ae135623fbd (patch)
tree86a26af77830705098dfb2aebc4470c56da546ca /drivers/scsi/cxlflash
parent54370503a7ec6460689e3cb46759c63162ab0c98 (diff)
scsi: cxlflash: Support starting an adapter context
Once the adapter context is created, it needs to be started by assigning the MMIO space for the context and by enabling the process element in the link. This commit adds the skeleton for starting the context and assigns the context specific MMIO space. Master contexts have access to the global MMIO space while the rest have access to the context specific space. Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com> Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/cxlflash')
-rw-r--r--drivers/scsi/cxlflash/ocxl_hw.c39
-rw-r--r--drivers/scsi/cxlflash/ocxl_hw.h3
2 files changed, 42 insertions, 0 deletions
diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c
index 235803407b89..b39a03d149d0 100644
--- a/drivers/scsi/cxlflash/ocxl_hw.c
+++ b/drivers/scsi/cxlflash/ocxl_hw.c
@@ -164,6 +164,44 @@ static int ocxlflash_process_element(void *ctx_cookie)
}
/**
+ * start_context() - local routine to start a context
+ * @ctx: Adapter context to be started.
+ *
+ * Assign the context specific MMIO space.
+ *
+ * Return: 0 on success, -errno on failure
+ */
+static int start_context(struct ocxlflash_context *ctx)
+{
+ struct ocxl_hw_afu *afu = ctx->hw_afu;
+ struct ocxl_afu_config *acfg = &afu->acfg;
+ bool master = ctx->master;
+
+ if (master) {
+ ctx->psn_size = acfg->global_mmio_size;
+ ctx->psn_phys = afu->gmmio_phys;
+ } else {
+ ctx->psn_size = acfg->pp_mmio_stride;
+ ctx->psn_phys = afu->ppmmio_phys + (ctx->pe * ctx->psn_size);
+ }
+
+ return 0;
+}
+
+/**
+ * ocxlflash_start_context() - start a kernel context
+ * @ctx_cookie: Adapter context to be started.
+ *
+ * Return: 0 on success, -errno on failure
+ */
+static int ocxlflash_start_context(void *ctx_cookie)
+{
+ struct ocxlflash_context *ctx = ctx_cookie;
+
+ return start_context(ctx);
+}
+
+/**
* ocxlflash_set_master() - sets the context as master
* @ctx_cookie: Adapter context to set as master.
*/
@@ -581,6 +619,7 @@ static void *ocxlflash_fops_get_context(struct file *file)
const struct cxlflash_backend_ops cxlflash_ocxl_ops = {
.module = THIS_MODULE,
.process_element = ocxlflash_process_element,
+ .start_context = ocxlflash_start_context,
.set_master = ocxlflash_set_master,
.get_context = ocxlflash_get_context,
.dev_context_init = ocxlflash_dev_context_init,
diff --git a/drivers/scsi/cxlflash/ocxl_hw.h b/drivers/scsi/cxlflash/ocxl_hw.h
index 18236e6dafd5..ee19717ad682 100644
--- a/drivers/scsi/cxlflash/ocxl_hw.h
+++ b/drivers/scsi/cxlflash/ocxl_hw.h
@@ -41,4 +41,7 @@ struct ocxlflash_context {
struct address_space *mapping; /* Mapping for pseudo filesystem */
bool master; /* Whether this is a master context */
int pe; /* Process element */
+
+ phys_addr_t psn_phys; /* Process mapping */
+ u64 psn_size; /* Process mapping size */
};