[PATCH 3/3] drm/xe: Warn on NULL job when user fence used in xe_sync_entry_signal

Nirmoy Das nirmoy.das at intel.com
Mon Mar 18 09:27:06 UTC 2024


On 3/16/2024 2:28 AM, Matthew Brost wrote:
> On Thu, Mar 14, 2024 at 10:53:20AM +0000, Matthew Auld wrote:
>> On 14/03/2024 09:54, Nirmoy Das wrote:
>>> Added a check and warn for NULL job when sync->type is
>>> DRM_XE_SYNC_TYPE_USER_FENCE to prevent potential crashes
>>> and aid in debugging
>>>
>>> Cc: Matthew Auld <matthew.auld at intel.com>
>>> Signed-off-by: Nirmoy Das <nirmoy.das at intel.com>
>>> ---
>>>    drivers/gpu/drm/xe/xe_sync.c | 10 +++++++---
>>>    1 file changed, 7 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/xe/xe_sync.c b/drivers/gpu/drm/xe/xe_sync.c
>>> index 02c9577fe418..fae466ba8e75 100644
>>> --- a/drivers/gpu/drm/xe/xe_sync.c
>>> +++ b/drivers/gpu/drm/xe/xe_sync.c
>>> @@ -255,9 +255,13 @@ void xe_sync_entry_signal(struct xe_sync_entry *sync, struct xe_sched_job *job,
>>>    			dma_fence_put(fence);
>>>    		}
>>>    	} else if (sync->type == DRM_XE_SYNC_TYPE_USER_FENCE) {
>>> -		job->user_fence.used = true;
>>> -		job->user_fence.addr = sync->addr;
>>> -		job->user_fence.value = sync->timeline_value;
>>> +		if (job) {
>>> +			job->user_fence.used = true;
>>> +			job->user_fence.addr = sync->addr;
>>> +			job->user_fence.value = sync->timeline_value;
>>> +		} else {
>>> +			XE_WARN_ON("NULL job passed with DRM_XE_SYNC_TYPE_USER_FENCE");
>> Just wondering if it might be better to just let it crash if that ever
>> happens? Assumption is that it's impossible and would be programmer error.
>>
>> Matt, any thoughts here?
>>
> The usage is probably add an xe_assert(xe, job) and then let the kernel crash.

xe_assert() would require passing xe device struct which is probably bit too much. How about a XE_WARN_ON(job) ?

Regards,
Nirmoy

>
> Matt
>
>>> +		}
>>>    	}
>>>    }


More information about the Intel-xe mailing list