Skip to content

Commit 559a285

Browse files
srishanmalexdeucher
authored andcommitted
drm/amdgpu: Replace 'amdgpu_job_submit_direct' with 'drm_sched_entity' in cleaner shader
This commit replaces the use of amdgpu_job_submit_direct which submits the job to the ring directly, with drm_sched_entity in the cleaner shader job submission process. The change allows the GPU scheduler to manage the cleaner shader job. - The job is then submitted to the GPU using the drm_sched_entity_push_job function, which allows the GPU scheduler to manage the job. This change improves the reliability of the cleaner shader job submission process by leveraging the capabilities of the GPU scheduler. Fixes: d361ad5 ("drm/amdgpu: Add sysfs interface for running cleaner shader") Cc: Christian König <[email protected]> Cc: Alex Deucher <[email protected]> Signed-off-by: Srinivasan Shanmugam <[email protected]> Suggested-by: Christian König <[email protected]> Reviewed-by: Christian König <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 2578487 commit 559a285

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

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

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,14 +1397,23 @@ static ssize_t amdgpu_gfx_get_available_compute_partition(struct device *dev,
13971397
static int amdgpu_gfx_run_cleaner_shader_job(struct amdgpu_ring *ring)
13981398
{
13991399
struct amdgpu_device *adev = ring->adev;
1400-
long timeout = msecs_to_jiffies(1000);
1401-
struct dma_fence *f = NULL;
1400+
struct drm_gpu_scheduler *sched = &ring->sched;
1401+
struct drm_sched_entity entity;
1402+
struct dma_fence *f;
14021403
struct amdgpu_job *job;
14031404
struct amdgpu_ib *ib;
14041405
int i, r;
14051406

1406-
r = amdgpu_job_alloc_with_ib(adev, NULL, NULL,
1407-
64, AMDGPU_IB_POOL_DIRECT,
1407+
/* Initialize the scheduler entity */
1408+
r = drm_sched_entity_init(&entity, DRM_SCHED_PRIORITY_NORMAL,
1409+
&sched, 1, NULL);
1410+
if (r) {
1411+
dev_err(adev->dev, "Failed setting up GFX kernel entity.\n");
1412+
goto err;
1413+
}
1414+
1415+
r = amdgpu_job_alloc_with_ib(ring->adev, &entity, NULL,
1416+
64, 0,
14081417
&job);
14091418
if (r)
14101419
goto err;
@@ -1416,24 +1425,18 @@ static int amdgpu_gfx_run_cleaner_shader_job(struct amdgpu_ring *ring)
14161425
ib->ptr[i] = ring->funcs->nop;
14171426
ib->length_dw = ring->funcs->align_mask + 1;
14181427

1419-
r = amdgpu_job_submit_direct(job, ring, &f);
1420-
if (r)
1421-
goto err_free;
1428+
f = amdgpu_job_submit(job);
14221429

1423-
r = dma_fence_wait_timeout(f, false, timeout);
1424-
if (r == 0)
1425-
r = -ETIMEDOUT;
1426-
else if (r > 0)
1427-
r = 0;
1430+
r = dma_fence_wait(f, false);
1431+
if (r)
1432+
goto err;
14281433

1429-
amdgpu_ib_free(adev, ib, f);
14301434
dma_fence_put(f);
14311435

1436+
/* Clean up the scheduler entity */
1437+
drm_sched_entity_destroy(&entity);
14321438
return 0;
14331439

1434-
err_free:
1435-
amdgpu_job_free(job);
1436-
amdgpu_ib_free(adev, ib, f);
14371440
err:
14381441
return r;
14391442
}

0 commit comments

Comments
 (0)