Commit graph

1,485,070 commits

Author SHA1 Message Date
Caden Chien
4c992efb2a drm/amdgpu/vpe: add vpe v3.0.1 support
This initializes VPE IP version 3.0.1

Signed-off-by: Caden Chien <chih-wei.chien@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:24:25 -04:00
Caden Chien
9958780315 drm/amdgpu/vpe: add vpe v3.0.0 support
This patch adds support for vpe v3.0.0 with new structs and ip functions

Signed-off-by: Caden Chien <chih-wei.chien@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:24:23 -04:00
Hawking Zhang
edd8529ca3 drm/amdgpu: Add vpe v3_0_0 ip headers v4
Add header files for vpe v3_0_0 register offsets
and shift masks

v2: Update vpe ip headers to LSC version
v3: Update vpe ip headers to BTO version
v4: Update registers (Alex)

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Frank Min <Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:24:18 -04:00
Emily Deng
60dc71e0fd drm/amdgpu/psp: wait for TOS ready on all AIDs in v15_0_3 ring create
When aid_mask is set, poll MP0 C2PMSG_64 on each AID instance before
creating the PSP GFX command ring.  Single-die paths are unchanged.

Signed-off-by: Emily Deng <Emily.Deng@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:24:09 -04:00
Lin Cao
bc8dfd9f5d drm/amdgpu: Add VPE FW list to PSP_15_0_3 under SRIOV
Add VPE FW list including VPE_CTX and VPE_CTL

Signed-off-by: Lin Cao <lincao12@amd.com>
Reviewed-by: Frank Min <Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:24:06 -04:00
Lin Cao
08441a9f62 drm/amdgpu: Add GFX FW list to PSP_15_0_3 under SRIOV
[Why]
Under SRIOV VF, GFX firmware are required to loaded.

[How]
Add GFX FW list.
FW contains:
PFP ucode, PFP data P0-P1
ME ucode, ME data P0-P1
MEC ucode, MEC data P0-P7
MES SCH ucode and data
MES KIQ ucode and data

Signed-off-by: Yifan Zha <Yifan.Zha@amd.com>
Signed-off-by: Lin Cao <lincao12@amd.com>
Reviewed-by: Frank Min<Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:24:02 -04:00
Lin Cao
64deb26f4a drm/amdgpu: add new MEC2 firmware loading framework
Add ucode loading support for MEC pipe stacks P4-P7:
 - add GFX_FW_TYPE_RS64_MEC_P4..P7 firmware types
 - add AMDGPU_UCODE_ID_CP_RS64_MEC_P4..P7 ucode ids
 - handle P4-P7 in ucode name/init, psp fw type

Signed-off-by: Yifan Zha <Yifan.Zha@amd.com>
Signed-off-by: Yiqing Yao <yiqing.yao@amd.com>
Signed-off-by: Lin Cao <lincao12@amd.com>
Reviewed-by: Frank Min<Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:23:59 -04:00
Yang Wang
36990c9af3 drm/amdgpu: support MP5 in firmware info queries
Handle AMDGPU_INFO_FW_MP5 in the firmware query path and report the MP5
firmware version in the debugfs firmware_info output.

Signed-off-by: Yang Wang <kevinyang.wang@amd.com>
Reviewed-By: Frank Min<Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:23:56 -04:00
Yang Wang
fa79acf571 drm/amdgpu: expose MP5 firmware version in sysfs
Add an mp5_fw_version attribute to the fw_version sysfs group,
so userspace can read the MP5 firmware version.

Signed-off-by: Yang Wang <kevinyang.wang@amd.com>
Reviewed-By: Frank Min<Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:23:53 -04:00
Frank Min
68ad3df835 drm/amdgpu: add infrastructrure for handling mp5 firmware
Add framework for MP5 firmware.

Signed-off-by: Frank Min <Frank.Min@amd.com>
Signed-off-by: Likun Gao <Likun.Gao@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:23:50 -04:00
Gangliang Xie
f615b52075 drm/amdgpu: add ta loading in psp v15_0_3
add ta loading in psp v15_0_3

Signed-off-by: Gangliang Xie <ganglxie@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:23:46 -04:00
Yang Wang
5cbe8a6790 drm/amdgpu: fix ASP 15.0.3 runtime DB offset
ASP 15.0.3 stores the PSP runtime database at a fixed 64KB offset from the IP
discovery table, not at the legacy offset from the end of VRAM.

Signed-off-by: Yang Wang <kevinyang.wang@amd.com>
Reviewed-By: Frank Min <Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:23:43 -04:00
Frank Min
4ba85fea5f drm/amdgpu: Add firmware type retrieval in PSP v15.0.3
Add firmware type retrieval in PSP v15.0.3 to adapt psp fw updates

Signed-off-by: Frank Min <Frank.Min@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:23:40 -04:00
Frank Min
abe264744b drm/amdgpu: Add support for PSP version 15.0.3
Add support for PSP version 15.0.3

v2: fix psp 15.0.3 C2P message reg access issue

Signed-off-by: Frank Min <Frank.Min@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:23:36 -04:00
Hawking Zhang
91a166e69c drm/amdgpu: Add mp v15_0_3 ip headers v4
Add header files for mp v15_0_3 register offsets
and shift masks

v2: Update mp ip headers to LSC version
v3: Update mp ip headers to BTO version
v4: Update registers (Alex)

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Frank Min <Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:23:34 -04:00
Likun Gao
5b8a05bcb9 drm/amdgpu: add support for lsdma v8
Add support for LSDMA v8

v2: fix wait_pio_status() per Philip's comments.

Reviewed-by: Philip Yang <philip.yang@amd.com>
Signed-off-by: Likun Gao <Likun.Gao@amd.com>
Reviewed-by: Frank Min <Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:23:29 -04:00
Hawking Zhang
c7a595f6dc drm/amdgpu: Add lsdma v8_0_1 ip headers
Add header files for lsdma v8_0_1 register offsets
and shift masks

v2: Update registers (Alex)

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Frank Min <Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:23:25 -04:00
Frank Min
481f34c243 drm/amdgpu: add hdp v8 ip block
add hdp v8 ip block

Signed-off-by: Frank Min <Frank.Min@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:23:23 -04:00
Hawking Zhang
fe9521296e drm/amdgpu: Add hdp v8_0_1 ip headers v3
Add header files for hdp v8_0_1 register offsets
and shift masks

v2: Update hdp ip headers to BTO version
v3: Update registers (Alex)

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Frank Min <Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:23:20 -04:00
Hawking Zhang
cd3b6f82ef drm/amdgpu: Add smuio v15_0_3 support
Add initial implementation for the new generation of smuio

v2: squash in clock counter changes

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Frank Min <Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:23:16 -04:00
Hawking Zhang
7f5a53bde6 drm/amdgpu: Add smuio v15_0_3 ip headers v4
Add header files for smuio v15_0_3 register offsets
and shift masks

v2: Update smuio ip headers to LSC version
v3: Update smuio ip headers to BTO version
v4: Update registers (Alex)

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Frank Min <Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:23:13 -04:00
ZhenGuo Yin
b34364d359 drm/amdgpu: fall back to RCC_HW_DEBUG for VF frame buffer size
On some SR-IOV VFs RCC_CONFIG_MEMSIZE reads back 0. Fall back to
RCC_HW_DEBUG for the frame buffer size in the nbif get_memsize()
callback and in the early-init paths that read the register directly.
Only VFs that read back 0 are affected.

Signed-off-by: ZhenGuo Yin <zhenguo.yin@amd.com>
Reviewed-by: Frank Min <frank.min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:23:09 -04:00
Hawking Zhang
fa53376be6 drm/amdgpu: Add nbif v7_10 support
Add initial implementation for the new generation of nbif

v2: squash in HDP, VPE, RLC/IH, SDMA fixes

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Frank Min <Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:23:05 -04:00
Hawking Zhang
e66a5ab119 drm/amdgpu: Add pcie v6_1_3 ip headers v4
Add header files for pcie v6_1_3 register offsets
and shift masks

v2: Update pcie ip headers to LSC version
v3: Update pcie ip headers to BTO version
v4: Update registers (Alex)

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Frank Min <Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:23:00 -04:00
Hawking Zhang
2562900b09 drm/amdgpu: Add nbif v7_10_0 ip headers v4
Add header files for nbif v7_10_0 register headers
and shift masks

v2: Update nbif ip headers to LSC version
v3: Update nbif ip headers to BTO version
v4: Update registers (Alex)
v5: Squash in SR-IOV updates (Alex)

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Frank Min <Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:22:56 -04:00
Hawking Zhang
01d6b9d032 drm/amdgpu/discovery: Add ih v8_0 ip block
Add ih v8_0 ip block

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Frank Min <Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:22:53 -04:00
Hawking Zhang
327edf9e92 drm/amdgpu: Add ih v8_0 support
Add initial implementation for the new generation of ih

v2: squash in flood control fix

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Frank Min <Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:22:48 -04:00
Hawking Zhang
0431798feb drm/amdgpu: Add osssys v8_0_1 ip headers v3
Add header files for osssys v8_0_1 register offsets
and shift masks

v2: Update osssys ip headers to BTO version
v3: Update registers (Alex)

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Frank Min <Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:22:42 -04:00
Hawking Zhang
46d702cdef drm/amdgpu: Add soc v2_0 ih client id table
To acommandate the specific ih client for soc v2_0

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Frank Min <Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:22:34 -04:00
Lin Cao
34f5b2eea3 drm/amdgpu: fix ip discovery table validation
Fix ip discovery table_check, get_mall_info, and get_vcn_info to guard
on both offset and size being non-zero before parsing.

Signed-off-by: Danijel Slivka <danijel.slivka@amd.com>
Signed-off-by: ZhenGuo Yin <zhenguo.yin@amd.com>
Signed-off-by: Lin Cao <lincao12@amd.com>
Reviewed-by: Frank Min<Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:22:26 -04:00
Eric Huang
a839ca90f4 drm/amdgpu: fix atomics on DF 5.0.2
DF 5.0.2 needs to program DF config register as DF 4.15.x, so
share the functions, they have the same register layout.

Signed-off-by: Eric Huang <jinhuieric.huang@amd.com>
Reviewed-by: David Belanger <david.belanger@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:22:19 -04:00
Likun Gao
7fba03cf78 drm/amdgpu: Add gc_info_v1_4 table support
Initialize amdgpu_gfx_config using values from
gc_info_v1_4.

Signed-off-by: Likun Gao <Likun.Gao@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:22:15 -04:00
Frank Min
e5e8342825 drm/amdgpu: update FIRMWARE ID for soc24
Update firmware ID for SOC24 to support more firmware.

Signed-off-by: Frank Min <Frank.Min@amd.com>
Signed-off-by: Likun Gao <Likun.Gao@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:22:08 -04:00
Frank Min
09b58ce953 drm/amdgpu: add debug info for psp ip key mgr ucode
Add debug info for psp ip key mgr ucode.

Signed-off-by: Frank Min <Frank.Min@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:22:02 -04:00
Frank Min
8de34e5cbe drm/amdgpu: add GDDR7 vram name
Add GDDR7 vram name.

Signed-off-by: Frank Min <Frank.Min@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:21:59 -04:00
Pierre-Eric Pelloux-Prayer
04a45bbc09 drm/amdgpu: use pm_runtime_resume_and_get amdgpu_gem_create_ioctl
This ioctl might trigger GPU work through ttm so make sure the GPU
is awake.

Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Co-developed-by: Shahyan Soltani <shahyan.soltani@amd.com>
Signed-off-by: Shahyan Soltani <shahyan.soltani@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:21:47 -04:00
Jesse Zhang
aa1a19e18e drm/amdgpu/gfx: add a shared gfx pipe reset helper
Serialize GFX recovery with mec.reset_mutex and attempt MES suspend
before locating a user HQD. Back up collateral kernel rings before reset,
then resume MES before testing and replaying rebuilt rings.

Allow reset to proceed if suspend fails. Always attempt resume, report
reset or resume errors, and leave schedulers stopped on failure.

Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:21:44 -04:00
Jesse Zhang
ac3477ac78 drm/amdgpu: factor out the MES user queue reset body
Extract mes_userq_reset_hw() for reuse by GFX recovery. Keep reset and
MES queue removal together, marking the queue HUNG only after both
operations succeed. The existing reset entry point uses the same helper.

Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:21:35 -04:00
Jesse Zhang
893642e0e3 drm/amdgpu/gfx11: set KMD_QUEUE for kernel gfx queues
Set KMD_QUEUE in the GFX MQD and kernel ring control registers so CP
preserves kernel IB VMIDs instead of replacing them with the queue VMID.
Use prop->kernel_queue to distinguish kernel and user MQDs.

Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:21:31 -04:00
Jesse Zhang
14741c0168 drm/amdgpu/gfx12: set KMD_QUEUE for kernel gfx queues
Set KMD_QUEUE in the GFX MQD and kernel ring control registers so CP
preserves kernel IB VMIDs instead of replacing them with the queue VMID.
Use prop->kernel_queue to distinguish kernel and user MQDs.

Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:21:13 -04:00
Jesse Zhang
49e3b50b41 drm/amdgpu/mes12: read the gfx user queue VMID for MMIO reset
Read the MES-assigned VMID from CP_GFX_HQD_VMID under srbm_mutex when
resetting a GFX user queue over MMIO. Kernel queues keep the IB VMID
supplied by the caller.

Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:21:11 -04:00
Jesse Zhang
ecae06f3ef drm/amdgpu/mes11: read the gfx user queue VMID for MMIO reset
Read the MES-assigned VMID from CP_GFX_HQD_VMID under srbm_mutex when
resetting a GFX user queue over MMIO. Kernel queues keep the IB VMID
supplied by the caller.

Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:20:58 -04:00
Jesse Zhang
cd3de60ae6 drm/amdgpu/mes11: restore collateral gfx queues after pipe reset
A pipe reset restarts the shared PFP/ME, but CP firmware dequeues only
the requested queue. Wait for its CP_VMID_RESET bit and HQD_ACTIVE to
clear, and return -ETIMEDOUT if recovery does not complete.

Preempt each collateral kernel queue and wait for its HQD to deactivate
before rebuilding its MQD/ring and remapping it. Leave the guilty kernel
queue to the outer reset helper.

Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:20:52 -04:00
Jesse Zhang
f3a41f6fe5 drm/amdgpu/mes12: restore collateral gfx queues after pipe reset
A pipe reset restarts the shared PFP/ME, but CP firmware dequeues only
the requested queue. Wait for its CP_VMID_RESET bit and HQD_ACTIVE to
clear, and return -ETIMEDOUT if recovery does not complete.

Preempt each collateral kernel queue and wait for its HQD to deactivate
before rebuilding its MQD/ring and remapping it. Leave the guilty kernel
queue to the outer reset helper.

Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:20:49 -04:00
Jesse Zhang
2bf7c12b95 drm/amdgpu/gfx: export amdgpu_gfx_mqd_reset_restore
Expose amdgpu_gfx_mqd_reset_restore() so MES11/12 pipe reset can rebuild
collateral kernel rings.

Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:20:45 -04:00
Jesse Zhang
6adc917949 drm/amdgpu/gfx11: implement detect_hung_queue
Implement detect_hung_queue() by matching enabled HQD doorbells over
MMIO, allowing GFX reset to locate the queue without a MES request.

Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:20:41 -04:00
Jesse Zhang
148882950d drm/amdgpu/gfx12: implement detect_hung_queue
Implement detect_hung_queue() by matching enabled HQD doorbells over
MMIO, allowing GFX reset to locate the queue without a MES request.

Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:20:37 -04:00
Jesse Zhang
c41659869d drm/amdgpu/gfx: add a detect_hung_queue callback
Allow GFX recovery to resolve a doorbell to an HQD (ME, pipe, queue)
without querying a stalled MES scheduler.

Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:20:33 -04:00
Jesse Zhang
78fbe15663 drm/amdgpu: fix empty fence backup and replay intervals
amdgpu_ring_set_fence_errors_and_reemit() and
amdgpu_ring_backup_unprocessed_commands() masked last_seq and sync_seq to
fence-array indices before the loop, then walked a do/while until the two
indices met. When hardware completed every command before the driver
signalled the fences, last_seq == sync_seq, but the masked-index do/while
could not tell that empty interval from a full table and walked the whole
fence array, backing up and replaying already-completed commands.

Read the raw sequence numbers, return early through amdgpu_fence_process()
when they are equal, and mask only at the array index. Guard the
force-completion against a NULL guilty_fence so a non-guilty backup does
not dereference it.

Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:20:29 -04:00
Jesse Zhang
b3f73daa1c drm/amdgpu: support non-guilty job save on ring backup
amdgpu_ring_backup_unprocessed_commands() is also used to preserve a
ring that carries no guilty command - for example a collateral kernel
gfx ring that shares the faulting pipe during a gfx user-queue pipe
reset. Such a ring is backed up with a NULL guilty_fence and all of its
unprocessed commands must be saved so they can be replayed after the
reset rebuilds the ring's MQD.

The early-return that skips an already-seen guilty fence compared
"ring->guilty_fence == guilty_fence", which is also true when both are
NULL. A non-guilty save therefore hit the early return and left
ring_backup_entries_to_copy at 0, so the pending commands were dropped
when the ring was rebuilt.

Guard the early return with a non-NULL guilty_fence so a NULL fence
never takes it and every unprocessed command is backed up.

Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-10-01 11:20:21 -04:00