From 68b75aac24fd6fc56155bcbd9218c83ba9a1b5ab Mon Sep 17 00:00:00 2001 From: Veera Sundaram Sankaran Date: Wed, 4 Mar 2020 11:56:18 -0800 Subject: [PATCH] disp: msm: use FB_NON_SEC_DIR_TRANS plane hint for TUI VM buffers Add plane buffer flag to get the correct aspace during TUI VM usecase. FB_NON_SEC_DIR_TRANS plane flag is set by user-mode to indicate S2-only non-secure buffer in TUI VM. Return the default drm device when SMMU is not available during get_aspace_device to make the working seamless with/without SMMU. Change-Id: I158dc17ba51ff4b2f302d3e7017db8ab3cfe2b84 Signed-off-by: Veera Sundaram Sankaran --- msm/msm_gem.c | 6 ------ msm/sde/sde_crtc.c | 8 ++++++++ msm/sde/sde_kms.c | 28 ++++++++++++++++++++++++---- msm/sde/sde_plane.c | 1 + 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/msm/msm_gem.c b/msm/msm_gem.c index e83f4eb861..d9cd8c9f73 100644 --- a/msm/msm_gem.c +++ b/msm/msm_gem.c @@ -1259,12 +1259,6 @@ struct drm_gem_object *msm_gem_import(struct drm_device *dev, int ret; unsigned long flags = 0; - /* if we don't have IOMMU, don't bother pretending we can import: */ - if (!iommu_present(&platform_bus_type)) { - dev_err(dev->dev, "cannot import without IOMMU\n"); - return ERR_PTR(-EINVAL); - } - size = PAGE_ALIGN(dmabuf->size); ret = msm_gem_new_impl(dev, size, MSM_BO_WC, dmabuf->resv, &obj, diff --git a/msm/sde/sde_crtc.c b/msm/sde/sde_crtc.c index 56f45d37b4..ea5569ee98 100644 --- a/msm/sde/sde_crtc.c +++ b/msm/sde/sde_crtc.c @@ -1726,6 +1726,8 @@ int sde_crtc_find_plane_fb_modes(struct drm_crtc *crtc, case SDE_DRM_FB_SEC_DIR_TRANS: (*fb_sec_dir)++; break; + case SDE_DRM_FB_NON_SEC_DIR_TRANS: + break; default: SDE_ERROR("Error: Plane[%d], fb_trans_mode:%d", DRMID(plane), mode); @@ -1773,6 +1775,8 @@ int sde_crtc_state_find_plane_fb_modes(struct drm_crtc_state *state, case SDE_DRM_FB_SEC_DIR_TRANS: (*fb_sec_dir)++; break; + case SDE_DRM_FB_NON_SEC_DIR_TRANS: + break; default: SDE_ERROR("Error: Plane[%d], fb_trans_mode:%d", DRMID(plane), mode); @@ -1927,6 +1931,10 @@ int sde_crtc_get_secure_transition_ops(struct drm_crtc *crtc, old_valid_fb, post_commit, &ops); break; + case SDE_DRM_FB_NON_SEC_DIR_TRANS: + ops = 0; + break; + default: SDE_ERROR("crtc%d: invalid plane fb_mode %d\n", DRMID(crtc), translation_mode); diff --git a/msm/sde/sde_kms.c b/msm/sde/sde_kms.c index afd6961aca..c6b8168ad8 100644 --- a/msm/sde/sde_kms.c +++ b/msm/sde/sde_kms.c @@ -2147,11 +2147,31 @@ _sde_kms_get_address_space(struct msm_kms *kms, static struct device *_sde_kms_get_address_space_device(struct msm_kms *kms, unsigned int domain) { - struct msm_gem_address_space *aspace = - _sde_kms_get_address_space(kms, domain); + struct sde_kms *sde_kms; + struct device *dev; + struct msm_gem_address_space *aspace; - return (aspace && aspace->domain_attached) ? - msm_gem_get_aspace_device(aspace) : NULL; + if (!kms) { + SDE_ERROR("invalid kms\n"); + return NULL; + } + + sde_kms = to_sde_kms(kms); + if (!sde_kms || !sde_kms->dev || !sde_kms->dev->dev) { + SDE_ERROR("invalid params\n"); + return NULL; + } + + /* return default device, when IOMMU is not present */ + if (!iommu_present(&platform_bus_type)) { + dev = sde_kms->dev->dev; + } else { + aspace = _sde_kms_get_address_space(kms, domain); + dev = (aspace && aspace->domain_attached) ? + msm_gem_get_aspace_device(aspace) : NULL; + } + + return dev; } static void _sde_kms_post_open(struct msm_kms *kms, struct drm_file *file) diff --git a/msm/sde/sde_plane.c b/msm/sde/sde_plane.c index 546461936f..e306e97bb1 100644 --- a/msm/sde/sde_plane.c +++ b/msm/sde/sde_plane.c @@ -701,6 +701,7 @@ static int _sde_plane_get_aspace( if (!aspace) return -EINVAL; break; + case SDE_DRM_FB_NON_SEC_DIR_TRANS: case SDE_DRM_FB_SEC_DIR_TRANS: *aspace = NULL; break;