aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_prime.c
Commit message (Collapse)AuthorAgeFilesLines
...
* drm: add mmap() to drm_gem_object_funcsGerd Hoffmann2019-10-171-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | drm_gem_object_funcs->vm_ops alone can't handle everything which needs to be done for mmap(), tweaking vm_flags for example. So add a new mmap() callback to drm_gem_object_funcs where this code can go to. Note that the vm_ops field is not used in case the mmap callback is present, it is expected that the callback sets vma->vm_ops instead. Also setting vm_flags and vm_page_prot is the job of the new callback. so drivers have more control over these flags. drm_gem_mmap_obj() will use the new callback for object specific mmap setup. With this in place the need for driver-speific fops->mmap callbacks goes away, drm_gem_mmap can be hooked instead. drm_gem_prime_mmap() will use the new callback too to just mmap gem objects directly instead of jumping though loops to make drm_gem_object_lookup() and fops->mmap work. Signed-off-by: Gerd Hoffmann <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm/prime: Ditch gem_prime_res_obj hookDaniel Vetter2019-07-311-3/+0
| | | | | | | | | | | | | | | Everyone is just using gem_object->resv now. Acked-by: Gerd Hoffmann <[email protected]> Cc: Gerd Hoffmann <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Cc: David Airlie <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Maarten Lankhorst <[email protected]> Cc: Maxime Ripard <[email protected]> Cc: Sean Paul <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm: direct include of drm.h in drm_prime.cSam Ravnborg2019-07-191-0/+1
| | | | | | | | | | | | | | | | | Do not rely on including drm.h from drm_file.h, as the include in drm_file.h will be dropped. Signed-off-by: Sam Ravnborg <[email protected]> Reviewed-by: Sean Paul <[email protected]> Cc: Maarten Lankhorst <[email protected]> Cc: Maxime Ripard <[email protected]> Cc: David Airlie <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Christian König <[email protected]> Cc: Noralf Trønnes <[email protected]> Cc: Chris Wilson <[email protected]> Cc: Eric Anholt <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm/prime: automatically set gem_obj->resv on importDaniel Vetter2019-06-211-0/+1
| | | | | | | | | | | | | | | It's really the only reasonable thing to do, and it won't hurt drivers which don't (yet) use drm_gem_object->resv. Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Cc: Maarten Lankhorst <[email protected]> Cc: Maxime Ripard <[email protected]> Cc: Sean Paul <[email protected]> Cc: David Airlie <[email protected]> Cc: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm/prime: Align gem_prime_export with obj_funcs.exportDaniel Vetter2019-06-211-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The idea is that gem_prime_export is deprecated in favor of obj_funcs.export. That's much easier to do if both have matching function signatures. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Acked-by: Christian König <[email protected]> Acked-by: Thierry Reding <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Cc: Russell King <[email protected]> Cc: Maarten Lankhorst <[email protected]> Cc: Maxime Ripard <[email protected]> Cc: Sean Paul <[email protected]> Cc: David Airlie <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Zhenyu Wang <[email protected]> Cc: Zhi Wang <[email protected]> Cc: Jani Nikula <[email protected]> Cc: Joonas Lahtinen <[email protected]> Cc: Rodrigo Vivi <[email protected]> Cc: Tomi Valkeinen <[email protected]> Cc: Alex Deucher <[email protected]> Cc: "Christian König" <[email protected]> Cc: "David (ChunMing) Zhou" <[email protected]> Cc: Thierry Reding <[email protected]> Cc: Jonathan Hunter <[email protected]> Cc: Dave Airlie <[email protected]> Cc: Eric Anholt <[email protected]> Cc: "Michel Dänzer" <[email protected]> Cc: Chris Wilson <[email protected]> Cc: Huang Rui <[email protected]> Cc: Felix Kuehling <[email protected]> Cc: Hawking Zhang <[email protected]> Cc: Feifei Xu <[email protected]> Cc: Jim Qu <[email protected]> Cc: Evan Quan <[email protected]> Cc: Matthew Auld <[email protected]> Cc: Mika Kuoppala <[email protected]> Cc: Thomas Zimmermann <[email protected]> Cc: Kate Stewart <[email protected]> Cc: Sumit Semwal <[email protected]> Cc: Jilayne Lovejoy <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Mikulas Patocka <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Junwei Zhang <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm/prime: Make DRIVER_PRIME a no-opDaniel Vetter2019-06-211-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | Drivers must fill out the handle_to_fd and fd_to_handle hooks to enable export/import prime functionality already. The additional DRIVER_PRIME flag doesn't serve any real purpose, since the overall flag doesn't even tell you whether import or export or maybe even both is supported. Ditch it. This patch just makes it defunct, subsequent patches will remove it from all the drivers. Note this changes the userspace visible errno in some situations from EOPNOTSUPP to ENOSYS. Userspace already needs to treat both as "no prime support", so this should break anything. v2: Improve commit message as suggested by Emil Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm/prime: Update docsDaniel Vetter2019-06-211-72/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Yes this is a bit a big patch, but since it's essentially a complete rewrite of all the prime docs I didn't see how to better split it up. Changes: - Consistently point to drm_gem_object_funcs as the preferred hooks, where applicable. - Document all the hooks in &drm_driver that lacked kerneldoc. - Completely new overview section, which now also includes the cleaned up lifetime/reference counting subchapter. I also mentioned the weak references in there due to the lookup caches. - Completely rewritten helper intro section, highlight the import/export related functionality. - Polish for all the functions and more cross references. I also sprinkled a bunch of todos all over. Most important: 0 code changes in here. The cleanup motivated by reading and improving all this will follow later on. v2: Actually update the prime helper docs. Plus add a few FIXMEs that I won't address right away in subsequent cleanup patches. v3: - Split out the function moving. This patch is now exclusively documentation changes. - Typos and nits (Sam). v4: Polish suggestions from Noralf. Acked-by: Gerd Hoffmann <[email protected]> Acked-by: Emil Velikov <[email protected]> Acked-by: Noralf Trønnes <[email protected]> Cc: Thomas Zimmermann <[email protected]> Cc: Gerd Hoffmann <[email protected]> Cc: Noralf Trønnes <[email protected]> Cc: Sam Ravnborg <[email protected]> Cc: Eric Anholt <[email protected]> Cc: Emil Velikov <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm/prime: Shuffle functions.Daniel Vetter2019-06-211-355/+355
| | | | | | | | | | | | | | | | | Reorder all the functions in drm_prime.[hc] into three groups: core, export helpers, import helpers. Not other changes beyond moving the functions and their unchanged kerneldoc around in here. Cc: Sam Ravnborg <[email protected]> Cc: Eric Anholt <[email protected]> Cc: Emil Velikov <[email protected]> Acked-by: Gerd Hoffmann <[email protected]> Acked-by: Emil Velikov <[email protected]> Acked-by: Noralf Trønnes <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm: drop use of drmP.h in drm/*Sam Ravnborg2019-05-271-2/+5
| | | | | | | | | | | | | | | | | | The use of the drmP.h header file is deprecated. Remove use from all files in drm/* so people do not look there and follow a bad example. Build tested allyesconfig,allmodconfig on x86, arm etc. Including alpha that is as always more challenging than the rest. Signed-off-by: Sam Ravnborg <[email protected]> Acked-by: Daniel Vetter <[email protected]> Cc: Maarten Lankhorst <[email protected]> Cc: Maxime Ripard <[email protected]> Cc: Sean Paul <[email protected]> Cc: David Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm: remove prime sg_table cachingChristian König2019-05-221-60/+17
| | | | | | | | That is now done by the DMA-buf helpers instead. Signed-off-by: Christian König <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Link: https://patchwork.kernel.org/patch/10943055/
* drm: Add reservation_object to drm_gem_objectRob Herring2019-02-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | Many users of drm_gem_object embed a struct reservation_object into their subclassed struct, so let's add one to struct drm_gem_object. This will allow removing the reservation object from the subclasses and removing the ->gem_prime_res_obj callback. With the addition, add a drm_gem_reservation_object_wait() helper function for drivers to use in wait ioctls. Cc: Maarten Lankhorst <[email protected]> Cc: Maxime Ripard <[email protected]> Cc: Sean Paul <[email protected]> Cc: David Airlie <[email protected]> Cc: Daniel Vetter <[email protected]> Signed-off-by: Rob Herring <[email protected]> Acked-by: Daniel Vetter <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Christian Gmeiner <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Maxime Ripard <[email protected]>
* drm/prime: Fix drm_gem_prime_mmap() stack useNoralf Trønnes2018-11-221-11/+20
| | | | | | | | | | | | | | | drivers/gpu/drm/drm_prime.c: In function 'drm_gem_prime_mmap': >> drivers/gpu/drm/drm_prime.c:688:1: warning: the frame size of 1592 bytes is larger than 1024 bytes [-Wframe-larger-than=] Fix by allocating on the heap. Fixes: 7698799f9554 ("drm/prime: Add drm_gem_prime_mmap()") Reported-by: kbuild test robot <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Christian König <[email protected]> Signed-off-by: Noralf Trønnes <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm/gem: Add drm_gem_object_funcsNoralf Trønnes2018-11-201-18/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds an optional function table on GEM objects. The main benefit is for drivers that support more than one type of memory (shmem,vram,cma) for their buffers depending on the hardware it runs on. With the callbacks attached to the GEM object itself, it is easier to have core helpers for the the various buffer types. The driver only has to make the decision about buffer type on GEM object creation and all other callbacks can be handled by the chosen helper. drm_driver->gem_prime_res_obj has not been added since there's a todo to put a reservation_object into drm_gem_object. v3: Add todo entry v2: Drop drm_gem_object_funcs->prime_mmap in favour of drm_gem_prime_mmap() (Daniel Vetter) v1: - drm_gem_object_funcs.map -> .prime_map let it only do PRIME mmap like the function it superseeds (Daniel Vetter) - Flip around the if ladders and make obj->funcs the first choice highlighting the fact that this the new default way of doing it (Daniel Vetter) Signed-off-by: Noralf Trønnes <[email protected]> Acked-by: Daniel Vetter <[email protected]> Acked-by: Christian König <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm/prime: Add drm_gem_prime_mmap()Noralf Trønnes2018-11-201-0/+37
| | | | | | | | | | | | Add a generic PRIME GEM mmap function. v2: Fix link in docs (Daniel Vetter) Suggested-by: Daniel Vetter <[email protected]> Signed-off-by: Noralf Trønnes <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Acked-by: Christian König <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm/driver: Add defaults for .gem_prime_export/import callbacksNoralf Trønnes2018-11-201-2/+8
| | | | | | | | | | | The majority of drivers use drm_gem_prime_export() and drm_gem_prime_import() for these callbacks so let's make them the default. Signed-off-by: Noralf Trønnes <[email protected]> Acked-by: Daniel Vetter <[email protected]> Acked-by: Christian König <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm: Remove defunct dma_buf_kmap stubsChris Wilson2018-10-051-30/+0
| | | | | | | | | | | | | | | | Since commit 09ea0dfbf972 ("dma-buf: make map_atomic and map function pointers optional"), we no longer need to provide stub no-op functions as the core now provides them directly. References: 09ea0dfbf972 ("dma-buf: make map_atomic and map function pointers optional") Signed-off-by: Chris Wilson <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Gerd Hoffmann <[email protected]> Cc: Alex Deucher <[email protected]> Cc: "Christian König" <[email protected]> Reviewed-by: Christian König <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm: Differentiate the lack of an interface from invalid parameterChris Wilson2018-09-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | If the ioctl is not supported on a particular piece of HW/driver combination, report ENOTSUP (aka EOPNOTSUPP) so that it can be easily distinguished from both the lack of the ioctl and from a regular invalid parameter. v2: Across all the kms ioctls we had a mixture of reporting EINVAL, ENODEV and a few ENOTSUPP (most where EINVAL) for a failed drm_core_check_feature(). Update everybody to report ENOTSUPP. v3: ENOTSUPP is an internal errno! It's value (524) does not correspond to a POSIX errno, the one we want is ENOTSUP. However, uapi/asm-generic/errno.h doesn't include ENOTSUP but man errno says "ENOTSUP and EOPNOTSUPP have the same value on Linux, but according to POSIX.1 these error values should be distinct." so use EOPNOTSUPP as its equivalent. Signed-off-by: Chris Wilson <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Ville Syrjälä <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> #v2 Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
* dma-buf: remove kmap_atomic interfaceChristian König2018-06-201-31/+0
| | | | | | | | | | Neither used nor correctly implemented anywhere. Just completely remove the interface. Signed-off-by: Christian König <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Acked-by: Sumit Semwal <[email protected]> Link: https://patchwork.freedesktop.org/patch/226645/
* dma_buf: remove device parameter from attach callback v2Christian König2018-06-201-2/+1
| | | | | | | | | | | The device parameter is completely unused because it is available in the attachment structure as well. v2: fix kerneldoc as well Signed-off-by: Christian König <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/226643/
* drm: Make the prime vmap/vunmap hooks optional.Eric Anholt2018-04-301-2/+6
| | | | | | | | | Some drivers leave these unimplemented, so don't make them have unimplemented stubs. Signed-off-by: Eric Anholt <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: Daniel Vetter <[email protected]>
* drm: add parameter explanation for some gem dmabuf_opsSamuel Li2018-03-281-0/+13
| | | | | | | | | To reduce some warnings. Reviewed-by: Alex Deucher <[email protected]> Signed-off-by: Samuel Li <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm/prime: make the pages array optional for drm_prime_sg_to_page_addr_arraysChristian König2018-03-061-10/+10
| | | | | | | | | | | | | Most of the time we only need the dma addresses. Signed-off-by: Christian König <[email protected]> Reviewed-by: Roger He <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Link: https://patchwork.freedesktop.org/patch/msgid/BN6PR12MB18262C0DE9B5F07B9A42EAE7F2C60@BN6PR12MB1826.namprd12.prod.outlook.com
* drm/prime: fix potential race in drm_gem_map_detachChristian König2018-03-061-15/+15
| | | | | | | | | | Unpin the GEM object only after freeing the sg table. Signed-off-by: Christian König <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Acked-by: Roger He <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm: add kernel doc for exported gem dmabuf_opsSamuel Li2018-01-191-0/+88
| | | | | | | | Signed-off-by: Samuel Li <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Reviewed-by: Christian König <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm: export gem dmabuf_ops for drivers to reuseSamuel Li2018-01-091-22/+31
| | | | | | | Signed-off-by: Samuel Li <[email protected]> Reviewed-by: Christian König <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm/prime: skip CPU sync in map/unmap dma_bufLucas Stach2017-12-041-3/+5
| | | | | | | | | | | | | | | | | | Dma-bufs should already be device coherent, as they are only pulled in the CPU domain via the begin/end cpu_access calls. As we cache the mapping set up by dma_map_sg a CPU sync at this point will not actually guarantee proper coherency on non-coherent architectures, so we can as well stop pretending. This is an important performance fix for architectures which need explicit cache synchronization and userspace doing lots of dma-buf imports. Improves Weston on Etnaviv performance 5x, where before this patch > 90% of Weston CPU time was spent synchronizing caches for buffers which are already device coherent. Signed-off-by: Lucas Stach <[email protected]> Reviewed-by: Chris Wilson <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm/core: clean up references to drm_dev_unref()Aishwarya Pant2017-09-271-1/+1
| | | | | | | | | | This is a continuation of a previous commit ("drm: introduce drm_dev_{get/put} functions") to replace all references to drm_dev_unref() in drm core files with drm_dev_put(). Signed-off-by: Aishwarya Pant <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/20170926170400.GA7671@aishwarya
* drm: introduce drm_dev_{get/put} functionsAishwarya Pant2017-09-261-1/+1
| | | | | | | | | | | | | | | Reference counting functions in the kernel typically use get/put suffixes. For maintaining coding style consistency, introduce drm_dev_{get/put} functions. All callers of drm_dev_ref() API have been converted in this patch and hence it has been dropped while the drm_dev_unref() API with non-trivial number of users remains for compatibility. The semantic patch scripts/coccinelle/api/drm-get-put.cocci has been updated with the new helper for conversion of drm_dev_unref() to drm_dev_put() Signed-off-by: Aishwarya Pant <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/6babda56134035a98220d5d37a4fd4048df214ce.1506413698.git.aishpant@gmail.com
* drm/prime: Introduce drm_gem_prime_import_devLaura Abbott2017-05-081-6/+24
| | | | | | | | | | | | The existing drm_gem_prime_import function uses the underlying struct device of a drm_device for attaching to a dma_buf. Some drivers (notably vgem) may not have an underlying device structure. Offer an alternate function to attach using any available device structure. Signed-off-by: Laura Abbott <[email protected]> Reviewed-by: Chris Wilson <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
* dma-buf: Rename dma-ops to prevent conflict with kunmap_atomic macroLogan Gunthorpe2017-04-201-4/+4
| | | | | | | | | | | | | | | | | | | | | | | Seeing the kunmap_atomic dma_buf_ops share the same name with a macro in highmem.h, the former can be aliased if any dma-buf user includes that header. I'm personally trying to include highmem.h inside scatterlist.h and this breaks the dma-buf code proper. Christoph Hellwig suggested [1] renaming it and pushing this patch ASAP. To maintain consistency I've renamed all four of kmap* and kunmap* to be map* and unmap*. (Even though only kmap_atomic presently conflicts.) [1] https://www.spinics.net/lists/target-devel/msg15070.html Signed-off-by: Logan Gunthorpe <[email protected]> Reviewed-by: Sinclair Yeh <[email protected]> Acked-by: Daniel Vetter <[email protected]> Acked-by: Sumit Semwal <[email protected]> Signed-off-by: Sumit Semwal <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm: Extract drm_prime.hDaniel Vetter2017-03-091-1/+2
| | | | | | | | | | | Plus a little bit more documentation. v2: Untangle the missing forward decls to make drm_prime|gem.h free-standing. Reviewed-by: Gustavo Padovan <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm: Introduce drm_gem_object_{get,put}()Thierry Reding2017-02-281-5/+5
| | | | | | | | | | | | | | | | | | For consistency with other reference counting APIs in the kernel, add drm_gem_object_get() and drm_gem_object_put(), as well as an unlocked variant of the latter, to reference count GEM buffer objects. Compatibility aliases are added to keep existing code working. To help speed up the transition, all the instances of the old functions in the DRM core are already replaced in this commit. The existing semantic patch for the DRM subsystem-wide conversion is extended to account for these new helpers. Reviewed-by: Sean Paul <[email protected]> Acked-by: Christian König <[email protected]> Signed-off-by: Thierry Reding <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm/prime: Clarify DMA-BUF/GEM Object lifetimeOleksandr Andrushchenko2017-01-271-2/+15
| | | | | | | | | | | | | | | | | | | From the description of the "DMA-BUF/GEM Object references and lifetime overview" it is not clear when exactly dma_buf gets destroyed and memory freed: only driver .release function mentioned which makes confusion on the real buffer's lifetime. Add more description so all the paths are covered. Cc: Rob Clark <[email protected]> Cc: Dave Airlie <[email protected]> Cc: Daniel Vetter <[email protected]> Signed-off-by: Oleksandr Andrushchenko <[email protected]> [danvet: Minor spelling fixes, and some clarification of the 2nd paragraph.] Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm/gem|prime|mm: Use recommened kerneldoc for struct member refsDaniel Vetter2017-01-251-1/+1
| | | | | | | | | | | | | | | | I just learned that &struct_name.member_name works and looks pretty even. It doesn't (yet) link to the member directly though, which would be really good for big structures or vfunc tables (where the per-member kerneldoc tends to be long). Also some minor drive-by polish where it makes sense, I read a lot of docs ... Cc: Jani Nikula <[email protected]> Cc: Chris Wilson <[email protected]> Reviewed-by: Gustavo Padovan <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm: Take ownership of the dmabuf->obj when exportingChris Wilson2016-12-081-5/+7
| | | | | | | | | | | | | | Currently the reference for the dmabuf->obj is incremented for the dmabuf in drm_gem_prime_handle_to_fd() (at the high level userspace interface), but is released in drm_gem_dmabuf_release() (the lowlevel handler). Improve the symmetry of the dmabuf->obj ownership by acquiring the reference in drm_gem_dmabuf_export(). This makes it easier to use the prime functions directly. Signed-off-by: Chris Wilson <[email protected]> [danvet: Update kerneldoc.] Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm: Fix up kerneldoc for new drm_gem_dmabuf_export()Chris Wilson2016-10-101-1/+2
| | | | | | | | | | | | | I hit send before completing a make htmldoc, and lo I forgot to fix up the cut'n'paste. Fixes: a4fce9cb782a ("drm/prime: Take a ref on the drm_dev when exporting...") Reported-by: kbuild test robot <[email protected]> Signed-off-by: Chris Wilson <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: [email protected] Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm/prime: Take a ref on the drm_dev when exporting a dma_bufChris Wilson2016-10-051-1/+29
| | | | | | | | | | | | | | | | | | | | | | | | | dma_buf may live a long time, longer than the last direct user of the driver. We already hold a reference to the owner module (that prevents the object code from disappearing), but there is no reference to the drm_dev - so the pointers to the driver backend themselves may vanish. v2: Resist temptation to fix the bug in armada_gem.c not setting the correct flags on the exported dma-buf (it should pass the flags through and not be arbitrarily setting O_RDWR). Use a common wrapper for exporting the dmabuf and acquiring the reference to the drm_device. Testcase: igt/vgem_basic/unload Suggested-by: Daniel Vetter <[email protected]> Signed-off-by: Chris Wilson <[email protected]> Cc: Petri Latvala <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: [email protected] Tested-by: Petri Latvala <[email protected]> Reviewed-by: Christian König <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm/prime: Pass the right module owner through to dma_buf_export()Chris Wilson2016-10-051-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | dma_buf_export() adds a reference to the owning module to the dmabuf (to prevent the driver from being unloaded whilst a third party still refers to the dmabuf). However, drm_gem_prime_export() was passing its own THIS_MODULE (i.e. drm.ko) rather than the driver. Extract the right owner from the device->fops instead. v2: Use C99 initializers to zero out unset elements of dma_buf_export_info v3: Extract the right module from dev->fops. Testcase: igt/vgem_basic/unload Reported-by: Petri Latvala <[email protected]> Signed-off-by: Chris Wilson <[email protected]> Cc: Petri Latvala <[email protected]> Cc: Christian König <[email protected]> Cc: [email protected] Tested-by: Petri Latvala <[email protected]> Reviewed-by: Petri Latvala <[email protected]> Reviewed-by: Christian König <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm: Convert prime dma-buf <-> handle to rbtreeChris Wilson2016-10-041-11/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently we use a linear walk to lookup a handle and return a dma-buf, and vice versa. A long overdue TODO task is to convert that to a hashtable. Since the initial implementation of dma-buf/prime, we now have resizeable hashtables we can use (and now a future task is to RCU enable the lookup!). However, this patch opts to use an rbtree instead to provide O(lgN) lookups (and insertion, deletion). rbtrees were chosen over using the RCU backed resizable hashtable to firstly avoid the reallocations (rbtrees can be embedded entirely within the parent struct) and to favour simpler code with predictable worst case behaviour. In simple testing, the difference between using the constant lookup and insertion of the rhashtable and the rbtree was less than 10% of the wall time (igt/benchmarks/prime_lookup) - both are dramatic improvements over the existing linear lists. v2: Favour rbtree over rhashtable Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94631 Signed-off-by: Chris Wilson <[email protected]> Cc: Sean Paul <[email protected]> Cc: David Herrmann <[email protected]> Reviewed-by: David Herrmann <[email protected]> Reviewed-by: Sean Paul <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm/prime: fix error path deadlock failRob Clark2016-06-131-4/+6
| | | | | | | | | | | | | There were a couple messed up things about this fail path. (1) it would drop object_name_lock twice (2) drm_gem_handle_delete() (in drm_gem_remove_prime_handles()) needs to grab prime_lock Reported-by: Alex Deucher <[email protected]> Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Alex Deucher <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm: Remove unused drm_device from drm_gem_object_lookup()Chris Wilson2016-05-171-1/+1
| | | | | | | | | | | | | drm_gem_object_lookup() has never required the drm_device for its file local translation of the user handle to the GEM object. Let's remove the unused parameter and save some space. Signed-off-by: Chris Wilson <[email protected]> Cc: [email protected] Cc: Dave Airlie <[email protected]> Cc: Daniel Vetter <[email protected]> [danvet: Fixup kerneldoc too.] Signed-off-by: Daniel Vetter <[email protected]>
* drm: prime: Honour O_RDWR during prime-handle-to-fdDaniel Thompson2016-02-091-7/+3
| | | | | | | | | | | | | | | | | | | | Currently DRM_IOCTL_PRIME_HANDLE_TO_FD rejects all flags except (DRM|O)_CLOEXEC making it difficult (maybe impossible) for userspace to mmap() the resulting dma-buf even when this is supported by the DRM driver. It is trivial to relax the restriction and permit read/write access. This is safe because the flags are seldom touched by drm; mostly they are passed verbatim to dma_buf calls. v3 (Tiago): removed unused flags variable from drm_prime_handle_to_fd_ioctl. Reviewed-by: Chris Wilson <[email protected]> Signed-off-by: Daniel Thompson <[email protected]> Signed-off-by: Tiago Vignatti <[email protected]> Reviewed-by: Stéphane Marchesin <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm/doc: Convert to markdownDanilo Cesar Lemes de Paula2015-12-151-10/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DRM Docbook is now Markdown ready. This means its doc is able to use markdown text on it. * Documentation/DocBook/drm.tmpl: Contains a table duplicated from drivers/gpu/drm/i915/i915_reg.h. This is not needed anymore * drivers/gpu/drm/drm_modeset_lock.c: had a code example that used to look pretty bad on html. Fixed by using proper code markup. * drivers/gpu/drm/drm_prime.c: Remove spaces between lines to make a proper markup list. * drivers/gpu/drm/i915/i915_reg.h: Altought pandoc supports tables, it doesn't support table cell spanning. But we can use fixed-width for those special cases. * include/drm/drm_vma_manager.h: Another code example that should be proper indented with four spaces. v2 (Daniel): Adjust name to gpu.xml due to rename. v3 (Daniel): Split out the actual enabling in the Makefile - this way we can merge the conversion, while just keeping the enabling in a drm-private tree. Signed-off-by: Danilo Cesar Lemes de Paula <[email protected]> (v1) Cc: Randy Dunlap <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Herbert Xu <[email protected]> Cc: Stephan Mueller <[email protected]> Cc: Michal Marek <[email protected]> Cc: [email protected] Cc: [email protected] Cc: intel-gfx <[email protected]> Cc: dri-devel <[email protected]> Acked-by: Dave Airlie <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
* drm: prime: Document gem_prime_mmapDaniel Thompson2015-06-191-1/+3
| | | | | | | | gem_prime_map is not currently described in the DRM manual, lets document it. Signed-off-by: Daniel Thompson <[email protected]> Signed-off-by: Daniel Vetter <[email protected]>
* drm/prime: Allow internal imports without import_sg_tableTomasz Figa2015-05-121-3/+3
| | | | | | | | | | | | | | Currently drm_gem_prime_import() checks if gem_prime_import_sg_table() is implemented in DRM driver ops. However it is not necessary for internal imports (i.e. dma_buf->ops == &drm_gem_prime_dmabuf_ops and obj->dev == dev), which only increment reference count on respective GEM objects. This patch makes the helper check this condition only in case of external imports fo rwhich importing sg table is indeed needed. Signed-off-by: Tomasz Figa <[email protected]> Signed-off-by: Daniel Vetter <[email protected]>
* dma-buf: cleanup dma_buf_export() to make it easily extensibleSumit Semwal2015-04-211-4/+8
| | | | | | | | | | | | | | | | | At present, dma_buf_export() takes a series of parameters, which makes it difficult to add any new parameters for exporters, if required. Make it simpler by moving all these parameters into a struct, and pass the struct * as parameter to dma_buf_export(). While at it, unite dma_buf_export_named() with dma_buf_export(), and change all callers accordingly. Reviewed-by: Maarten Lankhorst <[email protected]> Reviewed-by: Daniel Thompson <[email protected]> Acked-by: Mauro Carvalho Chehab <[email protected]> Acked-by: Dave Airlie <[email protected]> Signed-off-by: Sumit Semwal <[email protected]>
* Merge tag 'drm/fixes/for-3.19-rc1' of ↵Dave Airlie2014-11-141-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://people.freedesktop.org/~tagr/linux into drm-next drm: Miscellaneous fixes for v3.19-rc1 This is a small collection of fixes that I've been carrying around for a while now. Many of these have been posted and reviewed or acked. The few that haven't I deemed too trivial to bother. * tag 'drm/fixes/for-3.19-rc1' of git://people.freedesktop.org/~tagr/linux: video/hdmi: Relicense header under MIT license drm/gma500: mdfld: Reuse video/mipi_display.h drm: Make drm_mode_create_tv_properties() signature consistent drm: Implement drm_get_pci_dev() dummy for !PCI drm/prime: Use unsigned type for number of pages drm/gem: Fix typo in kerneldoc drm: Use const data when creating blob properties drm: Use size_t for blob property sizes
| * drm/prime: Use unsigned type for number of pagesThierry Reding2014-11-131-1/+1
| | | | | | | | | | | | | | | | The number of pages can never be negative, so an unsigned type is enough. This also matches the type of the n_pages argument of the sg_alloc_table_from_pages() function. Signed-off-by: Thierry Reding <[email protected]>
* | gpu:drm: Fix typo in Documentation/DocBook/drm.xmlMasanari Iida2014-10-211-2/+2
|/ | | | | | | | | | This patch fix spelling typos found in drm.xml. It is because the file is generated from comments in source codes, I have to fix the typos within source files. Signed-off-by: Masanari Iida <[email protected]> Acked-by: Randy Dunlap <[email protected]> Signed-off-by: Daniel Vetter <[email protected]>
* drm: Pass dma-buf as argument to gem_prime_import_sg_tableMaarten Lankhorst2014-09-301-1/+1
| | | | | | Allows importing dma_reservation_objects from a dma-buf. Signed-off-by: Maarten Lankhorst <[email protected]>