* [PATCH] drm/i915: fix remaining_timeout in intel_gt_retire_requests_timeout
@ 2022-03-25 17:58 Daniele Ceraolo Spurio
2022-03-25 18:29 ` Matthew Brost
2022-03-25 18:37 ` [Intel-gfx] " Das, Nirmoy
0 siblings, 2 replies; 5+ messages in thread
From: Daniele Ceraolo Spurio @ 2022-03-25 17:58 UTC (permalink / raw)
To: intel-gfx; +Cc: Matthew Brost, Daniele Ceraolo Spurio, John Harrison, dri-devel
In intel_gt_wait_for_idle, we use the remaining timeout returned from
intel_gt_retire_requests_timeout to wait on the GuC being idle. However,
the returned variable can have a negative value if something goes wrong
during the wait, leading to us hitting a GEM_BUG_ON in the GuC wait
function.
To fix this, make sure to only return the timeout if it is positive.
Fixes: b97060a99b01b ("drm/i915/guc: Update intel_gt_wait_for_idle to work with GuC")
Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: John Harrison <john.c.harrison@intel.com>
---
drivers/gpu/drm/i915/gt/intel_gt_requests.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_requests.c b/drivers/gpu/drm/i915/gt/intel_gt_requests.c
index edb881d756309..ef70c209976d8 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_requests.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_requests.c
@@ -197,7 +197,7 @@ out_active: spin_lock(&timelines->lock);
active_count++;
if (remaining_timeout)
- *remaining_timeout = timeout;
+ *remaining_timeout = timeout > 0 ? timeout : 0;
return active_count ? timeout : 0;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/i915: fix remaining_timeout in intel_gt_retire_requests_timeout
2022-03-25 17:58 [PATCH] drm/i915: fix remaining_timeout in intel_gt_retire_requests_timeout Daniele Ceraolo Spurio
@ 2022-03-25 18:29 ` Matthew Brost
2022-03-25 18:37 ` [Intel-gfx] " Das, Nirmoy
1 sibling, 0 replies; 5+ messages in thread
From: Matthew Brost @ 2022-03-25 18:29 UTC (permalink / raw)
To: Daniele Ceraolo Spurio; +Cc: intel-gfx, John Harrison, dri-devel
On Fri, Mar 25, 2022 at 10:58:39AM -0700, Daniele Ceraolo Spurio wrote:
> In intel_gt_wait_for_idle, we use the remaining timeout returned from
> intel_gt_retire_requests_timeout to wait on the GuC being idle. However,
> the returned variable can have a negative value if something goes wrong
> during the wait, leading to us hitting a GEM_BUG_ON in the GuC wait
> function.
> To fix this, make sure to only return the timeout if it is positive.
>
> Fixes: b97060a99b01b ("drm/i915/guc: Update intel_gt_wait_for_idle to work with GuC")
> Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: John Harrison <john.c.harrison@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> ---
> drivers/gpu/drm/i915/gt/intel_gt_requests.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_gt_requests.c b/drivers/gpu/drm/i915/gt/intel_gt_requests.c
> index edb881d756309..ef70c209976d8 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gt_requests.c
> +++ b/drivers/gpu/drm/i915/gt/intel_gt_requests.c
> @@ -197,7 +197,7 @@ out_active: spin_lock(&timelines->lock);
> active_count++;
>
> if (remaining_timeout)
> - *remaining_timeout = timeout;
> + *remaining_timeout = timeout > 0 ? timeout : 0;
>
> return active_count ? timeout : 0;
> }
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Intel-gfx] [PATCH] drm/i915: fix remaining_timeout in intel_gt_retire_requests_timeout
2022-03-25 17:58 [PATCH] drm/i915: fix remaining_timeout in intel_gt_retire_requests_timeout Daniele Ceraolo Spurio
2022-03-25 18:29 ` Matthew Brost
@ 2022-03-25 18:37 ` Das, Nirmoy
2022-03-25 20:33 ` Ceraolo Spurio, Daniele
1 sibling, 1 reply; 5+ messages in thread
From: Das, Nirmoy @ 2022-03-25 18:37 UTC (permalink / raw)
To: Daniele Ceraolo Spurio, intel-gfx; +Cc: dri-devel
On 3/25/2022 6:58 PM, Daniele Ceraolo Spurio wrote:
> In intel_gt_wait_for_idle, we use the remaining timeout returned from
> intel_gt_retire_requests_timeout to wait on the GuC being idle. However,
> the returned variable can have a negative value if something goes wrong
> during the wait, leading to us hitting a GEM_BUG_ON in the GuC wait
> function.
> To fix this, make sure to only return the timeout if it is positive.
>
> Fixes: b97060a99b01b ("drm/i915/guc: Update intel_gt_wait_for_idle to work with GuC")
> Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: John Harrison <john.c.harrison@intel.com>
> ---
> drivers/gpu/drm/i915/gt/intel_gt_requests.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_gt_requests.c b/drivers/gpu/drm/i915/gt/intel_gt_requests.c
> index edb881d756309..ef70c209976d8 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gt_requests.c
> +++ b/drivers/gpu/drm/i915/gt/intel_gt_requests.c
> @@ -197,7 +197,7 @@ out_active: spin_lock(&timelines->lock);
> active_count++;
>
> if (remaining_timeout)
> - *remaining_timeout = timeout;
> + *remaining_timeout = timeout > 0 ? timeout : 0;
Should the last flush_submission() be "if ( timeout > 0
&&flush_submission(gt, timeout))" ?
Nirmoy
>
> return active_count ? timeout : 0;
> }
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Intel-gfx] [PATCH] drm/i915: fix remaining_timeout in intel_gt_retire_requests_timeout
2022-03-25 18:37 ` [Intel-gfx] " Das, Nirmoy
@ 2022-03-25 20:33 ` Ceraolo Spurio, Daniele
2022-03-28 9:16 ` Das, Nirmoy
0 siblings, 1 reply; 5+ messages in thread
From: Ceraolo Spurio, Daniele @ 2022-03-25 20:33 UTC (permalink / raw)
To: Das, Nirmoy, intel-gfx; +Cc: dri-devel
On 3/25/2022 11:37 AM, Das, Nirmoy wrote:
>
> On 3/25/2022 6:58 PM, Daniele Ceraolo Spurio wrote:
>> In intel_gt_wait_for_idle, we use the remaining timeout returned from
>> intel_gt_retire_requests_timeout to wait on the GuC being idle. However,
>> the returned variable can have a negative value if something goes wrong
>> during the wait, leading to us hitting a GEM_BUG_ON in the GuC wait
>> function.
>> To fix this, make sure to only return the timeout if it is positive.
>>
>> Fixes: b97060a99b01b ("drm/i915/guc: Update intel_gt_wait_for_idle to
>> work with GuC")
>> Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
>> Cc: Matthew Brost <matthew.brost@intel.com>
>> Cc: John Harrison <john.c.harrison@intel.com>
>> ---
>> drivers/gpu/drm/i915/gt/intel_gt_requests.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/i915/gt/intel_gt_requests.c
>> b/drivers/gpu/drm/i915/gt/intel_gt_requests.c
>> index edb881d756309..ef70c209976d8 100644
>> --- a/drivers/gpu/drm/i915/gt/intel_gt_requests.c
>> +++ b/drivers/gpu/drm/i915/gt/intel_gt_requests.c
>> @@ -197,7 +197,7 @@ out_active: spin_lock(&timelines->lock);
>> active_count++;
>> if (remaining_timeout)
>> - *remaining_timeout = timeout;
>> + *remaining_timeout = timeout > 0 ? timeout : 0;
>
>
> Should the last flush_submission() be "if ( timeout > 0
> &&flush_submission(gt, timeout))" ?
I considered it, but flush_submission only checks for timeout != 0 so it
won't accidentally make use of a negative value thinking it's positive.
I don't know if the flush is purposely done even if timeout is negative
or if that's a mistake, but that code has been there long before we
modified the function to return the remaining timeout and never seems to
have caused issues, so I decided not to change it.
Daniele
>
>
> Nirmoy
>
>> return active_count ? timeout : 0;
>> }
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Intel-gfx] [PATCH] drm/i915: fix remaining_timeout in intel_gt_retire_requests_timeout
2022-03-25 20:33 ` Ceraolo Spurio, Daniele
@ 2022-03-28 9:16 ` Das, Nirmoy
0 siblings, 0 replies; 5+ messages in thread
From: Das, Nirmoy @ 2022-03-28 9:16 UTC (permalink / raw)
To: Ceraolo Spurio, Daniele, intel-gfx; +Cc: dri-devel
On 3/25/2022 9:33 PM, Ceraolo Spurio, Daniele wrote:
>
>
> On 3/25/2022 11:37 AM, Das, Nirmoy wrote:
>>
>> On 3/25/2022 6:58 PM, Daniele Ceraolo Spurio wrote:
>>> In intel_gt_wait_for_idle, we use the remaining timeout returned from
>>> intel_gt_retire_requests_timeout to wait on the GuC being idle.
>>> However,
>>> the returned variable can have a negative value if something goes wrong
>>> during the wait, leading to us hitting a GEM_BUG_ON in the GuC wait
>>> function.
>>> To fix this, make sure to only return the timeout if it is positive.
>>>
>>> Fixes: b97060a99b01b ("drm/i915/guc: Update intel_gt_wait_for_idle
>>> to work with GuC")
>>> Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
>>> Cc: Matthew Brost <matthew.brost@intel.com>
>>> Cc: John Harrison <john.c.harrison@intel.com>
>>> ---
>>> drivers/gpu/drm/i915/gt/intel_gt_requests.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/gt/intel_gt_requests.c
>>> b/drivers/gpu/drm/i915/gt/intel_gt_requests.c
>>> index edb881d756309..ef70c209976d8 100644
>>> --- a/drivers/gpu/drm/i915/gt/intel_gt_requests.c
>>> +++ b/drivers/gpu/drm/i915/gt/intel_gt_requests.c
>>> @@ -197,7 +197,7 @@ out_active: spin_lock(&timelines->lock);
>>> active_count++;
>>> if (remaining_timeout)
>>> - *remaining_timeout = timeout;
>>> + *remaining_timeout = timeout > 0 ? timeout : 0;
>>
>>
>> Should the last flush_submission() be "if ( timeout > 0
>> &&flush_submission(gt, timeout))" ?
>
> I considered it, but flush_submission only checks for timeout != 0 so
> it won't accidentally make use of a negative value thinking it's
> positive. I don't know if the flush is purposely done even if timeout
> is negative or if that's a mistake, but that code has been there long
> before we modified the function to return the remaining timeout and
> never seems to have caused issues, so I decided not to change it.
Yes, we need clarify if we really need the final flush if the timeout is
negative.
But this patch is Acked-by: Nirmoy Das <nirmoy.das@intel.com>
Nirmoy
>
> Daniele
>
>>
>>
>> Nirmoy
>>
>>> return active_count ? timeout : 0;
>>> }
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-28 9:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-25 17:58 [PATCH] drm/i915: fix remaining_timeout in intel_gt_retire_requests_timeout Daniele Ceraolo Spurio
2022-03-25 18:29 ` Matthew Brost
2022-03-25 18:37 ` [Intel-gfx] " Das, Nirmoy
2022-03-25 20:33 ` Ceraolo Spurio, Daniele
2022-03-28 9:16 ` Das, Nirmoy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox