ソースを参照

Merge d5bed2898aa514562a4fb6a5a0ae2732833a54f9 on remote branch

Change-Id: Ia0eade950e24b3a3fbefc0a0bd383fd2801285db
Linux Build Service Account 1 年間 前
コミット
04a76aa891
2 ファイル変更20 行追加8 行削除
  1. 19 7
      msm/synx/synx.c
  2. 1 1
      msm/synx/synx_util.c

+ 19 - 7
msm/synx/synx.c

@@ -2009,6 +2009,7 @@ static int synx_handle_import(struct synx_private_ioctl_arg *k_ioctl,
 {
 	struct synx_import_info import_info;
 	struct synx_import_params params = {0};
+	int result = SYNX_SUCCESS;
 
 	if (k_ioctl->size != sizeof(import_info))
 		return -SYNX_INVALID;
@@ -2018,28 +2019,32 @@ static int synx_handle_import(struct synx_private_ioctl_arg *k_ioctl,
 			k_ioctl->size))
 		return -EFAULT;
 
-	if (import_info.flags & SYNX_IMPORT_SYNX_FENCE)
-		params.indv.fence = &import_info.synx_obj;
-	else if (import_info.flags & SYNX_IMPORT_DMA_FENCE)
+	if (import_info.flags & SYNX_IMPORT_DMA_FENCE)
 		params.indv.fence =
 			sync_file_get_fence(import_info.desc.id[0]);
+	else if (import_info.flags & SYNX_IMPORT_SYNX_FENCE)
+		params.indv.fence = &import_info.synx_obj;
 
 	params.type = SYNX_IMPORT_INDV_PARAMS;
 	params.indv.flags = import_info.flags;
 	params.indv.new_h_synx = &import_info.new_synx_obj;
 
 	if (synx_import(session, &params))
-		return -SYNX_INVALID;
+		result = -SYNX_INVALID;
 
+	// Fence needs to be put irresepctive of import status
 	if (import_info.flags & SYNX_IMPORT_DMA_FENCE)
 		dma_fence_put(params.indv.fence);
 
+	if (result != SYNX_SUCCESS)
+		return result;
+
 	if (copy_to_user(u64_to_user_ptr(k_ioctl->ioctl_ptr),
 			&import_info,
 			k_ioctl->size))
 		return -EFAULT;
 
-	return SYNX_SUCCESS;
+	return result;
 }
 
 static int synx_handle_import_arr(
@@ -2082,12 +2087,19 @@ static int synx_handle_import_arr(
 	while (idx < arr_info.num_objs) {
 		params.new_h_synx = &arr[idx].new_synx_obj;
 		params.flags = arr[idx].flags;
-		if (arr[idx].flags & SYNX_IMPORT_SYNX_FENCE)
-			params.fence = &arr[idx].synx_obj;
+
 		if (arr[idx].flags & SYNX_IMPORT_DMA_FENCE)
 			params.fence =
 				sync_file_get_fence(arr[idx].desc.id[0]);
+		else if (arr[idx].flags & SYNX_IMPORT_SYNX_FENCE)
+			params.fence = &arr[idx].synx_obj;
+
 		rc = synx_native_import_indv(client, &params);
+
+		// Fence needs to be put irresepctive of import status
+		if (arr[idx].flags & SYNX_IMPORT_DMA_FENCE)
+			dma_fence_put(params.fence);
+
 		if (rc != SYNX_SUCCESS)
 			break;
 		idx++;

+ 1 - 1
msm/synx/synx_util.c

@@ -53,7 +53,7 @@ int synx_util_init_coredata(struct synx_coredata *synx_obj,
 		strlcpy(synx_obj->name, params->name, sizeof(synx_obj->name));
 
 	if (params->flags & SYNX_CREATE_DMA_FENCE) {
-		fence = params->fence;
+		fence = (struct dma_fence *)params->fence;
 		if (IS_ERR_OR_NULL(fence)) {
 			dprintk(SYNX_ERR, "invalid external fence\n");
 			goto free;