* [PATCH v2 1/4] dma-fence: add dma_fence_match_context helper
@ 2017-03-17 16:34 Philipp Zabel
2017-03-17 16:34 ` [PATCH v2 2/4] drm/etnaviv: submit support for in-fences Philipp Zabel
` (5 more replies)
0 siblings, 6 replies; 9+ messages in thread
From: Philipp Zabel @ 2017-03-17 16:34 UTC (permalink / raw)
To: dri-devel; +Cc: etnaviv, Russell King
Add a helper to check if all fences in a fence array are from a given
context. For convenience, the function can also handle being given a
non-array fence.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
drivers/dma-buf/dma-fence-array.c | 26 ++++++++++++++++++++++++++
include/linux/dma-fence-array.h | 2 ++
2 files changed, 28 insertions(+)
diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
index 67eb7c8fb88c3..0350829ba62e7 100644
--- a/drivers/dma-buf/dma-fence-array.c
+++ b/drivers/dma-buf/dma-fence-array.c
@@ -144,3 +144,29 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
return array;
}
EXPORT_SYMBOL(dma_fence_array_create);
+
+/**
+ * dma_fence_match_context - Check if all fences are from the given context
+ * @fence: [in] fence or fence array
+ * @context: [in] fence context to check all fences against
+ *
+ * Checks the provided fence or, for a fence array, all fences in the array
+ * against the given context. Returns false if any fence is from a different
+ * context.
+ */
+bool dma_fence_match_context(struct dma_fence *fence, u64 context)
+{
+ struct dma_fence_array *array = to_dma_fence_array(fence);
+ unsigned i;
+
+ if (!dma_fence_is_array(fence))
+ return fence->context == context;
+
+ for (i = 0; i < array->num_fences; i++) {
+ if (array->fences[i]->context != context)
+ return false;
+ }
+
+ return true;
+}
+EXPORT_SYMBOL(dma_fence_match_context);
diff --git a/include/linux/dma-fence-array.h b/include/linux/dma-fence-array.h
index 5900945f962dd..332a5420243c4 100644
--- a/include/linux/dma-fence-array.h
+++ b/include/linux/dma-fence-array.h
@@ -83,4 +83,6 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
u64 context, unsigned seqno,
bool signal_on_any);
+bool dma_fence_match_context(struct dma_fence *fence, u64 context);
+
#endif /* __LINUX_DMA_FENCE_ARRAY_H */
--
2.11.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/4] drm/etnaviv: submit support for in-fences
2017-03-17 16:34 [PATCH v2 1/4] dma-fence: add dma_fence_match_context helper Philipp Zabel
@ 2017-03-17 16:34 ` Philipp Zabel
2017-03-17 17:59 ` Gustavo Padovan
2017-03-17 18:06 ` Sumit Semwal
2017-03-17 16:34 ` [PATCH v2 3/4] drm/etnaviv: move fence allocation out of etnaviv_gpu_submit() Philipp Zabel
` (4 subsequent siblings)
5 siblings, 2 replies; 9+ messages in thread
From: Philipp Zabel @ 2017-03-17 16:34 UTC (permalink / raw)
To: dri-devel; +Cc: etnaviv, Russell King
Loosely based on commit f0a42bb5423a ("drm/msm: submit support for
in-fences"). Unfortunately, struct drm_etnaviv_gem_submit doesn't have
a flags field yet, so we have to extend the structure and trust that
drm_ioctl will clear the flags for us if an older userspace only submits
part of the struct.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
v2: Use dma_fence_match_context to skip waiting if all in-fences are ours.
---
drivers/gpu/drm/etnaviv/Kconfig | 1 +
drivers/gpu/drm/etnaviv/etnaviv_gem.h | 1 +
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 34 +++++++++++++++++++++++++++-
drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 5 +++-
drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 2 +-
include/uapi/drm/etnaviv_drm.h | 6 +++++
6 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/etnaviv/Kconfig b/drivers/gpu/drm/etnaviv/Kconfig
index cc1731c5289c2..71cee4e9fefbb 100644
--- a/drivers/gpu/drm/etnaviv/Kconfig
+++ b/drivers/gpu/drm/etnaviv/Kconfig
@@ -5,6 +5,7 @@ config DRM_ETNAVIV
depends on ARCH_MXC || ARCH_DOVE || (ARM && COMPILE_TEST)
depends on MMU
select SHMEM
+ select SYNC_FILE
select TMPFS
select IOMMU_API
select IOMMU_SUPPORT
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.h b/drivers/gpu/drm/etnaviv/etnaviv_gem.h
index e63ff116a3b3d..120410d67eb5b 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.h
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.h
@@ -107,6 +107,7 @@ struct etnaviv_gem_submit {
u32 fence;
unsigned int nr_bos;
struct etnaviv_gem_submit_bo bos[0];
+ u32 flags;
};
int etnaviv_gem_wait_bo(struct etnaviv_gpu *gpu, struct drm_gem_object *obj,
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
index 726090d7a6ace..fb8d5befbf4f1 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
@@ -14,7 +14,9 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <linux/dma-fence-array.h>
#include <linux/reservation.h>
+#include <linux/sync_file.h>
#include "etnaviv_cmdbuf.h"
#include "etnaviv_drv.h"
#include "etnaviv_gpu.h"
@@ -169,8 +171,10 @@ static int submit_fence_sync(const struct etnaviv_gem_submit *submit)
for (i = 0; i < submit->nr_bos; i++) {
struct etnaviv_gem_object *etnaviv_obj = submit->bos[i].obj;
bool write = submit->bos[i].flags & ETNA_SUBMIT_BO_WRITE;
+ bool explicit = !(submit->flags & ETNA_SUBMIT_NO_IMPLICIT);
- ret = etnaviv_gpu_fence_sync_obj(etnaviv_obj, context, write);
+ ret = etnaviv_gpu_fence_sync_obj(etnaviv_obj, context, write,
+ explicit);
if (ret)
break;
}
@@ -303,6 +307,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
struct etnaviv_gem_submit *submit;
struct etnaviv_cmdbuf *cmdbuf;
struct etnaviv_gpu *gpu;
+ struct dma_fence *in_fence = NULL;
void *stream;
int ret;
@@ -326,6 +331,11 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
return -EINVAL;
}
+ if (args->flags & ~ETNA_SUBMIT_FLAGS) {
+ DRM_ERROR("invalid flags: 0x%x\n", args->flags);
+ return -EINVAL;
+ }
+
/*
* Copy the command submission and bo array to kernel space in
* one go, and do this outside of any locks.
@@ -371,6 +381,8 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
goto err_submit_cmds;
}
+ submit->flags = args->flags;
+
ret = submit_lookup_objects(submit, file, bos, args->nr_bos);
if (ret)
goto err_submit_objects;
@@ -385,6 +397,24 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
goto err_submit_objects;
}
+ if (args->flags & ETNA_SUBMIT_FENCE_FD_IN) {
+ in_fence = sync_file_get_fence(args->fence_fd);
+ if (!in_fence) {
+ ret = -EINVAL;
+ goto err_submit_objects;
+ }
+
+ /*
+ * Wait if the fence is from a foreign context, or if the fence
+ * array contains any fence from a foreign context.
+ */
+ if (!dma_fence_match_context(in_fence, gpu->fence_context)) {
+ ret = dma_fence_wait(in_fence, true);
+ if (ret)
+ goto err_submit_objects;
+ }
+ }
+
ret = submit_fence_sync(submit);
if (ret)
goto err_submit_objects;
@@ -419,6 +449,8 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
flush_workqueue(priv->wq);
err_submit_objects:
+ if (in_fence)
+ dma_fence_put(in_fence);
submit_cleanup(submit);
err_submit_cmds:
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index 130d7d517a19a..51d52c72aef17 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -1064,7 +1064,7 @@ static struct dma_fence *etnaviv_gpu_fence_alloc(struct etnaviv_gpu *gpu)
}
int etnaviv_gpu_fence_sync_obj(struct etnaviv_gem_object *etnaviv_obj,
- unsigned int context, bool exclusive)
+ unsigned int context, bool exclusive, bool explicit)
{
struct reservation_object *robj = etnaviv_obj->resv;
struct reservation_object_list *fobj;
@@ -1077,6 +1077,9 @@ int etnaviv_gpu_fence_sync_obj(struct etnaviv_gem_object *etnaviv_obj,
return ret;
}
+ if (explicit)
+ return 0;
+
/*
* If we have any shared fences, then the exclusive fence
* should be ignored as it will already have been signalled.
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
index 1c0606ea7d5e8..dc27c7a039060 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
@@ -181,7 +181,7 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m);
#endif
int etnaviv_gpu_fence_sync_obj(struct etnaviv_gem_object *etnaviv_obj,
- unsigned int context, bool exclusive);
+ unsigned int context, bool exclusive, bool implicit);
void etnaviv_gpu_retire(struct etnaviv_gpu *gpu);
int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu,
diff --git a/include/uapi/drm/etnaviv_drm.h b/include/uapi/drm/etnaviv_drm.h
index 2584c1cca42f6..e9c388a1d8ebe 100644
--- a/include/uapi/drm/etnaviv_drm.h
+++ b/include/uapi/drm/etnaviv_drm.h
@@ -154,6 +154,10 @@ struct drm_etnaviv_gem_submit_bo {
* one or more cmdstream buffers. This allows for conditional execution
* (context-restore), and IB buffers needed for per tile/bin draw cmds.
*/
+#define ETNA_SUBMIT_NO_IMPLICIT 0x0001
+#define ETNA_SUBMIT_FENCE_FD_IN 0x0002
+#define ETNA_SUBMIT_FLAGS (ETNA_SUBMIT_NO_IMPLICIT | \
+ ETNA_SUBMIT_FENCE_FD_IN)
#define ETNA_PIPE_3D 0x00
#define ETNA_PIPE_2D 0x01
#define ETNA_PIPE_VG 0x02
@@ -167,6 +171,8 @@ struct drm_etnaviv_gem_submit {
__u64 bos; /* in, ptr to array of submit_bo's */
__u64 relocs; /* in, ptr to array of submit_reloc's */
__u64 stream; /* in, ptr to cmdstream */
+ __u32 flags; /* in, mask of ETNA_SUBMIT_x */
+ __s32 fence_fd; /* in, fence fd (see ETNA_SUBMIT_FENCE_FD_IN) */
};
/* The normal way to synchronize with the GPU is just to CPU_PREP on
--
2.11.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 3/4] drm/etnaviv: move fence allocation out of etnaviv_gpu_submit()
2017-03-17 16:34 [PATCH v2 1/4] dma-fence: add dma_fence_match_context helper Philipp Zabel
2017-03-17 16:34 ` [PATCH v2 2/4] drm/etnaviv: submit support for in-fences Philipp Zabel
@ 2017-03-17 16:34 ` Philipp Zabel
2017-03-17 16:34 ` [PATCH v2 4/4] drm/etnaviv: submit support for out-fences Philipp Zabel
` (3 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Philipp Zabel @ 2017-03-17 16:34 UTC (permalink / raw)
To: dri-devel; +Cc: etnaviv, Russell King
The next patch will need the dma_fence to create the sync_file in
etnaviv_ioctl_gem_submit, in case an out_fence_fd is requested.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com>
---
drivers/gpu/drm/etnaviv/etnaviv_gem.h | 3 ++-
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 8 +++++++-
drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 21 ++++++---------------
drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 1 +
4 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.h b/drivers/gpu/drm/etnaviv/etnaviv_gem.h
index 120410d67eb5b..c4a091e874269 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.h
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.h
@@ -20,6 +20,7 @@
#include <linux/reservation.h>
#include "etnaviv_drv.h"
+struct dma_fence;
struct etnaviv_gem_ops;
struct etnaviv_gem_object;
@@ -104,7 +105,7 @@ struct etnaviv_gem_submit {
struct drm_device *dev;
struct etnaviv_gpu *gpu;
struct ww_acquire_ctx ticket;
- u32 fence;
+ struct dma_fence *fence;
unsigned int nr_bos;
struct etnaviv_gem_submit_bo bos[0];
u32 flags;
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
index fb8d5befbf4f1..be88411de35a4 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
@@ -431,11 +431,17 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
memcpy(cmdbuf->vaddr, stream, args->stream_size);
cmdbuf->user_size = ALIGN(args->stream_size, 8);
+ submit->fence = etnaviv_gpu_fence_alloc(gpu);
+ if (!submit->fence) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
ret = etnaviv_gpu_submit(gpu, submit, cmdbuf);
if (ret == 0)
cmdbuf = NULL;
- args->fence = submit->fence;
+ args->fence = submit->fence->seqno;
out:
submit_unpin_objects(submit);
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index 51d52c72aef17..a439700cc577f 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -1047,7 +1047,7 @@ static const struct dma_fence_ops etnaviv_fence_ops = {
.release = etnaviv_fence_release,
};
-static struct dma_fence *etnaviv_gpu_fence_alloc(struct etnaviv_gpu *gpu)
+struct dma_fence *etnaviv_gpu_fence_alloc(struct etnaviv_gpu *gpu)
{
struct etnaviv_fence *f;
@@ -1290,7 +1290,6 @@ void etnaviv_gpu_pm_put(struct etnaviv_gpu *gpu)
int etnaviv_gpu_submit(struct etnaviv_gpu *gpu,
struct etnaviv_gem_submit *submit, struct etnaviv_cmdbuf *cmdbuf)
{
- struct dma_fence *fence;
unsigned int event, i;
int ret;
@@ -1314,18 +1313,10 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu,
goto out_pm_put;
}
- fence = etnaviv_gpu_fence_alloc(gpu);
- if (!fence) {
- event_free(gpu, event);
- ret = -ENOMEM;
- goto out_pm_put;
- }
-
mutex_lock(&gpu->lock);
- gpu->event[event].fence = fence;
- submit->fence = fence->seqno;
- gpu->active_fence = submit->fence;
+ gpu->event[event].fence = submit->fence;
+ gpu->active_fence = submit->fence->seqno;
if (gpu->lastctx != cmdbuf->ctx) {
gpu->mmu->need_flush = true;
@@ -1335,7 +1326,7 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu,
etnaviv_buffer_queue(gpu, event, cmdbuf);
- cmdbuf->fence = fence;
+ cmdbuf->fence = submit->fence;
list_add_tail(&cmdbuf->node, &gpu->active_cmd_list);
/* We're committed to adding this command buffer, hold a PM reference */
@@ -1351,10 +1342,10 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu,
if (submit->bos[i].flags & ETNA_SUBMIT_BO_WRITE)
reservation_object_add_excl_fence(etnaviv_obj->resv,
- fence);
+ submit->fence);
else
reservation_object_add_shared_fence(etnaviv_obj->resv,
- fence);
+ submit->fence);
}
cmdbuf->nr_bos = submit->nr_bos;
hangcheck_timer_reset(gpu);
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
index dc27c7a039060..20f7191018daf 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
@@ -180,6 +180,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu);
int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m);
#endif
+struct dma_fence *etnaviv_gpu_fence_alloc(struct etnaviv_gpu *gpu);
int etnaviv_gpu_fence_sync_obj(struct etnaviv_gem_object *etnaviv_obj,
unsigned int context, bool exclusive, bool implicit);
--
2.11.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 4/4] drm/etnaviv: submit support for out-fences
2017-03-17 16:34 [PATCH v2 1/4] dma-fence: add dma_fence_match_context helper Philipp Zabel
2017-03-17 16:34 ` [PATCH v2 2/4] drm/etnaviv: submit support for in-fences Philipp Zabel
2017-03-17 16:34 ` [PATCH v2 3/4] drm/etnaviv: move fence allocation out of etnaviv_gpu_submit() Philipp Zabel
@ 2017-03-17 16:34 ` Philipp Zabel
2017-03-17 17:58 ` [PATCH v2 1/4] dma-fence: add dma_fence_match_context helper Gustavo Padovan
` (2 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Philipp Zabel @ 2017-03-17 16:34 UTC (permalink / raw)
To: dri-devel; +Cc: etnaviv, Russell King
Based on commit 4cd0945901a6 ("drm/msm: submit support for out-fences").
We increment the minor driver version so userspace can detect explicit
fence support.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com>
---
v2: Dropped unnecessary braces
---
drivers/gpu/drm/etnaviv/etnaviv_drv.c | 2 +-
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 26 ++++++++++++++++++++++++++
include/uapi/drm/etnaviv_drm.h | 6 ++++--
3 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index 289a9f8c66710..5255278dde560 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -512,7 +512,7 @@ static struct drm_driver etnaviv_drm_driver = {
.desc = "etnaviv DRM",
.date = "20151214",
.major = 1,
- .minor = 0,
+ .minor = 1,
};
/*
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
index be88411de35a4..8a1381ca0354b 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
@@ -308,6 +308,8 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
struct etnaviv_cmdbuf *cmdbuf;
struct etnaviv_gpu *gpu;
struct dma_fence *in_fence = NULL;
+ struct sync_file *sync_file = NULL;
+ int out_fence_fd = -1;
void *stream;
int ret;
@@ -375,6 +377,14 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
goto err_submit_cmds;
}
+ if (args->flags & ETNA_SUBMIT_FENCE_FD_OUT) {
+ out_fence_fd = get_unused_fd_flags(O_CLOEXEC);
+ if (out_fence_fd < 0) {
+ ret = out_fence_fd;
+ goto err_submit_cmds;
+ }
+ }
+
submit = submit_create(dev, gpu, args->nr_bos);
if (!submit) {
ret = -ENOMEM;
@@ -437,10 +447,24 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
goto out;
}
+ if (args->flags & ETNA_SUBMIT_FENCE_FD_OUT) {
+ sync_file = sync_file_create(submit->fence);
+ if (!sync_file) {
+ dma_fence_put(submit->fence);
+ submit->fence = NULL;
+ ret = -ENOMEM;
+ goto out;
+ }
+ }
+
ret = etnaviv_gpu_submit(gpu, submit, cmdbuf);
if (ret == 0)
cmdbuf = NULL;
+ if (args->flags & ETNA_SUBMIT_FENCE_FD_OUT)
+ fd_install(out_fence_fd, sync_file->file);
+
+ args->fence_fd = out_fence_fd;
args->fence = submit->fence->seqno;
out:
@@ -460,6 +484,8 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
submit_cleanup(submit);
err_submit_cmds:
+ if (ret && (out_fence_fd >= 0))
+ put_unused_fd(out_fence_fd);
/* if we still own the cmdbuf */
if (cmdbuf)
etnaviv_cmdbuf_free(cmdbuf);
diff --git a/include/uapi/drm/etnaviv_drm.h b/include/uapi/drm/etnaviv_drm.h
index e9c388a1d8ebe..76f6f78a352ba 100644
--- a/include/uapi/drm/etnaviv_drm.h
+++ b/include/uapi/drm/etnaviv_drm.h
@@ -156,8 +156,10 @@ struct drm_etnaviv_gem_submit_bo {
*/
#define ETNA_SUBMIT_NO_IMPLICIT 0x0001
#define ETNA_SUBMIT_FENCE_FD_IN 0x0002
+#define ETNA_SUBMIT_FENCE_FD_OUT 0x0004
#define ETNA_SUBMIT_FLAGS (ETNA_SUBMIT_NO_IMPLICIT | \
- ETNA_SUBMIT_FENCE_FD_IN)
+ ETNA_SUBMIT_FENCE_FD_IN | \
+ ETNA_SUBMIT_FENCE_FD_OUT)
#define ETNA_PIPE_3D 0x00
#define ETNA_PIPE_2D 0x01
#define ETNA_PIPE_VG 0x02
@@ -172,7 +174,7 @@ struct drm_etnaviv_gem_submit {
__u64 relocs; /* in, ptr to array of submit_reloc's */
__u64 stream; /* in, ptr to cmdstream */
__u32 flags; /* in, mask of ETNA_SUBMIT_x */
- __s32 fence_fd; /* in, fence fd (see ETNA_SUBMIT_FENCE_FD_IN) */
+ __s32 fence_fd; /* in/out, fence fd (see ETNA_SUBMIT_FENCE_FD_x) */
};
/* The normal way to synchronize with the GPU is just to CPU_PREP on
--
2.11.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/4] dma-fence: add dma_fence_match_context helper
2017-03-17 16:34 [PATCH v2 1/4] dma-fence: add dma_fence_match_context helper Philipp Zabel
` (2 preceding siblings ...)
2017-03-17 16:34 ` [PATCH v2 4/4] drm/etnaviv: submit support for out-fences Philipp Zabel
@ 2017-03-17 17:58 ` Gustavo Padovan
2017-03-17 18:03 ` Sumit Semwal
2017-03-17 18:23 ` Christian König
5 siblings, 0 replies; 9+ messages in thread
From: Gustavo Padovan @ 2017-03-17 17:58 UTC (permalink / raw)
To: Philipp Zabel; +Cc: etnaviv, dri-devel, Russell King
Hi Philipp,
2017-03-17 Philipp Zabel <p.zabel@pengutronix.de>:
> Add a helper to check if all fences in a fence array are from a given
> context. For convenience, the function can also handle being given a
> non-array fence.
>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
> drivers/dma-buf/dma-fence-array.c | 26 ++++++++++++++++++++++++++
> include/linux/dma-fence-array.h | 2 ++
> 2 files changed, 28 insertions(+)
Looks good to me.
Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Gustavo
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/4] drm/etnaviv: submit support for in-fences
2017-03-17 16:34 ` [PATCH v2 2/4] drm/etnaviv: submit support for in-fences Philipp Zabel
@ 2017-03-17 17:59 ` Gustavo Padovan
2017-03-17 18:06 ` Sumit Semwal
1 sibling, 0 replies; 9+ messages in thread
From: Gustavo Padovan @ 2017-03-17 17:59 UTC (permalink / raw)
To: Philipp Zabel; +Cc: etnaviv, dri-devel, Russell King
Hi Philipp,
2017-03-17 Philipp Zabel <p.zabel@pengutronix.de>:
> Loosely based on commit f0a42bb5423a ("drm/msm: submit support for
> in-fences"). Unfortunately, struct drm_etnaviv_gem_submit doesn't have
> a flags field yet, so we have to extend the structure and trust that
> drm_ioctl will clear the flags for us if an older userspace only submits
> part of the struct.
>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
> v2: Use dma_fence_match_context to skip waiting if all in-fences are ours.
> ---
> drivers/gpu/drm/etnaviv/Kconfig | 1 +
> drivers/gpu/drm/etnaviv/etnaviv_gem.h | 1 +
> drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 34 +++++++++++++++++++++++++++-
> drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 5 +++-
> drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 2 +-
> include/uapi/drm/etnaviv_drm.h | 6 +++++
> 6 files changed, 46 insertions(+), 3 deletions(-)
Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Gustavo
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/4] dma-fence: add dma_fence_match_context helper
2017-03-17 16:34 [PATCH v2 1/4] dma-fence: add dma_fence_match_context helper Philipp Zabel
` (3 preceding siblings ...)
2017-03-17 17:58 ` [PATCH v2 1/4] dma-fence: add dma_fence_match_context helper Gustavo Padovan
@ 2017-03-17 18:03 ` Sumit Semwal
2017-03-17 18:23 ` Christian König
5 siblings, 0 replies; 9+ messages in thread
From: Sumit Semwal @ 2017-03-17 18:03 UTC (permalink / raw)
To: Philipp Zabel; +Cc: etnaviv, DRI mailing list, Russell King
Hi Philipp,
thanks for the patch!
On 17 March 2017 at 22:04, Philipp Zabel <p.zabel@pengutronix.de> wrote:
> Add a helper to check if all fences in a fence array are from a given
> context. For convenience, the function can also handle being given a
> non-array fence.
>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
Looks good to me, please feel free to add my
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
> drivers/dma-buf/dma-fence-array.c | 26 ++++++++++++++++++++++++++
> include/linux/dma-fence-array.h | 2 ++
> 2 files changed, 28 insertions(+)
>
> diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
> index 67eb7c8fb88c3..0350829ba62e7 100644
> --- a/drivers/dma-buf/dma-fence-array.c
> +++ b/drivers/dma-buf/dma-fence-array.c
> @@ -144,3 +144,29 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
> return array;
> }
> EXPORT_SYMBOL(dma_fence_array_create);
> +
> +/**
> + * dma_fence_match_context - Check if all fences are from the given context
> + * @fence: [in] fence or fence array
> + * @context: [in] fence context to check all fences against
> + *
> + * Checks the provided fence or, for a fence array, all fences in the array
> + * against the given context. Returns false if any fence is from a different
> + * context.
> + */
> +bool dma_fence_match_context(struct dma_fence *fence, u64 context)
> +{
> + struct dma_fence_array *array = to_dma_fence_array(fence);
> + unsigned i;
> +
> + if (!dma_fence_is_array(fence))
> + return fence->context == context;
> +
> + for (i = 0; i < array->num_fences; i++) {
> + if (array->fences[i]->context != context)
> + return false;
> + }
> +
> + return true;
> +}
> +EXPORT_SYMBOL(dma_fence_match_context);
> diff --git a/include/linux/dma-fence-array.h b/include/linux/dma-fence-array.h
> index 5900945f962dd..332a5420243c4 100644
> --- a/include/linux/dma-fence-array.h
> +++ b/include/linux/dma-fence-array.h
> @@ -83,4 +83,6 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
> u64 context, unsigned seqno,
> bool signal_on_any);
>
> +bool dma_fence_match_context(struct dma_fence *fence, u64 context);
> +
> #endif /* __LINUX_DMA_FENCE_ARRAY_H */
> --
> 2.11.0
>
Best,
Sumit.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/4] drm/etnaviv: submit support for in-fences
2017-03-17 16:34 ` [PATCH v2 2/4] drm/etnaviv: submit support for in-fences Philipp Zabel
2017-03-17 17:59 ` Gustavo Padovan
@ 2017-03-17 18:06 ` Sumit Semwal
1 sibling, 0 replies; 9+ messages in thread
From: Sumit Semwal @ 2017-03-17 18:06 UTC (permalink / raw)
To: Philipp Zabel; +Cc: etnaviv, DRI mailing list, Russell King
Hi Philipp,
Thanks for your patch!
On 17 March 2017 at 22:04, Philipp Zabel <p.zabel@pengutronix.de> wrote:
> Loosely based on commit f0a42bb5423a ("drm/msm: submit support for
> in-fences"). Unfortunately, struct drm_etnaviv_gem_submit doesn't have
> a flags field yet, so we have to extend the structure and trust that
> drm_ioctl will clear the flags for us if an older userspace only submits
> part of the struct.
>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Please feel free to add my
Reviewed-by: Sumit Semwal <sumit.semwal@linaro.org>
> ---
> v2: Use dma_fence_match_context to skip waiting if all in-fences are ours.
> ---
<snip>
Best,
Sumit.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/4] dma-fence: add dma_fence_match_context helper
2017-03-17 16:34 [PATCH v2 1/4] dma-fence: add dma_fence_match_context helper Philipp Zabel
` (4 preceding siblings ...)
2017-03-17 18:03 ` Sumit Semwal
@ 2017-03-17 18:23 ` Christian König
5 siblings, 0 replies; 9+ messages in thread
From: Christian König @ 2017-03-17 18:23 UTC (permalink / raw)
To: Philipp Zabel, dri-devel; +Cc: etnaviv, Russell King
Am 17.03.2017 um 17:34 schrieb Philipp Zabel:
> Add a helper to check if all fences in a fence array are from a given
> context. For convenience, the function can also handle being given a
> non-array fence.
>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/dma-buf/dma-fence-array.c | 26 ++++++++++++++++++++++++++
> include/linux/dma-fence-array.h | 2 ++
> 2 files changed, 28 insertions(+)
>
> diff --git a/drivers/dma-buf/dma-fence-array.c b/drivers/dma-buf/dma-fence-array.c
> index 67eb7c8fb88c3..0350829ba62e7 100644
> --- a/drivers/dma-buf/dma-fence-array.c
> +++ b/drivers/dma-buf/dma-fence-array.c
> @@ -144,3 +144,29 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
> return array;
> }
> EXPORT_SYMBOL(dma_fence_array_create);
> +
> +/**
> + * dma_fence_match_context - Check if all fences are from the given context
> + * @fence: [in] fence or fence array
> + * @context: [in] fence context to check all fences against
> + *
> + * Checks the provided fence or, for a fence array, all fences in the array
> + * against the given context. Returns false if any fence is from a different
> + * context.
> + */
> +bool dma_fence_match_context(struct dma_fence *fence, u64 context)
> +{
> + struct dma_fence_array *array = to_dma_fence_array(fence);
> + unsigned i;
> +
> + if (!dma_fence_is_array(fence))
> + return fence->context == context;
> +
> + for (i = 0; i < array->num_fences; i++) {
> + if (array->fences[i]->context != context)
> + return false;
> + }
> +
> + return true;
> +}
> +EXPORT_SYMBOL(dma_fence_match_context);
> diff --git a/include/linux/dma-fence-array.h b/include/linux/dma-fence-array.h
> index 5900945f962dd..332a5420243c4 100644
> --- a/include/linux/dma-fence-array.h
> +++ b/include/linux/dma-fence-array.h
> @@ -83,4 +83,6 @@ struct dma_fence_array *dma_fence_array_create(int num_fences,
> u64 context, unsigned seqno,
> bool signal_on_any);
>
> +bool dma_fence_match_context(struct dma_fence *fence, u64 context);
> +
> #endif /* __LINUX_DMA_FENCE_ARRAY_H */
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-03-17 18:23 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-17 16:34 [PATCH v2 1/4] dma-fence: add dma_fence_match_context helper Philipp Zabel
2017-03-17 16:34 ` [PATCH v2 2/4] drm/etnaviv: submit support for in-fences Philipp Zabel
2017-03-17 17:59 ` Gustavo Padovan
2017-03-17 18:06 ` Sumit Semwal
2017-03-17 16:34 ` [PATCH v2 3/4] drm/etnaviv: move fence allocation out of etnaviv_gpu_submit() Philipp Zabel
2017-03-17 16:34 ` [PATCH v2 4/4] drm/etnaviv: submit support for out-fences Philipp Zabel
2017-03-17 17:58 ` [PATCH v2 1/4] dma-fence: add dma_fence_match_context helper Gustavo Padovan
2017-03-17 18:03 ` Sumit Semwal
2017-03-17 18:23 ` Christian König
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.