From: Matthew Brost <matthew.brost@intel.com>
To: "Ghimiray, Himal Prasad" <himal.prasad.ghimiray@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <paulo.r.zanoni@intel.com>
Subject: Re: [PATCH] drm/xe: Return -ENOBUFS if a kmalloc fails which is tied to an array of binds
Date: Sat, 20 Jul 2024 23:14:36 +0000 [thread overview]
Message-ID: <ZpxE3A6BrzymJZYL@DUT025-TGLU.fm.intel.com> (raw)
In-Reply-To: <3bf93639-74b9-41ff-9d6c-1911506772a2@intel.com>
On Sun, Jul 21, 2024 at 12:34:27AM +0530, Ghimiray, Himal Prasad wrote:
>
>
> On 19-07-2024 22:53, Matthew Brost wrote:
> > The size of an array of binds is directly tied to several kmalloc in the
> > KMD, thus making these kmalloc more likely to fail. Return -ENOBUFS in
> > the case of these failures.
> >
> > The expected UMD behavior upon returning -ENOBUFS is to split an array
> > of binds into a series of single binds.
>
> Would it be appropriate to have some doc/guidelines in the form of drm_err
> or kernel doc regarding expected behavior from UMD if the ioctl returns a
> -ENOBUFS error ?
>
Yes, this on the todo list as part of error handling cleanup for both
exec and bind IOCTLs. I think kernel doc should go in xe_drm.h with a
list of errno returned and expected UMD actions. Eventually I'd like to
get this in place for all IOCTLs. I was going to work on getting exec
and bind IOCTLs fixed up in the next couple of weeks (we have an
internal doc of required changes) to have it ready for when Thomas is
back (2 more weeks).
I made this change as we already have -ENOBUFS implemented in a
different failure point for array of binds (BB being to large, see
xe_migrate.c) so might as well just finish up this error code to make it
complete as it is fairly simple change. Also Mesa has a MR [1] inflight
to handle -ENOBUFs situations.
Matt
[1] https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30276
> >
> > Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
> > Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> > ---
> > drivers/gpu/drm/xe/xe_vm.c | 12 ++++++------
> > 1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> > index 3fde2c8292ad..b715883f40d8 100644
> > --- a/drivers/gpu/drm/xe/xe_vm.c
> > +++ b/drivers/gpu/drm/xe/xe_vm.c
> > @@ -718,7 +718,7 @@ int xe_vm_userptr_check_repin(struct xe_vm *vm)
> > list_empty_careful(&vm->userptr.invalidated)) ? 0 : -EAGAIN;
> > }
> > -static int xe_vma_ops_alloc(struct xe_vma_ops *vops)
> > +static int xe_vma_ops_alloc(struct xe_vma_ops *vops, bool array_of_binds)
> > {
> > int i;
> > @@ -731,7 +731,7 @@ static int xe_vma_ops_alloc(struct xe_vma_ops *vops)
> > sizeof(*vops->pt_update_ops[i].ops),
> > GFP_KERNEL);
> > if (!vops->pt_update_ops[i].ops)
> > - return -ENOMEM;
> > + return array_of_binds ? -ENOBUFS : -ENOMEM;
> > }
> > return 0;
> > @@ -824,7 +824,7 @@ int xe_vm_rebind(struct xe_vm *vm, bool rebind_worker)
> > goto free_ops;
> > }
> > - err = xe_vma_ops_alloc(&vops);
> > + err = xe_vma_ops_alloc(&vops, false);
> > if (err)
> > goto free_ops;
> > @@ -871,7 +871,7 @@ struct dma_fence *xe_vma_rebind(struct xe_vm *vm, struct xe_vma *vma, u8 tile_ma
> > if (err)
> > return ERR_PTR(err);
> > - err = xe_vma_ops_alloc(&vops);
> > + err = xe_vma_ops_alloc(&vops, false);
> > if (err) {
> > fence = ERR_PTR(err);
> > goto free_ops;
> > @@ -2765,7 +2765,7 @@ static int vm_bind_ioctl_check_args(struct xe_device *xe,
> > sizeof(struct drm_xe_vm_bind_op),
> > GFP_KERNEL | __GFP_ACCOUNT);
> > if (!*bind_ops)
> > - return -ENOMEM;
> > + return args->num_binds > 1 ? -ENOBUFS : -ENOMEM;
> > err = __copy_from_user(*bind_ops, bind_user,
> > sizeof(struct drm_xe_vm_bind_op) *
> > @@ -3104,7 +3104,7 @@ int xe_vm_bind_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> > goto unwind_ops;
> > }
> > - err = xe_vma_ops_alloc(&vops);
> > + err = xe_vma_ops_alloc(&vops, args->num_binds > 1);
> > if (err)
> > goto unwind_ops;
next prev parent reply other threads:[~2024-07-20 23:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-19 17:23 [PATCH] drm/xe: Return -ENOBUFS if a kmalloc fails which is tied to an array of binds Matthew Brost
2024-07-19 17:27 ` ✓ CI.Patch_applied: success for " Patchwork
2024-07-19 17:28 ` ✓ CI.checkpatch: " Patchwork
2024-07-19 17:28 ` ✗ CI.KUnit: failure " Patchwork
2024-07-19 18:27 ` [PATCH] " Cavitt, Jonathan
2024-07-20 19:04 ` Ghimiray, Himal Prasad
2024-07-20 23:14 ` Matthew Brost [this message]
2024-07-20 23:20 ` Matthew Brost
2024-07-22 3:53 ` Ghimiray, Himal Prasad
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZpxE3A6BrzymJZYL@DUT025-TGLU.fm.intel.com \
--to=matthew.brost@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=paulo.r.zanoni@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox