From 3fb9c29953b3287280971f9d6fecec72851bbd6b Mon Sep 17 00:00:00 2001 From: Jayaprakash Madisetty Date: Wed, 29 Dec 2021 17:32:03 +0530 Subject: [PATCH] disp: msm: fail commit if drm_gem_obj was found attached to a sec CB This change fails the drm_atomic_commit and avoids S2 translation fault if drm_gem_object is found attached to a secure context bank during non secure session. In the current codeflow, we are detaching the gem object from secure CB and reattaching it to non secure CB, but only S1 pagetables entries get modified and S2 pagetables entries are not corrected since hyp_unassign is not called with CP_PIXEL VMID which can only be done by client when buffer gets allocated. Change-Id: I62302064f96276ef82044ee88fb89e295fb96b4b Signed-off-by: Jayaprakash Madisetty --- msm/msm_gem.c | 13 ++++++++++++- msm/sde/sde_plane.c | 4 +++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/msm/msm_gem.c b/msm/msm_gem.c index f7fdc8eef7..823367fd09 100644 --- a/msm/msm_gem.c +++ b/msm/msm_gem.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. * Copyright (C) 2013 Red Hat * Author: Rob Clark @@ -445,6 +445,17 @@ static int msm_gem_get_iova_locked(struct drm_gem_object *obj, if ((dev && obj->import_attach) && ((dev != obj->import_attach->dev) || msm_obj->obj_dirty)) { + + if (of_device_is_compatible(dev->of_node, "qcom,smmu_sde_unsec") && + of_device_is_compatible(obj->import_attach->dev->of_node, + "qcom,smmu_sde_sec")) { + SDE_EVT32(obj->import_attach->dev, dev, msm_obj->sgt, + msm_obj->obj_dirty); + DRM_ERROR("gem obj found mapped to %s, now requesting map on %s", + dev_name(obj->import_attach->dev), dev_name(dev)); + return -EINVAL; + } + dmabuf = obj->import_attach->dmabuf; dma_map_attrs = obj->import_attach->dma_map_attrs; diff --git a/msm/sde/sde_plane.c b/msm/sde/sde_plane.c index 84f16322c4..d4a6e0f498 100644 --- a/msm/sde/sde_plane.c +++ b/msm/sde/sde_plane.c @@ -1991,7 +1991,9 @@ static int sde_plane_prepare_fb(struct drm_plane *plane, ret = msm_framebuffer_prepare(fb, pstate->aspace); if (ret) { - SDE_ERROR("failed to prepare framebuffer\n"); + SDE_ERROR("failed to prepare framebuffer fb:%d plane:%d pipe:%d ret:%d\n", + fb->base.id, plane->base.id, psde->pipe, ret); + SDE_EVT32(fb->base.id, plane->base.id, psde->pipe, ret, SDE_EVTLOG_ERROR); return ret; } }