Skip to content

Commit 531b432

Browse files
committed
drm/amdgpu: always backup and reemit fences
If when we backup the ring contents for reemit before a ring reset, we skip jobs associated with the bad context, however, we need to make sure the fences are reemited as unprocessed submissions may depend on them. v2: clean up fence handling, make helpers static Reviewed-by: Timur Kristóf <timur.kristof@gmail.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit 155a748)
1 parent 9fc27cb commit 531b432

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ static u32 amdgpu_fence_read(struct amdgpu_ring *ring)
8989
return seq;
9090
}
9191

92+
static void amdgpu_fence_save_fence_wptr_start(struct amdgpu_fence *af)
93+
{
94+
af->fence_wptr_start = af->ring->wptr;
95+
}
96+
97+
static void amdgpu_fence_save_fence_wptr_end(struct amdgpu_fence *af)
98+
{
99+
af->fence_wptr_end = af->ring->wptr;
100+
}
101+
92102
/**
93103
* amdgpu_fence_emit - emit a fence on the requested ring
94104
*
@@ -116,8 +126,10 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring, struct amdgpu_fence *af,
116126
&ring->fence_drv.lock,
117127
adev->fence_context + ring->idx, seq);
118128

129+
amdgpu_fence_save_fence_wptr_start(af);
119130
amdgpu_ring_emit_fence(ring, ring->fence_drv.gpu_addr,
120131
seq, flags | AMDGPU_FENCE_FLAG_INT);
132+
amdgpu_fence_save_fence_wptr_end(af);
121133
amdgpu_fence_save_wptr(af);
122134
pm_runtime_get_noresume(adev_to_drm(adev)->dev);
123135
ptr = &ring->fence_drv.fences[seq & ring->fence_drv.num_fences_mask];
@@ -742,10 +754,6 @@ void amdgpu_fence_driver_guilty_force_completion(struct amdgpu_fence *af)
742754
/* if we've already reemitted once then just cancel everything */
743755
amdgpu_fence_driver_force_completion(af->ring);
744756
af->ring->ring_backup_entries_to_copy = 0;
745-
} else {
746-
/* signal the guilty fence */
747-
amdgpu_fence_write(ring, (u32)af->base.seqno);
748-
amdgpu_fence_process(ring);
749757
}
750758
}
751759

@@ -795,9 +803,15 @@ void amdgpu_ring_backup_unprocessed_commands(struct amdgpu_ring *ring,
795803
* just save the content from other contexts.
796804
*/
797805
if (!fence->reemitted &&
798-
(!guilty_fence || (fence->context != guilty_fence->context)))
806+
(!guilty_fence || (fence->context != guilty_fence->context))) {
799807
amdgpu_ring_backup_unprocessed_command(ring, wptr,
800808
fence->wptr);
809+
} else if (!fence->reemitted) {
810+
/* always save the fence */
811+
amdgpu_ring_backup_unprocessed_command(ring,
812+
fence->fence_wptr_start,
813+
fence->fence_wptr_end);
814+
}
801815
wptr = fence->wptr;
802816
fence->reemitted++;
803817
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,15 @@ struct amdgpu_fence {
144144
struct amdgpu_ring *ring;
145145
ktime_t start_timestamp;
146146

147-
/* wptr for the fence for resets */
147+
/* wptr for the total submission for resets */
148148
u64 wptr;
149149
/* fence context for resets */
150150
u64 context;
151151
/* has this fence been reemitted */
152152
unsigned int reemitted;
153+
/* wptr for the fence for the submission */
154+
u64 fence_wptr_start;
155+
u64 fence_wptr_end;
153156
};
154157

155158
extern const struct drm_sched_backend_ops amdgpu_sched_ops;

0 commit comments

Comments
 (0)