[PATCH] drm/amdgpu: fix random data corruption for sdma 7
Lazar, Lijo
lijo.lazar at amd.com
Wed Oct 16 04:40:57 UTC 2024
On 10/16/2024 8:29 AM, Min, Frank wrote:
> [AMD Official Use Only - AMD Internal Distribution Only]
>
> [AMD Official Use Only - AMD Internal Distribution Only]
>
> From: Frank Min <Frank.Min at amd.com>
>
> There is random data corruption caused by const fill, this is caused by write compression mode not correclt configured.
>
> So correct compression mode for const fill.
>
> Signed-off-by: Frank Min <Frank.Min at amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/sdma_v6_0_0_pkt_open.h | 5 ++++-
> drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c | 3 ++-
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v6_0_0_pkt_open.h b/drivers/gpu/drm/amd/amdgpu/sdma_v6_0_0_pkt_open.h
> index d8cf830916b9..18e73057e6ba 100644
> --- a/drivers/gpu/drm/amd/amdgpu/sdma_v6_0_0_pkt_open.h
> +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v6_0_0_pkt_open.h
> @@ -116,11 +116,14 @@
> #define SDMA_PKT_COPY_LINEAR_HEADER_sub_op_shift 8 #define SDMA_PKT_COPY_LINEAR_HEADER_SUB_OP(x) (((x) & SDMA_PKT_COPY_LINEAR_HEADER_sub_op_mask) << SDMA_PKT_COPY_LINEAR_HEADER_sub_op_shift)
>
> -/*define for encrypt field*/
> +/*define for encrypt/compress field*/
> #define SDMA_PKT_COPY_LINEAR_HEADER_encrypt_offset 0
> #define SDMA_PKT_COPY_LINEAR_HEADER_encrypt_mask 0x00000001
> #define SDMA_PKT_COPY_LINEAR_HEADER_encrypt_shift 16
> +/*sdma6 use bit 16 for data encryption*/
> #define SDMA_PKT_COPY_LINEAR_HEADER_ENCRYPT(x) (((x) & SDMA_PKT_COPY_LINEAR_HEADER_encrypt_mask) << SDMA_PKT_COPY_LINEAR_HEADER_encrypt_shift)
> +/*sdma7 use bit 16 for dcc compression*/ #define
> +SDMA_PKT_COPY_LINEAR_HEADER_COMPRESS(x) (((x) &
> +SDMA_PKT_COPY_LINEAR_HEADER_encrypt_mask) <<
> +SDMA_PKT_COPY_LINEAR_HEADER_encrypt_shift)
>
This doesn't look like the right way. The confusion is there because it
uses SDMA_PKT_COPY_LINEAR_HEADER_OP instead of
SDMA_PKT_CONSTANT_FILL_HEADER_OP.
It's better to
1) Bring in sdma 7 packet header definition (Mixing with SDMA 6 is also
not good)
2) Use SDMA_PKT_CONSTANT_FILL_HEADER_OP instead of
SDMA_PKT_COPY_LINEAR_HEADER_OP
3) Use the correct bit mask/shift as defined in sdma 7 packet header
definition for const_fill.
Thanks,
Lijo
> /*define for tmz field*/
> #define SDMA_PKT_COPY_LINEAR_HEADER_tmz_offset 0 diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c
> index a8763496aed3..9181579ae6a1 100644
> --- a/drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c
> @@ -1724,7 +1724,8 @@ static void sdma_v7_0_emit_fill_buffer(struct amdgpu_ib *ib,
> uint64_t dst_offset,
> uint32_t byte_count)
> {
> - ib->ptr[ib->length_dw++] = SDMA_PKT_COPY_LINEAR_HEADER_OP(SDMA_OP_CONST_FILL);
> + ib->ptr[ib->length_dw++] = SDMA_PKT_COPY_LINEAR_HEADER_OP(SDMA_OP_CONST_FILL) |
> + SDMA_PKT_COPY_LINEAR_HEADER_COMPRESS(1);
> ib->ptr[ib->length_dw++] = lower_32_bits(dst_offset);
> ib->ptr[ib->length_dw++] = upper_32_bits(dst_offset);
> ib->ptr[ib->length_dw++] = src_data;
> --
> 2.43.0
>
More information about the amd-gfx
mailing list