Kaynağa Gözat

disp: msm: sde: avoid VMID_TVM check during buf import in trusted-vm

Both trusted-vm and secure-camera preview buffers uses the same
VMID_TVM. In primary-vm, the check is used to determine the camera
preview usecase and attach it to the correct device. This is not
necessary for trusted-vm as it can default to nested trusted-vm
context bank. Avoid the check while its in trusted-vm.

Change-Id: I4391a4a1da9dca5d1f4b1719733b8d4edc1900a8
Signed-off-by: Veera Sundaram Sankaran <[email protected]>
Veera Sundaram Sankaran 2 yıl önce
ebeveyn
işleme
428a27027d
3 değiştirilmiş dosya ile 31 ekleme ve 12 silme
  1. 14 11
      msm/msm_gem_prime.c
  2. 2 1
      msm/msm_kms.h
  3. 15 0
      msm/sde/sde_kms.c

+ 14 - 11
msm/msm_gem_prime.c

@@ -157,19 +157,22 @@ struct drm_gem_object *msm_gem_prime_import(struct drm_device *dev,
 	}
 
 #if (KERNEL_VERSION(6, 1, 0) <= LINUX_VERSION_CODE)
-	ret = mem_buf_dma_buf_copy_vmperm(dma_buf, &vmid_list, &perms_list, &nelems);
-	if (ret) {
-		DRM_ERROR("get vmid list failure, ret:%d", ret);
-		goto fail_put;
-	}
+	/* avoid VMID checks in trusted-vm */
+	if (!kms->funcs->in_trusted_vm || !kms->funcs->in_trusted_vm(kms)) {
+		ret = mem_buf_dma_buf_copy_vmperm(dma_buf, &vmid_list, &perms_list, &nelems);
+		if (ret) {
+			DRM_ERROR("get vmid list failure, ret:%d", ret);
+			goto fail_put;
+		}
 
-	for (i = 0; i < nelems; i++)
-		if (vmid_list[i] == VMID_TVM)
-			is_nested_sec_vmid = true;
+		for (i = 0; i < nelems; i++)
+			if (vmid_list[i] == VMID_TVM)
+				is_nested_sec_vmid = true;
 
-	/* mem_buf_dma_buf_copy_vmperm uses kmemdup, do kfree to free up the memory */
-	kfree(vmid_list);
-	kfree(perms_list);
+		/* mem_buf_dma_buf_copy_vmperm uses kmemdup, do kfree to free up the memory */
+		kfree(vmid_list);
+		kfree(perms_list);
+	}
 #endif
 
 	/*

+ 2 - 1
msm/msm_kms.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
  * Copyright (C) 2013 Red Hat
  * Author: Rob Clark <[email protected]>
@@ -140,6 +140,7 @@ struct msm_kms_funcs {
 	/* topology dsc information */
 	int (*get_dsc_count)(const struct msm_kms *kms,
 			u32 hdisplay, u32 *num_dsc);
+	bool (*in_trusted_vm)(const struct msm_kms *kms);
 };
 
 struct msm_kms {

+ 15 - 0
msm/sde/sde_kms.c

@@ -3857,6 +3857,20 @@ static int sde_kms_get_dsc_count(const struct msm_kms *kms,
 	return 0;
 }
 
+static bool sde_kms_in_trusted_vm(const struct msm_kms *kms)
+{
+	struct sde_kms *sde_kms;
+
+	if (!kms) {
+		SDE_ERROR("invalid kms\n");
+		return false;
+	}
+
+	sde_kms = to_sde_kms(kms);
+
+	return sde_in_trusted_vm(sde_kms);
+}
+
 static int _sde_kms_null_commit(struct drm_device *dev,
 		struct drm_encoder *enc)
 {
@@ -4295,6 +4309,7 @@ static const struct msm_kms_funcs kms_funcs = {
 	.trigger_null_flush = sde_kms_trigger_null_flush,
 	.get_mixer_count = sde_kms_get_mixer_count,
 	.get_dsc_count = sde_kms_get_dsc_count,
+	.in_trusted_vm = sde_kms_in_trusted_vm,
 };
 
 static int _sde_kms_mmu_destroy(struct sde_kms *sde_kms)