diff mbox series

[1/2] drm/sched: don't try to construct error code from NULL ptr

Message ID 20191129132643.7828-1-l.stach@pengutronix.de (mailing list archive)
State New, archived
Headers show
Series [1/2] drm/sched: don't try to construct error code from NULL ptr | expand

Commit Message

Lucas Stach Nov. 29, 2019, 1:26 p.m. UTC
If the job submission fails with a NULL fence returned instead of an
error pointer we must not try to convert this into an error. The error
code in this case will be 0, which causes a warning splat from
dma_fence_set_error().

Also most drivers return NULL from the run_job callback if the fence
already has the error state set, so trying to set a 0 error code
actively destroys the valid error code on the fence.

Fixes: 167bf96014a0 (drm/sched: Set error to s_fence if HW job
       submission failed.)
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/gpu/drm/scheduler/sched_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Steven Price Nov. 29, 2019, 2:11 p.m. UTC | #1
On 29/11/2019 13:26, Lucas Stach wrote:
> If the job submission fails with a NULL fence returned instead of an
> error pointer we must not try to convert this into an error. The error
> code in this case will be 0, which causes a warning splat from
> dma_fence_set_error().
> 
> Also most drivers return NULL from the run_job callback if the fence
> already has the error state set, so trying to set a 0 error code
> actively destroys the valid error code on the fence.
> 
> Fixes: 167bf96014a0 (drm/sched: Set error to s_fence if HW job
>        submission failed.)
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>

This was already reported and a patch fixing it posted[1] (although your
commit message is significantly more informative). That patch also fixes
the other case in drm_sched_main().

[1] https://patchwork.kernel.org/patch/11218399/

Steve

> ---
>  drivers/gpu/drm/scheduler/sched_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
> index f39b97ed4ade..596a28d90e5c 100644
> --- a/drivers/gpu/drm/scheduler/sched_main.c
> +++ b/drivers/gpu/drm/scheduler/sched_main.c
> @@ -495,7 +495,7 @@ void drm_sched_resubmit_jobs(struct drm_gpu_scheduler *sched)
>  		dma_fence_put(s_job->s_fence->parent);
>  		fence = sched->ops->run_job(s_job);
>  
> -		if (IS_ERR_OR_NULL(fence)) {
> +		if (IS_ERR(fence)) {
>  			s_job->s_fence->parent = NULL;
>  			dma_fence_set_error(&s_fence->finished, PTR_ERR(fence));
>  		} else {
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index f39b97ed4ade..596a28d90e5c 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -495,7 +495,7 @@  void drm_sched_resubmit_jobs(struct drm_gpu_scheduler *sched)
 		dma_fence_put(s_job->s_fence->parent);
 		fence = sched->ops->run_job(s_job);
 
-		if (IS_ERR_OR_NULL(fence)) {
+		if (IS_ERR(fence)) {
 			s_job->s_fence->parent = NULL;
 			dma_fence_set_error(&s_fence->finished, PTR_ERR(fence));
 		} else {