Re: [PATCH v6 05/20] drm/i915/vm_bind: Implement bind and unbind of object
On Thu, 2022-11-10 at 08:32 -0800, Niranjana Vishwanathapura wrote: > On Wed, Nov 09, 2022 at 05:28:59PM -0800, Zanoni, Paulo R wrote: > > On Mon, 2022-11-07 at 00:51 -0800, Niranjana Vishwanathapura wrote: > > > Add uapi and implement support for bind and unbind of an > > > object at the specified GPU virtual addresses. > > > > > > The vm_bind mode is not supported in legacy execbuf2 ioctl. > > > It will be supported only in the newer execbuf3 ioctl. > > > > > > v2: On older platforms ctx->vm is not set, check for it. > > > In vm_bind call, add vma to vm_bind_list. > > > Add more input validity checks. > > > Update some documentation. > > > v3: In vm_bind call, add vma to vm_bound_list as user can > > > request a fence and pass to execbuf3 as input fence. > > > Remove short term pinning with PIN_VALIDATE flag. > > > v4: Replace vm->vm_bind_mode check with i915_gem_vm_is_vm_bind_mode(). > > > v5: Ensure all reserved fields are 0, use PIN_NOEVICT. > > > v6: Add reserved fields to drm_i915_gem_vm_bind. > > > > > > Reviewed-by: Matthew Auld > > > Signed-off-by: Niranjana Vishwanathapura > > > > > > Signed-off-by: Prathap Kumar Valsan > > > Signed-off-by: Andi Shyti > > > --- > > > drivers/gpu/drm/i915/Makefile | 1 + > > > drivers/gpu/drm/i915/gem/i915_gem_context.h | 15 + > > > .../gpu/drm/i915/gem/i915_gem_execbuffer.c| 5 + > > > drivers/gpu/drm/i915/gem/i915_gem_vm_bind.h | 26 ++ > > > .../drm/i915/gem/i915_gem_vm_bind_object.c| 324 ++ > > > drivers/gpu/drm/i915/gt/intel_gtt.c | 10 + > > > drivers/gpu/drm/i915/gt/intel_gtt.h | 9 + > > > drivers/gpu/drm/i915/i915_driver.c| 3 + > > > drivers/gpu/drm/i915/i915_vma.c | 1 + > > > drivers/gpu/drm/i915/i915_vma_types.h | 14 + > > > include/uapi/drm/i915_drm.h | 99 ++ > > > 11 files changed, 507 insertions(+) > > > create mode 100644 drivers/gpu/drm/i915/gem/i915_gem_vm_bind.h > > > create mode 100644 drivers/gpu/drm/i915/gem/i915_gem_vm_bind_object.c > > > > > > diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile > > > index 51704b54317c..b731f3ac80da 100644 > > > --- a/drivers/gpu/drm/i915/Makefile > > > +++ b/drivers/gpu/drm/i915/Makefile > > > @@ -166,6 +166,7 @@ gem-y += \ > > > gem/i915_gem_ttm_move.o \ > > > gem/i915_gem_ttm_pm.o \ > > > gem/i915_gem_userptr.o \ > > > + gem/i915_gem_vm_bind_object.o \ > > > gem/i915_gem_wait.o \ > > > gem/i915_gemfs.o > > > i915-y += \ > > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.h > > > b/drivers/gpu/drm/i915/gem/i915_gem_context.h > > > index 899fa8f1e0fe..e8b41aa8f8c4 100644 > > > --- a/drivers/gpu/drm/i915/gem/i915_gem_context.h > > > +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.h > > > @@ -139,6 +139,21 @@ int i915_gem_context_setparam_ioctl(struct > > > drm_device *dev, void *data, > > > int i915_gem_context_reset_stats_ioctl(struct drm_device *dev, void > > > *data, > > > struct drm_file *file); > > > > > > > > > > > > > > > +/** > > > + * i915_gem_vm_is_vm_bind_mode() - Check if address space is in vm_bind > > > mode > > > + * @vm: the address space > > > + * > > > + * Returns: > > > + * true: @vm is in vm_bind mode; allows only vm_bind method of binding. > > > + * false: @vm is not in vm_bind mode; allows only legacy execbuff method > > > + *of binding. > > > + */ > > > +static inline bool i915_gem_vm_is_vm_bind_mode(struct i915_address_space > > > *vm) > > > +{ > > > + /* No support to enable vm_bind mode yet */ > > > + return false; > > > +} > > > + > > > struct i915_address_space * > > > i915_gem_vm_lookup(struct drm_i915_file_private *file_priv, u32 id); > > > > > > > > > > > > > > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c > > > b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c > > > index 1160723c9d2d..c5bc9f6e887f 100644 > > > --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c > > > +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c > > > @@ -781,6 +781,11 @@ static int eb_select_context(struct i915_execbuffer > > > *eb) > > > if (unlikely(IS_ERR(ctx))) > > > return PTR_ERR(ctx); > > > > > > > > > > > > > > > + if (ctx->vm && i915_gem_vm_is_vm_bind_mode(ctx->vm)) { > > > + i915_gem_context_put(ctx); > > > + return -EOPNOTSUPP; > > > + } > > > + > > > eb->gem_context = ctx; > > > if (i915_gem_context_has_full_ppgtt(ctx)) > > > eb->invalid_flags |= EXEC_OBJECT_NEEDS_GTT; > > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_vm_bind.h > > > b/drivers/gpu/drm/i915/gem/i915_gem_vm_bind.h > > > new file mode 100644 > > > index ..36262a6357b5 > > > --- /dev/null > > > +++ b/drivers/gpu/drm/i915/gem/i915_gem_vm_bind.h > > > @@ -0,0 +1,26 @@ > > > +/* SPDX-License-Identifier: MIT */ > > > +/* > > > + * Copyright © 2022 Intel Corporation > > > + */ > >
Re: [PATCH v6 05/20] drm/i915/vm_bind: Implement bind and unbind of object
On Wed, Nov 09, 2022 at 05:28:59PM -0800, Zanoni, Paulo R wrote: On Mon, 2022-11-07 at 00:51 -0800, Niranjana Vishwanathapura wrote: Add uapi and implement support for bind and unbind of an object at the specified GPU virtual addresses. The vm_bind mode is not supported in legacy execbuf2 ioctl. It will be supported only in the newer execbuf3 ioctl. v2: On older platforms ctx->vm is not set, check for it. In vm_bind call, add vma to vm_bind_list. Add more input validity checks. Update some documentation. v3: In vm_bind call, add vma to vm_bound_list as user can request a fence and pass to execbuf3 as input fence. Remove short term pinning with PIN_VALIDATE flag. v4: Replace vm->vm_bind_mode check with i915_gem_vm_is_vm_bind_mode(). v5: Ensure all reserved fields are 0, use PIN_NOEVICT. v6: Add reserved fields to drm_i915_gem_vm_bind. Reviewed-by: Matthew Auld Signed-off-by: Niranjana Vishwanathapura Signed-off-by: Prathap Kumar Valsan Signed-off-by: Andi Shyti --- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/gem/i915_gem_context.h | 15 + .../gpu/drm/i915/gem/i915_gem_execbuffer.c| 5 + drivers/gpu/drm/i915/gem/i915_gem_vm_bind.h | 26 ++ .../drm/i915/gem/i915_gem_vm_bind_object.c| 324 ++ drivers/gpu/drm/i915/gt/intel_gtt.c | 10 + drivers/gpu/drm/i915/gt/intel_gtt.h | 9 + drivers/gpu/drm/i915/i915_driver.c| 3 + drivers/gpu/drm/i915/i915_vma.c | 1 + drivers/gpu/drm/i915/i915_vma_types.h | 14 + include/uapi/drm/i915_drm.h | 99 ++ 11 files changed, 507 insertions(+) create mode 100644 drivers/gpu/drm/i915/gem/i915_gem_vm_bind.h create mode 100644 drivers/gpu/drm/i915/gem/i915_gem_vm_bind_object.c diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 51704b54317c..b731f3ac80da 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -166,6 +166,7 @@ gem-y += \ gem/i915_gem_ttm_move.o \ gem/i915_gem_ttm_pm.o \ gem/i915_gem_userptr.o \ + gem/i915_gem_vm_bind_object.o \ gem/i915_gem_wait.o \ gem/i915_gemfs.o i915-y += \ diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.h b/drivers/gpu/drm/i915/gem/i915_gem_context.h index 899fa8f1e0fe..e8b41aa8f8c4 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_context.h +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.h @@ -139,6 +139,21 @@ int i915_gem_context_setparam_ioctl(struct drm_device *dev, void *data, int i915_gem_context_reset_stats_ioctl(struct drm_device *dev, void *data, struct drm_file *file); +/** + * i915_gem_vm_is_vm_bind_mode() - Check if address space is in vm_bind mode + * @vm: the address space + * + * Returns: + * true: @vm is in vm_bind mode; allows only vm_bind method of binding. + * false: @vm is not in vm_bind mode; allows only legacy execbuff method + *of binding. + */ +static inline bool i915_gem_vm_is_vm_bind_mode(struct i915_address_space *vm) +{ + /* No support to enable vm_bind mode yet */ + return false; +} + struct i915_address_space * i915_gem_vm_lookup(struct drm_i915_file_private *file_priv, u32 id); diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c index 1160723c9d2d..c5bc9f6e887f 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c @@ -781,6 +781,11 @@ static int eb_select_context(struct i915_execbuffer *eb) if (unlikely(IS_ERR(ctx))) return PTR_ERR(ctx); + if (ctx->vm && i915_gem_vm_is_vm_bind_mode(ctx->vm)) { + i915_gem_context_put(ctx); + return -EOPNOTSUPP; + } + eb->gem_context = ctx; if (i915_gem_context_has_full_ppgtt(ctx)) eb->invalid_flags |= EXEC_OBJECT_NEEDS_GTT; diff --git a/drivers/gpu/drm/i915/gem/i915_gem_vm_bind.h b/drivers/gpu/drm/i915/gem/i915_gem_vm_bind.h new file mode 100644 index ..36262a6357b5 --- /dev/null +++ b/drivers/gpu/drm/i915/gem/i915_gem_vm_bind.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright © 2022 Intel Corporation + */ + +#ifndef __I915_GEM_VM_BIND_H +#define __I915_GEM_VM_BIND_H + +#include + +struct drm_device; +struct drm_file; +struct i915_address_space; +struct i915_vma; + +struct i915_vma * +i915_gem_vm_bind_lookup_vma(struct i915_address_space *vm, u64 va); + +int i915_gem_vm_bind_ioctl(struct drm_device *dev, void *data, + struct drm_file *file); +int i915_gem_vm_unbind_ioctl(struct drm_device *dev, void *data, +struct drm_file *file); + +void i915_gem_vm_unbind_all(struct i915_address_space *vm); + +#endif /* __I915_GEM_VM_BIND_H */ diff --git a/drivers/gpu/drm/i915/gem/i915_gem_vm_bind_object.c b/drivers/gpu/drm/i915/gem/i915_ge
Re: [PATCH v6 05/20] drm/i915/vm_bind: Implement bind and unbind of object
On Mon, 2022-11-07 at 00:51 -0800, Niranjana Vishwanathapura wrote: > Add uapi and implement support for bind and unbind of an > object at the specified GPU virtual addresses. > > The vm_bind mode is not supported in legacy execbuf2 ioctl. > It will be supported only in the newer execbuf3 ioctl. > > v2: On older platforms ctx->vm is not set, check for it. > In vm_bind call, add vma to vm_bind_list. > Add more input validity checks. > Update some documentation. > v3: In vm_bind call, add vma to vm_bound_list as user can > request a fence and pass to execbuf3 as input fence. > Remove short term pinning with PIN_VALIDATE flag. > v4: Replace vm->vm_bind_mode check with i915_gem_vm_is_vm_bind_mode(). > v5: Ensure all reserved fields are 0, use PIN_NOEVICT. > v6: Add reserved fields to drm_i915_gem_vm_bind. > > Reviewed-by: Matthew Auld > Signed-off-by: Niranjana Vishwanathapura > Signed-off-by: Prathap Kumar Valsan > Signed-off-by: Andi Shyti > --- > drivers/gpu/drm/i915/Makefile | 1 + > drivers/gpu/drm/i915/gem/i915_gem_context.h | 15 + > .../gpu/drm/i915/gem/i915_gem_execbuffer.c| 5 + > drivers/gpu/drm/i915/gem/i915_gem_vm_bind.h | 26 ++ > .../drm/i915/gem/i915_gem_vm_bind_object.c| 324 ++ > drivers/gpu/drm/i915/gt/intel_gtt.c | 10 + > drivers/gpu/drm/i915/gt/intel_gtt.h | 9 + > drivers/gpu/drm/i915/i915_driver.c| 3 + > drivers/gpu/drm/i915/i915_vma.c | 1 + > drivers/gpu/drm/i915/i915_vma_types.h | 14 + > include/uapi/drm/i915_drm.h | 99 ++ > 11 files changed, 507 insertions(+) > create mode 100644 drivers/gpu/drm/i915/gem/i915_gem_vm_bind.h > create mode 100644 drivers/gpu/drm/i915/gem/i915_gem_vm_bind_object.c > > diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile > index 51704b54317c..b731f3ac80da 100644 > --- a/drivers/gpu/drm/i915/Makefile > +++ b/drivers/gpu/drm/i915/Makefile > @@ -166,6 +166,7 @@ gem-y += \ > gem/i915_gem_ttm_move.o \ > gem/i915_gem_ttm_pm.o \ > gem/i915_gem_userptr.o \ > + gem/i915_gem_vm_bind_object.o \ > gem/i915_gem_wait.o \ > gem/i915_gemfs.o > i915-y += \ > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.h > b/drivers/gpu/drm/i915/gem/i915_gem_context.h > index 899fa8f1e0fe..e8b41aa8f8c4 100644 > --- a/drivers/gpu/drm/i915/gem/i915_gem_context.h > +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.h > @@ -139,6 +139,21 @@ int i915_gem_context_setparam_ioctl(struct drm_device > *dev, void *data, > int i915_gem_context_reset_stats_ioctl(struct drm_device *dev, void *data, > struct drm_file *file); > > > > > +/** > + * i915_gem_vm_is_vm_bind_mode() - Check if address space is in vm_bind mode > + * @vm: the address space > + * > + * Returns: > + * true: @vm is in vm_bind mode; allows only vm_bind method of binding. > + * false: @vm is not in vm_bind mode; allows only legacy execbuff method > + *of binding. > + */ > +static inline bool i915_gem_vm_is_vm_bind_mode(struct i915_address_space *vm) > +{ > + /* No support to enable vm_bind mode yet */ > + return false; > +} > + > struct i915_address_space * > i915_gem_vm_lookup(struct drm_i915_file_private *file_priv, u32 id); > > > > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c > b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c > index 1160723c9d2d..c5bc9f6e887f 100644 > --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c > +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c > @@ -781,6 +781,11 @@ static int eb_select_context(struct i915_execbuffer *eb) > if (unlikely(IS_ERR(ctx))) > return PTR_ERR(ctx); > > > > > + if (ctx->vm && i915_gem_vm_is_vm_bind_mode(ctx->vm)) { > + i915_gem_context_put(ctx); > + return -EOPNOTSUPP; > + } > + > eb->gem_context = ctx; > if (i915_gem_context_has_full_ppgtt(ctx)) > eb->invalid_flags |= EXEC_OBJECT_NEEDS_GTT; > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_vm_bind.h > b/drivers/gpu/drm/i915/gem/i915_gem_vm_bind.h > new file mode 100644 > index ..36262a6357b5 > --- /dev/null > +++ b/drivers/gpu/drm/i915/gem/i915_gem_vm_bind.h > @@ -0,0 +1,26 @@ > +/* SPDX-License-Identifier: MIT */ > +/* > + * Copyright © 2022 Intel Corporation > + */ > + > +#ifndef __I915_GEM_VM_BIND_H > +#define __I915_GEM_VM_BIND_H > + > +#include > + > +struct drm_device; > +struct drm_file; > +struct i915_address_space; > +struct i915_vma; > + > +struct i915_vma * > +i915_gem_vm_bind_lookup_vma(struct i915_address_space *vm, u64 va); > + > +int i915_gem_vm_bind_ioctl(struct drm_device *dev, void *data, > +struct drm_file *file); > +int i915_gem_vm_unbind_ioctl(struct drm_device *dev, void *data, > + struct drm_file *file); > + > +void i915_gem_vm_unbind_all(struct i
[PATCH v6 05/20] drm/i915/vm_bind: Implement bind and unbind of object
Add uapi and implement support for bind and unbind of an object at the specified GPU virtual addresses. The vm_bind mode is not supported in legacy execbuf2 ioctl. It will be supported only in the newer execbuf3 ioctl. v2: On older platforms ctx->vm is not set, check for it. In vm_bind call, add vma to vm_bind_list. Add more input validity checks. Update some documentation. v3: In vm_bind call, add vma to vm_bound_list as user can request a fence and pass to execbuf3 as input fence. Remove short term pinning with PIN_VALIDATE flag. v4: Replace vm->vm_bind_mode check with i915_gem_vm_is_vm_bind_mode(). v5: Ensure all reserved fields are 0, use PIN_NOEVICT. v6: Add reserved fields to drm_i915_gem_vm_bind. Reviewed-by: Matthew Auld Signed-off-by: Niranjana Vishwanathapura Signed-off-by: Prathap Kumar Valsan Signed-off-by: Andi Shyti --- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/gem/i915_gem_context.h | 15 + .../gpu/drm/i915/gem/i915_gem_execbuffer.c| 5 + drivers/gpu/drm/i915/gem/i915_gem_vm_bind.h | 26 ++ .../drm/i915/gem/i915_gem_vm_bind_object.c| 324 ++ drivers/gpu/drm/i915/gt/intel_gtt.c | 10 + drivers/gpu/drm/i915/gt/intel_gtt.h | 9 + drivers/gpu/drm/i915/i915_driver.c| 3 + drivers/gpu/drm/i915/i915_vma.c | 1 + drivers/gpu/drm/i915/i915_vma_types.h | 14 + include/uapi/drm/i915_drm.h | 99 ++ 11 files changed, 507 insertions(+) create mode 100644 drivers/gpu/drm/i915/gem/i915_gem_vm_bind.h create mode 100644 drivers/gpu/drm/i915/gem/i915_gem_vm_bind_object.c diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 51704b54317c..b731f3ac80da 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -166,6 +166,7 @@ gem-y += \ gem/i915_gem_ttm_move.o \ gem/i915_gem_ttm_pm.o \ gem/i915_gem_userptr.o \ + gem/i915_gem_vm_bind_object.o \ gem/i915_gem_wait.o \ gem/i915_gemfs.o i915-y += \ diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.h b/drivers/gpu/drm/i915/gem/i915_gem_context.h index 899fa8f1e0fe..e8b41aa8f8c4 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_context.h +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.h @@ -139,6 +139,21 @@ int i915_gem_context_setparam_ioctl(struct drm_device *dev, void *data, int i915_gem_context_reset_stats_ioctl(struct drm_device *dev, void *data, struct drm_file *file); +/** + * i915_gem_vm_is_vm_bind_mode() - Check if address space is in vm_bind mode + * @vm: the address space + * + * Returns: + * true: @vm is in vm_bind mode; allows only vm_bind method of binding. + * false: @vm is not in vm_bind mode; allows only legacy execbuff method + *of binding. + */ +static inline bool i915_gem_vm_is_vm_bind_mode(struct i915_address_space *vm) +{ + /* No support to enable vm_bind mode yet */ + return false; +} + struct i915_address_space * i915_gem_vm_lookup(struct drm_i915_file_private *file_priv, u32 id); diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c index 1160723c9d2d..c5bc9f6e887f 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c @@ -781,6 +781,11 @@ static int eb_select_context(struct i915_execbuffer *eb) if (unlikely(IS_ERR(ctx))) return PTR_ERR(ctx); + if (ctx->vm && i915_gem_vm_is_vm_bind_mode(ctx->vm)) { + i915_gem_context_put(ctx); + return -EOPNOTSUPP; + } + eb->gem_context = ctx; if (i915_gem_context_has_full_ppgtt(ctx)) eb->invalid_flags |= EXEC_OBJECT_NEEDS_GTT; diff --git a/drivers/gpu/drm/i915/gem/i915_gem_vm_bind.h b/drivers/gpu/drm/i915/gem/i915_gem_vm_bind.h new file mode 100644 index ..36262a6357b5 --- /dev/null +++ b/drivers/gpu/drm/i915/gem/i915_gem_vm_bind.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright © 2022 Intel Corporation + */ + +#ifndef __I915_GEM_VM_BIND_H +#define __I915_GEM_VM_BIND_H + +#include + +struct drm_device; +struct drm_file; +struct i915_address_space; +struct i915_vma; + +struct i915_vma * +i915_gem_vm_bind_lookup_vma(struct i915_address_space *vm, u64 va); + +int i915_gem_vm_bind_ioctl(struct drm_device *dev, void *data, + struct drm_file *file); +int i915_gem_vm_unbind_ioctl(struct drm_device *dev, void *data, +struct drm_file *file); + +void i915_gem_vm_unbind_all(struct i915_address_space *vm); + +#endif /* __I915_GEM_VM_BIND_H */ diff --git a/drivers/gpu/drm/i915/gem/i915_gem_vm_bind_object.c b/drivers/gpu/drm/i915/gem/i915_gem_vm_bind_object.c new file mode 100644 index ..6f299806bee1 --- /dev/null +++ b/drivers/gpu/drm/i915/gem/i915_gem_vm_bind_object.c @