AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lang Yu <Lang.Yu@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Alex Deucher <alexander.deucher@amd.com>,
	Huang Rui <ray.huang@amd.com>, Lang Yu <Lang.Yu@amd.com>,
	Christian Koenig <christian.koenig@amd.com>
Subject: [PATCH] drm/amdgpu: add workarounds for Raven VCN TMZ issue
Date: Fri, 4 Mar 2022 17:15:55 +0800	[thread overview]
Message-ID: <20220304091555.4094582-1-Lang.Yu@amd.com> (raw)

It is a hardware issue that VCN can't handle a GTT
backing stored TMZ buffer on Raven.

Move such a TMZ buffer to VRAM domain before command
submission.

Signed-off-by: Lang Yu <Lang.Yu@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 27 ++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index af12256e1bd3..66345f2ce6ba 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -393,6 +393,24 @@ void amdgpu_cs_report_moved_bytes(struct amdgpu_device *adev, u64 num_bytes,
 	spin_unlock(&adev->mm_stats.lock);
 }
 
+static int raven_vcn_tmz_quirks(struct amdgpu_cs_parser *p, struct amdgpu_bo *bo, uint32_t *domain)
+{
+	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
+	struct amdgpu_ring *ring = to_amdgpu_ring(p->entity->rq->sched);
+
+	if ((adev->asic_type == CHIP_RAVEN) &&
+	    (bo->flags & AMDGPU_GEM_CREATE_ENCRYPTED) &&
+	    (ring->funcs->type == AMDGPU_HW_IP_VCN_DEC ||
+	    ring->funcs->type == AMDGPU_HW_IP_VCN_ENC ||
+	    ring->funcs->type == AMDGPU_HW_IP_VCN_JPEG)) {
+		if (domain)
+			*domain = AMDGPU_GEM_DOMAIN_VRAM;
+		return 1;
+	}
+
+	return 0;
+}
+
 static int amdgpu_cs_bo_validate(void *param, struct amdgpu_bo *bo)
 {
 	struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
@@ -403,6 +421,7 @@ static int amdgpu_cs_bo_validate(void *param, struct amdgpu_bo *bo)
 		.resv = bo->tbo.base.resv
 	};
 	uint32_t domain;
+	bool need_retry = 1;
 	int r;
 
 	if (bo->tbo.pin_count)
@@ -431,6 +450,8 @@ static int amdgpu_cs_bo_validate(void *param, struct amdgpu_bo *bo)
 		domain = bo->allowed_domains;
 	}
 
+	raven_vcn_tmz_quirks(p, bo, &domain);
+
 retry:
 	amdgpu_bo_placement_from_domain(bo, domain);
 	r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
@@ -442,6 +463,12 @@ static int amdgpu_cs_bo_validate(void *param, struct amdgpu_bo *bo)
 
 	if (unlikely(r == -ENOMEM) && domain != bo->allowed_domains) {
 		domain = bo->allowed_domains;
+		if (raven_vcn_tmz_quirks(p, bo, &domain)) {
+			if (need_retry)
+				need_retry = 0;
+			else
+				return r;
+		}
 		goto retry;
 	}
 
-- 
2.25.1


             reply	other threads:[~2022-03-04  9:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-04  9:15 Lang Yu [this message]
2022-03-04  9:25 ` [PATCH] drm/amdgpu: add workarounds for Raven VCN TMZ issue Christian König
2022-03-04  9:38   ` Lang Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220304091555.4094582-1-Lang.Yu@amd.com \
    --to=lang.yu@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=ray.huang@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox