Skip to content

Commit faa64f6

Browse files
frank9765alexdeucher
authored andcommitted
drm/amdgpu: add sdma 7.0 support for copy dcc buffer
1. Add dcc buffer flag for copy buffer 2. Add sdma 7.0 support copy dcc buffer Signed-off-by: Likun Gao <[email protected]> Signed-off-by: Frank Min <[email protected]> Reviewed-by: Hawking Zhang <[email protected]> Reviewed-by: Alex Deucher <[email protected]> Reviewed-by: Christian König <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 7c85e97 commit faa64f6

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
295295
struct amdgpu_res_cursor src_mm, dst_mm;
296296
struct dma_fence *fence = NULL;
297297
int r = 0;
298-
299298
uint32_t copy_flags = 0;
299+
struct amdgpu_bo *abo_src, *abo_dst;
300300

301301
if (!adev->mman.buffer_funcs_enabled) {
302302
DRM_ERROR("Trying to move memory with ring turned off.\n");
@@ -325,8 +325,14 @@ int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
325325
if (r)
326326
goto error;
327327

328+
abo_src = ttm_to_amdgpu_bo(src->bo);
329+
abo_dst = ttm_to_amdgpu_bo(dst->bo);
328330
if (tmz)
329331
copy_flags |= AMDGPU_COPY_FLAGS_TMZ;
332+
if (abo_src->flags & AMDGPU_GEM_CREATE_GFX12_DCC)
333+
copy_flags |= AMDGPU_COPY_FLAGS_READ_DECOMPRESSED;
334+
if (abo_dst->flags & AMDGPU_GEM_CREATE_GFX12_DCC)
335+
copy_flags |= AMDGPU_COPY_FLAGS_WRITE_COMPRESSED;
330336

331337
r = amdgpu_copy_buffer(ring, from, to, cur_size, resv,
332338
&next, false, true, copy_flags);

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ struct amdgpu_copy_mem {
112112
};
113113

114114
#define AMDGPU_COPY_FLAGS_TMZ (1 << 0)
115+
#define AMDGPU_COPY_FLAGS_READ_DECOMPRESSED (1 << 1)
116+
#define AMDGPU_COPY_FLAGS_WRITE_COMPRESSED (1 << 2)
115117

116118
int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size);
117119
void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev);
@@ -148,7 +150,6 @@ int amdgpu_ttm_init(struct amdgpu_device *adev);
148150
void amdgpu_ttm_fini(struct amdgpu_device *adev);
149151
void amdgpu_ttm_set_buffer_funcs_status(struct amdgpu_device *adev,
150152
bool enable);
151-
152153
int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t src_offset,
153154
uint64_t dst_offset, uint32_t byte_count,
154155
struct dma_resv *resv,

drivers/gpu/drm/amd/amdgpu/sdma_v6_0_0_pkt_open.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@
9191
#define SDMA_GCR_GLM_WB (1 << 4)
9292
#define SDMA_GCR_GL1_RANGE(x) (((x) & 0x3) << 2)
9393
#define SDMA_GCR_GLI_INV(x) (((x) & 0x3) << 0)
94+
95+
#define SDMA_DCC_DATA_FORMAT(x) ((x) & 0x3f)
96+
#define SDMA_DCC_NUM_TYPE(x) (((x) & 0x7) << 9)
97+
#define SDMA_DCC_READ_CM(x) (((x) & 0x3) << 16)
98+
#define SDMA_DCC_WRITE_CM(x) (((x) & 0x3) << 18)
99+
#define SDMA_DCC_MAX_COM(x) (((x) & 0x3) << 24)
100+
#define SDMA_DCC_MAX_UCOM(x) (((x) & 0x1) << 26)
101+
94102
/*
95103
** Definitions for SDMA_PKT_COPY_LINEAR packet
96104
*/

drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,13 +1568,22 @@ static void sdma_v7_0_emit_copy_buffer(struct amdgpu_ib *ib,
15681568
{
15691569
ib->ptr[ib->length_dw++] = SDMA_PKT_COPY_LINEAR_HEADER_OP(SDMA_OP_COPY) |
15701570
SDMA_PKT_COPY_LINEAR_HEADER_SUB_OP(SDMA_SUBOP_COPY_LINEAR) |
1571-
SDMA_PKT_COPY_LINEAR_HEADER_TMZ((copy_flags & AMDGPU_COPY_FLAGS_TMZ) ? 1 : 0);
1571+
SDMA_PKT_COPY_LINEAR_HEADER_TMZ((copy_flags & AMDGPU_COPY_FLAGS_TMZ) ? 1 : 0) |
1572+
SDMA_PKT_COPY_LINEAR_HEADER_CPV((copy_flags &
1573+
(AMDGPU_COPY_FLAGS_READ_DECOMPRESSED | AMDGPU_COPY_FLAGS_WRITE_COMPRESSED)) ? 1 : 0);
1574+
15721575
ib->ptr[ib->length_dw++] = byte_count - 1;
15731576
ib->ptr[ib->length_dw++] = 0; /* src/dst endian swap */
15741577
ib->ptr[ib->length_dw++] = lower_32_bits(src_offset);
15751578
ib->ptr[ib->length_dw++] = upper_32_bits(src_offset);
15761579
ib->ptr[ib->length_dw++] = lower_32_bits(dst_offset);
15771580
ib->ptr[ib->length_dw++] = upper_32_bits(dst_offset);
1581+
1582+
if ((copy_flags & (AMDGPU_COPY_FLAGS_READ_DECOMPRESSED | AMDGPU_COPY_FLAGS_WRITE_COMPRESSED)))
1583+
ib->ptr[ib->length_dw++] = SDMA_DCC_DATA_FORMAT(4) | SDMA_DCC_NUM_TYPE(4) |
1584+
((copy_flags & AMDGPU_COPY_FLAGS_READ_DECOMPRESSED) ? SDMA_DCC_READ_CM(2) : 0) |
1585+
((copy_flags & AMDGPU_COPY_FLAGS_WRITE_COMPRESSED) ? SDMA_DCC_WRITE_CM(1) : 0) |
1586+
SDMA_DCC_MAX_COM(1) | SDMA_DCC_MAX_UCOM(1);
15781587
}
15791588

15801589
/**
@@ -1603,7 +1612,6 @@ static const struct amdgpu_buffer_funcs sdma_v7_0_buffer_funcs = {
16031612
.copy_max_bytes = 0x400000,
16041613
.copy_num_dw = 7,
16051614
.emit_copy_buffer = sdma_v7_0_emit_copy_buffer,
1606-
16071615
.fill_max_bytes = 0x400000,
16081616
.fill_num_dw = 5,
16091617
.emit_fill_buffer = sdma_v7_0_emit_fill_buffer,

0 commit comments

Comments
 (0)