diff mbox series

drm/scheduler: fix drm_sched_job_add_implicit_dependencies harder

Message ID 20211116155545.473311-1-robdclark@gmail.com (mailing list archive)
State Not Applicable
Headers show
Series drm/scheduler: fix drm_sched_job_add_implicit_dependencies harder | expand

Commit Message

Rob Clark Nov. 16, 2021, 3:55 p.m. UTC
From: Rob Clark <robdclark@chromium.org>

drm_sched_job_add_dependency() could drop the last ref, so we need to do
the dma_fence_get() first.

Cc: Christian König <christian.koenig@amd.com>
Fixes: 9c2ba265352a drm/scheduler: ("use new iterator in drm_sched_job_add_implicit_dependencies v2")
Signed-off-by: Rob Clark <robdclark@chromium.org>
---
Applies on top of "drm/scheduler: fix drm_sched_job_add_implicit_dependencies"
but I don't think that has a stable commit sha yet.

 drivers/gpu/drm/scheduler/sched_main.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Amit Pundir Nov. 16, 2021, 6:30 p.m. UTC | #1
On Tue, 16 Nov 2021 at 21:21, Rob Clark <robdclark@gmail.com> wrote:
>
> From: Rob Clark <robdclark@chromium.org>
>
> drm_sched_job_add_dependency() could drop the last ref, so we need to do
> the dma_fence_get() first.
>

It fixed the splats I saw on RB5 (sm8250 | A650). Thanks.

Tested-by: Amit Pundir <amit.pundir@linaro.org>

> Cc: Christian König <christian.koenig@amd.com>
> Fixes: 9c2ba265352a drm/scheduler: ("use new iterator in drm_sched_job_add_implicit_dependencies v2")
> Signed-off-by: Rob Clark <robdclark@chromium.org>
> ---
> Applies on top of "drm/scheduler: fix drm_sched_job_add_implicit_dependencies"
> but I don't think that has a stable commit sha yet.
>
>  drivers/gpu/drm/scheduler/sched_main.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
> index 94fe51b3caa2..f91fb31ab7a7 100644
> --- a/drivers/gpu/drm/scheduler/sched_main.c
> +++ b/drivers/gpu/drm/scheduler/sched_main.c
> @@ -704,12 +704,13 @@ int drm_sched_job_add_implicit_dependencies(struct drm_sched_job *job,
>         int ret;
>
>         dma_resv_for_each_fence(&cursor, obj->resv, write, fence) {
> -               ret = drm_sched_job_add_dependency(job, fence);
> -               if (ret)
> -                       return ret;
> -
>                 /* Make sure to grab an additional ref on the added fence */
>                 dma_fence_get(fence);
> +               ret = drm_sched_job_add_dependency(job, fence);
> +               if (ret) {
> +                       dma_fence_put(fence);
> +                       return ret;
> +               }
>         }
>         return 0;
>  }
> --
> 2.33.1
>
Christian König Nov. 17, 2021, 7:27 a.m. UTC | #2
Am 16.11.21 um 19:30 schrieb Amit Pundir:
> On Tue, 16 Nov 2021 at 21:21, Rob Clark <robdclark@gmail.com> wrote:
>> From: Rob Clark <robdclark@chromium.org>
>>
>> drm_sched_job_add_dependency() could drop the last ref, so we need to do
>> the dma_fence_get() first.
>>
> It fixed the splats I saw on RB5 (sm8250 | A650). Thanks.
>
> Tested-by: Amit Pundir <amit.pundir@linaro.org>

I've added my rb, pushed this with the original fix to drm-misc-fixes 
and cleaned up the obvious fallout between drm-misc-fixes and 
drm-misc-next in drm-tip.

Thanks for the help and sorry for the noise,
Christian.

>
>> Cc: Christian König <christian.koenig@amd.com>
>> Fixes: 9c2ba265352a drm/scheduler: ("use new iterator in drm_sched_job_add_implicit_dependencies v2")
>> Signed-off-by: Rob Clark <robdclark@chromium.org>
>> ---
>> Applies on top of "drm/scheduler: fix drm_sched_job_add_implicit_dependencies"
>> but I don't think that has a stable commit sha yet.
>>
>>   drivers/gpu/drm/scheduler/sched_main.c | 9 +++++----
>>   1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
>> index 94fe51b3caa2..f91fb31ab7a7 100644
>> --- a/drivers/gpu/drm/scheduler/sched_main.c
>> +++ b/drivers/gpu/drm/scheduler/sched_main.c
>> @@ -704,12 +704,13 @@ int drm_sched_job_add_implicit_dependencies(struct drm_sched_job *job,
>>          int ret;
>>
>>          dma_resv_for_each_fence(&cursor, obj->resv, write, fence) {
>> -               ret = drm_sched_job_add_dependency(job, fence);
>> -               if (ret)
>> -                       return ret;
>> -
>>                  /* Make sure to grab an additional ref on the added fence */
>>                  dma_fence_get(fence);
>> +               ret = drm_sched_job_add_dependency(job, fence);
>> +               if (ret) {
>> +                       dma_fence_put(fence);
>> +                       return ret;
>> +               }
>>          }
>>          return 0;
>>   }
>> --
>> 2.33.1
>>
Steev Klimaszewski Nov. 18, 2021, 1:23 a.m. UTC | #3
On 11/17/21 1:27 AM, Christian König wrote:
> Am 16.11.21 um 19:30 schrieb Amit Pundir:
>> On Tue, 16 Nov 2021 at 21:21, Rob Clark <robdclark@gmail.com> wrote:
>>> From: Rob Clark <robdclark@chromium.org>
>>>
>>> drm_sched_job_add_dependency() could drop the last ref, so we need 
>>> to do
>>> the dma_fence_get() first.
>>>
>> It fixed the splats I saw on RB5 (sm8250 | A650). Thanks.
>>
>> Tested-by: Amit Pundir <amit.pundir@linaro.org>
>
> I've added my rb, pushed this with the original fix to drm-misc-fixes 
> and cleaned up the obvious fallout between drm-misc-fixes and 
> drm-misc-next in drm-tip.
>
> Thanks for the help and sorry for the noise,
> Christian.
>
I've run into this splat on the Lenovo Yoga C630 on 5.16-rc1 - are these 
2 patches (which fix it) going to be heading to 5.16 or were they 
targeted at 5.17?

-- steev
Rob Clark Nov. 18, 2021, 3:09 a.m. UTC | #4
On Wed, Nov 17, 2021 at 5:23 PM Steev Klimaszewski <steev@kali.org> wrote:
>
>
> On 11/17/21 1:27 AM, Christian König wrote:
> > Am 16.11.21 um 19:30 schrieb Amit Pundir:
> >> On Tue, 16 Nov 2021 at 21:21, Rob Clark <robdclark@gmail.com> wrote:
> >>> From: Rob Clark <robdclark@chromium.org>
> >>>
> >>> drm_sched_job_add_dependency() could drop the last ref, so we need
> >>> to do
> >>> the dma_fence_get() first.
> >>>
> >> It fixed the splats I saw on RB5 (sm8250 | A650). Thanks.
> >>
> >> Tested-by: Amit Pundir <amit.pundir@linaro.org>
> >
> > I've added my rb, pushed this with the original fix to drm-misc-fixes
> > and cleaned up the obvious fallout between drm-misc-fixes and
> > drm-misc-next in drm-tip.
> >
> > Thanks for the help and sorry for the noise,
> > Christian.
> >
> I've run into this splat on the Lenovo Yoga C630 on 5.16-rc1 - are these
> 2 patches (which fix it) going to be heading to 5.16 or were they
> targeted at 5.17?

these should be for v5.16

BR,
-R
Christian König Nov. 18, 2021, 6:59 a.m. UTC | #5
Am 18.11.21 um 04:09 schrieb Rob Clark:
> On Wed, Nov 17, 2021 at 5:23 PM Steev Klimaszewski <steev@kali.org> wrote:
>>
>> On 11/17/21 1:27 AM, Christian König wrote:
>>> Am 16.11.21 um 19:30 schrieb Amit Pundir:
>>>> On Tue, 16 Nov 2021 at 21:21, Rob Clark <robdclark@gmail.com> wrote:
>>>>> From: Rob Clark <robdclark@chromium.org>
>>>>>
>>>>> drm_sched_job_add_dependency() could drop the last ref, so we need
>>>>> to do
>>>>> the dma_fence_get() first.
>>>>>
>>>> It fixed the splats I saw on RB5 (sm8250 | A650). Thanks.
>>>>
>>>> Tested-by: Amit Pundir <amit.pundir@linaro.org>
>>> I've added my rb, pushed this with the original fix to drm-misc-fixes
>>> and cleaned up the obvious fallout between drm-misc-fixes and
>>> drm-misc-next in drm-tip.
>>>
>>> Thanks for the help and sorry for the noise,
>>> Christian.
>>>
>> I've run into this splat on the Lenovo Yoga C630 on 5.16-rc1 - are these
>> 2 patches (which fix it) going to be heading to 5.16 or were they
>> targeted at 5.17?
> these should be for v5.16

Yeah, they are already queued up for -rc2.

Regards,
Christian.

>
> BR,
> -R
diff mbox series

Patch

diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index 94fe51b3caa2..f91fb31ab7a7 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -704,12 +704,13 @@  int drm_sched_job_add_implicit_dependencies(struct drm_sched_job *job,
 	int ret;
 
 	dma_resv_for_each_fence(&cursor, obj->resv, write, fence) {
-		ret = drm_sched_job_add_dependency(job, fence);
-		if (ret)
-			return ret;
-
 		/* Make sure to grab an additional ref on the added fence */
 		dma_fence_get(fence);
+		ret = drm_sched_job_add_dependency(job, fence);
+		if (ret) {
+			dma_fence_put(fence);
+			return ret;
+		}
 	}
 	return 0;
 }