Updated fence patch series
Subsystems (19)
v2 cover Updated fence patch series
So after some more hacking I've moved dma-buf to its own subdirectory, drivers/dma-buf and applied the fence patches to its new place. I believe that the first patch should be applied regardless, and the rest should be ready now. :-)
Changes to the fence api:
- release_fence -> fence_release etc.
- __fence_init -> fence_init
- __fence_signal -> fence_signal_locked
- __fence_is_signaled -> fence_is_signaled_locked
- Changing BUG_ON to WARN_ON in fence_later, and return NULL if it triggers.
Android can expose fences to userspace. It's possible to make the new fence mechanism expose the same fences to userspace by changing sync_fence_create to take a struct fence instead of a struct sync_pt. No other change is needed, because only the fence parts of struct sync_pt are used. But because the userspace fences are a separate problem and I haven't really looked at it yet I feel it should stay in staging, for now.
---
Maarten Lankhorst (9):
dma-buf: move to drivers/dma-buf
fence: dma-buf cross-device synchronization (v18)
seqno-fence: Hardware dma-buf implementation of fencing (v6)
dma-buf: use reservation objects
android: convert sync to fence api, v6
reservation: add support for fences to enable cross-device synchronisation
dma-buf: add poll support, v3
reservation: update api and add some helpers
reservation: add suppport for read-only access using rcu
Documentation/DocBook/device-drivers.tmpl | 8 MAINTAINERS | 4 drivers/Makefile | 1 drivers/base/Kconfig | 9 drivers/base/Makefile | 1 drivers/base/dma-buf.c | 743 -------------------- drivers/base/reservation.c | 39 - drivers/dma-buf/Makefile | 1 drivers/dma-buf/dma-buf.c | 907 ++++++++++++++++++++++++ drivers/dma-buf/fence.c | 431 +++++++++++ drivers/dma-buf/reservation.c | 477 +++++++++++++ drivers/dma-buf/seqno-fence.c | 73 ++ drivers/gpu/drm/armada/armada_gem.c | 2 drivers/gpu/drm/drm_prime.c | 8 drivers/gpu/drm/exynos/exynos_drm_dmabuf.c | 2 drivers/gpu/drm/i915/i915_gem_dmabuf.c | 3 drivers/gpu/drm/nouveau/nouveau_drm.c | 1 drivers/gpu/drm/nouveau/nouveau_gem.h | 1 drivers/gpu/drm/nouveau/nouveau_prime.c | 7 drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 2 drivers/gpu/drm/radeon/radeon_drv.c | 2 drivers/gpu/drm/radeon/radeon_prime.c | 8 drivers/gpu/drm/tegra/gem.c | 2 drivers/gpu/drm/ttm/ttm_object.c | 2 drivers/media/v4l2-core/videobuf2-dma-contig.c | 2 drivers/staging/android/Kconfig | 1 drivers/staging/android/Makefile | 2 drivers/staging/android/ion/ion.c | 3 drivers/staging/android/sw_sync.c | 6 drivers/staging/android/sync.c | 913 ++++++++---------------- drivers/staging/android/sync.h | 79 +- drivers/staging/android/sync_debug.c | 247 ++++++ drivers/staging/android/trace/sync.h | 12 include/drm/drmP.h | 3 include/linux/dma-buf.h | 21 - include/linux/fence.h | 360 +++++++++ include/linux/reservation.h | 82 ++ include/linux/seqno-fence.h | 116 +++ include/trace/events/fence.h | 128 +++ 39 files changed, 3258 insertions(+), 1451 deletions(-) delete mode 100644 drivers/base/dma-buf.c delete mode 100644 drivers/base/reservation.c create mode 100644 drivers/dma-buf/Makefile create mode 100644 drivers/dma-buf/dma-buf.c create mode 100644 drivers/dma-buf/fence.c create mode 100644 drivers/dma-buf/reservation.c create mode 100644 drivers/dma-buf/seqno-fence.c create mode 100644 drivers/staging/android/sync_debug.c create mode 100644 include/linux/fence.h create mode 100644 include/linux/seqno-fence.h create mode 100644 include/trace/events/fence.h
Signature · 1 line
Signature
PATCH v2 1/9 dma-buf: move to drivers/dma-buf
--- Documentation/DocBook/device-drivers.tmpl | 3 MAINTAINERS | 4 drivers/Makefile | 1 drivers/base/Makefile | 1 drivers/base/dma-buf.c | 743 ----------------------------- drivers/base/reservation.c | 39 -- drivers/dma-buf/Makefile | 1 drivers/dma-buf/dma-buf.c | 743 +++++++++++++++++++++++++++++ drivers/dma-buf/reservation.c | 39 ++ 9 files changed, 787 insertions(+), 787 deletions(-) delete mode 100644 drivers/base/dma-buf.c delete mode 100644 drivers/base/reservation.c create mode 100644 drivers/dma-buf/Makefile create mode 100644 drivers/dma-buf/dma-buf.c create mode 100644 drivers/dma-buf/reservation.c
Documentation/DocBook/device-drivers.tmpl +1 -2
@@ -128,8 +128,7 @@ X!Edrivers/base/interface.c !Edrivers/base/bus.c </sect1> <sect1><title>Device Drivers DMA Management</title> -!Edrivers/base/dma-buf.c -!Edrivers/base/reservation.c +!Edrivers/dma-buf/dma-buf.c !Iinclude/linux/reservation.h !Edrivers/base/dma-coherent.c !Edrivers/base/dma-mapping.c
MAINTAINERS +2 -2
@@ -2882,8 +2882,8 @@ S: Maintained L: [email protected] L: [email protected] L: [email protected] -F: drivers/base/dma-buf* -F: include/linux/dma-buf* +F: drivers/dma-buf/ +F: include/linux/dma-buf* include/linux/reservation.h F: Documentation/dma-buf-sharing.txt T: git git://git.linaro.org/people/sumitsemwal/linux-dma-buf.git
drivers/Makefile +1 -0
@@ -61,6 +61,7 @@ obj-$(CONFIG_FB_INTEL) += video/fbdev/intelfb/ obj-$(CONFIG_PARPORT) += parport/ obj-y += base/ block/ misc/ mfd/ nfc/ +obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf/ obj-$(CONFIG_NUBUS) += nubus/ obj-y += macintosh/ obj-$(CONFIG_IDE) += ide/
drivers/base/Makefile +0 -1
@@ -10,7 +10,6 @@ obj-$(CONFIG_DMA_CMA) += dma-contiguous.o obj-y += power/ obj-$(CONFIG_HAS_DMA) += dma-mapping.o obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o -obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf.o reservation.o obj-$(CONFIG_ISA) += isa.o obj-$(CONFIG_FW_LOADER) += firmware_class.o obj-$(CONFIG_NUMA) += node.o
drivers/base/dma-buf.c deleted +0 -743
743 lines not on this page · raw message
drivers/base/reservation.c deleted +0 -39
@@ -1,39 +0,0 @@ -/* -* Copyright (C) 2012-2013 Canonical Ltd -* -* Based on bo.c which bears the following copyright notice, -* but is dual licensed: -* -* Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA -* All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the -* "Software"), to deal in the Software without restriction, including -* without limitation the rights to use, copy, modify, merge, publish, -* distribute, sub license, and/or sell copies of the Software, and to -* permit persons to whom the Software is furnished to do so, subject to -* the following conditions: -* -* The above copyright notice and this permission notice (including the -* next paragraph) shall be included in all copies or substantial portions -* of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, -* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -* USE OR OTHER DEALINGS IN THE SOFTWARE. -* -**************************************************************************/ -/* -* Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com> -*/ - -#include <linux/reservation.h> -#include <linux/export.h> - -DEFINE_WW_CLASS (reservation_ww_class); -EXPORT_SYMBOL (reservation_ww_class);
drivers/dma-buf/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-y := dma-buf.o reservation.o
drivers/dma-buf/dma-buf.c new file +743 -0
743 lines not on this page · raw message
drivers/dma-buf/reservation.c new file +39 -0
@@ -0,0 +1,39 @@ +/* +* Copyright (C) 2012-2013 Canonical Ltd +* +* Based on bo.c which bears the following copyright notice, +* but is dual licensed: +* +* Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA +* All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sub license, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice (including the +* next paragraph) shall be included in all copies or substantial portions +* of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, +* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +* USE OR OTHER DEALINGS IN THE SOFTWARE. +* +**************************************************************************/ +/* +* Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com> +*/ + +#include <linux/reservation.h> +#include <linux/export.h> + +DEFINE_WW_CLASS (reservation_ww_class); +EXPORT_SYMBOL (reservation_ww_class);
PATCH v2 2/9 fence: dma-buf cross-device synchronization (v18)
In reply to Maarten LankhorstA fence can be attached to a buffer which is being filled or consumed by hw, to allow userspace to pass the buffer without waiting to another device. For example, userspace can call page_flip ioctl to display the next frame of graphics after kicking the GPU but while the GPU is still rendering. The display device sharing the buffer with the GPU would attach a callback to get notified when the GPU's rendering-complete IRQ fires, to update the scan-out address of the display, without having to wake up userspace.
A driver must allocate a fence context for each execution ring that can run in parallel. The function for this takes an argument with how many contexts to allocate:
+ fence_context_alloc()
A fence is transient, one-shot deal. It is allocated and attached to one or more dma-buf's. When the one that attached it is done, with the pending operation, it can signal the fence:
+ fence_signal()
To have a rough approximation whether a fence is fired, call:
+ fence_is_signaled()
The dma-buf-mgr handles tracking, and waiting on, the fences associated with a dma-buf.
The one pending on the fence can add an async callback:
+ fence_add_callback()
The callback can optionally be cancelled with:
+ fence_remove_callback()
To wait synchronously, optionally with a timeout:
+ fence_wait()
+ fence_wait_timeout()
When emitting a fence, call:
+ trace_fence_emit()
To annotate that a fence is blocking on another fence, call:
+ trace_fence_annotate_wait_on(fence, on_fence)
A default software-only implementation is provided, which can be used by drivers attaching a fence to a buffer when they have no other means for hw sync. But a memory backed fence is also envisioned, because it is common that GPU's can write to, or poll on some memory location for synchronization. For example:
fence = custom_get_fence(...);
if ((seqno_fence = to_seqno_fence(fence)) != NULL) {
dma_buf *fence_buf = seqno_fence->sync_buf;
get_dma_buf(fence_buf); ... tell the hw the memory location to wait ... custom_wait_on(fence_buf, seqno_fence->seqno_ofs, fence->seqno);
} else {
/* fall-back to sw sync * /
fence_add_callback(fence, my_cb);}
On SoC platforms, if some other hw mechanism is provided for synchronizing between IP blocks, it could be supported as an alternate implementation with it's own fence ops in a similar way.
enable_signaling callback is used to provide sw signaling in case a cpu waiter is requested or no compatible hardware signaling could be used.
The intention is to provide a userspace interface (presumably via eventfd) later, to be used in conjunction with dma-buf's mmap support for sw access to buffers (or for userspace apps that would prefer to do their own synchronization).
v1: Original
v2: After discussion w/ danvet and mlankhorst on #dri-devel, we decided
that dma-fence didn't need to care about the sw->hw signaling path (it can be handled same as sw->sw case), and therefore the fence->ops can be simplified and more handled in the core. So remove the signal, add_callback, cancel_callback, and wait ops, and replace with a simple enable_signaling() op which can be used to inform a fence supporting hw->hw signaling that one or more devices which do not support hw signaling are waiting (and therefore it should enable an irq or do whatever is necessary in order that the CPU is notified when the fence is passed).
v3: Fix locking fail in attach_fence() and get_fence()
v4: Remove tie-in w/ dma-buf.. after discussion w/ danvet and mlankorst
we decided that we need to be able to attach one fence to N dma-buf's, so using the list_head in dma-fence struct would be problematic.
v5: [ Maarten Lankhorst ] Updated for dma-bikeshed-fence and dma-buf-manager.
v6: [ Maarten Lankhorst ] I removed dma_fence_cancel_callback and some comments
about checking if fence fired or not. This is broken by design. waitqueue_active during destruction is now fatal, since the signaller should be holding a reference in enable_signalling until it signalled the fence. Pass the original dma_fence_cb along, and call __remove_wait in the dma_fence_callback handler, so that no cleanup needs to be performed.
v7: [ Maarten Lankhorst ] Set cb->func and only enable sw signaling if
fence wasn't signaled yet, for example for hardware fences that may choose to signal blindly.
v8: [ Maarten Lankhorst ] Tons of tiny fixes, moved __dma_fence_init to
header and fixed include mess. dma-fence.h now includes dma-buf.h All members are now initialized, so kmalloc can be used for allocating a dma-fence. More documentation added.
v9: Change compiler bitfields to flags, change return type of
enable_signaling to bool. Rework dma_fence_wait. Added dma_fence_is_signaled and dma_fence_wait_timeout.
s/dma// and change exports to non GPL. Added fence_is_signaled and fence_enable_sw_signaling calls, add ability to override default wait operation.
v10: remove event_queue, use a custom list, export try_to_wake_up from
scheduler. Remove fence lock and use a global spinlock instead, this should hopefully remove all the locking headaches I was having on trying to implement this. enable_signaling is called with this lock held.
v11:
Use atomic ops for flags, lifting the need for some spin_lock_irqsaves. However I kept the guarantee that after fence_signal returns, it is guaranteed that enable_signaling has either been called to completion, or will not be called any more.
Add contexts and seqno to base fence implementation. This allows you to wait for less fences, by testing for seqno + signaled, and then only wait on the later fence.
Add FENCE_TRACE, FENCE_WARN, and FENCE_ERR. This makes debugging easier. An CONFIG_DEBUG_FENCE will be added to turn off the FENCE_TRACE spam, and another runtime option can turn it off at runtime.
v12:
Add CONFIG_FENCE_TRACE. Add missing documentation for the fence->context
and fence->seqno members.v13:
Fixup CONFIG_FENCE_TRACE kconfig description.
Move fence_context_alloc to fence.
Simplify fence_later.
Kill priv member to fence_cb.
v14:
Remove priv argument from fence_add_callback, oops!
v15:
Remove priv from documentation.
Explicitly include linux/atomic.h.
v16:
Add trace events.
Import changes required by android syncpoints.
v17:
Use wake_up_state instead of try_to_wake_up. (Colin Cross) Fix up commit description for seqno_fence. (Rob Clark)
v18:
Rename release_fence to fence_release.
Move to drivers/dma-buf/.
Rename __fence_is_signaled and __fence_signal to *_locked. Rename __fence_init to fence_init.
Make fence_default_wait return a signed long, and fix wait ops too.
--- Documentation/DocBook/device-drivers.tmpl | 2 MAINTAINERS | 2 drivers/base/Kconfig | 9 + drivers/dma-buf/Makefile | 2 drivers/dma-buf/fence.c | 431 +++++++++++++++++++++++++++++ include/linux/fence.h | 343 +++++++++++++++++++++++ include/trace/events/fence.h | 128 +++++++++ 7 files changed, 915 insertions(+), 2 deletions(-) create mode 100644 drivers/dma-buf/fence.c create mode 100644 include/linux/fence.h create mode 100644 include/trace/events/fence.h
Documentation/DocBook/device-drivers.tmpl +2 -0
@@ -129,6 +129,8 @@ X!Edrivers/base/interface.c </sect1> <sect1><title>Device Drivers DMA Management</title> !Edrivers/dma-buf/dma-buf.c +!Edrivers/dma-buf/fence.c +!Iinclude/linux/fence.h !Iinclude/linux/reservation.h !Edrivers/base/dma-coherent.c !Edrivers/base/dma-mapping.c
MAINTAINERS +1 -1
@@ -2883,7 +2883,7 @@ L: [email protected] L: [email protected] L: [email protected] F: drivers/dma-buf/ -F: include/linux/dma-buf* include/linux/reservation.h +F: include/linux/dma-buf* include/linux/reservation.h include/linux/fence.h F: Documentation/dma-buf-sharing.txt T: git git://git.linaro.org/people/sumitsemwal/linux-dma-buf.git
drivers/base/Kconfig +9 -0
@@ -208,6 +208,15 @@ config DMA_SHARED_BUFFER APIs extension; the file's descriptor can then be passed on to other driver. +config FENCE_TRACE + bool "Enable verbose FENCE_TRACE messages" + depends on DMA_SHARED_BUFFER + help + Enable the FENCE_TRACE printks. This will add extra + spam to the console log, but will make it easier to diagnose + lockup related problems for dma-buffers shared across multiple + devices. + config DMA_CMA bool "DMA Contiguous Memory Allocator" depends on HAVE_DMA_CONTIGUOUS && CMA
drivers/dma-buf/Makefile +1 -1
@@ -1 +1 @@ -obj-y := dma-buf.o reservation.o +obj-y := dma-buf.o fence.o reservation.o
drivers/dma-buf/fence.c new file +431 -0
431 lines not on this page · raw message
include/linux/fence.h new file +343 -0
343 lines not on this page · raw message
include/trace/events/fence.h new file +128 -0
128 lines not on this page · raw message
PATCH v2 3/9 seqno-fence: Hardware dma-buf implementation of fencing (v6)
In reply to Maarten LankhorstThis type of fence can be used with hardware synchronization for simple hardware that can block execution until the condition (dma_buf[offset] - value) >= 0 has been met when WAIT_GEQUAL is used, or (dma_buf[offset] != 0) has been met when WAIT_NONZERO is set.
A software fallback still has to be provided in case the fence is used with a device that doesn't support this mechanism. It is useful to expose this for graphics cards that have an op to support this.
Some cards like i915 can export those, but don't have an option to wait, so they need the software fallback.
I extended the original patch by Rob Clark.
v1: Original
v2: Renamed from bikeshed to seqno, moved into dma-fence.c since
not much was left of the file. Lots of documentation added.
v3: Use fence_ops instead of custom callbacks. Moved to own file
to avoid circular dependency between dma-buf.h and fence.h
v4: Add spinlock pointer to seqno_fence_init
v5: Add condition member to allow wait for != 0.
Fix small style errors pointed out by checkpatch.
v6: Move to a separate file. Fix up api changes in fences.
--- Documentation/DocBook/device-drivers.tmpl | 2 + MAINTAINERS | 2 - drivers/dma-buf/Makefile | 2 - drivers/dma-buf/seqno-fence.c | 73 ++++++++++++++++++ include/linux/seqno-fence.h | 116 +++++++++++++++++++++++++++++ 5 files changed, 193 insertions(+), 2 deletions(-) create mode 100644 drivers/dma-buf/seqno-fence.c create mode 100644 include/linux/seqno-fence.h
Documentation/DocBook/device-drivers.tmpl +2 -0
@@ -130,7 +130,9 @@ X!Edrivers/base/interface.c <sect1><title>Device Drivers DMA Management</title> !Edrivers/dma-buf/dma-buf.c !Edrivers/dma-buf/fence.c +!Edrivers/dma-buf/seqno-fence.c !Iinclude/linux/fence.h +!Iinclude/linux/seqno-fence.h !Iinclude/linux/reservation.h !Edrivers/base/dma-coherent.c !Edrivers/base/dma-mapping.c
MAINTAINERS +1 -1
@@ -2883,7 +2883,7 @@ L: [email protected] L: [email protected] L: [email protected] F: drivers/dma-buf/ -F: include/linux/dma-buf* include/linux/reservation.h include/linux/fence.h +F: include/linux/dma-buf* include/linux/reservation.h include/linux/*fence.h F: Documentation/dma-buf-sharing.txt T: git git://git.linaro.org/people/sumitsemwal/linux-dma-buf.git
drivers/dma-buf/Makefile +1 -1
@@ -1 +1 @@ -obj-y := dma-buf.o fence.o reservation.o +obj-y := dma-buf.o fence.o reservation.o seqno-fence.o
drivers/dma-buf/seqno-fence.c new file +73 -0
73 lines not on this page · raw message
include/linux/seqno-fence.h new file +116 -0
116 lines not on this page · raw message
PATCH v2 4/9 dma-buf: use reservation objects
In reply to Maarten LankhorstThis allows reservation objects to be used in dma-buf. it's required for implementing polling support on the fences that belong to a dma-buf.
--- drivers/dma-buf/dma-buf.c | 22 ++++++++++++++++++++-- drivers/gpu/drm/armada/armada_gem.c | 2 +- drivers/gpu/drm/drm_prime.c | 8 +++++++- drivers/gpu/drm/exynos/exynos_drm_dmabuf.c | 2 +- drivers/gpu/drm/i915/i915_gem_dmabuf.c | 3 ++- drivers/gpu/drm/nouveau/nouveau_drm.c | 1 + drivers/gpu/drm/nouveau/nouveau_gem.h | 1 + drivers/gpu/drm/nouveau/nouveau_prime.c | 7 +++++++ drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 2 +- drivers/gpu/drm/radeon/radeon_drv.c | 2 ++ drivers/gpu/drm/radeon/radeon_prime.c | 8 ++++++++ drivers/gpu/drm/tegra/gem.c | 2 +- drivers/gpu/drm/ttm/ttm_object.c | 2 +- drivers/media/v4l2-core/videobuf2-dma-contig.c | 2 +- drivers/staging/android/ion/ion.c | 3 ++- include/drm/drmP.h | 3 +++ include/linux/dma-buf.h | 9 ++++++--- 17 files changed, 65 insertions(+), 14 deletions(-)
drivers/dma-buf/dma-buf.c +20 -2
@@ -25,10 +25,12 @@#include <linux/fs.h> #include <linux/slab.h> #include <linux/dma-buf.h> +#include <linux/fence.h> #include <linux/anon_inodes.h> #include <linux/export.h> #include <linux/debugfs.h> #include <linux/seq_file.h> +#include <linux/reservation.h> static inline int is_dma_buf_file (struct file *);
@@ -56,6 +58,9 @@ static int dma_buf_release(struct inode *inode, struct file *file)list_del (&dmabuf->list_node);mutex_unlock (&db_list.lock); +if (dmabuf->resv == (struct reservation_object *)&dmabuf[1 ]) +reservation_object_fini (dmabuf->resv); +kfree (dmabuf);return 0 ; }
@@ -128,6 +133,7 @@ static inline int is_dma_buf_file(struct file *file)* @size: [in] Size of the buffer * @flags: [in] mode flags for the file. * @exp_name: [in] name of the exporting module - useful for debugging. +* @resv: [in] reservation-object, NULL to allocate default one. * * Returns, on success, a newly created dma_buf object, which wraps the * supplied private data and operations for dma_buf_ops. On either missing
@@ -135,10 +141,17 @@ static inline int is_dma_buf_file(struct file *file)* */ struct dma_buf *dma_buf_export_named (void *priv,const struct dma_buf_ops *ops, -size_t size,int flags,const char *exp_name) +size_t size,int flags,const char *exp_name, +struct reservation_object *resv) {struct dma_buf *dmabuf;struct file *file; +size_t alloc_size =sizeof (struct dma_buf ); +if (!resv) + alloc_size +=sizeof (struct reservation_object ); +else +/* prevent &dma_buf[1] == dma_buf->resv */ + alloc_size +=1 ; if (WARN_ON(!priv || !ops || !ops->map_dma_buf
@@ -150,7 +163,7 @@ struct dma_buf *dma_buf_export_named(void *priv, const struct dma_buf_ops *ops,return ERR_PTR (-EINVAL ); } - dmabuf =kzalloc (sizeof (struct dma_buf ),GFP_KERNEL ); + dmabuf =kzalloc (alloc_size,GFP_KERNEL );if (dmabuf ==NULL )return ERR_PTR (-ENOMEM );
@@ -158,6 +171,11 @@ struct dma_buf *dma_buf_export_named(void *priv, const struct dma_buf_ops *ops, dmabuf->ops = ops; dmabuf->size = size; dmabuf->exp_name = exp_name; +if (!resv) { + resv = (struct reservation_object *)&dmabuf[1 ]; +reservation_object_init (resv); + } + dmabuf->resv = resv; file =anon_inode_getfile ("dmabuf" , &dma_buf_fops, dmabuf, flags);if (IS_ERR (file)) {
drivers/gpu/drm/armada/armada_gem.c +1 -1
@@ -539,7 +539,7 @@ armada_gem_prime_export(struct drm_device *dev, struct drm_gem_object *obj, int flags) {return dma_buf_export (obj, &armada_gem_prime_dmabuf_ops, obj->size, -O_RDWR ); +O_RDWR ,NULL ); } struct drm_gem_object *
drivers/gpu/drm/drm_prime.c +7 -1
@@ -336,7 +336,13 @@ static const struct dma_buf_ops drm_gem_prime_dmabuf_ops = {struct dma_buf *drm_gem_prime_export (struct drm_device *dev,struct drm_gem_object *obj,int flags) { -return dma_buf_export (obj, &drm_gem_prime_dmabuf_ops, obj->size, flags); +struct reservation_object *robj =NULL ; + +if (dev->driver->gem_prime_res_obj) + robj = dev->driver->gem_prime_res_obj (obj); + +return dma_buf_export (obj, &drm_gem_prime_dmabuf_ops, obj->size, + flags, robj); }EXPORT_SYMBOL (drm_gem_prime_export);
drivers/gpu/drm/exynos/exynos_drm_dmabuf.c +1 -1
@@ -187,7 +187,7 @@ struct dma_buf *exynos_dmabuf_prime_export(struct drm_device *drm_dev,struct exynos_drm_gem_obj *exynos_gem_obj =to_exynos_gem_obj (obj);return dma_buf_export (obj, &exynos_dmabuf_ops, - exynos_gem_obj->base.size, flags); + exynos_gem_obj->base.size, flags,NULL ); } struct drm_gem_object *exynos_dmabuf_prime_import(struct drm_device *drm_dev,
drivers/gpu/drm/i915/i915_gem_dmabuf.c +2 -1
@@ -237,7 +237,8 @@ struct dma_buf *i915_gem_prime_export(struct drm_device *dev,return ERR_PTR (ret); } -return dma_buf_export (gem_obj, &i915_dmabuf_ops, gem_obj->size, flags); +return dma_buf_export (gem_obj, &i915_dmabuf_ops, gem_obj->size, flags, +NULL ); }static int i915_gem_object_get_pages_dmabuf (struct drm_i915_gem_object *obj)
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -0
@@ -844,6 +844,7 @@ driver = { .gem_prime_export = drm_gem_prime_export, .gem_prime_import = drm_gem_prime_import, .gem_prime_pin = nouveau_gem_prime_pin, + .gem_prime_res_obj = nouveau_gem_prime_res_obj, .gem_prime_unpin = nouveau_gem_prime_unpin, .gem_prime_get_sg_table = nouveau_gem_prime_get_sg_table, .gem_prime_import_sg_table = nouveau_gem_prime_import_sg_table,
drivers/gpu/drm/nouveau/nouveau_gem.h +1 -0
@@ -35,6 +35,7 @@ extern int nouveau_gem_ioctl_info(struct drm_device *, void *, struct drm_file *);extern int nouveau_gem_prime_pin (struct drm_gem_object *); +struct reservation_object *nouveau_gem_prime_res_obj (struct drm_gem_object *);extern void nouveau_gem_prime_unpin (struct drm_gem_object *);extern struct sg_table *nouveau_gem_prime_get_sg_table (struct drm_gem_object *); extern struct drm_gem_object *nouveau_gem_prime_import_sg_table(
drivers/gpu/drm/nouveau/nouveau_prime.c +7 -0
@@ -102,3 +102,10 @@ void nouveau_gem_prime_unpin(struct drm_gem_object *obj)nouveau_bo_unpin (nvbo); } + +struct reservation_object *nouveau_gem_prime_res_obj (struct drm_gem_object *obj) +{ +struct nouveau_bo *nvbo =nouveau_gem_object (obj); + +return nvbo->bo.resv; +}
drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c +1 -1
@@ -171,7 +171,7 @@ static struct dma_buf_ops omap_dmabuf_ops = {struct dma_buf *omap_gem_prime_export (struct drm_device *dev,struct drm_gem_object *obj,int flags) { -return dma_buf_export (obj, &omap_dmabuf_ops, obj->size, flags); +return dma_buf_export (obj, &omap_dmabuf_ops, obj->size, flags,NULL ); } struct drm_gem_object *omap_gem_prime_import(struct drm_device *dev,
drivers/gpu/drm/radeon/radeon_drv.c +2 -0
@@ -132,6 +132,7 @@ struct drm_gem_object *radeon_gem_prime_import_sg_table(struct drm_device *dev, struct sg_table *sg);int radeon_gem_prime_pin (struct drm_gem_object *obj);void radeon_gem_prime_unpin (struct drm_gem_object *obj); +struct reservation_object *radeon_gem_prime_res_obj (struct drm_gem_object *);void *radeon_gem_prime_vmap (struct drm_gem_object *obj);void radeon_gem_prime_vunmap (struct drm_gem_object *obj,void *vaddr); extern long radeon_kms_compat_ioctl(struct file *filp, unsigned int cmd,
@@ -562,6 +563,7 @@ static struct drm_driver kms_driver = { .gem_prime_import = drm_gem_prime_import, .gem_prime_pin = radeon_gem_prime_pin, .gem_prime_unpin = radeon_gem_prime_unpin, + .gem_prime_res_obj = radeon_gem_prime_res_obj, .gem_prime_get_sg_table = radeon_gem_prime_get_sg_table, .gem_prime_import_sg_table = radeon_gem_prime_import_sg_table, .gem_prime_vmap = radeon_gem_prime_vmap,
drivers/gpu/drm/radeon/radeon_prime.c +8 -0
@@ -103,3 +103,11 @@ void radeon_gem_prime_unpin(struct drm_gem_object *obj)radeon_bo_unpin (bo);radeon_bo_unreserve (bo); } + + +struct reservation_object *radeon_gem_prime_res_obj (struct drm_gem_object *obj) +{ +struct radeon_bo *bo =gem_to_radeon_bo (obj); + +return bo->tbo.resv; +}
drivers/gpu/drm/tegra/gem.c +1 -1
@@ -420,7 +420,7 @@ struct dma_buf *tegra_gem_prime_export(struct drm_device *drm, int flags) {return dma_buf_export (gem, &tegra_gem_prime_dmabuf_ops, gem->size, - flags); + flags,NULL ); } struct drm_gem_object *tegra_gem_prime_import(struct drm_device *drm,
drivers/gpu/drm/ttm/ttm_object.c +1 -1
@@ -695,7 +695,7 @@ int ttm_prime_handle_to_fd(struct ttm_object_file *tfile, } dma_buf =dma_buf_export (prime, &tdev->ops, - prime->size, flags); + prime->size, flags,NULL );if (IS_ERR (dma_buf)) { ret =PTR_ERR (dma_buf); ttm_mem_global_free(tdev->mem_glob,
drivers/media/v4l2-core/videobuf2-dma-contig.c +1 -1
@@ -404,7 +404,7 @@ static struct dma_buf *vb2_dc_get_dmabuf(void *buf_priv, unsigned long flags)if (WARN_ON (!buf->sgt_base))return NULL ; - dbuf =dma_buf_export (buf, &vb2_dc_dmabuf_ops, buf->size, flags); + dbuf =dma_buf_export (buf, &vb2_dc_dmabuf_ops, buf->size, flags,NULL );if (IS_ERR (dbuf))return NULL ;
drivers/staging/android/ion/ion.c +2 -1
@@ -1120,7 +1120,8 @@ struct dma_buf *ion_share_dma_buf(struct ion_client *client,ion_buffer_get (buffer);mutex_unlock (&client->lock); - dmabuf =dma_buf_export (buffer, &dma_buf_ops, buffer->size,O_RDWR ); + dmabuf =dma_buf_export (buffer, &dma_buf_ops, buffer->size,O_RDWR , +NULL );if (IS_ERR (dmabuf)) {ion_buffer_put (buffer);return dmabuf;
include/drm/drmP.h +3 -0
@@ -83,6 +83,7 @@ struct drm_device;struct device_node ;struct videomode ; +struct reservation_object ;#include <drm/drm_os_linux.h> #include <drm/drm_hashtab.h>
@@ -923,6 +924,8 @@ struct drm_driver {/* low-level interface used by drm_gem_prime_{import,export} */ int (*gem_prime_pin)(struct drm_gem_object *obj);void (*gem_prime_unpin)(struct drm_gem_object *obj); +struct reservation_object * (*gem_prime_res_obj)( +struct drm_gem_object *obj);struct sg_table *(*gem_prime_get_sg_table)(struct drm_gem_object *obj); struct drm_gem_object *(*gem_prime_import_sg_table)( struct drm_device *dev, size_t size,
include/linux/dma-buf.h +6 -3
@@ -115,6 +115,7 @@ struct dma_buf_ops {* @exp_name: name of the exporter; useful for debugging. * @list_node: node for dma_buf accounting and debugging. * @priv: exporter specific private data for this buffer object. +* @resv: reservation object linked to this dma-buf */ struct dma_buf {size_t size;
@@ -128,6 +129,7 @@ struct dma_buf {const char *exp_name;struct list_head list_node;void *priv; +struct reservation_object *resv; };/**
@@ -168,10 +170,11 @@ void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *dmabuf_attach);struct dma_buf *dma_buf_export_named (void *priv,const struct dma_buf_ops *ops, -size_t size,int flags,const char *); +size_t size,int flags,const char *, +struct reservation_object *); -#define dma_buf_export (priv, ops, size, flags) \ - dma_buf_export_named(priv, ops, size, flags, KBUILD_MODNAME) +#define dma_buf_export (priv, ops, size, flags, resv) \ + dma_buf_export_named(priv, ops, size, flags, KBUILD_MODNAME, resv)int dma_buf_fd (struct dma_buf *dmabuf,int flags);struct dma_buf *dma_buf_get (int fd);
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 5/9 android: convert sync to fence api, v6
In reply to Maarten LankhorstJust to show it's easy.
Android syncpoints can be mapped to a timeline. This removes the need to maintain a separate api for synchronization. I've left the android trace events in place, but the core fence events should already be sufficient for debugging.
v2:
- Call fence_remove_callback in sync_fence_free if not all fences have fired. v3:
- Merge Colin Cross' bugfixes, and the android fence merge optimization. v4:
- Merge with the upstream fixes.
v5:
- Fix small style issues pointed out by Thomas Hellstrom.
v6:
- Fix for updates to fence api.
--- drivers/staging/android/Kconfig | 1 drivers/staging/android/Makefile | 2 drivers/staging/android/sw_sync.c | 6 drivers/staging/android/sync.c | 913 +++++++++++----------------------- drivers/staging/android/sync.h | 79 ++- drivers/staging/android/sync_debug.c | 247 +++++++++ drivers/staging/android/trace/sync.h | 12 7 files changed, 609 insertions(+), 651 deletions(-) create mode 100644 drivers/staging/android/sync_debug.c
drivers/staging/android/Kconfig +1 -0
@@ -88,6 +88,7 @@ config SYNC bool "Synchronization framework" default n select ANON_INODES + select DMA_SHARED_BUFFER ---help--- This option enables the framework for synchronization between multiple drivers. Sync implementations can take advantage of hardware
drivers/staging/android/Makefile +1 -1
@@ -9,5 +9,5 @@ obj-$(CONFIG_ANDROID_TIMED_OUTPUT) += timed_output.o obj-$(CONFIG_ANDROID_TIMED_GPIO) += timed_gpio.o obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER) += lowmemorykiller.o obj-$(CONFIG_ANDROID_INTF_ALARM_DEV) += alarm-dev.o -obj-$(CONFIG_SYNC) += sync.o +obj-$(CONFIG_SYNC) += sync.o sync_debug.o obj-$(CONFIG_SW_SYNC) += sw_sync.o
drivers/staging/android/sw_sync.c +2 -4
@@ -50,7 +50,7 @@ static struct sync_pt *sw_sync_pt_dup(struct sync_pt *sync_pt) {struct sw_sync_pt *pt = (struct sw_sync_pt *) sync_pt;struct sw_sync_timeline *obj = - (struct sw_sync_timeline *)sync_pt->parent; + (struct sw_sync_timeline *)sync_pt_parent (sync_pt);return (struct sync_pt *)sw_sync_pt_create (obj, pt->value); }
@@ -59,7 +59,7 @@ static int sw_sync_pt_has_signaled(struct sync_pt *sync_pt) {struct sw_sync_pt *pt = (struct sw_sync_pt *)sync_pt;struct sw_sync_timeline *obj = - (struct sw_sync_timeline *)sync_pt->parent; + (struct sw_sync_timeline *)sync_pt_parent (sync_pt);return sw_sync_cmp (obj->value, pt->value) >=0 ; }
@@ -97,7 +97,6 @@ static void sw_sync_pt_value_str(struct sync_pt *sync_pt, char *str, int size) {struct sw_sync_pt *pt = (struct sw_sync_pt *)sync_pt; -snprintf (str, size,"%d" , pt->value); }
@@ -157,7 +156,6 @@ static int sw_sync_open(struct inode *inode, struct file *file)static int sw_sync_release (struct inode *inode,struct file *file) {struct sw_sync_timeline *obj = file->private_data; -sync_timeline_destroy (&obj->obj);return 0 ; }
drivers/staging/android/sync.c +307 -606
1,154 lines not on this page · raw message
drivers/staging/android/sync.h +45 -34
154 lines not on this page · raw message
drivers/staging/android/sync_debug.c new file +247 -0
247 lines not on this page · raw message
drivers/staging/android/trace/sync.h +6 -6
@@ -45,7 +45,7 @@ TRACE_EVENT(sync_wait,TP_fast_assign ( __assign_str(name, fence->name); - __entry->status = fence->status; + __entry->status =atomic_read (&fence->status); __entry->begin = begin; ),
@@ -54,19 +54,19 @@ TRACE_EVENT(sync_wait, ); TRACE_EVENT(sync_pt, - TP_PROTO(struct sync_pt *pt), + TP_PROTO(struct fence *pt), TP_ARGS(pt), TP_STRUCT__entry( - __string(timeline, pt->parent->name) + __string(timeline, pt->ops->get_timeline_name(pt)) __array(char, value, 32) ), TP_fast_assign( - __assign_str(timeline, pt->parent->name); - if (pt->parent->ops->pt_value_str) { - pt->parent->ops->pt_value_str(pt, __entry->value, + __assign_str(timeline, pt->ops->get_timeline_name(pt)); + if (pt->ops->fence_value_str) { + pt->ops->fence_value_str(pt, __entry->value, sizeof(__entry->value)); } else { __entry->value[0] = '\0';
PATCH v2 6/9 reservation: add support for fences to enable cross-device synchronisation
In reply to Maarten Lankhorst--- include/linux/reservation.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
include/linux/reservation.h +19 -1
@@ -6,7 +6,7 @@* Copyright (C) 2012 Texas Instruments * * Authors: -* Rob Clark <[email protected]> +* Rob Clark <[email protected]> * Maarten Lankhorst <[email protected]> * Thomas Hellstrom <thellstrom-at-vmware-dot-com> *
@@ -40,22 +40,40 @@#define _LINUX_RESERVATION_H#include <linux/ww_mutex.h> +#include <linux/fence.h> +#include <linux/slab.h> extern struct ww_class reservation_ww_class;struct reservation_object {struct ww_mutex lock; + +struct fence *fence_excl; +struct fence **fence_shared; +u32 fence_shared_count, fence_shared_max; };static inline void reservation_object_init (struct reservation_object *obj) {ww_mutex_init (&obj->lock, &reservation_ww_class); + + obj->fence_shared_count = obj->fence_shared_max =0 ; + obj->fence_shared =NULL ; + obj->fence_excl =NULL ; }static inline void reservation_object_fini (struct reservation_object *obj) { +int i; + +if (obj->fence_excl) +fence_put (obj->fence_excl); +for (i =0 ; i < obj->fence_shared_count; ++i) +fence_put (obj->fence_shared[i]); +kfree (obj->fence_shared); +ww_mutex_destroy (&obj->lock); }
PATCH v2 7/9 dma-buf: add poll support, v3
In reply to Maarten LankhorstThanks to Fengguang Wu for spotting a missing static cast.
v2:
- Kill unused variable need_shared.
v3:
- Clarify the BUG() in dma_buf_release some more. (Rob Clark)
--- drivers/dma-buf/dma-buf.c | 108 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/dma-buf.h | 12 +++++ 2 files changed, 120 insertions(+)
drivers/dma-buf/dma-buf.c +108 -0
@@ -30,6 +30,7 @@#include <linux/export.h> #include <linux/debugfs.h> #include <linux/seq_file.h> +#include <linux/poll.h> #include <linux/reservation.h> static inline int is_dma_buf_file (struct file *);
@@ -52,6 +53,16 @@ static int dma_buf_release(struct inode *inode, struct file *file)BUG_ON (dmabuf->vmapping_counter); +/* +* Any fences that a dma-buf poll can wait on should be signaled +* before releasing dma-buf. This is the responsibility of each +* driver that uses the reservation objects. +* +* If you hit this BUG() it means someone dropped their ref to the +* dma-buf while still having pending operation to the buffer. +*/ +BUG_ON (dmabuf->cb_shared.active || dmabuf->cb_excl.active); + dmabuf->ops->release (dmabuf);mutex_lock (&db_list.lock);
@@ -108,10 +119,103 @@ static loff_t dma_buf_llseek(struct file *file, loff_t offset, int whence)return base + offset; } +static void dma_buf_poll_cb (struct fence *fence,struct fence_cb *cb) +{ +struct dma_buf_poll_cb_t *dcb = (struct dma_buf_poll_cb_t *)cb; +unsigned long flags; + +spin_lock_irqsave (&dcb->poll->lock, flags); +wake_up_locked_poll (dcb->poll, dcb->active); + dcb->active =0 ; +spin_unlock_irqrestore (&dcb->poll->lock, flags); +} + +static unsigned int dma_buf_poll (struct file *file,poll_table *poll) +{ +struct dma_buf *dmabuf; +struct reservation_object *resv; +unsigned long events; + + dmabuf = file->private_data; +if (!dmabuf || !dmabuf->resv) +return POLLERR ; + + resv = dmabuf->resv; + +poll_wait (file, &dmabuf->poll, poll); + + events =poll_requested_events (poll) & (POLLIN |POLLOUT ); +if (!events) +return 0 ; + +ww_mutex_lock (&resv->lock,NULL ); + +if (resv->fence_excl && (!(events &POLLOUT ) || + resv->fence_shared_count ==0 )) { +struct dma_buf_poll_cb_t *dcb = &dmabuf->cb_excl; +unsigned long pevents =POLLIN ; + +if (resv->fence_shared_count ==0 ) + pevents |=POLLOUT ; + +spin_lock_irq (&dmabuf->poll.lock); +if (dcb->active) { + dcb->active |= pevents; + events &= ~pevents; + }else + dcb->active = pevents; +spin_unlock_irq (&dmabuf->poll.lock); + +if (events & pevents) { +if (!fence_add_callback (resv->fence_excl, + &dcb->cb, dma_buf_poll_cb)) + events &= ~pevents; +else +/* +* No callback queued, wake up any additional +* waiters. +*/ +dma_buf_poll_cb (NULL , &dcb->cb); + } + } + +if ((events &POLLOUT ) && resv->fence_shared_count >0 ) { +struct dma_buf_poll_cb_t *dcb = &dmabuf->cb_shared; +int i; + +/* Only queue a new callback if no event has fired yet */ +spin_lock_irq (&dmabuf->poll.lock); +if (dcb->active) + events &= ~POLLOUT ; +else + dcb->active =POLLOUT ; +spin_unlock_irq (&dmabuf->poll.lock); + +if (!(events &POLLOUT )) + goto out; + +for (i =0 ; i < resv->fence_shared_count; ++i) +if (!fence_add_callback (resv->fence_shared[i], + &dcb->cb, dma_buf_poll_cb)) { + events &= ~POLLOUT ; +break ; + } + +/* No callback queued, wake up any additional waiters. */ +if (i == resv->fence_shared_count) +dma_buf_poll_cb (NULL , &dcb->cb); + } + +out: +ww_mutex_unlock (&resv->lock); +return events; +} +static const struct file_operations dma_buf_fops = { .release = dma_buf_release, .mmap = dma_buf_mmap_internal, .llseek = dma_buf_llseek, + .poll = dma_buf_poll, };/*
@@ -171,6 +275,10 @@ struct dma_buf *dma_buf_export_named(void *priv, const struct dma_buf_ops *ops, dmabuf->ops = ops; dmabuf->size = size; dmabuf->exp_name = exp_name; +init_waitqueue_head (&dmabuf->poll); + dmabuf->cb_excl.poll = dmabuf->cb_shared.poll = &dmabuf->poll; + dmabuf->cb_excl.active = dmabuf->cb_shared.active =0 ; +if (!resv) { resv = (struct reservation_object *)&dmabuf[1 ];reservation_object_init (resv);
include/linux/dma-buf.h +12 -0
@@ -30,6 +30,8 @@#include <linux/list.h> #include <linux/dma-mapping.h> #include <linux/fs.h> +#include <linux/fence.h> +#include <linux/wait.h> struct device ;struct dma_buf ;
@@ -130,6 +132,16 @@ struct dma_buf {struct list_head list_node;void *priv;struct reservation_object *resv; + +/* poll support */ +wait_queue_head_t poll; + +struct dma_buf_poll_cb_t { +struct fence_cb cb; +wait_queue_head_t *poll; + +unsigned long active; + } cb_excl, cb_shared; };/**
PATCH v2 8/9 reservation: update api and add some helpers
In reply to Maarten LankhorstMove the list of shared fences to a struct, and return it in reservation_object_get_list().
Add reservation_object_get_excl to get the exclusive fence.
Add reservation_object_reserve_shared(), which reserves space in the reservation_object for 1 more shared fence.
reservation_object_add_shared_fence() and reservation_object_add_excl_fence() are used to assign a new fence to a reservation_object pointer, to complete a reservation.
Changes since v1:
- Add reservation_object_get_excl, reorder code a bit.
--- Documentation/DocBook/device-drivers.tmpl | 1 drivers/dma-buf/dma-buf.c | 35 ++++--- drivers/dma-buf/reservation.c | 156 +++++++++++++++++++++++++++++ include/linux/reservation.h | 56 +++++++++- 4 files changed, 229 insertions(+), 19 deletions(-)
Documentation/DocBook/device-drivers.tmpl +1 -0
@@ -133,6 +133,7 @@ X!Edrivers/base/interface.c !Edrivers/dma-buf/seqno-fence.c !Iinclude/linux/fence.h !Iinclude/linux/seqno-fence.h +!Edrivers/dma-buf/reservation.c !Iinclude/linux/reservation.h !Edrivers/base/dma-coherent.c !Edrivers/base/dma-mapping.c
drivers/dma-buf/dma-buf.c +24 -11
@@ -134,7 +134,10 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll) {struct dma_buf *dmabuf;struct reservation_object *resv; +struct reservation_object_list *fobj; +struct fence *fence_excl;unsigned long events; +unsigned shared_count; dmabuf = file->private_data;if (!dmabuf || !dmabuf->resv)
@@ -150,12 +153,18 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll)ww_mutex_lock (&resv->lock,NULL ); -if (resv->fence_excl && (!(events &POLLOUT ) || - resv->fence_shared_count ==0 )) { + fobj = resv->fence; +if (!fobj) + goto out; + + shared_count = fobj->shared_count; + fence_excl = resv->fence_excl; + +if (fence_excl && (!(events &POLLOUT ) || shared_count ==0 )) {struct dma_buf_poll_cb_t *dcb = &dmabuf->cb_excl;unsigned long pevents =POLLIN ; -if (resv->fence_shared_count ==0 ) +if (shared_count ==0 ) pevents |=POLLOUT ;spin_lock_irq (&dmabuf->poll.lock);
@@ -167,19 +176,20 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll)spin_unlock_irq (&dmabuf->poll.lock);if (events & pevents) { -if (!fence_add_callback (resv->fence_excl, - &dcb->cb, dma_buf_poll_cb)) +if (!fence_add_callback (fence_excl, &dcb->cb, + dma_buf_poll_cb)) { events &= ~pevents; -else + }else {/* * No callback queued, wake up any additional * waiters. */ dma_buf_poll_cb (NULL , &dcb->cb); + } } } -if ((events &POLLOUT ) && resv->fence_shared_count >0 ) { +if ((events &POLLOUT ) && shared_count >0 ) {struct dma_buf_poll_cb_t *dcb = &dmabuf->cb_shared;int i;
@@ -194,15 +204,18 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll)if (!(events &POLLOUT )) goto out; -for (i =0 ; i < resv->fence_shared_count; ++i) -if (!fence_add_callback (resv->fence_shared[i], - &dcb->cb, dma_buf_poll_cb)) { +for (i =0 ; i < shared_count; ++i) { +struct fence *fence = fobj->shared[i]; + +if (!fence_add_callback (fence, &dcb->cb, + dma_buf_poll_cb)) { events &= ~POLLOUT ;break ; } + }/* No callback queued, wake up any additional waiters. */ -if (i == resv->fence_shared_count) +if (i == shared_count)dma_buf_poll_cb (NULL , &dcb->cb); }
drivers/dma-buf/reservation.c +155 -1
163 lines not on this page · raw message
include/linux/reservation.h +49 -7
85 lines not on this page · raw message
PATCH v2 9/9 reservation: add suppport for read-only access using rcu
In reply to Maarten LankhorstThis adds some extra functions to deal with rcu.
reservation_object_get_fences_rcu() will obtain the list of shared and exclusive fences without obtaining the ww_mutex.
reservation_object_wait_timeout_rcu() will wait on all fences of the reservation_object, without obtaining the ww_mutex.
reservation_object_test_signaled_rcu() will test if all fences of the reservation_object are signaled without using the ww_mutex.
reservation_object_get_excl and reservation_object_get_list require the reservation object to be held, updating requires write_seqcount_begin/end. If only the exclusive fence is needed, rcu_dereference followed by fence_get_rcu can be used, if the shared fences are needed it's recommended to use the supplied functions.
--- drivers/dma-buf/dma-buf.c | 47 ++++-- drivers/dma-buf/fence.c | 2 drivers/dma-buf/reservation.c | 336 ++++++++++++++++++++++++++++++++++++++--- include/linux/fence.h | 17 ++ include/linux/reservation.h | 52 ++++-- 5 files changed, 400 insertions(+), 54 deletions(-)
drivers/dma-buf/dma-buf.c +36 -11
@@ -137,7 +137,7 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll)struct reservation_object_list *fobj;struct fence *fence_excl;unsigned long events; -unsigned shared_count; +unsigned shared_count, seq; dmabuf = file->private_data;if (!dmabuf || !dmabuf->resv)
@@ -151,14 +151,20 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll)if (!events)return 0 ; -ww_mutex_lock (&resv->lock,NULL ); +retry: + seq =read_seqcount_begin (&resv->seq); +rcu_read_lock (); - fobj = resv->fence; -if (!fobj) - goto out; - - shared_count = fobj->shared_count; - fence_excl = resv->fence_excl; + fobj =rcu_dereference (resv->fence); +if (fobj) + shared_count = fobj->shared_count; +else + shared_count =0 ; + fence_excl =rcu_dereference (resv->fence_excl); +if (read_seqcount_retry (&resv->seq, seq)) { +rcu_read_unlock (); + goto retry; + }if (fence_excl && (!(events &POLLOUT ) || shared_count ==0 )) {struct dma_buf_poll_cb_t *dcb = &dmabuf->cb_excl;
@@ -176,14 +182,20 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll)spin_unlock_irq (&dmabuf->poll.lock);if (events & pevents) { -if (!fence_add_callback (fence_excl, &dcb->cb, +if (!fence_get_rcu (fence_excl)) { +/* force a recheck */ + events &= ~pevents; +dma_buf_poll_cb (NULL , &dcb->cb); + }else if (!fence_add_callback (fence_excl, &dcb->cb, dma_buf_poll_cb)) { events &= ~pevents; +fence_put (fence_excl); }else {/* * No callback queued, wake up any additional * waiters. */ +fence_put (fence_excl);dma_buf_poll_cb (NULL , &dcb->cb); } }
@@ -205,13 +217,26 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll) goto out;for (i =0 ; i < shared_count; ++i) { -struct fence *fence = fobj->shared[i]; +struct fence *fence =rcu_dereference (fobj->shared[i]); +if (!fence_get_rcu (fence)) { +/* +* fence refcount dropped to zero, this means +* that fobj has been freed +* +* call dma_buf_poll_cb and force a recheck! +*/ + events &= ~POLLOUT ; +dma_buf_poll_cb (NULL , &dcb->cb); +break ; + }if (!fence_add_callback (fence, &dcb->cb, dma_buf_poll_cb)) { +fence_put (fence); events &= ~POLLOUT ;break ; } +fence_put (fence); }/* No callback queued, wake up any additional waiters. */
@@ -220,7 +245,7 @@ static unsigned int dma_buf_poll(struct file *file, poll_table *poll) } out: -ww_mutex_unlock (&resv->lock); +rcu_read_unlock ();return events; }
drivers/dma-buf/fence.c +1 -1
@@ -184,7 +184,7 @@ EXPORT_SYMBOL(fence_release);void fence_free (struct fence *fence) { -kfree (fence); +kfree_rcu (fence, rcu); }EXPORT_SYMBOL (fence_free);
drivers/dma-buf/reservation.c +310 -26
406 lines not on this page · raw message
include/linux/fence.h +17 -0
@@ -28,6 +28,7 @@#include <linux/kref.h> #include <linux/sched.h> #include <linux/printk.h> +#include <linux/rcupdate.h> struct fence ;struct fence_ops ;
@@ -37,6 +38,7 @@ struct fence_cb;* struct fence - software synchronization primitive * @refcount: refcount for this fence * @ops: fence_ops associated with this fence +* @rcu: used for releasing fence with kfree_rcu * @cb_list: list of all callbacks to call * @lock: spin_lock_irqsave used for locking * @context: execution context this fence belongs to, returned by
@@ -70,6 +72,7 @@ struct fence_cb;struct fence {struct kref refcount;const struct fence_ops *ops; +struct rcu_head rcu;struct list_head cb_list;spinlock_t *lock;unsigned context, seqno;
@@ -192,6 +195,20 @@ static inline struct fence *fence_get(struct fence *fence) }/** +* fence_get_rcu - get a fence from a reservation_object_list with rcu read lock +* @fence: [in] fence to increase refcount of +* +* Function returns NULL if no refcount could be obtained, or the fence. +*/ +static inline struct fence *fence_get_rcu (struct fence *fence) +{ +if (kref_get_unless_zero (&fence->refcount)) +return fence; +else +return NULL ; +} + +/** * fence_put - decreases refcount of the fence * @fence: [in] fence to reduce refcount of */
include/linux/reservation.h +36 -16
105 lines not on this page · raw message
Re: [PATCH v2 1/9] dma-buf: move to drivers/dma-buf
In reply to Maarten LankhorstQuoted 1 line · Maarten Lankhorst
Signed-off-by Maarten Lankhorst <[email protected]>
It would help to use '-M' option with format-patch for this kind of rework.
Regards,
Arend
Quoted 1,672 lines
--- Documentation/DocBook/device-drivers.tmpl | 3 MAINTAINERS | 4 drivers/Makefile | 1 drivers/base/Makefile | 1 drivers/base/dma-buf.c | 743 ----------------------------- drivers/base/reservation.c | 39 -- drivers/dma-buf/Makefile | 1 drivers/dma-buf/dma-buf.c | 743 +++++++++++++++++++++++++++++ drivers/dma-buf/reservation.c | 39 ++ 9 files changed, 787 insertions(+), 787 deletions(-) delete mode 100644 drivers/base/dma-buf.c delete mode 100644 drivers/base/reservation.c create mode 100644 drivers/dma-buf/Makefile create mode 100644 drivers/dma-buf/dma-buf.c create mode 100644 drivers/dma-buf/reservation.cDocumentation/DocBook/device-drivers.tmpl +1
-2@@ -128,8 +128,7 @@ X!Edrivers/base/interface.c !Edrivers/base/bus.c </sect1> <sect1><title>Device Drivers DMA Management</title> -!Edrivers/base/dma-buf.c -!Edrivers/base/reservation.c +!Edrivers/dma-buf/dma-buf.c !Iinclude/linux/reservation.h !Edrivers/base/dma-coherent.c !Edrivers/base/dma-mapping.cMAINTAINERS +2
-2@@ -2882,8 +2882,8 @@ S: Maintained L: [email protected] L: [email protected] L: [email protected] -F: drivers/base/dma-buf* -F: include/linux/dma-buf* +F: drivers/dma-buf/ +F: include/linux/dma-buf* include/linux/reservation.h F: Documentation/dma-buf-sharing.txt T: git git://git.linaro.org/people/sumitsemwal/linux-dma-buf.gitdrivers/Makefile +1
-0@@ -61,6 +61,7 @@ obj-$(CONFIG_FB_INTEL) += video/fbdev/intelfb/ obj-$(CONFIG_PARPORT) += parport/ obj-y += base/ block/ misc/ mfd/ nfc/ +obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf/ obj-$(CONFIG_NUBUS) += nubus/ obj-y += macintosh/ obj-$(CONFIG_IDE) += ide/drivers/base/Makefile +0
-1@@ -10,7 +10,6 @@ obj-$(CONFIG_DMA_CMA) += dma-contiguous.o obj-y += power/ obj-$(CONFIG_HAS_DMA) += dma-mapping.o obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o -obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf.o reservation.o obj-$(CONFIG_ISA) += isa.o obj-$(CONFIG_FW_LOADER) += firmware_class.o obj-$(CONFIG_NUMA) += node.odrivers/base/dma-buf.c deleted +0
-743@@ -1,743 +0,0 @@ -/* -* Framework for buffer objects that can be shared across devices/subsystems. -* -* Copyright(C) 2011 Linaro Limited. All rights reserved. -* Author: Sumit Semwal <[email protected]> -* -* Many thanks to linaro-mm-sig list, and specially -* Arnd Bergmann <[email protected]>, Rob Clark <[email protected]> and -* Daniel Vetter <[email protected]> for their support in creation and -* refining of this idea. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License version 2 as published by -* the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along with -* this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include <linux/fs.h> -#include <linux/slab.h> -#include <linux/dma-buf.h> -#include <linux/anon_inodes.h> -#include <linux/export.h> -#include <linux/debugfs.h> -#include <linux/seq_file.h> - -static inline int is_dma_buf_file (struct file *); - -struct dma_buf_list { -struct list_head head; -struct mutex lock; -}; - -static struct dma_buf_list db_list; - -static int dma_buf_release (struct inode *inode,struct file *file) -{ -struct dma_buf *dmabuf; - -if (!is_dma_buf_file (file)) -return -EINVAL ; - - dmabuf = file->private_data; - -BUG_ON (dmabuf->vmapping_counter); - - dmabuf->ops->release (dmabuf); - -mutex_lock (&db_list.lock); -list_del (&dmabuf->list_node); -mutex_unlock (&db_list.lock); - -kfree (dmabuf); -return 0 ; -} - -static int dma_buf_mmap_internal (struct file *file,struct vm_area_struct *vma) -{ -struct dma_buf *dmabuf; - -if (!is_dma_buf_file (file)) -return -EINVAL ; - - dmabuf = file->private_data; - -/* check for overflowing the buffer's size */ -if (vma->vm_pgoff + ((vma->vm_end - vma->vm_start) >>PAGE_SHIFT ) > - dmabuf->size >>PAGE_SHIFT ) -return -EINVAL ; - -return dmabuf->ops->mmap (dmabuf, vma); -} - -static loff_t dma_buf_llseek (struct file *file,loff_t offset,int whence) -{ -struct dma_buf *dmabuf; -loff_t base; - -if (!is_dma_buf_file (file)) -return -EBADF ; - - dmabuf = file->private_data; - -/* only support discovering the end of the buffer, -but also allow SEEK_SET to maintain the idiomatic -SEEK_END(0), SEEK_CUR(0) pattern */ -if (whence ==SEEK_END ) - base = dmabuf->size; -else if (whence ==SEEK_SET ) - base =0 ; -else -return -EINVAL ; - -if (offset !=0 ) -return -EINVAL ; - -return base + offset; -} - -static const struct file_operations dma_buf_fops = { - .release = dma_buf_release, - .mmap = dma_buf_mmap_internal, - .llseek = dma_buf_llseek, -}; - -/* -* is_dma_buf_file - Check if struct file* is associated with dma_buf -*/ -static inline int is_dma_buf_file (struct file *file) -{ -return file->f_op == &dma_buf_fops; -} - -/** -* dma_buf_export_named - Creates a new dma_buf, and associates an anon file -* with this buffer, so it can be exported. -* Also connect the allocator specific data and ops to the buffer. -* Additionally, provide a name string for exporter; useful in debugging. -* -* @priv: [in] Attach private data of allocator to this buffer -* @ops: [in] Attach allocator-defined dma buf ops to the new buffer. -* @size: [in] Size of the buffer -* @flags: [in] mode flags for the file. -* @exp_name: [in] name of the exporting module - useful for debugging. -* -* Returns, on success, a newly created dma_buf object, which wraps the -* supplied private data and operations for dma_buf_ops. On either missing -* ops, or error in allocating struct dma_buf, will return negative error. -* -*/ -struct dma_buf *dma_buf_export_named (void *priv,const struct dma_buf_ops *ops, -size_t size,int flags,const char *exp_name) -{ -struct dma_buf *dmabuf; -struct file *file; - -if (WARN_ON (!priv || !ops - || !ops->map_dma_buf - || !ops->unmap_dma_buf - || !ops->release - || !ops->kmap_atomic - || !ops->kmap - || !ops->mmap)) { -return ERR_PTR (-EINVAL ); - } - - dmabuf =kzalloc (sizeof (struct dma_buf ),GFP_KERNEL ); -if (dmabuf ==NULL ) -return ERR_PTR (-ENOMEM ); - - dmabuf->priv = priv; - dmabuf->ops = ops; - dmabuf->size = size; - dmabuf->exp_name = exp_name; - - file =anon_inode_getfile ("dmabuf" , &dma_buf_fops, dmabuf, flags); -if (IS_ERR (file)) { -kfree (dmabuf); -return ERR_CAST (file); - } - - file->f_mode |=FMODE_LSEEK ; - dmabuf->file = file; - -mutex_init (&dmabuf->lock); -INIT_LIST_HEAD (&dmabuf->attachments); - -mutex_lock (&db_list.lock); -list_add (&dmabuf->list_node, &db_list.head); -mutex_unlock (&db_list.lock); - -return dmabuf; -} -EXPORT_SYMBOL_GPL (dma_buf_export_named); - - -/** -* dma_buf_fd - returns a file descriptor for the given dma_buf -* @dmabuf: [in] pointer to dma_buf for which fd is required. -* @flags: [in] flags to give to fd -* -* On success, returns an associated 'fd'. Else, returns error. -*/ -int dma_buf_fd (struct dma_buf *dmabuf,int flags) -{ -int fd; - -if (!dmabuf || !dmabuf->file) -return -EINVAL ; - - fd =get_unused_fd_flags (flags); -if (fd <0 ) -return fd; - -fd_install (fd, dmabuf->file); - -return fd; -} -EXPORT_SYMBOL_GPL (dma_buf_fd); - -/** -* dma_buf_get - returns the dma_buf structure related to an fd -* @fd: [in] fd associated with the dma_buf to be returned -* -* On success, returns the dma_buf structure associated with an fd; uses -* file's refcounting done by fget to increase refcount. returns ERR_PTR -* otherwise. -*/ -struct dma_buf *dma_buf_get (int fd) -{ -struct file *file; - - file =fget (fd); - -if (!file) -return ERR_PTR (-EBADF ); - -if (!is_dma_buf_file (file)) { -fput (file); -return ERR_PTR (-EINVAL ); - } - -return file->private_data; -} -EXPORT_SYMBOL_GPL (dma_buf_get); - -/** -* dma_buf_put - decreases refcount of the buffer -* @dmabuf: [in] buffer to reduce refcount of -* -* Uses file's refcounting done implicitly by fput() -*/ -void dma_buf_put (struct dma_buf *dmabuf) -{ -if (WARN_ON (!dmabuf || !dmabuf->file)) -return ; - -fput (dmabuf->file); -} -EXPORT_SYMBOL_GPL (dma_buf_put); - -/** -* dma_buf_attach - Add the device to dma_buf's attachments list; optionally, -* calls attach() of dma_buf_ops to allow device-specific attach functionality -* @dmabuf: [in] buffer to attach device to. -* @dev: [in] device to be attached. -* -* Returns struct dma_buf_attachment * for this attachment; returns ERR_PTR on -* error. -*/ -struct dma_buf_attachment *dma_buf_attach (struct dma_buf *dmabuf, -struct device *dev) -{ -struct dma_buf_attachment *attach; -int ret; - -if (WARN_ON (!dmabuf || !dev)) -return ERR_PTR (-EINVAL ); - - attach =kzalloc (sizeof (struct dma_buf_attachment ),GFP_KERNEL ); -if (attach ==NULL ) -return ERR_PTR (-ENOMEM ); - - attach->dev = dev; - attach->dmabuf = dmabuf; - -mutex_lock (&dmabuf->lock); - -if (dmabuf->ops->attach) { - ret = dmabuf->ops->attach (dmabuf, dev, attach); -if (ret) - goto err_attach; - } -list_add (&attach->node, &dmabuf->attachments); - -mutex_unlock (&dmabuf->lock); -return attach; - -err_attach: -kfree (attach); -mutex_unlock (&dmabuf->lock); -return ERR_PTR (ret); -} -EXPORT_SYMBOL_GPL (dma_buf_attach); - -/** -* dma_buf_detach - Remove the given attachment from dmabuf's attachments list; -* optionally calls detach() of dma_buf_ops for device-specific detach -* @dmabuf: [in] buffer to detach from. -* @attach: [in] attachment to be detached; is free'd after this call. -* -*/ -void dma_buf_detach (struct dma_buf *dmabuf,struct dma_buf_attachment *attach) -{ -if (WARN_ON (!dmabuf || !attach)) -return ; - -mutex_lock (&dmabuf->lock); -list_del (&attach->node); -if (dmabuf->ops->detach) - dmabuf->ops->detach (dmabuf, attach); - -mutex_unlock (&dmabuf->lock); -kfree (attach); -} -EXPORT_SYMBOL_GPL (dma_buf_detach); - -/** -* dma_buf_map_attachment - Returns the scatterlist table of the attachment; -* mapped into _device_ address space. Is a wrapper for map_dma_buf() of the -* dma_buf_ops. -* @attach: [in] attachment whose scatterlist is to be returned -* @direction: [in] direction of DMA transfer -* -* Returns sg_table containing the scatterlist to be returned; returns ERR_PTR -* on error. -*/ -struct sg_table *dma_buf_map_attachment (struct dma_buf_attachment *attach, -enum dma_data_direction direction) -{ -struct sg_table *sg_table =ERR_PTR (-EINVAL ); - -might_sleep (); - -if (WARN_ON (!attach || !attach->dmabuf)) -return ERR_PTR (-EINVAL ); - - sg_table = attach->dmabuf->ops->map_dma_buf (attach, direction); -if (!sg_table) - sg_table =ERR_PTR (-ENOMEM ); - -return sg_table; -} -EXPORT_SYMBOL_GPL (dma_buf_map_attachment); - -/** -* dma_buf_unmap_attachment - unmaps and decreases usecount of the buffer;might -* deallocate the scatterlist associated. Is a wrapper for unmap_dma_buf() of -* dma_buf_ops. -* @attach: [in] attachment to unmap buffer from -* @sg_table: [in] scatterlist info of the buffer to unmap -* @direction: [in] direction of DMA transfer -* -*/ -void dma_buf_unmap_attachment (struct dma_buf_attachment *attach, -struct sg_table *sg_table, -enum dma_data_direction direction) -{ -might_sleep (); - -if (WARN_ON (!attach || !attach->dmabuf || !sg_table)) -return ; - - attach->dmabuf->ops->unmap_dma_buf (attach, sg_table, - direction); -} -EXPORT_SYMBOL_GPL (dma_buf_unmap_attachment); - - -/** -* dma_buf_begin_cpu_access - Must be called before accessing a dma_buf from the -* cpu in the kernel context. Calls begin_cpu_access to allow exporter-specific -* preparations. Coherency is only guaranteed in the specified range for the -* specified access direction. -* @dmabuf: [in] buffer to prepare cpu access for. -* @start: [in] start of range for cpu access. -* @len: [in] length of range for cpu access. -* @direction: [in] length of range for cpu access. -* -* Can return negative error values, returns 0 on success. -*/ -int dma_buf_begin_cpu_access (struct dma_buf *dmabuf,size_t start,size_t len, -enum dma_data_direction direction) -{ -int ret =0 ; - -if (WARN_ON (!dmabuf)) -return -EINVAL ; - -if (dmabuf->ops->begin_cpu_access) - ret = dmabuf->ops->begin_cpu_access (dmabuf, start, len, direction); - -return ret; -} -EXPORT_SYMBOL_GPL (dma_buf_begin_cpu_access); - -/** -* dma_buf_end_cpu_access - Must be called after accessing a dma_buf from the -* cpu in the kernel context. Calls end_cpu_access to allow exporter-specific -* actions. Coherency is only guaranteed in the specified range for the -* specified access direction. -* @dmabuf: [in] buffer to complete cpu access for. -* @start: [in] start of range for cpu access. -* @len: [in] length of range for cpu access. -* @direction: [in] length of range for cpu access. -* -* This call must always succeed. -*/ -void dma_buf_end_cpu_access (struct dma_buf *dmabuf,size_t start,size_t len, -enum dma_data_direction direction) -{ -WARN_ON (!dmabuf); - -if (dmabuf->ops->end_cpu_access) - dmabuf->ops->end_cpu_access (dmabuf, start, len, direction); -} -EXPORT_SYMBOL_GPL (dma_buf_end_cpu_access); - -/** -* dma_buf_kmap_atomic - Map a page of the buffer object into kernel address -* space. The same restrictions as for kmap_atomic and friends apply. -* @dmabuf: [in] buffer to map page from. -* @page_num: [in] page in PAGE_SIZE units to map. -* -* This call must always succeed, any necessary preparations that might fail -* need to be done in begin_cpu_access. -*/ -void *dma_buf_kmap_atomic (struct dma_buf *dmabuf,unsigned long page_num) -{ -WARN_ON (!dmabuf); - -return dmabuf->ops->kmap_atomic (dmabuf, page_num); -} -EXPORT_SYMBOL_GPL (dma_buf_kmap_atomic); - -/** -* dma_buf_kunmap_atomic - Unmap a page obtained by dma_buf_kmap_atomic. -* @dmabuf: [in] buffer to unmap page from. -* @page_num: [in] page in PAGE_SIZE units to unmap. -* @vaddr: [in] kernel space pointer obtained from dma_buf_kmap_atomic. -* -* This call must always succeed. -*/ -void dma_buf_kunmap_atomic (struct dma_buf *dmabuf,unsigned long page_num, -void *vaddr) -{ -WARN_ON (!dmabuf); - -if (dmabuf->ops->kunmap_atomic) - dmabuf->ops->kunmap_atomic (dmabuf, page_num, vaddr); -} -EXPORT_SYMBOL_GPL (dma_buf_kunmap_atomic); - -/** -* dma_buf_kmap - Map a page of the buffer object into kernel address space. The -* same restrictions as for kmap and friends apply. -* @dmabuf: [in] buffer to map page from. -* @page_num: [in] page in PAGE_SIZE units to map. -* -* This call must always succeed, any necessary preparations that might fail -* need to be done in begin_cpu_access. -*/ -void *dma_buf_kmap (struct dma_buf *dmabuf,unsigned long page_num) -{ -WARN_ON (!dmabuf); - -return dmabuf->ops->kmap (dmabuf, page_num); -} -EXPORT_SYMBOL_GPL (dma_buf_kmap); - -/** -* dma_buf_kunmap - Unmap a page obtained by dma_buf_kmap. -* @dmabuf: [in] buffer to unmap page from. -* @page_num: [in] page in PAGE_SIZE units to unmap. -* @vaddr: [in] kernel space pointer obtained from dma_buf_kmap. -* -* This call must always succeed. -*/ -void dma_buf_kunmap (struct dma_buf *dmabuf,unsigned long page_num, -void *vaddr) -{ -WARN_ON (!dmabuf); - -if (dmabuf->ops->kunmap) - dmabuf->ops->kunmap (dmabuf, page_num, vaddr); -} -EXPORT_SYMBOL_GPL (dma_buf_kunmap); - - -/** -* dma_buf_mmap - Setup up a userspace mmap with the given vma -* @dmabuf: [in] buffer that should back the vma -* @vma: [in] vma for the mmap -* @pgoff: [in] offset in pages where this mmap should start within the -* dma-buf buffer. -* -* This function adjusts the passed in vma so that it points at the file of the -* dma_buf operation. It also adjusts the starting pgoff and does bounds -* checking on the size of the vma. Then it calls the exporters mmap function to -* set up the mapping. -* -* Can return negative error values, returns 0 on success. -*/ -int dma_buf_mmap (struct dma_buf *dmabuf,struct vm_area_struct *vma, -unsigned long pgoff) -{ -struct file *oldfile; -int ret; - -if (WARN_ON (!dmabuf || !vma)) -return -EINVAL ; - -/* check for offset overflow */ -if (pgoff + ((vma->vm_end - vma->vm_start) >>PAGE_SHIFT ) < pgoff) -return -EOVERFLOW ; - -/* check for overflowing the buffer's size */ -if (pgoff + ((vma->vm_end - vma->vm_start) >>PAGE_SHIFT ) > - dmabuf->size >>PAGE_SHIFT ) -return -EINVAL ; - -/* readjust the vma */ -get_file (dmabuf->file); - oldfile = vma->vm_file; - vma->vm_file = dmabuf->file; - vma->vm_pgoff = pgoff; - - ret = dmabuf->ops->mmap (dmabuf, vma); -if (ret) { -/* restore old parameters on failure */ - vma->vm_file = oldfile; -fput (dmabuf->file); - }else { -if (oldfile) -fput (oldfile); - } -return ret; - -} -EXPORT_SYMBOL_GPL (dma_buf_mmap); - -/** -* dma_buf_vmap - Create virtual mapping for the buffer object into kernel -* address space. Same restrictions as for vmap and friends apply. -* @dmabuf: [in] buffer to vmap -* -* This call may fail due to lack of virtual mapping address space. -* These calls are optional in drivers. The intended use for them -* is for mapping objects linear in kernel space for high use objects. -* Please attempt to use kmap/kunmap before thinking about these interfaces. -* -* Returns NULL on error. -*/ -void *dma_buf_vmap (struct dma_buf *dmabuf) -{ -void *ptr; - -if (WARN_ON (!dmabuf)) -return NULL ; - -if (!dmabuf->ops->vmap) -return NULL ; - -mutex_lock (&dmabuf->lock); -if (dmabuf->vmapping_counter) { - dmabuf->vmapping_counter++; -BUG_ON (!dmabuf->vmap_ptr); - ptr = dmabuf->vmap_ptr; - goto out_unlock; - } - -BUG_ON (dmabuf->vmap_ptr); - - ptr = dmabuf->ops->vmap (dmabuf); -if (WARN_ON_ONCE (IS_ERR (ptr))) - ptr =NULL ; -if (!ptr) - goto out_unlock; - - dmabuf->vmap_ptr = ptr; - dmabuf->vmapping_counter =1 ; - -out_unlock: -mutex_unlock (&dmabuf->lock); -return ptr; -} -EXPORT_SYMBOL_GPL (dma_buf_vmap); - -/** -* dma_buf_vunmap - Unmap a vmap obtained by dma_buf_vmap. -* @dmabuf: [in] buffer to vunmap -* @vaddr: [in] vmap to vunmap -*/ -void dma_buf_vunmap (struct dma_buf *dmabuf,void *vaddr) -{ -if (WARN_ON (!dmabuf)) -return ; - -BUG_ON (!dmabuf->vmap_ptr); -BUG_ON (dmabuf->vmapping_counter ==0 ); -BUG_ON (dmabuf->vmap_ptr != vaddr); - -mutex_lock (&dmabuf->lock); -if (--dmabuf->vmapping_counter ==0 ) { -if (dmabuf->ops->vunmap) - dmabuf->ops->vunmap (dmabuf, vaddr); - dmabuf->vmap_ptr =NULL ; - } -mutex_unlock (&dmabuf->lock); -} -EXPORT_SYMBOL_GPL (dma_buf_vunmap); - -#ifdef CONFIG_DEBUG_FS -static int dma_buf_describe (struct seq_file *s) -{ -int ret; -struct dma_buf *buf_obj; -struct dma_buf_attachment *attach_obj; -int count =0 , attach_count; -size_t size =0 ; - - ret =mutex_lock_interruptible (&db_list.lock); - -if (ret) -return ret; - -seq_puts (s,"\nDma-buf Objects:\n" ); -seq_puts (s,"size\tflags\tmode\tcount\texp_name\n" ); - -list_for_each_entry (buf_obj, &db_list.head, list_node) { - ret =mutex_lock_interruptible (&buf_obj->lock); - -if (ret) { -seq_puts (s, -"\tERROR locking buffer object: skipping\n" ); -continue ; - } - -seq_printf (s,"%08zu\t%08x\t%08x\t%08ld\t%s\n" , - buf_obj->size, - buf_obj->file->f_flags, buf_obj->file->f_mode, - (long )(buf_obj->file->f_count.counter), - buf_obj->exp_name); - -seq_puts (s,"\tAttached Devices:\n" ); - attach_count =0 ; - -list_for_each_entry (attach_obj, &buf_obj->attachments, node) { -seq_puts (s,"\t" ); - -seq_printf (s,"%s\n" ,dev_name (attach_obj->dev)); - attach_count++; - } - -seq_printf (s,"Total %d devices attached\n\n" , - attach_count); - - count++; - size += buf_obj->size; -mutex_unlock (&buf_obj->lock); - } - -seq_printf (s,"\nTotal %d objects, %zu bytes\n" , count, size); - -mutex_unlock (&db_list.lock); -return 0 ; -} - -static int dma_buf_show (struct seq_file *s,void *unused) -{ -void (*func)(struct seq_file *) = s->private; -func (s); -return 0 ; -} - -static int dma_buf_debug_open (struct inode *inode,struct file *file) -{ -return single_open (file, dma_buf_show, inode->i_private); -} - -static const struct file_operations dma_buf_debug_fops = { - .open = dma_buf_debug_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static struct dentry *dma_buf_debugfs_dir; - -static int dma_buf_init_debugfs (void ) -{ -int err =0 ; - dma_buf_debugfs_dir =debugfs_create_dir ("dma_buf" ,NULL ); -if (IS_ERR (dma_buf_debugfs_dir)) { - err =PTR_ERR (dma_buf_debugfs_dir); - dma_buf_debugfs_dir =NULL ; -return err; - } - - err =dma_buf_debugfs_create_file ("bufinfo" , dma_buf_describe); - -if (err) -pr_debug ("dma_buf: debugfs: failed to create node bufinfo\n" ); - -return err; -} - -static void dma_buf_uninit_debugfs (void ) -{ -if (dma_buf_debugfs_dir) -debugfs_remove_recursive (dma_buf_debugfs_dir); -} - -int dma_buf_debugfs_create_file (const char *name, -int (*write)(struct seq_file *)) -{ -struct dentry *d; - - d =debugfs_create_file (name,S_IRUGO , dma_buf_debugfs_dir, - write, &dma_buf_debug_fops); - -return PTR_ERR_OR_ZERO (d); -} -#else -static inline int dma_buf_init_debugfs (void ) -{ -return 0 ; -} -static inline void dma_buf_uninit_debugfs (void ) -{ -} -#endif - -static int __init dma_buf_init (void ) -{ -mutex_init (&db_list.lock); -INIT_LIST_HEAD (&db_list.head); -dma_buf_init_debugfs (); -return 0 ; -} -subsys_initcall (dma_buf_init); - -static void __exit dma_buf_deinit(void) -{ -dma_buf_uninit_debugfs (); -} -__exitcall (dma_buf_deinit);drivers/base/reservation.c deleted +0
-39@@ -1,39 +0,0 @@ -/* -* Copyright (C) 2012-2013 Canonical Ltd -* -* Based on bo.c which bears the following copyright notice, -* but is dual licensed: -* -* Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA -* All Rights Reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining a -* copy of this software and associated documentation files (the -* "Software"), to deal in the Software without restriction, including -* without limitation the rights to use, copy, modify, merge, publish, -* distribute, sub license, and/or sell copies of the Software, and to -* permit persons to whom the Software is furnished to do so, subject to -* the following conditions: -* -* The above copyright notice and this permission notice (including the -* next paragraph) shall be included in all copies or substantial portions -* of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, -* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -* USE OR OTHER DEALINGS IN THE SOFTWARE. -* -**************************************************************************/ -/* -* Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com> -*/ - -#include <linux/reservation.h> -#include <linux/export.h> - -DEFINE_WW_CLASS (reservation_ww_class); -EXPORT_SYMBOL (reservation_ww_class);drivers/dma-buf/Makefile new file +1
-0@@ -0,0 +1 @@ +obj-y := dma-buf.o reservation.odrivers/dma-buf/dma-buf.c new file +743
-0@@ -0,0 +1,743 @@ +/* +* Framework for buffer objects that can be shared across devices/subsystems. +* +* Copyright(C) 2011 Linaro Limited. All rights reserved. +* Author: Sumit Semwal <[email protected]> +* +* Many thanks to linaro-mm-sig list, and specially +* Arnd Bergmann <[email protected]>, Rob Clark <[email protected]> and +* Daniel Vetter <[email protected]> for their support in creation and +* refining of this idea. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published by +* the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <linux/fs.h> +#include <linux/slab.h> +#include <linux/dma-buf.h> +#include <linux/anon_inodes.h> +#include <linux/export.h> +#include <linux/debugfs.h> +#include <linux/seq_file.h> + +static inline int is_dma_buf_file (struct file *); + +struct dma_buf_list { +struct list_head head; +struct mutex lock; +}; + +static struct dma_buf_list db_list; + +static int dma_buf_release (struct inode *inode,struct file *file) +{ +struct dma_buf *dmabuf; + +if (!is_dma_buf_file (file)) +return -EINVAL ; + + dmabuf = file->private_data; + +BUG_ON (dmabuf->vmapping_counter); + + dmabuf->ops->release (dmabuf); + +mutex_lock (&db_list.lock); +list_del (&dmabuf->list_node); +mutex_unlock (&db_list.lock); + +kfree (dmabuf); +return 0 ; +} + +static int dma_buf_mmap_internal (struct file *file,struct vm_area_struct *vma) +{ +struct dma_buf *dmabuf; + +if (!is_dma_buf_file (file)) +return -EINVAL ; + + dmabuf = file->private_data; + +/* check for overflowing the buffer's size */ +if (vma->vm_pgoff + ((vma->vm_end - vma->vm_start) >>PAGE_SHIFT ) > + dmabuf->size >>PAGE_SHIFT ) +return -EINVAL ; + +return dmabuf->ops->mmap (dmabuf, vma); +} + +static loff_t dma_buf_llseek (struct file *file,loff_t offset,int whence) +{ +struct dma_buf *dmabuf; +loff_t base; + +if (!is_dma_buf_file (file)) +return -EBADF ; + + dmabuf = file->private_data; + +/* only support discovering the end of the buffer, +but also allow SEEK_SET to maintain the idiomatic +SEEK_END(0), SEEK_CUR(0) pattern */ +if (whence ==SEEK_END ) + base = dmabuf->size; +else if (whence ==SEEK_SET ) + base =0 ; +else +return -EINVAL ; + +if (offset !=0 ) +return -EINVAL ; + +return base + offset; +} + +static const struct file_operations dma_buf_fops = { + .release = dma_buf_release, + .mmap = dma_buf_mmap_internal, + .llseek = dma_buf_llseek, +}; + +/* +* is_dma_buf_file - Check if struct file* is associated with dma_buf +*/ +static inline int is_dma_buf_file (struct file *file) +{ +return file->f_op == &dma_buf_fops; +} + +/** +* dma_buf_export_named - Creates a new dma_buf, and associates an anon file +* with this buffer, so it can be exported. +* Also connect the allocator specific data and ops to the buffer. +* Additionally, provide a name string for exporter; useful in debugging. +* +* @priv: [in] Attach private data of allocator to this buffer +* @ops: [in] Attach allocator-defined dma buf ops to the new buffer. +* @size: [in] Size of the buffer +* @flags: [in] mode flags for the file. +* @exp_name: [in] name of the exporting module - useful for debugging. +* +* Returns, on success, a newly created dma_buf object, which wraps the +* supplied private data and operations for dma_buf_ops. On either missing +* ops, or error in allocating struct dma_buf, will return negative error. +* +*/ +struct dma_buf *dma_buf_export_named (void *priv,const struct dma_buf_ops *ops, +size_t size,int flags,const char *exp_name) +{ +struct dma_buf *dmabuf; +struct file *file; + +if (WARN_ON (!priv || !ops + || !ops->map_dma_buf + || !ops->unmap_dma_buf + || !ops->release + || !ops->kmap_atomic + || !ops->kmap + || !ops->mmap)) { +return ERR_PTR (-EINVAL ); + } + + dmabuf =kzalloc (sizeof (struct dma_buf ),GFP_KERNEL ); +if (dmabuf ==NULL ) +return ERR_PTR (-ENOMEM ); + + dmabuf->priv = priv; + dmabuf->ops = ops; + dmabuf->size = size; + dmabuf->exp_name = exp_name; + + file =anon_inode_getfile ("dmabuf" , &dma_buf_fops, dmabuf, flags); +if (IS_ERR (file)) { +kfree (dmabuf); +return ERR_CAST (file); + } + + file->f_mode |=FMODE_LSEEK ; + dmabuf->file = file; + +mutex_init (&dmabuf->lock); +INIT_LIST_HEAD (&dmabuf->attachments); + +mutex_lock (&db_list.lock); +list_add (&dmabuf->list_node, &db_list.head); +mutex_unlock (&db_list.lock); + +return dmabuf; +} +EXPORT_SYMBOL_GPL (dma_buf_export_named); + + +/** +* dma_buf_fd - returns a file descriptor for the given dma_buf +* @dmabuf: [in] pointer to dma_buf for which fd is required. +* @flags: [in] flags to give to fd +* +* On success, returns an associated 'fd'. Else, returns error. +*/ +int dma_buf_fd (struct dma_buf *dmabuf,int flags) +{ +int fd; + +if (!dmabuf || !dmabuf->file) +return -EINVAL ; + + fd =get_unused_fd_flags (flags); +if (fd <0 ) +return fd; + +fd_install (fd, dmabuf->file); + +return fd; +} +EXPORT_SYMBOL_GPL (dma_buf_fd); + +/** +* dma_buf_get - returns the dma_buf structure related to an fd +* @fd: [in] fd associated with the dma_buf to be returned +* +* On success, returns the dma_buf structure associated with an fd; uses +* file's refcounting done by fget to increase refcount. returns ERR_PTR +* otherwise. +*/ +struct dma_buf *dma_buf_get (int fd) +{ +struct file *file; + + file =fget (fd); + +if (!file) +return ERR_PTR (-EBADF ); + +if (!is_dma_buf_file (file)) { +fput (file); +return ERR_PTR (-EINVAL ); + } + +return file->private_data; +} +EXPORT_SYMBOL_GPL (dma_buf_get); + +/** +* dma_buf_put - decreases refcount of the buffer +* @dmabuf: [in] buffer to reduce refcount of +* +* Uses file's refcounting done implicitly by fput() +*/ +void dma_buf_put (struct dma_buf *dmabuf) +{ +if (WARN_ON (!dmabuf || !dmabuf->file)) +return ; + +fput (dmabuf->file); +} +EXPORT_SYMBOL_GPL (dma_buf_put); + +/** +* dma_buf_attach - Add the device to dma_buf's attachments list; optionally, +* calls attach() of dma_buf_ops to allow device-specific attach functionality +* @dmabuf: [in] buffer to attach device to. +* @dev: [in] device to be attached. +* +* Returns struct dma_buf_attachment * for this attachment; returns ERR_PTR on +* error. +*/ +struct dma_buf_attachment *dma_buf_attach (struct dma_buf *dmabuf, +struct device *dev) +{ +struct dma_buf_attachment *attach; +int ret; + +if (WARN_ON (!dmabuf || !dev)) +return ERR_PTR (-EINVAL ); + + attach =kzalloc (sizeof (struct dma_buf_attachment ),GFP_KERNEL ); +if (attach ==NULL ) +return ERR_PTR (-ENOMEM ); + + attach->dev = dev; + attach->dmabuf = dmabuf; + +mutex_lock (&dmabuf->lock); + +if (dmabuf->ops->attach) { + ret = dmabuf->ops->attach (dmabuf, dev, attach); +if (ret) + goto err_attach; + } +list_add (&attach->node, &dmabuf->attachments); + +mutex_unlock (&dmabuf->lock); +return attach; + +err_attach: +kfree (attach); +mutex_unlock (&dmabuf->lock); +return ERR_PTR (ret); +} +EXPORT_SYMBOL_GPL (dma_buf_attach); + +/** +* dma_buf_detach - Remove the given attachment from dmabuf's attachments list; +* optionally calls detach() of dma_buf_ops for device-specific detach +* @dmabuf: [in] buffer to detach from. +* @attach: [in] attachment to be detached; is free'd after this call. +* +*/ +void dma_buf_detach (struct dma_buf *dmabuf,struct dma_buf_attachment *attach) +{ +if (WARN_ON (!dmabuf || !attach)) +return ; + +mutex_lock (&dmabuf->lock); +list_del (&attach->node); +if (dmabuf->ops->detach) + dmabuf->ops->detach (dmabuf, attach); + +mutex_unlock (&dmabuf->lock); +kfree (attach); +} +EXPORT_SYMBOL_GPL (dma_buf_detach); + +/** +* dma_buf_map_attachment - Returns the scatterlist table of the attachment; +* mapped into _device_ address space. Is a wrapper for map_dma_buf() of the +* dma_buf_ops. +* @attach: [in] attachment whose scatterlist is to be returned +* @direction: [in] direction of DMA transfer +* +* Returns sg_table containing the scatterlist to be returned; returns ERR_PTR +* on error. +*/ +struct sg_table *dma_buf_map_attachment (struct dma_buf_attachment *attach, +enum dma_data_direction direction) +{ +struct sg_table *sg_table =ERR_PTR (-EINVAL ); + +might_sleep (); + +if (WARN_ON (!attach || !attach->dmabuf)) +return ERR_PTR (-EINVAL ); + + sg_table = attach->dmabuf->ops->map_dma_buf (attach, direction); +if (!sg_table) + sg_table =ERR_PTR (-ENOMEM ); + +return sg_table; +} +EXPORT_SYMBOL_GPL (dma_buf_map_attachment); + +/** +* dma_buf_unmap_attachment - unmaps and decreases usecount of the buffer;might +* deallocate the scatterlist associated. Is a wrapper for unmap_dma_buf() of +* dma_buf_ops. +* @attach: [in] attachment to unmap buffer from +* @sg_table: [in] scatterlist info of the buffer to unmap +* @direction: [in] direction of DMA transfer +* +*/ +void dma_buf_unmap_attachment (struct dma_buf_attachment *attach, +struct sg_table *sg_table, +enum dma_data_direction direction) +{ +might_sleep (); + +if (WARN_ON (!attach || !attach->dmabuf || !sg_table)) +return ; + + attach->dmabuf->ops->unmap_dma_buf (attach, sg_table, + direction); +} +EXPORT_SYMBOL_GPL (dma_buf_unmap_attachment); + + +/** +* dma_buf_begin_cpu_access - Must be called before accessing a dma_buf from the +* cpu in the kernel context. Calls begin_cpu_access to allow exporter-specific +* preparations. Coherency is only guaranteed in the specified range for the +* specified access direction. +* @dmabuf: [in] buffer to prepare cpu access for. +* @start: [in] start of range for cpu access. +* @len: [in] length of range for cpu access. +* @direction: [in] length of range for cpu access. +* +* Can return negative error values, returns 0 on success. +*/ +int dma_buf_begin_cpu_access (struct dma_buf *dmabuf,size_t start,size_t len, +enum dma_data_direction direction) +{ +int ret =0 ; + +if (WARN_ON (!dmabuf)) +return -EINVAL ; + +if (dmabuf->ops->begin_cpu_access) + ret = dmabuf->ops->begin_cpu_access (dmabuf, start, len, direction); + +return ret; +} +EXPORT_SYMBOL_GPL (dma_buf_begin_cpu_access); + +/** +* dma_buf_end_cpu_access - Must be called after accessing a dma_buf from the +* cpu in the kernel context. Calls end_cpu_access to allow exporter-specific +* actions. Coherency is only guaranteed in the specified range for the +* specified access direction. +* @dmabuf: [in] buffer to complete cpu access for. +* @start: [in] start of range for cpu access. +* @len: [in] length of range for cpu access. +* @direction: [in] length of range for cpu access. +* +* This call must always succeed. +*/ +void dma_buf_end_cpu_access (struct dma_buf *dmabuf,size_t start,size_t len, +enum dma_data_direction direction) +{ +WARN_ON (!dmabuf); + +if (dmabuf->ops->end_cpu_access) + dmabuf->ops->end_cpu_access (dmabuf, start, len, direction); +} +EXPORT_SYMBOL_GPL (dma_buf_end_cpu_access); + +/** +* dma_buf_kmap_atomic - Map a page of the buffer object into kernel address +* space. The same restrictions as for kmap_atomic and friends apply. +* @dmabuf: [in] buffer to map page from. +* @page_num: [in] page in PAGE_SIZE units to map. +* +* This call must always succeed, any necessary preparations that might fail +* need to be done in begin_cpu_access. +*/ +void *dma_buf_kmap_atomic (struct dma_buf *dmabuf,unsigned long page_num) +{ +WARN_ON (!dmabuf); + +return dmabuf->ops->kmap_atomic (dmabuf, page_num); +} +EXPORT_SYMBOL_GPL (dma_buf_kmap_atomic); + +/** +* dma_buf_kunmap_atomic - Unmap a page obtained by dma_buf_kmap_atomic. +* @dmabuf: [in] buffer to unmap page from. +* @page_num: [in] page in PAGE_SIZE units to unmap. +* @vaddr: [in] kernel space pointer obtained from dma_buf_kmap_atomic. +* +* This call must always succeed. +*/ +void dma_buf_kunmap_atomic (struct dma_buf *dmabuf,unsigned long page_num, +void *vaddr) +{ +WARN_ON (!dmabuf); + +if (dmabuf->ops->kunmap_atomic) + dmabuf->ops->kunmap_atomic (dmabuf, page_num, vaddr); +} +EXPORT_SYMBOL_GPL (dma_buf_kunmap_atomic); + +/** +* dma_buf_kmap - Map a page of the buffer object into kernel address space. The +* same restrictions as for kmap and friends apply. +* @dmabuf: [in] buffer to map page from. +* @page_num: [in] page in PAGE_SIZE units to map. +* +* This call must always succeed, any necessary preparations that might fail +* need to be done in begin_cpu_access. +*/ +void *dma_buf_kmap (struct dma_buf *dmabuf,unsigned long page_num) +{ +WARN_ON (!dmabuf); + +return dmabuf->ops->kmap (dmabuf, page_num); +} +EXPORT_SYMBOL_GPL (dma_buf_kmap); + +/** +* dma_buf_kunmap - Unmap a page obtained by dma_buf_kmap. +* @dmabuf: [in] buffer to unmap page from. +* @page_num: [in] page in PAGE_SIZE units to unmap. +* @vaddr: [in] kernel space pointer obtained from dma_buf_kmap. +* +* This call must always succeed. +*/ +void dma_buf_kunmap (struct dma_buf *dmabuf,unsigned long page_num, +void *vaddr) +{ +WARN_ON (!dmabuf); + +if (dmabuf->ops->kunmap) + dmabuf->ops->kunmap (dmabuf, page_num, vaddr); +} +EXPORT_SYMBOL_GPL (dma_buf_kunmap); + + +/** +* dma_buf_mmap - Setup up a userspace mmap with the given vma +* @dmabuf: [in] buffer that should back the vma +* @vma: [in] vma for the mmap +* @pgoff: [in] offset in pages where this mmap should start within the +* dma-buf buffer. +* +* This function adjusts the passed in vma so that it points at the file of the +* dma_buf operation. It also adjusts the starting pgoff and does bounds +* checking on the size of the vma. Then it calls the exporters mmap function to +* set up the mapping. +* +* Can return negative error values, returns 0 on success. +*/ +int dma_buf_mmap (struct dma_buf *dmabuf,struct vm_area_struct *vma, +unsigned long pgoff) +{ +struct file *oldfile; +int ret; + +if (WARN_ON (!dmabuf || !vma)) +return -EINVAL ; + +/* check for offset overflow */ +if (pgoff + ((vma->vm_end - vma->vm_start) >>PAGE_SHIFT ) < pgoff) +return -EOVERFLOW ; + +/* check for overflowing the buffer's size */ +if (pgoff + ((vma->vm_end - vma->vm_start) >>PAGE_SHIFT ) > + dmabuf->size >>PAGE_SHIFT ) +return -EINVAL ; + +/* readjust the vma */ +get_file (dmabuf->file); + oldfile = vma->vm_file; + vma->vm_file = dmabuf->file; + vma->vm_pgoff = pgoff; + + ret = dmabuf->ops->mmap (dmabuf, vma); +if (ret) { +/* restore old parameters on failure */ + vma->vm_file = oldfile; +fput (dmabuf->file); + }else { +if (oldfile) +fput (oldfile); + } +return ret; + +} +EXPORT_SYMBOL_GPL (dma_buf_mmap); + +/** +* dma_buf_vmap - Create virtual mapping for the buffer object into kernel +* address space. Same restrictions as for vmap and friends apply. +* @dmabuf: [in] buffer to vmap +* +* This call may fail due to lack of virtual mapping address space. +* These calls are optional in drivers. The intended use for them +* is for mapping objects linear in kernel space for high use objects. +* Please attempt to use kmap/kunmap before thinking about these interfaces. +* +* Returns NULL on error. +*/ +void *dma_buf_vmap (struct dma_buf *dmabuf) +{ +void *ptr; + +if (WARN_ON (!dmabuf)) +return NULL ; + +if (!dmabuf->ops->vmap) +return NULL ; + +mutex_lock (&dmabuf->lock); +if (dmabuf->vmapping_counter) { + dmabuf->vmapping_counter++; +BUG_ON (!dmabuf->vmap_ptr); + ptr = dmabuf->vmap_ptr; + goto out_unlock; + } + +BUG_ON (dmabuf->vmap_ptr); + + ptr = dmabuf->ops->vmap (dmabuf); +if (WARN_ON_ONCE (IS_ERR (ptr))) + ptr =NULL ; +if (!ptr) + goto out_unlock; + + dmabuf->vmap_ptr = ptr; + dmabuf->vmapping_counter =1 ; + +out_unlock: +mutex_unlock (&dmabuf->lock); +return ptr; +} +EXPORT_SYMBOL_GPL (dma_buf_vmap); + +/** +* dma_buf_vunmap - Unmap a vmap obtained by dma_buf_vmap. +* @dmabuf: [in] buffer to vunmap +* @vaddr: [in] vmap to vunmap +*/ +void dma_buf_vunmap (struct dma_buf *dmabuf,void *vaddr) +{ +if (WARN_ON (!dmabuf)) +return ; + +BUG_ON (!dmabuf->vmap_ptr); +BUG_ON (dmabuf->vmapping_counter ==0 ); +BUG_ON (dmabuf->vmap_ptr != vaddr); + +mutex_lock (&dmabuf->lock); +if (--dmabuf->vmapping_counter ==0 ) { +if (dmabuf->ops->vunmap) + dmabuf->ops->vunmap (dmabuf, vaddr); + dmabuf->vmap_ptr =NULL ; + } +mutex_unlock (&dmabuf->lock); +} +EXPORT_SYMBOL_GPL (dma_buf_vunmap); + +#ifdef CONFIG_DEBUG_FS +static int dma_buf_describe (struct seq_file *s) +{ +int ret; +struct dma_buf *buf_obj; +struct dma_buf_attachment *attach_obj; +int count =0 , attach_count; +size_t size =0 ; + + ret =mutex_lock_interruptible (&db_list.lock); + +if (ret) +return ret; + +seq_puts (s,"\nDma-buf Objects:\n" ); +seq_puts (s,"size\tflags\tmode\tcount\texp_name\n" ); + +list_for_each_entry (buf_obj, &db_list.head, list_node) { + ret =mutex_lock_interruptible (&buf_obj->lock); + +if (ret) { +seq_puts (s, +"\tERROR locking buffer object: skipping\n" ); +continue ; + } + +seq_printf (s,"%08zu\t%08x\t%08x\t%08ld\t%s\n" , + buf_obj->size, + buf_obj->file->f_flags, buf_obj->file->f_mode, + (long )(buf_obj->file->f_count.counter), + buf_obj->exp_name); + +seq_puts (s,"\tAttached Devices:\n" ); + attach_count =0 ; + +list_for_each_entry (attach_obj, &buf_obj->attachments, node) { +seq_puts (s,"\t" ); + +seq_printf (s,"%s\n" ,dev_name (attach_obj->dev)); + attach_count++; + } + +seq_printf (s,"Total %d devices attached\n\n" , + attach_count); + + count++; + size += buf_obj->size; +mutex_unlock (&buf_obj->lock); + } + +seq_printf (s,"\nTotal %d objects, %zu bytes\n" , count, size); + +mutex_unlock (&db_list.lock); +return 0 ; +} + +static int dma_buf_show (struct seq_file *s,void *unused) +{ +void (*func)(struct seq_file *) = s->private; +func (s); +return 0 ; +} + +static int dma_buf_debug_open (struct inode *inode,struct file *file) +{ +return single_open (file, dma_buf_show, inode->i_private); +} + +static const struct file_operations dma_buf_debug_fops = { + .open = dma_buf_debug_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static struct dentry *dma_buf_debugfs_dir; + +static int dma_buf_init_debugfs (void ) +{ +int err =0 ; + dma_buf_debugfs_dir =debugfs_create_dir ("dma_buf" ,NULL ); +if (IS_ERR (dma_buf_debugfs_dir)) { + err =PTR_ERR (dma_buf_debugfs_dir); + dma_buf_debugfs_dir =NULL ; +return err; + } + + err =dma_buf_debugfs_create_file ("bufinfo" , dma_buf_describe); + +if (err) +pr_debug ("dma_buf: debugfs: failed to create node bufinfo\n" ); + +return err; +} + +static void dma_buf_uninit_debugfs (void ) +{ +if (dma_buf_debugfs_dir) +debugfs_remove_recursive (dma_buf_debugfs_dir); +} + +int dma_buf_debugfs_create_file (const char *name, +int (*write)(struct seq_file *)) +{ +struct dentry *d; + + d =debugfs_create_file (name,S_IRUGO , dma_buf_debugfs_dir, + write, &dma_buf_debug_fops); + +return PTR_ERR_OR_ZERO (d); +} +#else +static inline int dma_buf_init_debugfs (void ) +{ +return 0 ; +} +static inline void dma_buf_uninit_debugfs (void ) +{ +} +#endif + +static int __init dma_buf_init (void ) +{ +mutex_init (&db_list.lock); +INIT_LIST_HEAD (&db_list.head); +dma_buf_init_debugfs (); +return 0 ; +} +subsys_initcall (dma_buf_init); + +static void __exit dma_buf_deinit(void) +{ +dma_buf_uninit_debugfs (); +} +__exitcall (dma_buf_deinit);drivers/dma-buf/reservation.c new file +39
-1@@ -0,0 +1,39 @@ +/* +* Copyright (C) 2012-2013 Canonical Ltd +* +* Based on bo.c which bears the following copyright notice, +* but is dual licensed: +* +* Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA +* All Rights Reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sub license, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice (including the +* next paragraph) shall be included in all copies or substantial portions +* of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, +* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +* USE OR OTHER DEALINGS IN THE SOFTWARE. +* +**************************************************************************/ +/* +* Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com> +*/ + +#include <linux/reservation.h> +#include <linux/export.h> + +DEFINE_WW_CLASS (reservation_ww_class); +EXPORT_SYMBOL (reservation_ww_class); --To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 1/9] dma-buf: move to drivers/dma-buf
op 01-07-14 13:06, Arend van Spriel schreef:
Quoted 7 lines · Maarten Lankhorst
Quoted 1 line
Signed-off-by Maarten Lankhorst <[email protected]>It would help to use '-M' option with format-patch for this kind of rework.
Regards,
Arend
Thanks, was looking for some option but didn't find it.
Have a rediff below. :-)
8< --------
---
Documentation/DocBook/device-drivers.tmpl | 3 +--
MAINTAINERS | 4 ++--
drivers/Makefile | 1 +
drivers/base/Makefile | 1 -
drivers/dma-buf/Makefile | 1 +
drivers/{base => dma-buf}/dma-buf.c | 0
drivers/{base => dma-buf}/reservation.c | 0
7 files changed, 5 insertions(+), 5 deletions(-)
create mode 100644 drivers/dma-buf/Makefile
rename drivers/{base => dma-buf}/dma-buf.c (100%)
rename drivers/{base => dma-buf}/reservation.c (100%)Documentation/DocBook/device-drivers.tmpl +1 -2
@@ -128,8 +128,7 @@ X!Edrivers/base/interface.c !Edrivers/base/bus.c </sect1> <sect1><title>Device Drivers DMA Management</title> -!Edrivers/base/dma-buf.c -!Edrivers/base/reservation.c +!Edrivers/dma-buf/dma-buf.c !Iinclude/linux/reservation.h !Edrivers/base/dma-coherent.c !Edrivers/base/dma-mapping.c
MAINTAINERS +2 -2
@@ -2882,8 +2882,8 @@ S: Maintained L: [email protected] L: [email protected] L: [email protected] -F: drivers/base/dma-buf* -F: include/linux/dma-buf* +F: drivers/dma-buf/ +F: include/linux/dma-buf* include/linux/reservation.h F: Documentation/dma-buf-sharing.txt T: git git://git.linaro.org/people/sumitsemwal/linux-dma-buf.git
drivers/Makefile +1 -0
@@ -61,6 +61,7 @@ obj-$(CONFIG_FB_INTEL) += video/fbdev/intelfb/ obj-$(CONFIG_PARPORT) += parport/ obj-y += base/ block/ misc/ mfd/ nfc/ +obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf/ obj-$(CONFIG_NUBUS) += nubus/ obj-y += macintosh/ obj-$(CONFIG_IDE) += ide/
drivers/base/Makefile +0 -1
@@ -10,7 +10,6 @@ obj-$(CONFIG_DMA_CMA) += dma-contiguous.o obj-y += power/ obj-$(CONFIG_HAS_DMA) += dma-mapping.o obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o -obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf.o reservation.o obj-$(CONFIG_ISA) += isa.o obj-$(CONFIG_FW_LOADER) += firmware_class.o obj-$(CONFIG_NUMA) += node.o
drivers/dma-buf/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-y := dma-buf.o reservation.o
drivers/dma-buf/dma-buf.c renamed from drivers/base/dma-buf.c +0 -0
drivers/dma-buf/reservation.c renamed from drivers/base/reservation.c +0 -0
Signature · 1 line
2.0.0
Greg KH
maintainerQuoted 12 lines · Maarten Lankhorst
So after some more hacking I've moved dma-buf to its own subdirectory,
drivers/dma-bufand applied the fence patches to its new place. I believe that the first patch should be applied regardless, and the rest should be ready now. :-)Changes to the fence api:
-release_fence->fence_releaseetc.
-__fence_init->fence_init
-__fence_signal->fence_signal_locked
-__fence_is_signaled->fence_is_signaled_locked
- ChangingBUG_ONtoWARN_ONinfence_later, and return NULL if it triggers.
Quoted 6 lines
Android can expose fences to userspace. It's possible to make the new fence mechanism expose the same fences to userspace by changing
sync_fence_createto take a struct fence instead of a structsync_pt. No other change is needed, because only the fence parts of structsync_ptare used. But because the userspace fences are a separate problem and I haven't really looked at it yet I feel it should stay in staging, for now.
Ok, that's reasonable.
At first glance, this all looks "sane" to me, any objection from anyone if I merge this through my driver-core tree for 3.17?
thanks,
greg k-h
op 02-07-14 07:37, Greg KH schreef:
Quoted 19 lines · Maarten Lankhorst
Quoted 12 lines
So after some more hacking I've moved dma-buf to its own subdirectory,
drivers/dma-bufand applied the fence patches to its new place. I believe that the first patch should be applied regardless, and the rest should be ready now. :-)Changes to the fence api:
-release_fence->fence_releaseetc.
-__fence_init->fence_init
-__fence_signal->fence_signal_locked
-__fence_is_signaled->fence_is_signaled_locked
- ChangingBUG_ONtoWARN_ONinfence_later, and return NULL if it triggers.Quoted 6 lines
Android can expose fences to userspace. It's possible to make the new fence mechanism expose the same fences to userspace by changing
sync_fence_createto take a struct fence instead of a structsync_pt. No other change is needed, because only the fence parts of structsync_ptare used. But because the userspace fences are a separate problem and I haven't really looked at it yet I feel it should stay in staging, for now.
Quoted 5 lines
Ok, that's reasonable.
At first glance, this all looks "sane" to me, any objection from anyone if I merge this through my driver-core tree for 3.17?
Sounds good to me, let me know when you pull it in, so I can rebase my drm conversion on top of it. :-)
~Maarten
Quoted 11 lines · Greg KH
Quoted 6 lines
Android can expose fences to userspace. It's possible to make the new fence mechanism expose the same fences to userspace by changing
sync_fence_createto take a struct fence instead of a structsync_pt. No other change is needed, because only the fence parts of structsync_ptare used. But because the userspace fences are a separate problem and I haven't really looked at it yet I feel it should stay in staging, for now.Ok, that's reasonable.
At first glance, this all looks "sane" to me, any objection from anyone if I merge this through my driver-core tree for 3.17?
Ack from my side fwiw.
Just for the record (again) about android syncpts. I think using android syncpts stuff as the official userspace interfaces for fences for userspace that wants to do explicit syncing is the sane approach - after all the (only) big platform using explicit fencing is Android since opencl is kinda not yet there really on linux (which would be the other guy really interested in explicit fencing).
But before we de-stage android syncpts (and so bake in the userspace abi forever) I really want to see a full upstream gpu driver implementation using fences and running on both X+DRI userspace (implicit syncing) and android (expclicit syncing), including good test coverage for corner-cases to make sure we've addressed all warts and hidden dragons. i915 looks like the most likely candidate to get there first (we have the code for both use-cases out-of-tree after all) so I'll keep on pestering people. No promises though ;-)
Cheers, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Greg KH
maintainerQuoted 8 lines · Daniel Vetter
Quoted 7 lines · Greg KH
Quoted 6 lines
Android can expose fences to userspace. It's possible to make the new fence mechanism expose the same fences to userspace by changing
sync_fence_createto take a struct fence instead of a structsync_pt. No other change is needed, because only the fence parts of structsync_ptare used. But because the userspace fences are a separate problem and I haven't really looked at it yet I feel it should stay in staging, for now.
Quoted 6 lines
Quoted 4 lines
Ok, that's reasonable.
At first glance, this all looks "sane" to me, any objection from anyone if I merge this through my driver-core tree for 3.17?
Ack from my side fwiw.
Thanks, I'll queue it up later today.
greg k-h
Sumit Semwal
maintainerHi Greg,
Quoted 20 lines · Greg KH
Quoted 12 lines · Maarten Lankhorst
So after some more hacking I've moved dma-buf to its own subdirectory,
drivers/dma-bufand applied the fence patches to its new place. I believe that the first patch should be applied regardless, and the rest should be ready now. :-)Changes to the fence api:
-release_fence->fence_releaseetc.
-__fence_init->fence_init
-__fence_signal->fence_signal_locked
-__fence_is_signaled->fence_is_signaled_locked
- ChangingBUG_ONtoWARN_ONinfence_later, and return NULL if it triggers.Quoted 6 lines
Android can expose fences to userspace. It's possible to make the new fence mechanism expose the same fences to userspace by changing
sync_fence_createto take a struct fence instead of a structsync_pt. No other change is needed, because only the fence parts of structsync_ptare used. But because the userspace fences are a separate problem and I haven't really looked at it yet I feel it should stay in staging, for now.
Quoted 5 lines
Ok, that's reasonable.
At first glance, this all looks "sane" to me, any objection from anyone if I merge this through my driver-core tree for 3.17?
Fwiw, Ack from me as well!
Quoted 3 lines
thanks,
greg k-h
Best regards,
~Sumit.
Quoted 9 lines · Greg KH
Quoted 8 lines · Daniel Vetter
Quoted 7 lines · Greg KH
Quoted 6 lines
Android can expose fences to userspace. It's possible to make the new fence mechanism expose the same fences to userspace by changing
sync_fence_createto take a struct fence instead of a structsync_pt. No other change is needed, because only the fence parts of structsync_ptare used. But because the userspace fences are a separate problem and I haven't really looked at it yet I feel it should stay in staging, for now.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Ok, that's reasonable.
At first glance, this all looks "sane" to me, any objection from anyone if I merge this through my driver-core tree for 3.17?
Ack from my side fwiw.
Thanks, I'll queue it up later today.
btw should we add you as a (co)maintainer for driver/core/dma-buf since you seem to want to keep a closer tab on what the insane gfx folks are up to in there?
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Greg KH
maintainerQuoted 15 lines · Daniel Vetter
Quoted 14 lines · Greg KH
Quoted 13 lines · Daniel Vetter
Quoted 11 lines · Greg KH
Quoted 6 lines
Android can expose fences to userspace. It's possible to make the new fence mechanism expose the same fences to userspace by changing
sync_fence_createto take a struct fence instead of a structsync_pt. No other change is needed, because only the fence parts of structsync_ptare used. But because the userspace fences are a separate problem and I haven't really looked at it yet I feel it should stay in staging, for now.Ok, that's reasonable.
At first glance, this all looks "sane" to me, any objection from anyone if I merge this through my driver-core tree for 3.17?
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Ack from my side fwiw.
Thanks, I'll queue it up later today.
btw should we add you as a (co)maintainer for driver/core/dma-buf since you seem to want to keep a closer tab on what the insane gfx folks are up to in there?
Sure, why not, what's one more maintainership...
Oh, does that mean you want me to be the one collecting the patches and forwarding them on to Linus? If so, that's fine, I can easily do that as well due to my infrastructure being set up for it.
thanks,
greg k-h
Sumit Semwal
maintainerQuoted 24 lines · Greg KH
Quoted 15 lines · Daniel Vetter
Quoted 14 lines · Greg KH
Quoted 13 lines · Daniel Vetter
Quoted 11 lines · Greg KH
Quoted 6 lines
Android can expose fences to userspace. It's possible to make the new fence mechanism expose the same fences to userspace by changing
sync_fence_createto take a struct fence instead of a structsync_pt. No other change is needed, because only the fence parts of structsync_ptare used. But because the userspace fences are a separate problem and I haven't really looked at it yet I feel it should stay in staging, for now.Ok, that's reasonable.
At first glance, this all looks "sane" to me, any objection from anyone if I merge this through my driver-core tree for 3.17?
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Ack from my side fwiw.
Thanks, I'll queue it up later today.
btw should we add you as a (co)maintainer for driver/core/dma-buf since you seem to want to keep a closer tab on what the insane gfx folks are up to in there?
Quoted 6 lines
Sure, why not, what's one more maintainership...
Oh, does that mean you want me to be the one collecting the patches and forwarding them on to Linus? If so, that's fine, I can easily do that as well due to my infrastructure being set up for it.
If you're ok, I could continue to do the collecting / forwarding business - I guess Daniel meant more from the 'not miss patches that need review'!
Upto you!
Quoted 3 lines
thanks,
greg k-h
Thanks and best regards,
~Sumit
Signature · 5 lines
Thanks and regards, Sumit Semwal Graphics Engineer - Graphics working group Linaro.org │ Open source software for ARM SoCs
Greg KH
maintainerQuoted 27 lines · Sumit Semwal
Quoted 26 lines · Greg KH
Quoted 15 lines · Daniel Vetter
Quoted 14 lines · Greg KH
Quoted 13 lines · Daniel Vetter
Quoted 11 lines · Greg KH
Quoted 6 lines
Android can expose fences to userspace. It's possible to make the new fence mechanism expose the same fences to userspace by changing
sync_fence_createto take a struct fence instead of a structsync_pt. No other change is needed, because only the fence parts of structsync_ptare used. But because the userspace fences are a separate problem and I haven't really looked at it yet I feel it should stay in staging, for now.Ok, that's reasonable.
At first glance, this all looks "sane" to me, any objection from anyone if I merge this through my driver-core tree for 3.17?
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Ack from my side fwiw.
Thanks, I'll queue it up later today.
btw should we add you as a (co)maintainer for driver/core/dma-buf since you seem to want to keep a closer tab on what the insane gfx folks are up to in there?
Sure, why not, what's one more maintainership...
Quoted 7 lines
Quoted 4 lines
Oh, does that mean you want me to be the one collecting the patches and forwarding them on to Linus? If so, that's fine, I can easily do that as well due to my infrastructure being set up for it.
If you're ok, I could continue to do the collecting / forwarding business - I guess Daniel meant more from the 'not miss patches that need review'!
Hey, I'm more than willing to have other people do the real work of collecting / forwarding :)
I'll just review stuff as it floats by, that's not enough of a role to put me in "MAINTAINERS" at all.
thanks,
greg k-h
Greg KH
maintainerQuoted 20 lines · Maarten Lankhorst
op 02-07-14 07:37, Greg KH schreef:
Quoted 19 lines · Maarten Lankhorst
Quoted 18 lines
So after some more hacking I've moved dma-buf to its own subdirectory,
drivers/dma-bufand applied the fence patches to its new place. I believe that the first patch should be applied regardless, and the rest should be ready now. :-)Changes to the fence api:
-release_fence->fence_releaseetc.
-__fence_init->fence_init
-__fence_signal->fence_signal_locked
-__fence_is_signaled->fence_is_signaled_locked
- ChangingBUG_ONtoWARN_ONinfence_later, and return NULL if it triggers.Android can expose fences to userspace. It's possible to make the new fence mechanism expose the same fences to userspace by changing
sync_fence_createto take a struct fence instead of a structsync_pt. No other change is needed, because only the fence parts of structsync_ptare used. But because the userspace fences are a separate problem and I haven't really looked at it yet I feel it should stay in staging, for now.
Quoted 7 lines
Quoted 5 lines
Ok, that's reasonable.
At first glance, this all looks "sane" to me, any objection from anyone if I merge this through my driver-core tree for 3.17?
Sounds good to me, let me know when you pull it in, so I can rebase my drm conversion on top of it. :-)
All are now queued up and in my driver-core tree in the driver-core-next branch, you should have gotten the emails about it.
thanks,
greg k-h