[Intel-xe] [PATCH v2 01/27] drm/xe: Allow num_binds == 0 in VM bind IOCTL

Matthew Brost matthew.brost at intel.com
Thu Nov 9 13:59:56 UTC 2023


On Wed, Nov 08, 2023 at 01:30:56PM +0200, Lionel Landwerlin wrote:
> On 07/11/2023 07:25, Matthew Brost wrote:
> > The idea being out-syncs can signal indicating all previous operations
> > on the bind queue are complete. An example use case of this would be
> > support for implementing vkQueueWaitForIdle easily.
> > 
> > Signed-off-by: Matthew Brost <matthew.brost at intel.com>
> > ---
> >   drivers/gpu/drm/xe/xe_vm.c | 30 ++++++++++++++++++------------
> >   1 file changed, 18 insertions(+), 12 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> > index d26c90f0d702..403444ff3856 100644
> > --- a/drivers/gpu/drm/xe/xe_vm.c
> > +++ b/drivers/gpu/drm/xe/xe_vm.c
> > @@ -2850,7 +2850,6 @@ static int vm_bind_ioctl_check_args(struct xe_device *xe,
> >   	int i;
> >   	if (XE_IOCTL_DBG(xe, args->extensions) ||
> > -	    XE_IOCTL_DBG(xe, !args->num_binds) ||
> >   	    XE_IOCTL_DBG(xe, args->num_binds > MAX_BINDS))
> 
> 
> Just randomly noticed this, but is there a uAPI for the MAX_BINDS?
> 
> Or do we need to hardcode that in the UMD and hope it never changes?
> 

We should probably report this somewhere. Let me look into this.

Thanks - Matt

> 
> -Lionel
> 
> 
> >   		return -EINVAL;
> > @@ -2977,7 +2976,7 @@ int xe_vm_bind_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> >   			goto put_exec_queue;
> >   		}
> > -		if (XE_IOCTL_DBG(xe, async !=
> > +		if (XE_IOCTL_DBG(xe, args->num_binds && async !=
> >   				 !!(q->flags & EXEC_QUEUE_FLAG_VM_ASYNC))) {
> >   			err = -EINVAL;
> >   			goto put_exec_queue;
> > @@ -2991,7 +2990,7 @@ int xe_vm_bind_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> >   	}
> >   	if (!args->exec_queue_id) {
> > -		if (XE_IOCTL_DBG(xe, async !=
> > +		if (XE_IOCTL_DBG(xe, args->num_binds && async !=
> >   				 !!(vm->flags & XE_VM_FLAG_ASYNC_DEFAULT))) {
> >   			err = -EINVAL;
> >   			goto put_vm;
> > @@ -3028,16 +3027,18 @@ int xe_vm_bind_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> >   		}
> >   	}
> > -	bos = kzalloc(sizeof(*bos) * args->num_binds, GFP_KERNEL);
> > -	if (!bos) {
> > -		err = -ENOMEM;
> > -		goto release_vm_lock;
> > -	}
> > +	if (args->num_binds) {
> > +		bos = kzalloc(sizeof(*bos) * args->num_binds, GFP_KERNEL);
> > +		if (!bos) {
> > +			err = -ENOMEM;
> > +			goto release_vm_lock;
> > +		}
> > -	ops = kzalloc(sizeof(*ops) * args->num_binds, GFP_KERNEL);
> > -	if (!ops) {
> > -		err = -ENOMEM;
> > -		goto release_vm_lock;
> > +		ops = kzalloc(sizeof(*ops) * args->num_binds, GFP_KERNEL);
> > +		if (!ops) {
> > +			err = -ENOMEM;
> > +			goto release_vm_lock;
> > +		}
> >   	}
> >   	for (i = 0; i < args->num_binds; ++i) {
> > @@ -3092,6 +3093,11 @@ int xe_vm_bind_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> >   			goto free_syncs;
> >   	}
> > +	if (!args->num_binds) {
> > +		err = -ENODATA;
> > +		goto free_syncs;
> > +	}
> > +
> >   	for (i = 0; i < args->num_binds; ++i) {
> >   		u64 range = bind_ops[i].range;
> >   		u64 addr = bind_ops[i].addr;
> 
> 


More information about the Intel-xe mailing list