summaryrefslogtreecommitdiff
path: root/drivers/scsi/cxlflash/ocxl_hw.h
diff options
context:
space:
mode:
authorUma Krishnan <ukrishn@linux.vnet.ibm.com>2018-03-26 11:35:00 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2018-04-18 19:32:50 -0400
commitf81face7256339c584ee9baba3240ddac74a0293 (patch)
tree48e843b81cb84b32a72ea1b6ff617b396710ce6a /drivers/scsi/cxlflash/ocxl_hw.h
parentd91dd3a7d11a17a2e309a15e4765283212e30290 (diff)
scsi: cxlflash: Introduce OCXL context state machine
In order to protect the OCXL hardware contexts from getting clobbered, a simple state machine is added to indicate when a context is in open, close or start state. The expected states are validated throughout the code to prevent illegal operations on a context. A mutex is added to protect writes to the context state field. 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/ocxl_hw.h')
-rw-r--r--drivers/scsi/cxlflash/ocxl_hw.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/scsi/cxlflash/ocxl_hw.h b/drivers/scsi/cxlflash/ocxl_hw.h
index acd280135989..1829e55c974a 100644
--- a/drivers/scsi/cxlflash/ocxl_hw.h
+++ b/drivers/scsi/cxlflash/ocxl_hw.h
@@ -46,6 +46,12 @@ struct ocxl_hw_afu {
bool is_present; /* Function has AFUs defined */
};
+enum ocxlflash_ctx_state {
+ CLOSED,
+ OPENED,
+ STARTED
+};
+
struct ocxlflash_context {
struct ocxl_hw_afu *hw_afu; /* HW AFU back pointer */
struct address_space *mapping; /* Mapping for pseudo filesystem */
@@ -57,6 +63,8 @@ struct ocxlflash_context {
spinlock_t slock; /* Protects irq/fault/event updates */
wait_queue_head_t wq; /* Wait queue for poll and interrupts */
+ struct mutex state_mutex; /* Mutex to update context state */
+ enum ocxlflash_ctx_state state; /* Context state */
struct ocxlflash_irqs *irqs; /* Pointer to array of structures */
int num_irqs; /* Number of interrupts */