* Re: [PATCH 4/6] drm/nouveau: Support sync FDs and syncobjs
@ 2020-08-28 21:46 kernel test robot
0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2020-08-28 21:46 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 5150 bytes --]
CC: kbuild-all(a)lists.01.org
In-Reply-To: <20200828104016.1672195-5-thierry.reding@gmail.com>
References: <20200828104016.1672195-5-thierry.reding@gmail.com>
TO: Thierry Reding <thierry.reding@gmail.com>
Hi Thierry,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[also build test WARNING on v5.9-rc2 next-20200828]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Thierry-Reding/drm-nouveau-Support-sync-FDs-and-sync-objects/20200828-184155
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 15bc20c6af4ceee97a1f90b43c0e386643c071b4
:::::: branch date: 11 hours ago
:::::: commit date: 11 hours ago
config: x86_64-randconfig-m001-20200828 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
New smatch warnings:
drivers/gpu/drm/nouveau/nouveau_gem.c:772 nouveau_channel_emit_fence() warn: passing zero to 'ERR_PTR'
Old smatch warnings:
include/drm/ttm/ttm_bo_driver.h:641 __ttm_bo_reserve() warn: inconsistent returns '*bo->base.resv'.
# https://github.com/0day-ci/linux/commit/2a7ed4e5037cdf9d59e36812ae6ce230df64d472
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Thierry-Reding/drm-nouveau-Support-sync-FDs-and-sync-objects/20200828-184155
git checkout 2a7ed4e5037cdf9d59e36812ae6ce230df64d472
vim +/ERR_PTR +772 drivers/gpu/drm/nouveau/nouveau_gem.c
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 727
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 728 static struct nouveau_fence *
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 729 nouveau_channel_emit_fence(struct nouveau_channel *channel,
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 730 struct drm_file *file_priv,
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 731 struct drm_nouveau_gem_fence *f)
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 732 {
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 733 struct nouveau_fence *fence;
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 734 int ret;
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 735
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 736 ret = nouveau_fence_new(channel, false, &fence);
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 737 if (ret < 0)
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 738 return ERR_PTR(ret);
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 739
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 740 if (f->flags & NOUVEAU_GEM_FENCE_FD) {
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 741 struct sync_file *file;
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 742 int fd;
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 743
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 744 fd = get_unused_fd_flags(O_CLOEXEC);
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 745 if (fd < 0) {
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 746 ret = fd;
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 747 goto put;
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 748 }
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 749
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 750 file = sync_file_create(&fence->base);
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 751 if (!file) {
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 752 put_unused_fd(fd);
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 753 ret = -ENOMEM;
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 754 goto put;
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 755 }
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 756
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 757 fd_install(fd, file->file);
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 758 f->handle = fd;
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 759 } else {
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 760 struct drm_syncobj *syncobj;
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 761
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 762 ret = drm_syncobj_create(&syncobj, 0, &fence->base);
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 763 if (ret < 0)
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 764 goto put;
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 765
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 766 ret = drm_syncobj_get_handle(file_priv, syncobj, &f->handle);
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 767 drm_syncobj_put(syncobj);
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 768 }
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 769
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 770 put:
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 771 nouveau_fence_unref(&fence);
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 @772 return ERR_PTR(ret);
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 773 }
2a7ed4e5037cdf9 Thierry Reding 2020-08-28 774
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 38811 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 0/6] drm/nouveau: Support sync FDs and sync objects
@ 2020-08-28 10:40 Thierry Reding
[not found] ` <20200828104016.1672195-1-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Thierry Reding @ 2020-08-28 10:40 UTC (permalink / raw)
To: Ben Skeggs
Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Hi,
This series implements a new IOCTL to submit push buffers that can
optionally return a sync FD or sync object to userspace. This is useful
in cases where userspace wants to synchronize operations between the GPU
and another driver (such as KMS for display). Among other things this
allows extensions such as eglDupNativeFenceFDANDROID to be implemented.
Note that patch 4 modifies the ABI introduced in patch 3 by allowing DRM
sync objects to be passed rather than only sync FDs. It also allows any
number of sync FDs/objects to be passed in or emitted. I think those are
useful features, but I left them in a separate patch in case everybody
else thinks that this won't be needed. If we decide to merge the new ABI
then patch 4 should be squashed into patch 3.
The corresponding userspace changes can be found here:
libdrm: https://gitlab.freedesktop.org/tagr/drm/-/commits/nouveau-sync-fd-v2/
mesa: https://gitlab.freedesktop.org/tagr/mesa/-/commits/nouveau-sync-fd/
I've verified that this works with kmscube's --atomic mode and Weston.
Thierry
Thierry Reding (6):
drm/nouveau: Split nouveau_fence_sync()
drm/nouveau: Add nouveau_fence_ref()
drm/nouveau: Support fence FDs at kickoff
drm/nouveau: Support sync FDs and syncobjs
drm/nouveau: Support DMA fence arrays
drm/nouveau: Allow zero pushbuffer submits
drivers/gpu/drm/nouveau/dispnv04/crtc.c | 4 +-
drivers/gpu/drm/nouveau/nouveau_bo.c | 38 ++-
drivers/gpu/drm/nouveau/nouveau_bo.h | 2 +
drivers/gpu/drm/nouveau/nouveau_drm.c | 1 +
drivers/gpu/drm/nouveau/nouveau_fence.c | 90 +++---
drivers/gpu/drm/nouveau/nouveau_fence.h | 3 +-
drivers/gpu/drm/nouveau/nouveau_gem.c | 402 ++++++++++++++++++------
drivers/gpu/drm/nouveau/nouveau_gem.h | 2 +
include/uapi/drm/nouveau_drm.h | 23 ++
9 files changed, 410 insertions(+), 155 deletions(-)
--
2.28.0
^ permalink raw reply [flat|nested] 5+ messages in thread[parent not found: <20200828104016.1672195-1-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* [PATCH 4/6] drm/nouveau: Support sync FDs and syncobjs 2020-08-28 10:40 [PATCH 0/6] drm/nouveau: Support sync FDs and sync objects Thierry Reding @ 2020-08-28 10:40 ` Thierry Reding 0 siblings, 0 replies; 5+ messages in thread From: Thierry Reding @ 2020-08-28 10:40 UTC (permalink / raw) To: Ben Skeggs Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> Extends the new NOUVEAU_GEM_PUSHBUF2 IOCTL to accept and emit one or more sync FDs and/or DRM native sync objects. Signed-off-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> --- Note: If acceptable, this should be merged into the previous patch that adds the new IOCTL. drivers/gpu/drm/nouveau/nouveau_gem.c | 180 ++++++++++++++++++++++---- include/uapi/drm/nouveau_drm.h | 21 ++- 2 files changed, 167 insertions(+), 34 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 039f244c0a00..b3ece731e4e1 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -26,6 +26,7 @@ #include <linux/file.h> #include <linux/sync_file.h> +#include <drm/drm_syncobj.h> #include "nouveau_drv.h" #include "nouveau_dma.h" @@ -680,12 +681,137 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_cli *cli, return ret; } +static int nouveau_channel_wait_fence(struct nouveau_channel *channel, + struct drm_file *file_priv, + struct drm_nouveau_gem_fence *f) +{ + struct dma_fence *fence; + + if (f->flags & NOUVEAU_GEM_FENCE_FD) { + fence = sync_file_get_fence(f->handle); + if (!fence) + return -ENOENT; + } else { + struct drm_syncobj *syncobj; + + syncobj = drm_syncobj_find(file_priv, f->handle); + if (!syncobj) + return -ENOENT; + + fence = drm_syncobj_fence_get(syncobj); + drm_syncobj_put(syncobj); + } + + return nouveau_fence_sync(fence, channel, true); +} + +static int nouveau_channel_wait_fences(struct nouveau_channel *channel, + struct drm_file *file_priv, + struct drm_nouveau_gem_fence *fences, + unsigned int num_fences) +{ + unsigned int i; + int ret; + + for (i = 0; i < num_fences; i++) { + if (fences[i].flags & NOUVEAU_GEM_FENCE_WAIT) { + ret = nouveau_channel_wait_fence(channel, file_priv, + &fences[i]); + if (ret < 0) + return ret; + } + } + + return 0; +} + +static struct nouveau_fence * +nouveau_channel_emit_fence(struct nouveau_channel *channel, + struct drm_file *file_priv, + struct drm_nouveau_gem_fence *f) +{ + struct nouveau_fence *fence; + int ret; + + ret = nouveau_fence_new(channel, false, &fence); + if (ret < 0) + return ERR_PTR(ret); + + if (f->flags & NOUVEAU_GEM_FENCE_FD) { + struct sync_file *file; + int fd; + + fd = get_unused_fd_flags(O_CLOEXEC); + if (fd < 0) { + ret = fd; + goto put; + } + + file = sync_file_create(&fence->base); + if (!file) { + put_unused_fd(fd); + ret = -ENOMEM; + goto put; + } + + fd_install(fd, file->file); + f->handle = fd; + } else { + struct drm_syncobj *syncobj; + + ret = drm_syncobj_create(&syncobj, 0, &fence->base); + if (ret < 0) + goto put; + + ret = drm_syncobj_get_handle(file_priv, syncobj, &f->handle); + drm_syncobj_put(syncobj); + } + +put: + nouveau_fence_unref(&fence); + return ERR_PTR(ret); +} + +static struct nouveau_fence * +nouveau_channel_emit_fences(struct nouveau_channel *channel, + struct drm_file *file_priv, + struct drm_nouveau_gem_fence *fences, + unsigned int num_fences) +{ + struct nouveau_fence *fence = NULL, *f; + unsigned int i; + int ret; + + for (i = 0; i < num_fences; i++) { + if (fences[i].flags & NOUVEAU_GEM_FENCE_EMIT) { + f = nouveau_channel_emit_fence(channel, file_priv, + &fences[i]); + if (IS_ERR(f)) + return f; + + if (!fence) + fence = f; + } + } + + if (!fence) { + ret = nouveau_fence_new(channel, false, &fence); + if (ret) + fence = ERR_PTR(ret); + } else { + nouveau_fence_ref(fence); + } + + return fence; +} + static int __nouveau_gem_ioctl_pushbuf(struct drm_device *dev, struct drm_nouveau_gem_pushbuf2 *request, struct drm_file *file_priv) { struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv); + struct drm_nouveau_gem_fence __user *user_fences; struct nouveau_cli *cli = nouveau_cli(file_priv); struct nouveau_abi16_chan *temp; struct nouveau_drm *drm = nouveau_drm(dev); @@ -693,12 +819,13 @@ __nouveau_gem_ioctl_pushbuf(struct drm_device *dev, struct drm_nouveau_gem_pushbuf_push *push; struct drm_nouveau_gem_pushbuf_reloc *reloc = NULL; struct drm_nouveau_gem_pushbuf_bo *bo; + struct drm_nouveau_gem_fence *fences = NULL; struct nouveau_channel *chan = NULL; struct validate_op op; struct nouveau_fence *fence = NULL; - struct dma_fence *prefence = NULL; int i, j, ret = 0; bool do_reloc = false, sync = false; + size_t size; /* check for unrecognized flags */ if (request->flags & ~NOUVEAU_GEM_PUSHBUF_FLAGS) @@ -773,13 +900,18 @@ __nouveau_gem_ioctl_pushbuf(struct drm_device *dev, goto out_prevalid; } - if (request->flags & NOUVEAU_GEM_PUSHBUF_FENCE_WAIT) { - prefence = sync_file_get_fence(request->fence); - if (prefence) { - ret = nouveau_fence_sync(prefence, chan, true); - if (ret < 0) - goto out; + if (request->num_fences > 0) { + fences = u_memcpya(request->fences, request->num_fences, + sizeof(*fences)); + if (IS_ERR(fences)) { + ret = PTR_ERR(fences); + goto out; } + + ret = nouveau_channel_wait_fences(chan, file_priv, fences, + request->num_fences); + if (ret < 0) + goto out; } /* Apply any relocations that are required */ @@ -869,10 +1001,13 @@ __nouveau_gem_ioctl_pushbuf(struct drm_device *dev, } } - ret = nouveau_fence_new(chan, false, &fence); - if (ret) { + fence = nouveau_channel_emit_fences(chan, file_priv, fences, + request->num_fences); + if (IS_ERR(fence)) { + ret = PTR_ERR(fence); NV_PRINTK(err, cli, "error fencing pushbuf: %d\n", ret); WIND_RING(chan); + fence = NULL; goto out; } @@ -883,29 +1018,18 @@ __nouveau_gem_ioctl_pushbuf(struct drm_device *dev, } } - if (request->flags & NOUVEAU_GEM_PUSHBUF_FENCE_EMIT) { - struct sync_file *file; - int fd; - - fd = get_unused_fd_flags(O_CLOEXEC); - if (fd < 0) { - ret = fd; - goto out; - } - - file = sync_file_create(&fence->base); - if (!file) { - put_unused_fd(fd); - goto out; - } + user_fences = u64_to_user_ptr(request->fences); + size = sizeof(*fences) * request->num_fences; - fd_install(fd, file->file); - request->fence = fd; + if (copy_to_user(user_fences, fences, size)) { + WIND_RING(chan); + ret = -EFAULT; + fence = NULL; + goto out; } out: - if (prefence) - dma_fence_put(prefence); + u_free(fences); validate_fini(&op, chan, fence, bo); nouveau_fence_unref(&fence); diff --git a/include/uapi/drm/nouveau_drm.h b/include/uapi/drm/nouveau_drm.h index 85425dc90301..5b8d40228a1b 100644 --- a/include/uapi/drm/nouveau_drm.h +++ b/include/uapi/drm/nouveau_drm.h @@ -115,16 +115,25 @@ struct drm_nouveau_gem_pushbuf { __u64 gart_available; }; -#define NOUVEAU_GEM_PUSHBUF_FENCE_WAIT (1 << 0) -#define NOUVEAU_GEM_PUSHBUF_FENCE_EMIT (1 << 1) -#define NOUVEAU_GEM_PUSHBUF_FLAGS (NOUVEAU_GEM_PUSHBUF_FENCE_WAIT | \ - NOUVEAU_GEM_PUSHBUF_FENCE_EMIT) +#define NOUVEAU_GEM_FENCE_WAIT (1 << 0) +#define NOUVEAU_GEM_FENCE_EMIT (1 << 1) +#define NOUVEAU_GEM_FENCE_FD (1 << 2) +#define NOUVEAU_GEM_FENCE_FLAGS (NOUVEAU_GEM_FENCE_WAIT | \ + NOUVEAU_GEM_FENCE_EMIT | \ + NOUVEAU_GEM_FENCE_FD) + +struct drm_nouveau_gem_fence { + __u32 handle; + __u32 flags; +}; + +#define NOUVEAU_GEM_PUSHBUF_FLAGS 0 struct drm_nouveau_gem_pushbuf2 { struct drm_nouveau_gem_pushbuf base; __u32 flags; - __s32 fence; - __u64 reserved; + __u32 num_fences; + __u64 fences; }; #define NOUVEAU_GEM_CPU_PREP_NOWAIT 0x00000001 -- 2.28.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/6] drm/nouveau: Support sync FDs and syncobjs @ 2020-08-28 10:40 ` Thierry Reding 0 siblings, 0 replies; 5+ messages in thread From: Thierry Reding @ 2020-08-28 10:40 UTC (permalink / raw) To: Ben Skeggs; +Cc: nouveau, dri-devel From: Thierry Reding <treding@nvidia.com> Extends the new NOUVEAU_GEM_PUSHBUF2 IOCTL to accept and emit one or more sync FDs and/or DRM native sync objects. Signed-off-by: Thierry Reding <treding@nvidia.com> --- Note: If acceptable, this should be merged into the previous patch that adds the new IOCTL. drivers/gpu/drm/nouveau/nouveau_gem.c | 180 ++++++++++++++++++++++---- include/uapi/drm/nouveau_drm.h | 21 ++- 2 files changed, 167 insertions(+), 34 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 039f244c0a00..b3ece731e4e1 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -26,6 +26,7 @@ #include <linux/file.h> #include <linux/sync_file.h> +#include <drm/drm_syncobj.h> #include "nouveau_drv.h" #include "nouveau_dma.h" @@ -680,12 +681,137 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_cli *cli, return ret; } +static int nouveau_channel_wait_fence(struct nouveau_channel *channel, + struct drm_file *file_priv, + struct drm_nouveau_gem_fence *f) +{ + struct dma_fence *fence; + + if (f->flags & NOUVEAU_GEM_FENCE_FD) { + fence = sync_file_get_fence(f->handle); + if (!fence) + return -ENOENT; + } else { + struct drm_syncobj *syncobj; + + syncobj = drm_syncobj_find(file_priv, f->handle); + if (!syncobj) + return -ENOENT; + + fence = drm_syncobj_fence_get(syncobj); + drm_syncobj_put(syncobj); + } + + return nouveau_fence_sync(fence, channel, true); +} + +static int nouveau_channel_wait_fences(struct nouveau_channel *channel, + struct drm_file *file_priv, + struct drm_nouveau_gem_fence *fences, + unsigned int num_fences) +{ + unsigned int i; + int ret; + + for (i = 0; i < num_fences; i++) { + if (fences[i].flags & NOUVEAU_GEM_FENCE_WAIT) { + ret = nouveau_channel_wait_fence(channel, file_priv, + &fences[i]); + if (ret < 0) + return ret; + } + } + + return 0; +} + +static struct nouveau_fence * +nouveau_channel_emit_fence(struct nouveau_channel *channel, + struct drm_file *file_priv, + struct drm_nouveau_gem_fence *f) +{ + struct nouveau_fence *fence; + int ret; + + ret = nouveau_fence_new(channel, false, &fence); + if (ret < 0) + return ERR_PTR(ret); + + if (f->flags & NOUVEAU_GEM_FENCE_FD) { + struct sync_file *file; + int fd; + + fd = get_unused_fd_flags(O_CLOEXEC); + if (fd < 0) { + ret = fd; + goto put; + } + + file = sync_file_create(&fence->base); + if (!file) { + put_unused_fd(fd); + ret = -ENOMEM; + goto put; + } + + fd_install(fd, file->file); + f->handle = fd; + } else { + struct drm_syncobj *syncobj; + + ret = drm_syncobj_create(&syncobj, 0, &fence->base); + if (ret < 0) + goto put; + + ret = drm_syncobj_get_handle(file_priv, syncobj, &f->handle); + drm_syncobj_put(syncobj); + } + +put: + nouveau_fence_unref(&fence); + return ERR_PTR(ret); +} + +static struct nouveau_fence * +nouveau_channel_emit_fences(struct nouveau_channel *channel, + struct drm_file *file_priv, + struct drm_nouveau_gem_fence *fences, + unsigned int num_fences) +{ + struct nouveau_fence *fence = NULL, *f; + unsigned int i; + int ret; + + for (i = 0; i < num_fences; i++) { + if (fences[i].flags & NOUVEAU_GEM_FENCE_EMIT) { + f = nouveau_channel_emit_fence(channel, file_priv, + &fences[i]); + if (IS_ERR(f)) + return f; + + if (!fence) + fence = f; + } + } + + if (!fence) { + ret = nouveau_fence_new(channel, false, &fence); + if (ret) + fence = ERR_PTR(ret); + } else { + nouveau_fence_ref(fence); + } + + return fence; +} + static int __nouveau_gem_ioctl_pushbuf(struct drm_device *dev, struct drm_nouveau_gem_pushbuf2 *request, struct drm_file *file_priv) { struct nouveau_abi16 *abi16 = nouveau_abi16_get(file_priv); + struct drm_nouveau_gem_fence __user *user_fences; struct nouveau_cli *cli = nouveau_cli(file_priv); struct nouveau_abi16_chan *temp; struct nouveau_drm *drm = nouveau_drm(dev); @@ -693,12 +819,13 @@ __nouveau_gem_ioctl_pushbuf(struct drm_device *dev, struct drm_nouveau_gem_pushbuf_push *push; struct drm_nouveau_gem_pushbuf_reloc *reloc = NULL; struct drm_nouveau_gem_pushbuf_bo *bo; + struct drm_nouveau_gem_fence *fences = NULL; struct nouveau_channel *chan = NULL; struct validate_op op; struct nouveau_fence *fence = NULL; - struct dma_fence *prefence = NULL; int i, j, ret = 0; bool do_reloc = false, sync = false; + size_t size; /* check for unrecognized flags */ if (request->flags & ~NOUVEAU_GEM_PUSHBUF_FLAGS) @@ -773,13 +900,18 @@ __nouveau_gem_ioctl_pushbuf(struct drm_device *dev, goto out_prevalid; } - if (request->flags & NOUVEAU_GEM_PUSHBUF_FENCE_WAIT) { - prefence = sync_file_get_fence(request->fence); - if (prefence) { - ret = nouveau_fence_sync(prefence, chan, true); - if (ret < 0) - goto out; + if (request->num_fences > 0) { + fences = u_memcpya(request->fences, request->num_fences, + sizeof(*fences)); + if (IS_ERR(fences)) { + ret = PTR_ERR(fences); + goto out; } + + ret = nouveau_channel_wait_fences(chan, file_priv, fences, + request->num_fences); + if (ret < 0) + goto out; } /* Apply any relocations that are required */ @@ -869,10 +1001,13 @@ __nouveau_gem_ioctl_pushbuf(struct drm_device *dev, } } - ret = nouveau_fence_new(chan, false, &fence); - if (ret) { + fence = nouveau_channel_emit_fences(chan, file_priv, fences, + request->num_fences); + if (IS_ERR(fence)) { + ret = PTR_ERR(fence); NV_PRINTK(err, cli, "error fencing pushbuf: %d\n", ret); WIND_RING(chan); + fence = NULL; goto out; } @@ -883,29 +1018,18 @@ __nouveau_gem_ioctl_pushbuf(struct drm_device *dev, } } - if (request->flags & NOUVEAU_GEM_PUSHBUF_FENCE_EMIT) { - struct sync_file *file; - int fd; - - fd = get_unused_fd_flags(O_CLOEXEC); - if (fd < 0) { - ret = fd; - goto out; - } - - file = sync_file_create(&fence->base); - if (!file) { - put_unused_fd(fd); - goto out; - } + user_fences = u64_to_user_ptr(request->fences); + size = sizeof(*fences) * request->num_fences; - fd_install(fd, file->file); - request->fence = fd; + if (copy_to_user(user_fences, fences, size)) { + WIND_RING(chan); + ret = -EFAULT; + fence = NULL; + goto out; } out: - if (prefence) - dma_fence_put(prefence); + u_free(fences); validate_fini(&op, chan, fence, bo); nouveau_fence_unref(&fence); diff --git a/include/uapi/drm/nouveau_drm.h b/include/uapi/drm/nouveau_drm.h index 85425dc90301..5b8d40228a1b 100644 --- a/include/uapi/drm/nouveau_drm.h +++ b/include/uapi/drm/nouveau_drm.h @@ -115,16 +115,25 @@ struct drm_nouveau_gem_pushbuf { __u64 gart_available; }; -#define NOUVEAU_GEM_PUSHBUF_FENCE_WAIT (1 << 0) -#define NOUVEAU_GEM_PUSHBUF_FENCE_EMIT (1 << 1) -#define NOUVEAU_GEM_PUSHBUF_FLAGS (NOUVEAU_GEM_PUSHBUF_FENCE_WAIT | \ - NOUVEAU_GEM_PUSHBUF_FENCE_EMIT) +#define NOUVEAU_GEM_FENCE_WAIT (1 << 0) +#define NOUVEAU_GEM_FENCE_EMIT (1 << 1) +#define NOUVEAU_GEM_FENCE_FD (1 << 2) +#define NOUVEAU_GEM_FENCE_FLAGS (NOUVEAU_GEM_FENCE_WAIT | \ + NOUVEAU_GEM_FENCE_EMIT | \ + NOUVEAU_GEM_FENCE_FD) + +struct drm_nouveau_gem_fence { + __u32 handle; + __u32 flags; +}; + +#define NOUVEAU_GEM_PUSHBUF_FLAGS 0 struct drm_nouveau_gem_pushbuf2 { struct drm_nouveau_gem_pushbuf base; __u32 flags; - __s32 fence; - __u64 reserved; + __u32 num_fences; + __u64 fences; }; #define NOUVEAU_GEM_CPU_PREP_NOWAIT 0x00000001 -- 2.28.0 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 4/6] drm/nouveau: Support sync FDs and syncobjs 2020-08-28 10:40 ` Thierry Reding @ 2020-08-31 12:27 ` Dan Carpenter -1 siblings, 0 replies; 5+ messages in thread From: Dan Carpenter @ 2020-08-31 12:27 UTC (permalink / raw) To: kbuild [-- Attachment #1: Type: text/plain, Size: 4496 bytes --] Hi Thierry, url: https://github.com/0day-ci/linux/commits/Thierry-Reding/drm-nouveau-Support-sync-FDs-and-sync-objects/20200828-184155 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 15bc20c6af4ceee97a1f90b43c0e386643c071b4 config: x86_64-randconfig-m001-20200828 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> New smatch warnings: drivers/gpu/drm/nouveau/nouveau_gem.c:772 nouveau_channel_emit_fence() warn: passing zero to 'ERR_PTR' Old smatch warnings: include/drm/ttm/ttm_bo_driver.h:641 __ttm_bo_reserve() warn: inconsistent returns '*bo->base.resv'. # https://github.com/0day-ci/linux/commit/2a7ed4e5037cdf9d59e36812ae6ce230df64d472 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Thierry-Reding/drm-nouveau-Support-sync-FDs-and-sync-objects/20200828-184155 git checkout 2a7ed4e5037cdf9d59e36812ae6ce230df64d472 vim +/ERR_PTR +772 drivers/gpu/drm/nouveau/nouveau_gem.c 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 728 static struct nouveau_fence * 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 729 nouveau_channel_emit_fence(struct nouveau_channel *channel, 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 730 struct drm_file *file_priv, 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 731 struct drm_nouveau_gem_fence *f) 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 732 { 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 733 struct nouveau_fence *fence; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 734 int ret; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 735 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 736 ret = nouveau_fence_new(channel, false, &fence); 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 737 if (ret < 0) 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 738 return ERR_PTR(ret); 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 739 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 740 if (f->flags & NOUVEAU_GEM_FENCE_FD) { 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 741 struct sync_file *file; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 742 int fd; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 743 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 744 fd = get_unused_fd_flags(O_CLOEXEC); 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 745 if (fd < 0) { 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 746 ret = fd; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 747 goto put; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 748 } 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 749 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 750 file = sync_file_create(&fence->base); 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 751 if (!file) { 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 752 put_unused_fd(fd); 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 753 ret = -ENOMEM; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 754 goto put; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 755 } 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 756 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 757 fd_install(fd, file->file); 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 758 f->handle = fd; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 759 } else { 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 760 struct drm_syncobj *syncobj; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 761 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 762 ret = drm_syncobj_create(&syncobj, 0, &fence->base); 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 763 if (ret < 0) 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 764 goto put; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 765 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 766 ret = drm_syncobj_get_handle(file_priv, syncobj, &f->handle); 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 767 drm_syncobj_put(syncobj); 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 768 } 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 769 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 770 put: 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 771 nouveau_fence_unref(&fence); 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 @772 return ERR_PTR(ret); There is no "return fence;" success path in this function? 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 773 } --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org [-- Attachment #2: config.gz --] [-- Type: application/gzip, Size: 38811 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 4/6] drm/nouveau: Support sync FDs and syncobjs @ 2020-08-31 12:27 ` Dan Carpenter 0 siblings, 0 replies; 5+ messages in thread From: Dan Carpenter @ 2020-08-31 12:27 UTC (permalink / raw) To: kbuild-all [-- Attachment #1: Type: text/plain, Size: 4496 bytes --] Hi Thierry, url: https://github.com/0day-ci/linux/commits/Thierry-Reding/drm-nouveau-Support-sync-FDs-and-sync-objects/20200828-184155 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 15bc20c6af4ceee97a1f90b43c0e386643c071b4 config: x86_64-randconfig-m001-20200828 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> New smatch warnings: drivers/gpu/drm/nouveau/nouveau_gem.c:772 nouveau_channel_emit_fence() warn: passing zero to 'ERR_PTR' Old smatch warnings: include/drm/ttm/ttm_bo_driver.h:641 __ttm_bo_reserve() warn: inconsistent returns '*bo->base.resv'. # https://github.com/0day-ci/linux/commit/2a7ed4e5037cdf9d59e36812ae6ce230df64d472 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Thierry-Reding/drm-nouveau-Support-sync-FDs-and-sync-objects/20200828-184155 git checkout 2a7ed4e5037cdf9d59e36812ae6ce230df64d472 vim +/ERR_PTR +772 drivers/gpu/drm/nouveau/nouveau_gem.c 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 728 static struct nouveau_fence * 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 729 nouveau_channel_emit_fence(struct nouveau_channel *channel, 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 730 struct drm_file *file_priv, 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 731 struct drm_nouveau_gem_fence *f) 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 732 { 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 733 struct nouveau_fence *fence; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 734 int ret; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 735 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 736 ret = nouveau_fence_new(channel, false, &fence); 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 737 if (ret < 0) 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 738 return ERR_PTR(ret); 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 739 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 740 if (f->flags & NOUVEAU_GEM_FENCE_FD) { 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 741 struct sync_file *file; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 742 int fd; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 743 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 744 fd = get_unused_fd_flags(O_CLOEXEC); 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 745 if (fd < 0) { 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 746 ret = fd; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 747 goto put; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 748 } 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 749 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 750 file = sync_file_create(&fence->base); 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 751 if (!file) { 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 752 put_unused_fd(fd); 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 753 ret = -ENOMEM; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 754 goto put; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 755 } 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 756 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 757 fd_install(fd, file->file); 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 758 f->handle = fd; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 759 } else { 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 760 struct drm_syncobj *syncobj; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 761 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 762 ret = drm_syncobj_create(&syncobj, 0, &fence->base); 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 763 if (ret < 0) 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 764 goto put; 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 765 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 766 ret = drm_syncobj_get_handle(file_priv, syncobj, &f->handle); 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 767 drm_syncobj_put(syncobj); 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 768 } 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 769 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 770 put: 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 771 nouveau_fence_unref(&fence); 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 @772 return ERR_PTR(ret); There is no "return fence;" success path in this function? 2a7ed4e5037cdf9 Thierry Reding 2020-08-28 773 } --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org [-- Attachment #2: config.gz --] [-- Type: application/gzip, Size: 38811 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-08-31 12:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-28 21:46 [PATCH 4/6] drm/nouveau: Support sync FDs and syncobjs kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2020-08-28 10:40 [PATCH 0/6] drm/nouveau: Support sync FDs and sync objects Thierry Reding
[not found] ` <20200828104016.1672195-1-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2020-08-28 10:40 ` [PATCH 4/6] drm/nouveau: Support sync FDs and syncobjs Thierry Reding
2020-08-28 10:40 ` Thierry Reding
2020-08-31 12:27 ` Dan Carpenter
2020-08-31 12:27 ` Dan Carpenter
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.