Procházet zdrojové kódy

mm-drivers: hw_fence: remove client id mask registration logic

Remove client id bitmask to track registered clients. This
allows support of more than 64 transmit clients.

Change-Id: Ia2b4667d008bfceb0b46bfd3e14302e5bec82cb3
Signed-off-by: Grace An <[email protected]>
Grace An před 2 roky
rodič
revize
b13dcfb79e

+ 3 - 4
hw_fence/include/hw_fence_drv_priv.h

@@ -244,7 +244,7 @@ struct msm_hw_fence_dbg_data {
  * @ctl_start_ptr: pointer to the ctl_start registers of the display hw (platforms with no dpu-ipc)
  * @ctl_start_size: size of the ctl_start registers of the display hw (platforms with no dpu-ipc)
  * @client_id_mask: bitmask for tracking registered client_ids
- * @clients_mask_lock: lock to synchronize access to the clients mask
+ * @clients_register_lock: lock to synchronize clients registration and deregistration
  * @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
@@ -316,9 +316,8 @@ struct hw_fence_driver_data {
 	void *ctl_start_ptr[HW_FENCE_MAX_DPU_LOOPBACK_CLIENTS];
 	uint32_t ctl_start_size[HW_FENCE_MAX_DPU_LOOPBACK_CLIENTS];
 
-	/* bitmask for tracking registered client_ids */
-	u64 client_id_mask;
-	struct mutex clients_mask_lock;
+	/* synchronize client_ids registration and deregistration */
+	struct mutex clients_register_lock;
 
 	/* table with registered client handles */
 	struct msm_hw_fence_client *clients[HW_FENCE_CLIENT_MAX];

+ 3 - 3
hw_fence/src/hw_fence_drv_debug.c

@@ -895,10 +895,10 @@ int process_validation_client_loopback(struct hw_fence_driver_data *drv_data,
 		return -EINVAL;
 	}
 
-	mutex_lock(&drv_data->clients_mask_lock);
+	mutex_lock(&drv_data->clients_register_lock);
 
 	if (!drv_data->clients[client_id]) {
-		mutex_unlock(&drv_data->clients_mask_lock);
+		mutex_unlock(&drv_data->clients_register_lock);
 		return -EINVAL;
 	}
 
@@ -912,7 +912,7 @@ int process_validation_client_loopback(struct hw_fence_driver_data *drv_data,
 	/* wake-up waiting client */
 	wake_up_all(&hw_fence_client->wait_queue);
 
-	mutex_unlock(&drv_data->clients_mask_lock);
+	mutex_unlock(&drv_data->clients_register_lock);
 
 	return 0;
 }

+ 2 - 3
hw_fence/src/hw_fence_drv_priv.c

@@ -624,10 +624,9 @@ void hw_fence_cleanup_client(struct hw_fence_driver_data *drv_data,
 	 *  allocation, then we will need to notify FenceCTL about the client that is
 	 *  going-away here.
 	 */
-	mutex_lock(&drv_data->clients_mask_lock);
-	drv_data->client_id_mask &= ~BIT(hw_fence_client->client_id);
+	mutex_lock(&drv_data->clients_register_lock);
 	drv_data->clients[hw_fence_client->client_id] = NULL;
-	mutex_unlock(&drv_data->clients_mask_lock);
+	mutex_unlock(&drv_data->clients_register_lock);
 
 	/* Deallocate client's object */
 	HWFNC_DBG_LUT("freeing client_id:%d\n", hw_fence_client->client_id);

+ 11 - 16
hw_fence/src/msm_hw_fence.c

@@ -35,27 +35,24 @@ void *msm_hw_fence_register(enum hw_fence_client_id client_id,
 			!mem_descriptor, client_id);
 		return ERR_PTR(-EINVAL);
 	}
+	/* Alloc client handle */
+	hw_fence_client =  kzalloc(sizeof(*hw_fence_client), GFP_KERNEL);
+	if (!hw_fence_client)
+		return ERR_PTR(-ENOMEM);
 
 	/* Avoid race condition if multiple-threads request same client at same time */
-	mutex_lock(&hw_fence_drv_data->clients_mask_lock);
-	if (hw_fence_drv_data->client_id_mask & BIT(client_id)) {
+	mutex_lock(&hw_fence_drv_data->clients_register_lock);
+	if (hw_fence_drv_data->clients[client_id]) {
 		HWFNC_ERR("client with id %d already registered\n", client_id);
-		mutex_unlock(&hw_fence_drv_data->clients_mask_lock);
+		mutex_unlock(&hw_fence_drv_data->clients_register_lock);
+		kfree(hw_fence_client);
 		return ERR_PTR(-EINVAL);
 	}
 
 	/* Mark client as registered */
-	hw_fence_drv_data->client_id_mask |= BIT(client_id);
-	mutex_unlock(&hw_fence_drv_data->clients_mask_lock);
+	hw_fence_drv_data->clients[client_id] = hw_fence_client;
+	mutex_unlock(&hw_fence_drv_data->clients_register_lock);
 
-	/* Alloc client handle */
-	hw_fence_client =  kzalloc(sizeof(*hw_fence_client), GFP_KERNEL);
-	if (!hw_fence_client) {
-		mutex_lock(&hw_fence_drv_data->clients_mask_lock);
-		hw_fence_drv_data->client_id_mask &= ~BIT(client_id);
-		mutex_unlock(&hw_fence_drv_data->clients_mask_lock);
-		return ERR_PTR(-ENOMEM);
-	}
 	hw_fence_client->client_id = client_id;
 	hw_fence_client->ipc_client_id = hw_fence_ipcc_get_client_id(hw_fence_drv_data, client_id);
 
@@ -74,8 +71,6 @@ void *msm_hw_fence_register(enum hw_fence_client_id client_id,
 
 	hw_fence_client->update_rxq = hw_fence_ipcc_needs_rxq_update(hw_fence_drv_data, client_id);
 
-	hw_fence_drv_data->clients[client_id] = hw_fence_client;
-
 	/* Alloc Client HFI Headers and Queues */
 	ret = hw_fence_alloc_client_resources(hw_fence_drv_data,
 		hw_fence_client, mem_descriptor);
@@ -401,7 +396,7 @@ static int msm_hw_fence_probe_init(struct platform_device *pdev)
 	if (rc)
 		goto error;
 
-	mutex_init(&hw_fence_drv_data->clients_mask_lock);
+	mutex_init(&hw_fence_drv_data->clients_register_lock);
 
 	/* set ready ealue so clients can register */
 	hw_fence_drv_data->resources_ready = true;