[PATCH 4/5] drm/amdgpu: support for DCC feature

Alex Deucher alexander.deucher at amd.com
Fri May 31 16:07:34 UTC 2024


From: Likun Gao <Likun.Gao at amd.com>

Deal with AMDGPU_GEM_CREATE_GFX12_DCC to set DCC bit
when needed.

Signed-off-by: Likun Gao <Likun.Gao at amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang at amd.com>
Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 6 ++++++
 drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c  | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 3b67809a59bc..1f22b4208729 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -334,6 +334,7 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
 		      AMDGPU_GEM_CREATE_VM_ALWAYS_VALID |
 		      AMDGPU_GEM_CREATE_EXPLICIT_SYNC |
 		      AMDGPU_GEM_CREATE_ENCRYPTED |
+		      AMDGPU_GEM_CREATE_GFX12_DCC |
 		      AMDGPU_GEM_CREATE_DISCARDABLE))
 		return -EINVAL;
 
@@ -341,6 +342,11 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
 	if (args->in.domains & ~AMDGPU_GEM_DOMAIN_MASK)
 		return -EINVAL;
 
+	if ((flags & AMDGPU_GEM_CREATE_GFX12_DCC) &&
+	    ((amdgpu_ip_version(adev, GC_HWIP, 0) < IP_VERSION(12, 0, 0)) ||
+	     !(args->in.domains & AMDGPU_GEM_DOMAIN_VRAM)))
+		return -EINVAL;
+
 	if (!amdgpu_is_tmz(adev) && (flags & AMDGPU_GEM_CREATE_ENCRYPTED)) {
 		DRM_NOTE_ONCE("Cannot allocate secure buffer since TMZ is disabled\n");
 		return -EINVAL;
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c
index 6b0b59f819c9..1896f9ed1ea9 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c
@@ -531,6 +531,9 @@ static void gmc_v12_0_get_vm_pte(struct amdgpu_device *adev,
 	is_system = (bo->tbo.resource->mem_type == TTM_PL_TT) ||
 		(bo->tbo.resource->mem_type == AMDGPU_PL_PREEMPT);
 
+	if (bo && bo->flags & AMDGPU_GEM_CREATE_GFX12_DCC)
+		*flags |= AMDGPU_PTE_DCC;
+
 	/* WA for HW bug */
 	if (is_system || ((bo_adev != adev) && coherent))
 		*flags = AMDGPU_PTE_MTYPE_GFX12(*flags, MTYPE_NC);
-- 
2.45.1



More information about the amd-gfx mailing list