disp: msm: perform delayed buf attach during secure transitions

While transitioning from secure usecases, the secure
context bank is attached back only during the commit
phase. This leads to invalid secure context-bank device
issue, when the prime_to_fd call is made for the next
frame. Avoid it, by attaching to default drm device
during the prime_to_fd call and reattach it to the
secure context-bank device at the delayed import time.

Change-Id: I43e6da7f117f20746943a48b5f2657e9ae2947ea
Signed-off-by: Veera Sundaram Sankaran <veeras@codeaurora.org>
This commit is contained in:
Veera Sundaram Sankaran
2019-12-13 12:03:29 -08:00
committed by Gerrit - the friendly Code Review server
parent e7f3931297
commit a9574eb8c2
2 changed files with 45 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
* Copyright (C) 2013 Red Hat * Copyright (C) 2013 Red Hat
* Author: Rob Clark <robdclark@gmail.com> * Author: Rob Clark <robdclark@gmail.com>
* *
@@ -416,9 +416,36 @@ static int msm_gem_get_iova_locked(struct drm_gem_object *obj,
if (!vma) { if (!vma) {
struct page **pages; struct page **pages;
struct device *dev;
struct dma_buf *dmabuf;
bool reattach = false;
dev = msm_gem_get_aspace_device(aspace);
if (dev && obj->import_attach &&
(dev != obj->import_attach->dev)) {
dmabuf = obj->import_attach->dmabuf;
DRM_DEBUG("detach nsec-dev:%pK attach sec-dev:%pK\n",
obj->import_attach->dev, dev);
SDE_EVT32(obj->import_attach->dev, dev, msm_obj->sgt);
if (msm_obj->sgt)
dma_buf_unmap_attachment(obj->import_attach,
msm_obj->sgt, DMA_BIDIRECTIONAL);
dma_buf_detach(dmabuf, obj->import_attach);
obj->import_attach = dma_buf_attach(dmabuf, dev);
if (IS_ERR(obj->import_attach)) {
DRM_ERROR("dma_buf_attach failure, err=%ld\n",
PTR_ERR(obj->import_attach));
goto unlock;
}
reattach = true;
}
/* perform delayed import for buffers without existing sgt */ /* perform delayed import for buffers without existing sgt */
if (((msm_obj->flags & MSM_BO_EXTBUF) && !(msm_obj->sgt))) { if (((msm_obj->flags & MSM_BO_EXTBUF) && !(msm_obj->sgt))
|| reattach) {
ret = msm_gem_delayed_import(obj); ret = msm_gem_delayed_import(obj);
if (ret) { if (ret) {
DRM_ERROR("delayed dma-buf import failed %d\n", DRM_ERROR("delayed dma-buf import failed %d\n",

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
* Copyright (C) 2013 Red Hat * Copyright (C) 2013 Red Hat
* Author: Rob Clark <robdclark@gmail.com> * Author: Rob Clark <robdclark@gmail.com>
* *
@@ -133,15 +133,26 @@ struct drm_gem_object *msm_gem_prime_import(struct drm_device *dev,
} }
if (flags & ION_FLAG_SECURE) { if (flags & ION_FLAG_SECURE) {
if (flags & ION_FLAG_CP_PIXEL) if (flags & ION_FLAG_CP_PIXEL) {
attach_dev = kms->funcs->get_address_space_device(kms, attach_dev = kms->funcs->get_address_space_device(kms,
MSM_SMMU_DOMAIN_SECURE); MSM_SMMU_DOMAIN_SECURE);
/*
else if ((flags & ION_FLAG_CP_SEC_DISPLAY) * While transitioning from secure use-cases, the
|| (flags & ION_FLAG_CP_CAMERA_PREVIEW)) * secure-cb might still not be attached back, while
* the prime_fd_to_handle call is made for the next
* frame. Attach those buffers to default drm device
* and reattaching with the correct context-bank
* will be handled in msm_gem_delayed_import
*/
if (!attach_dev)
attach_dev = dev->dev; attach_dev = dev->dev;
else
} 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%lx\n", flags); DRM_ERROR("invalid ion secure flag: 0x%lx\n", flags);
}
} else { } else {
attach_dev = kms->funcs->get_address_space_device(kms, attach_dev = kms->funcs->get_address_space_device(kms,
MSM_SMMU_DOMAIN_UNSECURE); MSM_SMMU_DOMAIN_UNSECURE);