@@ -617,3 +617,41 @@ void qce_get_version(struct qce_device *qce, u32 *major, u32 *minor, u32 *step)
*minor = (val & CORE_MINOR_REV_MASK) >> CORE_MINOR_REV_SHIFT;
*step = (val & CORE_STEP_REV_MASK) >> CORE_STEP_REV_SHIFT;
}
+
+int qce_bam_acquire_lock(struct qce_device *qce)
+{
+ u32 val = 0;
+ int ret;
+
+ qce_clear_bam_transaction(qce);
+
+ /* This is just a dummy read to acquire lock bam pipe */
+ qce_read_reg_dma(qce, REG_STATUS2, &val, 1);
+
+ ret = qce_submit_cmd_desc(qce, QCE_DMA_DESC_FLAG_LOCK);
+ if (ret) {
+ dev_err(qce->dev, "Error in LOCK cmd descriptor\n");
+ return ret;
+ }
+
+ return 0;
+}
+
+int qce_bam_release_lock(struct qce_device *qce)
+{
+ u32 val = 0;
+ int ret;
+
+ qce_clear_bam_transaction(qce);
+
+ /* This just dummy read to release lock on bam pipe*/
+ qce_read_reg_dma(qce, REG_STATUS2, &val, 1);
+
+ ret = qce_submit_cmd_desc(qce, QCE_DMA_DESC_FLAG_UNLOCK);
+ if (ret) {
+ dev_err(qce->dev, "Error in LOCK cmd descriptor\n");
+ return ret;
+ }
+
+ return 0;
+}
@@ -68,4 +68,6 @@ int qce_read_reg_dma(struct qce_device *qce, unsigned int offset, void *buff,
void qce_clear_bam_transaction(struct qce_device *qce);
int qce_submit_cmd_desc(struct qce_device *qce, unsigned long flags);
struct qce_bam_transaction *qce_alloc_bam_txn(struct qce_dma_data *dma);
+int qce_bam_acquire_lock(struct qce_device *qce);
+int qce_bam_release_lock(struct qce_device *qce);
#endif /* _CORE_H_ */
Add support for lock acquire and lock release api. When multiple EE's(Execution Environment) want to access CE5 then there will be race condition b/w multiple EE's. Since each EE's having their dedicated BAM pipe, BAM allows Locking and Unlocking on BAM pipe. So if one EE's requesting for CE5 access then that EE's first has to LOCK the BAM pipe while setting LOCK bit on command descriptor and then access it. After finishing the request EE's has to UNLOCK the BAM pipe so in this way we race condition will not happen. Added these two API qce_bam_acquire_lock() and qce_bam_release_lock() for the same. Signed-off-by: Md Sadre Alam <quic_mdalam@quicinc.com> --- drivers/crypto/qce/common.c | 38 +++++++++++++++++++++++++++++++++++++ drivers/crypto/qce/core.h | 2 ++ 2 files changed, 40 insertions(+)