test/amdgpu: implement jpeg queue tests
Subsystems (2)
PATCH 4/4 test/amdgpu: implement jpeg queue tests
The jpeg queue tests are used to verify the resiliency of GPU. If there is job timeout on a jpeg queue, driver could only reset this jpeg queue with other queues (like gfx/vcn/jpeg queues) unaffected.
Brief description of queue tests:
1. Query the queue sched mask info and select one ready queue. If there are multiple queues, the following steps will be executed on per ready queue (1: ready, 0: not ready).
2. Insert invalid content into the normal decode flow and check the result of jobs submit.
If submit returns without error, there is no job timeout. If submit returns with error, there is job timeout and driver will reset queue.
--- tests/amdgpu/amd_jpeg_queue.c | 115 ++++++++++++++++++++++++++++++++++ tests/amdgpu/meson.build | 1 + 2 files changed, 116 insertions(+) create mode 100644 tests/amdgpu/amd_jpeg_queue.c
tests/amdgpu/amd_jpeg_queue.c new file +115 -0
@@ -0,0 +1,115 @@ +// SPDX-License-Identifier: MIT +// Copyright 2025 Advanced Micro Devices, Inc. + +#include "lib/amdgpu/amd_jpeg_shared.h" +#include "lib/amdgpu/amd_ip_blocks.h" + +static bool +is_queue_tests_enable (amdgpu_device_handle device_handle, +struct mmd_shared_context *context,struct pci_addr *pci) +{ +bool ret =is_jpeg_tests_enable (device_handle, context); + +if (!ret) +return false; + +if (!is_reset_enable (AMD_IP_VCN_JPEG ,AMDGPU_RESET_TYPE_PER_QUEUE , pci)) { +igt_info ("The ASIC does NOT support jpeg queue reset\n" ); +return false; + }else if (context->vcn_ip_version_major <4 ) { +igt_info ("The vcn ip does NOT support jpeg queue reset\n" ); +return false; + } + +return ret; +} + +static int +jpeg_queue_decode (amdgpu_device_handle device_handle, +struct mmd_shared_context *shared_context,int err) +{ +struct amdgpu_mmd_bo dec_buf; +int size, ret; +uint32_t idx; +struct mmd_context acontext = {0 }; +struct mmd_context *context = &acontext; +int64_t dec_buf_addr; + + ret =mmd_context_init (device_handle, context); +if (ret) { +igt_info ("mmd_context_init fail!\n" ); +return ret; + } + + size =32 *1024 ;/* 8K bitstream + 24K output */ + context->num_resources =0 ; +alloc_resource (device_handle, &dec_buf, size,AMDGPU_GEM_DOMAIN_VRAM ); + context->resources[context->num_resources++] = dec_buf.handle; + context->resources[context->num_resources++] = context->ib_handle; + ret =amdgpu_bo_cpu_map (dec_buf.handle, (void **)&dec_buf.ptr); +if (ret) { +igt_info ("amdgpu_bo_cpu_map map dec_buf fail!\n" ); + goto err_handle; + } +memcpy (dec_buf.ptr, jpeg_bitstream,sizeof (jpeg_bitstream)); + + idx =0 ; + dec_buf_addr = dec_buf.addr; +if (err ==INVALID_DECODER_BITSTREAM_BUFFER ) + dec_buf_addr =0xdead ; + +send_cmd_bitstream_direct (context, dec_buf_addr, &idx); +send_cmd_target_direct (context, dec_buf_addr + (size /4 ), &idx); + +amdgpu_bo_cpu_unmap (dec_buf.handle); +submit (device_handle, context, idx,AMDGPU_HW_IP_VCN_JPEG ); + +/* +* For job timeout test case, submit job will return error, +* here needn't return error. +*/ + ret =0 ; + +err_handle: +free_resource (&dec_buf); +mmd_context_clean (device_handle, context); +return ret; +} + +igt_main +{ +amdgpu_device_handle device; +struct mmd_shared_context shared_context = {}; +int fd =-1 ; +uint32_t major, minor; +int err; +struct pci_addr pci; + + igt_fixture { + fd =drm_open_driver (DRIVER_AMDGPU ); + err =amdgpu_device_initialize (fd, &major, &minor, &device); +igt_require (err ==0 ); +igt_info ("Initialized amdgpu, driver version %d.%d\n" , + major, minor); + err =mmd_shared_context_init (device, &shared_context); +igt_require (err ==0 ); + +igt_skip_on (get_pci_addr_from_fd (fd, &pci)); +igt_info ("PCI Address: domain %04x, bus %02x, device %02x, function %02x\n" , + pci.domain, pci.bus, pci.device, pci.function); +igt_skip_on (!is_queue_tests_enable (device, &shared_context, &pci)); + shared_context.ip_type =AMD_IP_VCN_JPEG ; + } + +igt_describe ("Test whether jpeg queue" ); + igt_subtest("jpeg-decoder-queue-reset") { + err = (int )INVALID_DECODER_BITSTREAM_BUFFER ; +mm_queue_test_helper (device, &shared_context, jpeg_queue_decode, err, &pci); + } + + igt_fixture { +amdgpu_device_deinitialize (device); +drm_close_driver (fd); + } + +}
tests/amdgpu/meson.build +1 -0
@@ -19,6 +19,7 @@ if libdrm_amdgpu.found() 'amd_ilr', 'amd_info', 'amd_jpeg_dec', + 'amd_jpeg_queue', 'amd_link_settings', 'amd_max_bpc', 'amd_mem_leak',
Signature · 1 line
2.34.1
PATCH 1/4 lib/amdgpu: implement vcn/jpeg queue tests
Query the vcn/jpeg queue reset mask to check if driver has supported queue reset.
Add common api to query the queue sched mask info and select the ready queue (1: ready, 0: not ready), then execute test on the selected queue.
If there are multiple queues, test will be executed on per ready queue.
Queue test shall be independent, because some vcn ips do not support queue reset. And decode/encode normal tests and queue tests have some same functions, we move the duplicated code to the shared lib files.
--- lib/amdgpu/amd_ip_blocks.c | 4 + lib/amdgpu/amd_jpeg_shared.c | 191 +++++++++++++++++++++++++++++++++++ lib/amdgpu/amd_jpeg_shared.h | 145 ++++++++++++++++++++++++++ lib/amdgpu/amd_mmd_shared.c | 62 +++++++++++- lib/amdgpu/amd_mmd_shared.h | 19 ++++ lib/amdgpu/amd_vcn_shared.c | 191 +++++++++++++++++++++++++++++++++++ lib/amdgpu/amd_vcn_shared.h | 144 ++++++++++++++++++++++++++ lib/meson.build | 2 + 8 files changed, 756 insertions(+), 2 deletions(-) create mode 100644 lib/amdgpu/amd_jpeg_shared.c create mode 100644 lib/amdgpu/amd_jpeg_shared.h create mode 100644 lib/amdgpu/amd_vcn_shared.c create mode 100644 lib/amdgpu/amd_vcn_shared.h
lib/amdgpu/amd_ip_blocks.c +4 -0
@@ -1050,6 +1050,10 @@ is_reset_enable(enum amd_ip_block_type ip_type, uint32_t reset_type, const strucsnprintf (reset_mask,sizeof (reset_mask) -1 ,"gfx_reset_mask" ); else if (ip_type == AMD_IP_COMPUTE) snprintf(reset_mask, sizeof(reset_mask) - 1, "compute_reset_mask"); + else if (ip_type == AMD_IP_VCN_UNIFIED) + snprintf(reset_mask, sizeof(reset_mask) - 1, "vcn_reset_mask"); + else if (ip_type == AMD_IP_VCN_JPEG) + snprintf(reset_mask, sizeof(reset_mask) - 1, "jpeg_reset_mask"); else snprintf(reset_mask, sizeof(reset_mask) - 1, "sdma_reset_mask");
lib/amdgpu/amd_jpeg_shared.c new file +191 -0
192 lines not on this page · raw message
lib/amdgpu/amd_jpeg_shared.h new file +145 -0
146 lines not on this page · raw message
lib/amdgpu/amd_mmd_shared.c +60 -2
66 lines not on this page · raw message
lib/amdgpu/amd_mmd_shared.h +19 -0
@@ -7,6 +7,7 @@#include "amdgpu_drm.h" #include "igt.h" +#include "amd_ip_blocks.h" #include "amd_mmd_decode_messages.h" #include "amd_mmd_util_math.h" #include "amd_memory.h"
@@ -27,6 +28,17 @@#define IB_SIZE 4096#define MAX_RESOURCES 16 +enum decoder_error_type { +INVALID_DECODER_IB_TYPE =0 , +INVALID_DECODER_IB_SIZE , +INVALID_DECODER_DPB_BUFFER , +INVALID_DECODER_CODEC_PARAM , +INVALID_DECODER_TARGET_BUFFER , +INVALID_DECODER_BITSTREAM , +INVALID_DECODER_BITSTREAM_BUFFER , +INVALID_DECODER_NONE , +}; +struct mmd_shared_context {uint32_t family_id;uint32_t chip_id;
@@ -51,6 +63,7 @@ struct mmd_shared_context {uint32_t vpe_ip_version_major;uint32_t vpe_ip_version_minor;bool vpe_ring; +enum amd_ip_block_type ip_type; };struct mmd_context {
@@ -117,3 +130,9 @@ alloc_resource(amdgpu_device_handle device_handle,void free_resource (struct amdgpu_mmd_bo *mmd_bo); + +typedef int (*mm_test_callback ) (amdgpu_device_handle device_handle,struct mmd_shared_context *context, +int err); +int +mm_queue_test_helper (amdgpu_device_handle device_handle,struct mmd_shared_context *context, +mm_test_callback test,int err_type,const struct pci_addr *pci);
lib/amdgpu/amd_vcn_shared.c new file +191 -0
192 lines not on this page · raw message
lib/amdgpu/amd_vcn_shared.h new file +144 -0
145 lines not on this page · raw message
lib/meson.build +2 -0
@@ -168,6 +168,8 @@ if libdrm_amdgpu.found() 'amdgpu/amd_cp_dma.c', 'amdgpu/amd_mem_leak.c', 'amdgpu/amd_mmd_shared.c', + 'amdgpu/amd_jpeg_shared.c', + 'amdgpu/amd_vcn_shared.c', 'amdgpu/amd_userq.c' ] if libdrm_amdgpu.version().version_compare('> 2.4.99')
Signature · 1 line
2.34.1
PATCH 2/4 test/amdgpu: to implement vcn/jpeg queue tests
In reply to Ruili JiRemove the duplicated code for vcn/jpeg tests.
--- tests/amdgpu/amd_jpeg_dec.c | 306 +------------------------------ tests/amdgpu/amd_vcn.c | 347 +++--------------------------------- 2 files changed, 27 insertions(+), 626 deletions(-)
tests/amdgpu/amd_jpeg_dec.c +1 -305
@@ -2,205 +2,7 @@// Copyright 2023 Advanced Micro Devices, Inc. // Copyright 2017 Advanced Micro Devices, Inc. -#include "lib/amdgpu/amd_mmd_shared.h" - -/* jpeg registers */ -#define mmUVD_JPEG_CNTL 0x0200 -#define mmUVD_JPEG_RB_BASE 0x0201 -#define mmUVD_JPEG_RB_WPTR 0x0202 -#define mmUVD_JPEG_RB_RPTR 0x0203 -#define mmUVD_JPEG_RB_SIZE 0x0204 -#define mmUVD_JPEG_TIER_CNTL2 0x021a -#define mmUVD_JPEG_UV_TILING_CTRL 0x021c -#define mmUVD_JPEG_TILING_CTRL 0x021e -#define mmUVD_JPEG_OUTBUF_RPTR 0x0220 -#define mmUVD_JPEG_OUTBUF_WPTR 0x0221 -#define mmUVD_JPEG_PITCH 0x0222 -#define mmUVD_JPEG_INT_EN 0x0229 -#define mmUVD_JPEG_UV_PITCH 0x022b -#define mmUVD_JPEG_INDEX 0x023e -#define mmUVD_JPEG_DATA 0x023f -#define mmUVD_LMI_JPEG_WRITE_64BIT_BAR_HIGH 0x0438 -#define mmUVD_LMI_JPEG_WRITE_64BIT_BAR_LOW 0x0439 -#define mmUVD_LMI_JPEG_READ_64BIT_BAR_HIGH 0x045a -#define mmUVD_LMI_JPEG_READ_64BIT_BAR_LOW 0x045b -#define mmUVD_CTX_INDEX 0x0528 -#define mmUVD_CTX_DATA 0x0529 -#define mmUVD_SOFT_RESET 0x05a0 - -#define vcnipUVD_JPEG_DEC_SOFT_RST 0x402f -#define vcnipUVD_JRBC_IB_COND_RD_TIMER 0x408e -#define vcnipUVD_JRBC_IB_REF_DATA 0x408f -#define vcnipUVD_LMI_JPEG_READ_64BIT_BAR_HIGH 0x40e1 -#define vcnipUVD_LMI_JPEG_READ_64BIT_BAR_LOW 0x40e0 -#define vcnipUVD_JPEG_RB_BASE 0x4001 -#define vcnipUVD_JPEG_RB_SIZE 0x4004 -#define vcnipUVD_JPEG_RB_WPTR 0x4002 -#define vcnipUVD_JPEG_PITCH 0x401f -#define vcnipUVD_JPEG_UV_PITCH 0x4020 -#define vcnipJPEG_DEC_ADDR_MODE 0x4027 -#define vcnipJPEG_DEC_Y_GFX10_TILING_SURFACE 0x4024 -#define vcnipJPEG_DEC_UV_GFX10_TILING_SURFACE 0x4025 -#define vcnipUVD_LMI_JPEG_WRITE_64BIT_BAR_HIGH 0x40e3 -#define vcnipUVD_LMI_JPEG_WRITE_64BIT_BAR_LOW 0x40e2 -#define vcnipUVD_JPEG_INDEX 0x402c -#define vcnipUVD_JPEG_DATA 0x402d -#define vcnipUVD_JPEG_TIER_CNTL2 0x400f -#define vcnipUVD_JPEG_OUTBUF_RPTR 0x401e -#define vcnipUVD_JPEG_OUTBUF_CNTL 0x401c -#define vcnipUVD_JPEG_INT_EN 0x400a -#define vcnipUVD_JPEG_CNTL 0x4000 -#define vcnipUVD_JPEG_RB_RPTR 0x4003 -#define vcnipUVD_JPEG_OUTBUF_WPTR 0x401d - -#define vcnipUVD_JPEG_DEC_SOFT_RST_1 0x4051 -#define vcnipUVD_JPEG_PITCH_1 0x4043 -#define vcnipUVD_JPEG_UV_PITCH_1 0x4044 -#define vcnipJPEG_DEC_ADDR_MODE_1 0x404B -#define vcnipUVD_JPEG_TIER_CNTL2_1 0x400E -#define vcnipUVD_JPEG_OUTBUF_CNTL_1 0x4040 -#define vcnipUVD_JPEG_OUTBUF_WPTR_1 0x4041 -#define vcnipUVD_JPEG_OUTBUF_RPTR_1 0x4042 -#define vcnipUVD_JPEG_LUMA_BASE0_0 0x41C0 -#define vcnipUVD_JPEG_CHROMA_BASE0_0 0x41C1 -#define vcnipJPEG_DEC_Y_GFX10_TILING_SURFACE_1 0x4048 -#define vcnipJPEG_DEC_UV_GFX10_TILING_SURFACE_1 0x4049 -#define vcnipUVD_LMI_JPEG_WRITE_64BIT_BAR_HIGH_1 0x40B5 -#define vcnipUVD_LMI_JPEG_WRITE_64BIT_BAR_LOW_1 0x40B4 -#define vcnipUVD_LMI_JPEG_READ_64BIT_BAR_HIGH_1 0x40B3 -#define vcnipUVD_LMI_JPEG_READ_64BIT_BAR_LOW_1 0x40B2 - -static uint32_t jpeg_dec_soft_rst; -static uint32_t jrbc_ib_cond_rd_timer; -static uint32_t jrbc_ib_ref_data; -static uint32_t lmi_jpeg_read_64bit_bar_high; -static uint32_t lmi_jpeg_read_64bit_bar_low; -static uint32_t jpeg_rb_base; -static uint32_t jpeg_rb_size; -static uint32_t jpeg_rb_wptr; -static uint32_t jpeg_pitch; -static uint32_t jpeg_uv_pitch; -static uint32_t dec_addr_mode; -static uint32_t dec_y_gfx10_tiling_surface; -static uint32_t dec_uv_gfx10_tiling_surface; -static uint32_t lmi_jpeg_write_64bit_bar_high; -static uint32_t lmi_jpeg_write_64bit_bar_low; -static uint32_t jpeg_tier_cntl2; -static uint32_t jpeg_outbuf_rptr; -static uint32_t jpeg_outbuf_cntl; -static uint32_t jpeg_int_en; -static uint32_t jpeg_cntl; -static uint32_t jpeg_rb_rptr; -static uint32_t jpeg_outbuf_wptr; -static uint32_t jpeg_luma_base0_0; -static uint32_t jpeg_chroma_base0_0; - -#define RDECODE_PKT_REG_J (x) ((unsigned int)(x)&0x3FFFF) -#define RDECODE_PKT_RES_J (x) (((unsigned int)(x)&0x3F) << 18) -#define RDECODE_PKT_COND_J (x) (((unsigned int)(x)&0xF) << 24) -#define RDECODE_PKT_TYPE_J (x) (((unsigned int)(x)&0xF) << 28) -#define RDECODE_PKTJ (reg, cond, type) (RDECODE_PKT_REG_J(reg) | \ - RDECODE_PKT_RES_J(0) | \ - RDECODE_PKT_COND_J(cond) | \ - RDECODE_PKT_TYPE_J(type)) - -#define UVD_BASE_INST0_SEG1 0x00007E00 -#define SOC15_REG_ADDR (reg) (UVD_BASE_INST0_SEG1 + reg) - -#define COND0 0 -#define COND1 1 -#define COND3 3 -#define TYPE0 0 -#define TYPE1 1 -#define TYPE3 3 -#define JPEG_DEC_DT_PITCH 0x100 -#define WIDTH 64 -#define JPEG_DEC_BSD_SIZE 0x200 -#define JPEG_DEC_LUMA_OFFSET 0 -#define JPEG_DEC_CHROMA_OFFSET 0x4000 -#define JPEG_DEC_SUM 262144 -#define IB_SIZE 4096 -#define MAX_RESOURCES 16 - -static bool -is_jpeg_tests_enable (amdgpu_device_handle device_handle, -struct mmd_shared_context *context) -{ -struct drm_amdgpu_info_hw_ip info; -int r; - - r =amdgpu_query_hw_ip_info (device_handle,AMDGPU_HW_IP_VCN_JPEG ,0 , &info); - -if (r !=0 || !info.available_rings || - (context->family_id <AMDGPU_FAMILY_RV && - (context->family_id ==AMDGPU_FAMILY_AI && - (context->chip_id - context->chip_rev) <0x32 ))) {/* Arcturus */ -igt_info ("\n\nThe ASIC NOT support JPEG, test disabled\n" ); -return false; - } - -if (info.hw_ip_version_major ==1 ) - context->jpeg_direct_reg = false; -else if (info.hw_ip_version_major >1 && info.hw_ip_version_major <=4 ) - context->jpeg_direct_reg = true; -else -return false; - - jrbc_ib_cond_rd_timer = vcnipUVD_JRBC_IB_COND_RD_TIMER; - jrbc_ib_ref_data = vcnipUVD_JRBC_IB_REF_DATA; - jpeg_rb_base = vcnipUVD_JPEG_RB_BASE; - jpeg_rb_size = vcnipUVD_JPEG_RB_SIZE; - jpeg_rb_wptr = vcnipUVD_JPEG_RB_WPTR; - jpeg_int_en = vcnipUVD_JPEG_INT_EN; - jpeg_cntl = vcnipUVD_JPEG_CNTL; - jpeg_rb_rptr = vcnipUVD_JPEG_RB_RPTR; - -if (context->family_id ==AMDGPU_FAMILY_AI && - (context->chip_id - context->chip_rev) >0x3c ) {/* gfx940 */ - jpeg_dec_soft_rst = vcnipUVD_JPEG_DEC_SOFT_RST_1; - lmi_jpeg_read_64bit_bar_high = vcnipUVD_LMI_JPEG_READ_64BIT_BAR_HIGH_1; - lmi_jpeg_read_64bit_bar_low = vcnipUVD_LMI_JPEG_READ_64BIT_BAR_LOW_1; - jpeg_pitch = vcnipUVD_JPEG_PITCH_1; - jpeg_uv_pitch = vcnipUVD_JPEG_UV_PITCH_1; - dec_addr_mode = vcnipJPEG_DEC_ADDR_MODE_1; - dec_y_gfx10_tiling_surface = vcnipJPEG_DEC_Y_GFX10_TILING_SURFACE_1; - dec_uv_gfx10_tiling_surface = vcnipJPEG_DEC_UV_GFX10_TILING_SURFACE_1; - lmi_jpeg_write_64bit_bar_high = vcnipUVD_LMI_JPEG_WRITE_64BIT_BAR_HIGH_1; - lmi_jpeg_write_64bit_bar_low = vcnipUVD_LMI_JPEG_WRITE_64BIT_BAR_LOW_1; - jpeg_tier_cntl2 = vcnipUVD_JPEG_TIER_CNTL2_1; - jpeg_outbuf_cntl = vcnipUVD_JPEG_OUTBUF_CNTL_1; - jpeg_outbuf_rptr = vcnipUVD_JPEG_OUTBUF_RPTR_1; - jpeg_outbuf_wptr = vcnipUVD_JPEG_OUTBUF_WPTR_1; - jpeg_luma_base0_0 = vcnipUVD_JPEG_LUMA_BASE0_0; - jpeg_chroma_base0_0 = vcnipUVD_JPEG_CHROMA_BASE0_0; - }else { - jpeg_dec_soft_rst = vcnipUVD_JPEG_DEC_SOFT_RST; - lmi_jpeg_read_64bit_bar_high = vcnipUVD_LMI_JPEG_READ_64BIT_BAR_HIGH; - lmi_jpeg_read_64bit_bar_low = vcnipUVD_LMI_JPEG_READ_64BIT_BAR_LOW; - jpeg_pitch = vcnipUVD_JPEG_PITCH; - jpeg_uv_pitch = vcnipUVD_JPEG_UV_PITCH; - dec_addr_mode = vcnipJPEG_DEC_ADDR_MODE; - dec_y_gfx10_tiling_surface = vcnipJPEG_DEC_Y_GFX10_TILING_SURFACE; - dec_uv_gfx10_tiling_surface = vcnipJPEG_DEC_UV_GFX10_TILING_SURFACE; - lmi_jpeg_write_64bit_bar_high = vcnipUVD_LMI_JPEG_WRITE_64BIT_BAR_HIGH; - lmi_jpeg_write_64bit_bar_low = vcnipUVD_LMI_JPEG_WRITE_64BIT_BAR_LOW; - jpeg_tier_cntl2 = vcnipUVD_JPEG_TIER_CNTL2; - jpeg_outbuf_cntl = vcnipUVD_JPEG_OUTBUF_CNTL; - jpeg_outbuf_rptr = vcnipUVD_JPEG_OUTBUF_RPTR; - jpeg_outbuf_wptr = vcnipUVD_JPEG_OUTBUF_WPTR; - } - -return true; -} - - -static void -set_reg_jpeg (struct mmd_context *context,uint32_t reg,uint32_t cond, -uint32_t type,uint32_t val,uint32_t *idx) -{ - context->ib_cpu[(*idx)++] =RDECODE_PKTJ (reg, cond, type); - context->ib_cpu[(*idx)++] = val; -} +#include "lib/amdgpu/amd_jpeg_shared.h" /* send a bitstream buffer command */ static void
@@ -356,112 +158,6 @@ send_cmd_target(struct mmd_context *context, uint64_t addr,set_reg_jpeg (context,SOC15_REG_ADDR (mmUVD_CTX_DATA),COND0 ,TYPE0 ,0 , idx); } -/* send a bitstream buffer command */ -static void -send_cmd_bitstream_direct (struct mmd_context *context,uint64_t addr, -uint32_t *idx) -{ - -/* jpeg soft reset */ -set_reg_jpeg (context, jpeg_dec_soft_rst,COND0 ,TYPE0 ,1 , idx); - -/* ensuring the Reset is asserted in SCLK domain */ -set_reg_jpeg (context, jrbc_ib_cond_rd_timer,COND0 ,TYPE0 ,0x01400200 , idx); -set_reg_jpeg (context, jrbc_ib_ref_data,COND0 ,TYPE0 , (0x1 <<0x10 ), idx); -set_reg_jpeg (context, jpeg_dec_soft_rst,COND3 ,TYPE3 , (0x1 <<0x10 ), idx); - -/* wait mem */ -set_reg_jpeg (context, jpeg_dec_soft_rst,COND0 ,TYPE0 ,0 , idx); - -/* ensuring the Reset is de-asserted in SCLK domain */ -set_reg_jpeg (context, jrbc_ib_ref_data,COND0 ,TYPE0 , (0 <<0x10 ), idx); -set_reg_jpeg (context, jpeg_dec_soft_rst,COND3 ,TYPE3 , (0x1 <<0x10 ), idx); - -/* set UVD_LMI_JPEG_READ_64BIT_BAR_LOW/HIGH based on bitstream buffer address */ -set_reg_jpeg (context, lmi_jpeg_read_64bit_bar_high,COND0 ,TYPE0 , - (addr >>32 ), idx); -set_reg_jpeg (context, lmi_jpeg_read_64bit_bar_low,COND0 ,TYPE0 , - addr, idx); - -/* set jpeg_rb_base */ -set_reg_jpeg (context, jpeg_rb_base,COND0 ,TYPE0 ,0 , idx); - -/* set jpeg_rb_base */ -set_reg_jpeg (context, jpeg_rb_size,COND0 ,TYPE0 ,0xFFFFFFF0 , idx); - -/* set jpeg_rb_wptr */ -set_reg_jpeg (context, jpeg_rb_wptr,COND0 ,TYPE0 , - (JPEG_DEC_BSD_SIZE >>2 ), idx); -} - -/* send a target buffer command */ -static void -send_cmd_target_direct (struct mmd_context *context,uint64_t addr, -uint32_t *idx) -{ - -set_reg_jpeg (context, jpeg_pitch,COND0 ,TYPE0 , - (JPEG_DEC_DT_PITCH >>4 ), idx); -set_reg_jpeg (context, jpeg_uv_pitch,COND0 ,TYPE0 , - (JPEG_DEC_DT_PITCH >>4 ), idx); - -set_reg_jpeg (context, dec_addr_mode,COND0 ,TYPE0 ,0 , idx); -set_reg_jpeg (context, dec_y_gfx10_tiling_surface,COND0 ,TYPE0 , -0 , idx); -set_reg_jpeg (context, dec_uv_gfx10_tiling_surface,COND0 ,TYPE0 , -0 , idx); - -/* set UVD_LMI_JPEG_WRITE_64BIT_BAR_LOW/HIGH based on target buffer address */ -set_reg_jpeg (context, lmi_jpeg_write_64bit_bar_high,COND0 ,TYPE0 , - (addr >>32 ), idx); -set_reg_jpeg (context, lmi_jpeg_write_64bit_bar_low,COND0 ,TYPE0 , - addr, idx); - -/* set output buffer data address */ -if (jpeg_luma_base0_0) { -set_reg_jpeg (context, jpeg_luma_base0_0,COND0 ,TYPE0 , -JPEG_DEC_LUMA_OFFSET , idx); -set_reg_jpeg (context, jpeg_chroma_base0_0,COND0 ,TYPE0 , -JPEG_DEC_CHROMA_OFFSET , idx); - }else { -set_reg_jpeg (context, vcnipUVD_JPEG_INDEX,COND0 ,TYPE0 ,0 , idx); -set_reg_jpeg (context, vcnipUVD_JPEG_DATA,COND0 ,TYPE0 , -JPEG_DEC_LUMA_OFFSET , idx); -set_reg_jpeg (context, vcnipUVD_JPEG_INDEX,COND0 ,TYPE0 ,1 , idx); -set_reg_jpeg (context, vcnipUVD_JPEG_DATA,COND0 ,TYPE0 , -JPEG_DEC_CHROMA_OFFSET , idx); - } -set_reg_jpeg (context, jpeg_tier_cntl2,COND0 ,0 ,0 , idx); - -/* set output buffer read pointer */ -set_reg_jpeg (context, jpeg_outbuf_rptr,COND0 ,TYPE0 ,0 , idx); -set_reg_jpeg (context, jpeg_outbuf_cntl,COND0 ,TYPE0 , - ((0x00001587 & (~0x00000180L )) | (0x1 <<0x7 ) | (0x1 <<0x6 )), - idx); - -/* enable error interrupts */ -set_reg_jpeg (context, jpeg_int_en,COND0 ,TYPE0 ,0xFFFFFFFE , idx); - -/* start engine command */ -set_reg_jpeg (context, jpeg_cntl,COND0 ,TYPE0 ,0xE , idx); - -/* wait for job completion, wait for job JBSI fetch done */ -set_reg_jpeg (context, jrbc_ib_ref_data,COND0 ,TYPE0 , - (JPEG_DEC_BSD_SIZE >>2 ), idx); -set_reg_jpeg (context, jrbc_ib_cond_rd_timer,COND0 ,TYPE0 , -0x01400200 , idx); -set_reg_jpeg (context, jpeg_rb_rptr,COND3 ,TYPE3 ,0xFFFFFFFF , idx); - -/* wait for job jpeg outbuf idle */ -set_reg_jpeg (context, jrbc_ib_ref_data,COND0 ,TYPE0 ,0xFFFFFFFF , - idx); -set_reg_jpeg (context, jpeg_outbuf_wptr,COND3 ,TYPE3 ,0x00000001 , - idx); - -/* stop engine */ -set_reg_jpeg (context, jpeg_cntl,COND0 ,TYPE0 ,0x4 , idx); -} -static void amdgpu_cs_jpeg_decode (amdgpu_device_handle device_handle,struct mmd_shared_context *shared_context)
tests/amdgpu/amd_vcn.c +26 -321
386 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 3/4 test/amdgpu: implement vcn queue tests
In reply to Ruili JiThe vcn queue tests are used to verify the resiliency of GPU. If there is job timeout on a vcn queue, driver could only reset this vcn queue with other queues (like gfx/vcn/jpeg queues) unaffected.
Brief description of queue tests:
1. Query the queue sched mask info and select one ready queue. If there are multiple queues, the following steps will be executed on per ready queue (1: ready, 0: not ready).
2. Insert invalid content into the normal decode flow and check the result of jobs submit.
If submit returns without error, there is no job timeout. If submit returns with error, there is job timeout and driver will reset queue.
--- tests/amdgpu/amd_vcn_queue.c | 100 +++++++++++++++++++++++++++++++++++ tests/amdgpu/meson.build | 1 + 2 files changed, 101 insertions(+) create mode 100644 tests/amdgpu/amd_vcn_queue.c
tests/amdgpu/amd_vcn_queue.c new file +100 -0
@@ -0,0 +1,100 @@ +// SPDX-License-Identifier: MIT +// Copyright 2025 Advanced Micro Devices, Inc. + +#include "lib/amdgpu/amd_vcn_shared.h" +#include "lib/amdgpu/amd_ip_blocks.h" + +static bool +is_queue_tests_enable (amdgpu_device_handle device_handle, +struct mmd_shared_context *context,struct pci_addr *pci) +{ +bool ret =is_vcn_tests_enable (device_handle, context); + +if (!ret) +return false; + +if (!is_reset_enable (AMD_IP_VCN_UNIFIED ,AMDGPU_RESET_TYPE_PER_QUEUE , pci)) { +igt_info ("The ASIC does NOT support vcn queue reset\n" ); +return false; + }else if (context->vcn_ip_version_major <4 ) { +igt_info ("The vcn ip does NOT support vcn queue reset\n" ); +return false; + } + +return ret; +} + +static int +vcn_queue_test (amdgpu_device_handle device_handle, +struct mmd_shared_context *shared_context,int err) +{ +struct mmd_context context = {}; +struct vcn_context v_context = {}; +signed int ip; +int len, ret; + + ret =mmd_context_init (device_handle, &context); +igt_require (ret ==0 ); + + context.num_resources =0 ; +alloc_resource (device_handle, &v_context.session_ctx_buf,32 *4096 ,AMDGPU_GEM_DOMAIN_GTT ); + context.resources[context.num_resources++] = v_context.session_ctx_buf.handle; + context.resources[context.num_resources++] = context.ib_handle; + len =0 ; +vcn_dec_cmd (shared_context, &context, &v_context, v_context.session_ctx_buf.addr, +DECODE_CMD_SESSION_CONTEXT_BUFFER , &len, err); + +amdgpu_cs_sq_ib_tail (&v_context, context.ib_cpu + len); + ip =AMDGPU_HW_IP_VCN_ENC ; +submit (device_handle, &context, len, ip); + +/* +* For job timeout test case, submit job will return error, +* here needn't return error. +*/ + +mmd_context_clean (device_handle, &context); +return 0 ; +} + +igt_main +{ +amdgpu_device_handle device; +struct mmd_context context = {}; +struct mmd_shared_context shared_context = {}; +int fd =-1 ; +uint32_t major, minor; +struct pci_addr pci; +int err; + + igt_fixture { + fd =drm_open_driver (DRIVER_AMDGPU ); + err =amdgpu_device_initialize (fd, &major, &minor, &device); +igt_require (err ==0 ); +igt_info ("Initialized amdgpu, driver version %d.%d\n" , + major, minor); + err =mmd_shared_context_init (device, &shared_context); +igt_require (err ==0 ); + err =mmd_context_init (device, &context); +igt_require (err ==0 ); +igt_skip_on (!is_vcn_tests_enable (device, &shared_context)); +igt_skip_on_f (!shared_context.dec_ring && !shared_context.enc_ring,"vcn no decorder and encoder rings\n" ); +igt_skip_on (get_pci_addr_from_fd (fd, &pci)); +igt_info ("PCI Address: domain %04x, bus %02x, device %02x, function %02x\n" , + pci.domain, pci.bus, pci.device, pci.function); +igt_skip_on (!is_queue_tests_enable (device, &shared_context, &pci)); + shared_context.ip_type =AMD_IP_VCN_UNIFIED ; + } + +igt_describe ("Test whether vcn queue" ); + igt_subtest("vcn-decoder-queue-reset-test") { + err = (int )INVALID_DECODER_IB_SIZE ; +mm_queue_test_helper (device, &shared_context, vcn_queue_test, err, &pci); + } + + igt_fixture { +mmd_context_clean (device, &context); +amdgpu_device_deinitialize (device); +drm_close_driver (fd); + } +}
tests/amdgpu/meson.build +1 -0
@@ -36,6 +36,7 @@ if libdrm_amdgpu.found() 'amd_uvd_enc', 'amd_vce_enc', 'amd_vcn', + 'amd_vcn_queue', 'amd_vm', 'amd_vrr_range', 'amd_mall',
Signature · 1 line
2.34.1
All four patches in the series look good to me —Reviewed-by Vitaly Prosyak ,[email protected]>
Thanks, Vitaly
Quoted 157 lines · Ruili Ji
The jpeg queue tests are used to verify the resiliency of GPU. If there is job timeout on a jpeg queue, driver could only reset this jpeg queue with other queues (like gfx/vcn/jpeg queues) unaffected.
Brief description of queue tests:
1. Query the queue sched mask info and select one ready queue. If there are multiple queues, the following steps will be executed on per ready queue (1: ready, 0: not ready).
2. Insert invalid content into the normal decode flow and check the result of jobs submit.
If submit returns without error, there is no job timeout. If submit returns with error, there is job timeout and driver will reset queue.Signed-off-by Ruili Ji <[email protected]>Reviewed-by Ruijing Dong <[email protected]>Reviewed-by Vitaly Prosyak <[email protected]>--- tests/amdgpu/amd_jpeg_queue.c | 115 ++++++++++++++++++++++++++++++++++ tests/amdgpu/meson.build | 1 + 2 files changed, 116 insertions(+) create mode 100644 tests/amdgpu/amd_jpeg_queue.ctests/amdgpu/amd_jpeg_queue.c new file +115
-0@@ -0,0 +1,115 @@ +// SPDX-License-Identifier: MIT +// Copyright 2025 Advanced Micro Devices, Inc. + +#include "lib/amdgpu/amd_jpeg_shared.h" +#include "lib/amdgpu/amd_ip_blocks.h" + +static bool +is_queue_tests_enable (amdgpu_device_handle device_handle, +struct mmd_shared_context *context,struct pci_addr *pci) +{ +bool ret =is_jpeg_tests_enable (device_handle, context); + +if (!ret) +return false; + +if (!is_reset_enable (AMD_IP_VCN_JPEG ,AMDGPU_RESET_TYPE_PER_QUEUE , pci)) { +igt_info ("The ASIC does NOT support jpeg queue reset\n" ); +return false; + }else if (context->vcn_ip_version_major <4 ) { +igt_info ("The vcn ip does NOT support jpeg queue reset\n" ); +return false; + } + +return ret; +} + +static int +jpeg_queue_decode (amdgpu_device_handle device_handle, +struct mmd_shared_context *shared_context,int err) +{ +struct amdgpu_mmd_bo dec_buf; +int size, ret; +uint32_t idx; +struct mmd_context acontext = {0 }; +struct mmd_context *context = &acontext; +int64_t dec_buf_addr; + + ret =mmd_context_init (device_handle, context); +if (ret) { +igt_info ("mmd_context_init fail!\n" ); +return ret; + } + + size =32 *1024 ;/* 8K bitstream + 24K output */ + context->num_resources =0 ; +alloc_resource (device_handle, &dec_buf, size,AMDGPU_GEM_DOMAIN_VRAM ); + context->resources[context->num_resources++] = dec_buf.handle; + context->resources[context->num_resources++] = context->ib_handle; + ret =amdgpu_bo_cpu_map (dec_buf.handle, (void **)&dec_buf.ptr); +if (ret) { +igt_info ("amdgpu_bo_cpu_map map dec_buf fail!\n" ); + goto err_handle; + } +memcpy (dec_buf.ptr, jpeg_bitstream,sizeof (jpeg_bitstream)); + + idx =0 ; + dec_buf_addr = dec_buf.addr; +if (err ==INVALID_DECODER_BITSTREAM_BUFFER ) + dec_buf_addr =0xdead ; + +send_cmd_bitstream_direct (context, dec_buf_addr, &idx); +send_cmd_target_direct (context, dec_buf_addr + (size /4 ), &idx); + +amdgpu_bo_cpu_unmap (dec_buf.handle); +submit (device_handle, context, idx,AMDGPU_HW_IP_VCN_JPEG ); + +/* +* For job timeout test case, submit job will return error, +* here needn't return error. +*/ + ret =0 ; + +err_handle: +free_resource (&dec_buf); +mmd_context_clean (device_handle, context); +return ret; +} + +igt_main +{ +amdgpu_device_handle device; +struct mmd_shared_context shared_context = {}; +int fd =-1 ; +uint32_t major, minor; +int err; +struct pci_addr pci; + + igt_fixture { + fd =drm_open_driver (DRIVER_AMDGPU ); + err =amdgpu_device_initialize (fd, &major, &minor, &device); +igt_require (err ==0 ); +igt_info ("Initialized amdgpu, driver version %d.%d\n" , + major, minor); + err =mmd_shared_context_init (device, &shared_context); +igt_require (err ==0 ); + +igt_skip_on (get_pci_addr_from_fd (fd, &pci)); +igt_info ("PCI Address: domain %04x, bus %02x, device %02x, function %02x\n" , + pci.domain, pci.bus, pci.device, pci.function); +igt_skip_on (!is_queue_tests_enable (device, &shared_context, &pci)); + shared_context.ip_type =AMD_IP_VCN_JPEG ; + } + +igt_describe ("Test whether jpeg queue" ); + igt_subtest("jpeg-decoder-queue-reset") { + err = (int )INVALID_DECODER_BITSTREAM_BUFFER ; +mm_queue_test_helper (device, &shared_context, jpeg_queue_decode, err, &pci); + } + + igt_fixture { +amdgpu_device_deinitialize (device); +drm_close_driver (fd); + } + +}tests/amdgpu/meson.build +1
-0@@ -19,6 +19,7 @@ if libdrm_amdgpu.found() 'amd_ilr', 'amd_info', 'amd_jpeg_dec', + 'amd_jpeg_queue', 'amd_link_settings', 'amd_max_bpc', 'amd_mem_leak',