[RFC 09/29] drm/xe/svm: Allow unaligned addresses and ranges for prefetch

Ghimiray, Himal Prasad himal.prasad.ghimiray at intel.com
Mon Apr 7 06:15:41 UTC 2025



On 04-04-2025 02:22, Matthew Brost wrote:
> On Fri, Mar 14, 2025 at 01:32:06PM +0530, Himal Prasad Ghimiray wrote:
>> The SVM prefetch operation can handle unaligned addresses and range sizes.
>> This commit updates the ioctl parameter checks to accommodate unaligned
>> addresses and range sizes for SVM prefetch operations.
>>
> 
> Do we really want to allow unaligned to page size prefetches? That seems
> rather odd use case. Was this a specific request from the UMD team?

Yes, this came as a requirement from UMD team.

> 
> Matt
> 
>> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray at intel.com>
>> ---
>>   drivers/gpu/drm/xe/xe_vm.c | 18 ++++++++++++++++--
>>   1 file changed, 16 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
>> index 07cad2804b14..c6343a629c02 100644
>> --- a/drivers/gpu/drm/xe/xe_vm.c
>> +++ b/drivers/gpu/drm/xe/xe_vm.c
>> @@ -3086,6 +3086,16 @@ ALLOW_ERROR_INJECTION(vm_bind_ioctl_ops_execute, ERRNO);
>>   #define XE_64K_PAGE_MASK 0xffffull
>>   #define ALL_DRM_XE_SYNCS_FLAGS (DRM_XE_SYNCS_FLAG_WAIT_FOR_OP)
>>   
>> +static bool addr_not_in_cpu_addr_vma(struct xe_vm *vm, u64 addr)
>> +{
>> +	struct xe_vma *vma;
>> +
>> +	down_write(&vm->lock);
>> +	vma = xe_vm_find_vma_by_addr(vm, addr);
>> +	up_write(&vm->lock);
>> +	return !xe_vma_is_cpu_addr_mirror(vma);
>> +}
>> +
>>   static int vm_bind_ioctl_check_args(struct xe_device *xe, struct xe_vm *vm,
>>   				    struct drm_xe_vm_bind *args,
>>   				    struct drm_xe_vm_bind_op **bind_ops)
>> @@ -3194,8 +3204,12 @@ static int vm_bind_ioctl_check_args(struct xe_device *xe, struct xe_vm *vm,
>>   		}
>>   
>>   		if (XE_IOCTL_DBG(xe, obj_offset & ~PAGE_MASK) ||
>> -		    XE_IOCTL_DBG(xe, addr & ~PAGE_MASK) ||
>> -		    XE_IOCTL_DBG(xe, range & ~PAGE_MASK) ||
>> +		    XE_IOCTL_DBG(xe, (addr & ~PAGE_MASK) &&
>> +				 (addr_not_in_cpu_addr_vma(vm, addr) ||
>> +				 op != DRM_XE_VM_BIND_OP_PREFETCH)) ||
>> +		    XE_IOCTL_DBG(xe, (range & ~PAGE_MASK) &&
>> +				 (addr_not_in_cpu_addr_vma(vm, addr) ||
>> +				 op != DRM_XE_VM_BIND_OP_PREFETCH)) ||
>>   		    XE_IOCTL_DBG(xe, !range &&
>>   				 op != DRM_XE_VM_BIND_OP_UNMAP_ALL)) {
>>   			err = -EINVAL;
>> -- 
>> 2.34.1
>>



More information about the Intel-xe mailing list