Skip to content

Commit b13eb02

Browse files
ChristianKoenigAMDalexdeucher
authored andcommitted
drm/amdgpu: add amdgpu_error_* debugfs file
This allows us to insert some error codes into the bottom of the pipeline on an engine. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Luben Tuikov <luben.tuikov@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 2eb841b commit b13eb02

3 files changed

Lines changed: 41 additions & 0 deletions

File tree

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,30 @@ void amdgpu_fence_driver_clear_job_fences(struct amdgpu_ring *ring)
691691
}
692692
}
693693

694+
/**
695+
* amdgpu_fence_driver_set_error - set error code on fences
696+
* @ring: the ring which contains the fences
697+
* @error: the error code to set
698+
*
699+
* Set an error code to all the fences pending on the ring.
700+
*/
701+
void amdgpu_fence_driver_set_error(struct amdgpu_ring *ring, int error)
702+
{
703+
struct amdgpu_fence_driver *drv = &ring->fence_drv;
704+
unsigned long flags;
705+
706+
spin_lock_irqsave(&drv->lock, flags);
707+
for (unsigned int i = 0; i <= drv->num_fences_mask; ++i) {
708+
struct dma_fence *fence;
709+
710+
fence = rcu_dereference_protected(drv->fences[i],
711+
lockdep_is_held(&drv->lock));
712+
if (fence && !dma_fence_is_signaled_locked(fence))
713+
dma_fence_set_error(fence, error);
714+
}
715+
spin_unlock_irqrestore(&drv->lock, flags);
716+
}
717+
694718
/**
695719
* amdgpu_fence_driver_force_completion - force signal latest fence of ring
696720
*

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,17 @@ static const struct file_operations amdgpu_debugfs_mqd_fops = {
561561
.llseek = default_llseek
562562
};
563563

564+
static int amdgpu_debugfs_ring_error(void *data, u64 val)
565+
{
566+
struct amdgpu_ring *ring = data;
567+
568+
amdgpu_fence_driver_set_error(ring, val);
569+
return 0;
570+
}
571+
572+
DEFINE_DEBUGFS_ATTRIBUTE_SIGNED(amdgpu_debugfs_error_fops, NULL,
573+
amdgpu_debugfs_ring_error, "%lld\n");
574+
564575
#endif
565576

566577
void amdgpu_debugfs_ring_init(struct amdgpu_device *adev,
@@ -582,6 +593,11 @@ void amdgpu_debugfs_ring_init(struct amdgpu_device *adev,
582593
&amdgpu_debugfs_mqd_fops,
583594
ring->mqd_size);
584595
}
596+
597+
sprintf(name, "amdgpu_error_%s", ring->name);
598+
debugfs_create_file(name, 0200, root, ring,
599+
&amdgpu_debugfs_error_fops);
600+
585601
#endif
586602
}
587603

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ struct amdgpu_fence_driver {
126126
extern const struct drm_sched_backend_ops amdgpu_sched_ops;
127127

128128
void amdgpu_fence_driver_clear_job_fences(struct amdgpu_ring *ring);
129+
void amdgpu_fence_driver_set_error(struct amdgpu_ring *ring, int error);
129130
void amdgpu_fence_driver_force_completion(struct amdgpu_ring *ring);
130131

131132
int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring);

0 commit comments

Comments
 (0)