Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d1fdf14 authored by Veera Sundaram Sankaran's avatar Veera Sundaram Sankaran
Browse files

drm: msm: attach devices to dma_buf based on ION flags



Attach the appropriate secure/non-secure context-bank
device based on secure/non-secure buffers.
For secure-display and secure-camera-preview buffers,
attach it with the MDP device which does not have IOMMU.
These are direct S2-translation buffers and does not
require S1/S2 translations of IOMMU. This is required
as during the secure-camera-preview/secure-display usecases,
the secure-context bank is detached and might leave
the IOMMU ops in an unknown state.

Change-Id: I457865461e6b57fa90fa58884d78dc813ed5f7ec
Signed-off-by: default avatarVeera Sundaram Sankaran <veeras@codeaurora.org>
parent f5f31790
Loading
Loading
Loading
Loading
+20 −5
Original line number Diff line number Diff line
@@ -128,11 +128,26 @@ struct drm_gem_object *msm_gem_prime_import(struct drm_device *dev,
		goto fail_put;
	}

	domain = (flags & ION_FLAG_SECURE) ? MSM_SMMU_DOMAIN_SECURE :
						MSM_SMMU_DOMAIN_UNSECURE;
	if (kms && kms->funcs->get_address_space_device)
		attach_dev = kms->funcs->get_address_space_device(
							kms, domain);
	if (!kms || !kms->funcs->get_address_space_device) {
		DRM_ERROR("invalid kms ops\n");
		goto fail_put;
	}

	if (flags & ION_FLAG_SECURE) {
		if (flags & ION_FLAG_CP_PIXEL)
			attach_dev = kms->funcs->get_address_space_device(kms,
						MSM_SMMU_DOMAIN_SECURE);

		else if ((flags & ION_FLAG_CP_SEC_DISPLAY)
				|| (flags & ION_FLAG_CP_CAMERA_PREVIEW))
			attach_dev = dev->dev;
		else
			DRM_ERROR("invalid ion secure flag: 0x%x\n", flags);
	} else {
		attach_dev = kms->funcs->get_address_space_device(kms,
						MSM_SMMU_DOMAIN_UNSECURE);
	}

	if (!attach_dev) {
		DRM_ERROR("aspace device not found for domain:%d\n", domain);
		ret = -EINVAL;