Przeglądaj źródła

mm-drivers: hw_fence: avoid hw fences creation until fctl ready

This change adds a check to avoid hw-fences creation until
the fence controller is ready.

Change-Id: I613c19d9dfd8836f8ded6bcb0162bef647df7bc3
Signed-off-by: Ingrid Gallardo <[email protected]>
Ingrid Gallardo 3 lat temu
rodzic
commit
2ae3dcadde

+ 3 - 0
hw_fence/include/hw_fence_drv_priv.h

@@ -211,6 +211,7 @@ struct msm_hw_fence_dbg_data {
  * @client_id_mask: bitmask for tracking registered client_ids
  * @clients_mask_lock: lock to synchronize access to the clients mask
  * @msm_hw_fence_client: table with the handles of the registered clients
+ * @vm_ready: flag to indicate if vm has been initialized
  * @ipcc_dpu_initialized: flag to indicate if dpu hw is initialized
  */
 struct hw_fence_driver_data {
@@ -286,6 +287,8 @@ struct hw_fence_driver_data {
 
 	/* table with registered client handles */
 	struct msm_hw_fence_client *clients[HW_FENCE_CLIENT_MAX];
+
+	bool vm_ready;
 #ifdef HW_DPU_IPCC
 	/* state variables */
 	bool ipcc_dpu_initialized;

+ 2 - 0
hw_fence/src/hw_fence_drv_utils.c

@@ -306,6 +306,8 @@ static int hw_fence_rm_cb(struct notifier_block *nb, unsigned long cmd, void *da
 		HWFNC_DBG_INIT("init mem\n");
 		if (hw_fence_gunyah_share_mem(drv_data, self_vmid, peer_vmid))
 			HWFNC_ERR("failed to share memory\n");
+		else
+			drv_data->vm_ready = true;
 		break;
 	case GH_RM_VM_STATUS_RESET:
 		HWFNC_DBG_INIT("reset\n");

+ 24 - 4
hw_fence/src/msm_hw_fence.c

@@ -142,6 +142,12 @@ int msm_hw_fence_create(void *client_handle,
 		HWFNC_ERR("Invalid input\n");
 		return -EINVAL;
 	}
+
+	if (!hw_fence_drv_data->vm_ready) {
+		HWFNC_DBG_H("VM not ready, cannot create fence\n");
+		return -EAGAIN;
+	}
+
 	hw_fence_client = (struct msm_hw_fence_client *)client_handle;
 	fence = (struct dma_fence *)params->fence;
 
@@ -233,6 +239,12 @@ int msm_hw_fence_wait_update(void *client_handle,
 		HWFNC_ERR("Invalid data\n");
 		return -EINVAL;
 	}
+
+	if (!hw_fence_drv_data->vm_ready) {
+		HWFNC_DBG_H("VM not ready, cannot destroy fence\n");
+		return -EAGAIN;
+	}
+
 	hw_fence_client = (struct msm_hw_fence_client *)client_handle;
 
 	HWFNC_DBG_H("+\n");
@@ -276,6 +288,12 @@ int msm_hw_fence_reset_client(void *client_handle, u32 reset_flags)
 		HWFNC_ERR("Invalid client handle!\n");
 		return -EINVAL;
 	}
+
+	if (!hw_fence_drv_data->vm_ready) {
+		HWFNC_DBG_H("VM not ready, cannot reset client\n");
+		return -EAGAIN;
+	}
+
 	hw_fence_client = (struct msm_hw_fence_client *)client_handle;
 	hw_fences_tbl = hw_fence_drv_data->hw_fences_tbl;
 
@@ -292,8 +310,9 @@ int msm_hw_fence_update_txq(void *client_handle, u64 handle, u64 flags, u32 erro
 {
 	struct msm_hw_fence_client *hw_fence_client;
 
-	if (IS_ERR_OR_NULL(hw_fence_drv_data) || !hw_fence_drv_data->resources_ready) {
-		HWFNC_ERR("hw fence driver not ready\n");
+	if (IS_ERR_OR_NULL(hw_fence_drv_data) || !hw_fence_drv_data->resources_ready ||
+			!hw_fence_drv_data->vm_ready) {
+		HWFNC_ERR("hw fence driver  or vm not ready\n");
 		return -EAGAIN;
 	} else if (IS_ERR_OR_NULL(client_handle) ||
 			(handle >= hw_fence_drv_data->hw_fences_tbl_cnt)) {
@@ -319,8 +338,9 @@ int msm_hw_fence_trigger_signal(void *client_handle,
 {
 	struct msm_hw_fence_client *hw_fence_client;
 
-	if (IS_ERR_OR_NULL(hw_fence_drv_data) || !hw_fence_drv_data->resources_ready) {
-		HWFNC_ERR("hw fence driver not ready\n");
+	if (IS_ERR_OR_NULL(hw_fence_drv_data) || !hw_fence_drv_data->resources_ready
+			|| !hw_fence_drv_data->vm_ready) {
+		HWFNC_ERR("hw fence driver or vm not ready\n");
 		return -EAGAIN;
 	} else if (IS_ERR_OR_NULL(client_handle)) {
 		HWFNC_ERR("Invalid client\n");