From 8e00aa10d2c7675231af568c5cf7e3b7a3e69bdc Mon Sep 17 00:00:00 2001 From: Jordan Crouse Date: Fri, 7 Apr 2017 15:01:43 -0600 Subject: [PATCH] msm/drm: Add secure support to GPU IOMMU Add support for creating a secure domain in the GPU IOMMU. By default the secure domain is bound to context bank name "gfx3d_secure". Change-Id: Ic0dedbad19f69ec4175624dc80f2114bfda2e195 Signed-off-by: Jordan Crouse --- drivers/gpu/drm/msm/msm_iommu.c | 27 +++++++++++++++++++++++++++ drivers/gpu/drm/msm/msm_mmu.h | 1 + 2 files changed, 28 insertions(+) diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c index f5d89f76dda8..b52c4752c5fe 100644 --- a/drivers/gpu/drm/msm/msm_iommu.c +++ b/drivers/gpu/drm/msm/msm_iommu.c @@ -17,6 +17,7 @@ #include #include +#include #include "msm_drv.h" #include "msm_iommu.h" @@ -142,6 +143,20 @@ static int msm_iommu_attach_dynamic(struct msm_mmu *mmu, const char **names, return 0; } +static int msm_iommu_attach_secure(struct msm_mmu *mmu, const char **names, + int cnt) +{ + struct msm_iommu *iommu = to_msm_iommu(mmu); + int ret, vmid = VMID_CP_PIXEL; + + ret = iommu_domain_set_attr(iommu->domain, DOMAIN_ATTR_SECURE_VMID, + &vmid); + if (ret) + return ret; + + return iommu_attach_device(iommu->domain, mmu->dev); +} + static void msm_iommu_detach(struct msm_mmu *mmu) { struct msm_iommu *iommu = to_msm_iommu(mmu); @@ -250,6 +265,14 @@ static const struct msm_mmu_funcs user_funcs = { .disable = msm_iommu_clocks_disable, }; +static const struct msm_mmu_funcs secure_funcs = { + .attach = msm_iommu_attach_secure, + .detach = msm_iommu_detach, + .map = msm_iommu_map, + .unmap = msm_iommu_unmap, + .destroy = msm_iommu_destroy, +}; + static const struct msm_mmu_funcs dynamic_funcs = { .attach = msm_iommu_attach_dynamic, .detach = msm_iommu_detach_dynamic, @@ -270,6 +293,10 @@ static const struct { .cbname = "gfx3d_user", .funcs = &user_funcs, }, + [MSM_IOMMU_DOMAIN_SECURE] = { + .cbname = "gfx3d_secure", + .funcs = &secure_funcs + }, }; static struct msm_mmu *iommu_create(struct device *dev, diff --git a/drivers/gpu/drm/msm/msm_mmu.h b/drivers/gpu/drm/msm/msm_mmu.h index 8be3cefd686d..033370ccbe24 100644 --- a/drivers/gpu/drm/msm/msm_mmu.h +++ b/drivers/gpu/drm/msm/msm_mmu.h @@ -33,6 +33,7 @@ enum msm_mmu_domain_type { enum msm_iommu_domain_type { MSM_IOMMU_DOMAIN_DEFAULT, MSM_IOMMU_DOMAIN_USER, + MSM_IOMMU_DOMAIN_SECURE, }; struct msm_mmu_funcs {