summaryrefslogtreecommitdiff
path: root/drivers
AgeCommit message (Collapse)AuthorFilesLines
2014-11-27dma-buf/dmabuf-sync: fix referece droppingsubmit/tizen/20141127.130559accepted/tizen/mobile/20141201.013959accepted/tizen/common/20141127.143546Inki Dae1-4/+8
Cancel fence free worker if there is no any task or dma device. And do not drop a reference of dmabuf at fence free worker, which is over-dropping. Change-Id: Ib7378d4efc68a8f7ee7a161296f6a9c0e78f77a7 Signed-off-by: Inki Dae <inki.dae@samsung.com>
2014-11-27input: keyboard: mcs_touchkey: use strcpy for assign device nameBeomho Seo1-1/+4
This patch use strcpy() for assign input device name. Change-Id: I2d363de2b0fe88d771ed71a861f7880a73dc6dac Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
2014-11-27exynos: fimc-is: Support for V4L2 controlsBeata Michalska9-72/+669
Add support for FIMC ISP and SCALERC v4l2 controls Change-Id: I360597cbaed60a24f3184df3c5617f868fd02749 Signed-off-by: Beata Michalska <b.michalska@samsung.com>
2014-11-27exynos: fimc-is: Internal buffer list cleanupBeata Michalska5-18/+113
As the driver maintaines separate buffer lists per each video device which are beyond control of v4l2/vb2 framework, those lists should be properly handled and cleared once the buffers are no longer available. The changes introduced allow controlling state of each queued buffer and removing it from internal buffer lists when needed. Signed-off-by: Beata Michalska <b.michalska@samsung.com> Change-Id: I4dea7df3910d6836edee1387c5a1147649043b81
2014-11-27exynos3: fimc-is: Add support for FIMC IS on Exynos3250Beata Michalska21-922/+3462
The changes introduced provide support for FIMC-IS subsystem avalilable on Exynos3250. They cover the differences in both: the hardware itself as well as the subtle discrepancies between the firmwares controlling the FIMC IS on both SoCs. Regarding the above mentioned firmware variations: the initial driver has been extended with a simplified interface handling those variations thus living the core driver independent of the actual firmware version. Missing code paths have been added to cover handling some of the most probable failures/errors. Signed-off-by: Beata Michalska <b.michalska@samsung.com> Change-Id: Ie07312013a6a0ee14b88803360f0832d0ad4038d
2014-11-27exynos5: fimc-is: Code cleanupBeata Michalska3-77/+148
- Code cleanup for Exynos5/3 media device driver - Proper locking for vb2 buffers for both FIMC ISP and FIMC SCC v4l2 subdevices - Improved handling VIDIOC_REQBUFS ioctl Signed-off-by: Beata Michalska <b.michalska@samsung.com> Change-Id: If7ee3f7861678169c2c0f0fc217d3507b3e3d4fc
2014-11-27exynos: fimc-lite: Capture frame end event notificationBeata Michalska1-17/+20
This patch adds notifying v4l2 subdevs upon capture frame end event. Signed-off-by: Beata Michalska <b.michalska@samsung.com> Change-Id: Id3e81b4692a6f2cfc91ffde7050a3ae6db719971
2014-11-27exynos: mipi-csis: Fix clock handling for exynos3250Beata Michalska1-13/+29
In case of Exynos3250 only gate clock is required thus all the remaining mipi-csis clocks are considered as optional. Signed-off-by: Beata Michalska <b.michalska@samsung.com> Change-Id: Ibadffe49739add39f156737cbb723b24a5dd4ff5
2014-11-27exynos: mipi-csis: Fix handling csis events/errorsBeata Michalska1-14/+18
Particular interrupt source mask should specify each and every possible event/error reflecting the s5pcsis_events table content. Change-Id: I3149364cf219d8ec2c13297a8890537585ae77ca Signed-off-by: Beata Michalska <b.michalska@samsung.com>
2014-11-27exynos5: fimc-is: Add driver data entry for S5K68B1 sensorSylwester Nawrocki2-4/+16
Change-Id: I7e1c466c6622b39c2999e2245c7815e6517dd157 Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
2014-11-27exynos5-is: Make sclk_bayer clock handling optionalSylwester Nawrocki1-11/+16
There is no sclk_bayer clock on exynos3250. Some flag at the variant data could be added later to handle properly error from clk calls. Change-Id: I249169e1a7c451db6805dee7d01dd95816f329e0 Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
2014-11-27exynos5-is: Allow initialization when fimc-is is a master nodeSylwester Nawrocki7-113/+222
Change platform sub-devices registration method so the driver can support exynos3250 DT binding, i.e. initialize when fimc-is is the complex root node, not "camera". This also merges exynos5-fimc-is and exynos-mdevice into single kernel module called exynos-iss.ko. Change-Id: Ie340fd7a3e1f7b5dba2c71963c920f324fab4e5a Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
2014-11-27[media] Add driver for exynos5 FIMC-IS subsystemArun Kumar K22-0/+7243
This driver is for the FIMC-IS IP available in Samsung Exynos5 SoC onwards. exynos5-fimc-is: Add common driver header files This patch adds all the common header files used by the fimc-is driver. It includes the commands for interfacing with the firmware and error codes from IS firmware, metadata and command parameter definitions. exynos5-fimc-is: Add register definition and context header This patch adds the register definition file for the fimc-is driver and also the header file containing the main context for the driver. exynos5-fimc-is: Add isp subdev fimc-is driver takes video data input from the ISP video node which is added in this patch. This node accepts Bayer input buffers which is given from the IS sensors. exynos5-fimc-is: Add scaler subdev FIMC-IS has two hardware scalers named as scaler-codec and scaler-preview. This patch adds the common code handling the video nodes and subdevs of both the scalers. exynos5-fimc-is: Add sensor interface Some sensors to be used with fimc-is are exclusively controlled by the fimc-is firmware. This minimal sensor driver provides the required info for the firmware to configure the sensors sitting on I2C bus. exynos5-fimc-is: Add the hardware pipeline control This patch adds the crucial hardware pipeline control for the fimc-is driver. All the subdev nodes will call this pipeline interfaces to reach the hardware. Responsibilities of this module involves configuring and maintaining the hardware pipeline involving multiple sub-ips like ISP, DRC, Scalers, ODC, 3DNR, FD etc. exynos5-fimc-is: Add the hardware interface module The hardware interface module finally sends the commands to the FIMC-IS firmware and runs the interrupt handler for getting the responses. Signed-off-by: Arun Kumar K <arun.kk@samsung.com> Signed-off-by: Kilyeon Im <kilyeon.im@samsung.com> Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com> exynos5-is: Add Kconfig and Makefile Adds Kconfig and Makefile for exynos5-is driver files. [b.michalska@samsung.com: Implementation adjusted to current version of V4L2 framework: - updated prototype for stop_streaming v4l2 capture ops - vb2_queue struct's field tiemstamp_type updated to timestamp_flags] Change-Id: I066a86151048b4b5871bd3732773b87219f04fd1 Signed-off-by: Shaik Ameer Basha <shaik.ameer@samsung.com> Signed-off-by: Arun Kumar K <arun.kk@samsung.com> Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
2014-11-27exynos5-is: Add media device driver for exynos5 SoCs camera subsystemShaik Ameer Basha2-0/+1336
This patch adds a top level media device driver for the Exynos5 SoC series camera subsystem. The driver currently supports processing pipelines involving following IP blocks: * MIPI-CSIS MIPI CSI-2 bus front-end to the FIMC-LITE, image sensors with MIPI CSI-2 bus should be linked with FIMC-LITE through this sub-device. * FIMC-LITE Supports capture interface from device (Sensor, MIPI-CSIS) to memory. Supports interconnection (through internal data FIFO links) between devices like MIPI-CSIS and FIMC-IS. * FIMC-IS Camera ISP with multiple image processing and peripheral devices like I2C or SPI bus controllers. The G-Scaler IP is not yet supported. The media device creates two kinds of pipelines for connecting the above mentioned IP blocks. The pipeline0 contains Sensor, MIPI-CSIS and FIMC-LITE devices and allows to capture image data from external sensor to memory. Pipeline1 uses FIMC-IS components for image processing operations on the captured raw image data and provides scaled YUV image data at its output. Pipeline0 +--------+ +-----------+ +-----------+ +--------+ | Sensor | --> | MIPI-CSIS | --> | FIMC-LITE | --> | Memory | +--------+ +-----------+ +-----------+ +--------+ Pipeline1 +--------+ +---------+ +-----------+ +-----------+ | Memory | --> | ISP | --> | SCC | --> | SCP | +--------+ +---------+ +-----------+ +-----------+ Signed-off-by: Shaik Ameer Basha <shaik.ameer@samsung.com> Signed-off-by: Arun Kumar K <arun.kk@samsung.com> [s.nawrocki@samsung.com: improved the commit description, removed inclusion of nonexistent <linux/of_i2c.h> header] Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Change-Id: Icccb5c45cebe4b46790a1bdce436c00090924d7a
2014-11-27exynos: mipi-csis: Add suport for Exynos3250Beata Michalska1-74/+183
Adapt current implementation to cover differences in MIPI CSIS registers layout. Change-Id: I092394f722c019dbb80ac833dc41256566388e8e Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Beata Michalska <b.michalska@samsung.com>
2014-11-27exynos: fimc-lite: Add support for exynos3250Beata Michalska4-11/+45
Add support for enabling/disabling local output path along with disabling interrupts upon capture being stopped. Change-Id: I8ed2e100138f567dbd10c2eb5083b12110a3c799 Signed-off-by: Beata Michalska <b.michalska@samsung.com>
2014-11-27exynos: fimc-lite: Add compatible string for exynos3250Sylwester Nawrocki1-2/+15
Allow driver initialization on exynos3250. Further changes of the IP handling will be added in subsequent patches. Change-Id: Ifb4571b8173c34a8677c6dba6d23ddfcac63bb2b Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
2014-11-27V4L: Add driver for Samsung S5K8B1YX image sensorSylwester Nawrocki3-0/+378
This patch adds a stub driver for Samsung S5K8B2YX raw image sensor. There is currently no I2C communication done in this driver. It can be added if required. This driver was tested only with Exynos FIMC-IS subsystem (camera ISP), which communicates with the sensor over I2C bus in firmware. Change-Id: I40ea0b1d6bbb139b85f60941343fd8207f4ece8a Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
2014-11-25dma-buf/dmabuf-sync: add dmabuf_sync_reference_reservation functionsubmit/tizen/20141126.081420accepted/tizen/mobile/20141126.082557accepted/tizen/common/20141126.162632Inki Dae1-0/+46
This patch adds dmabuf_sync_reference_reservation function that can get/drop a reference to all fences added to reservation_object of a given dmabuf object, and calls it before blocked and after waked up to avoid null pointer dereference. Change-Id: I32f31b5a54e233d4a06b9915d26b04cda4e31d01 Signed-off-by: Inki Dae <inki.dae@samsung.com>
2014-11-25drm/exynos: add dmabuf sync support for page flipInki Dae1-0/+74
This patch adds dmabuf sync support for page flip. With this patch, a dma buffer shared with cpu or other dma devices, which buffer is accessed by display or HDMI controllers, could be synchronized implicitly. Change-Id: I7bd88b293d4d99b87488c0c1c8b07cb72acfb5e6 Signed-off-by: Inki Dae <inki.dae@samsung.com>
2014-11-24dma-buf/dmabuf-sync: fix request order checkInki Dae1-2/+9
This patch fixes infinite loop issue which could be incurred when same task requested sync before previous sync of the same task is signaled. For this, it checks if the context of a given sync object is same as previous one. Change-Id: I214a3011de4a8513d9aea5f5d56d85acf3ffae7e Signed-off-by: Inki Dae <inki.dae@samsung.com>
2014-11-25cpufreq: stats: fix index of last entity in load_tableSeung-Woo Kim1-1/+1
Array load_table should be pointed with last entity index instead of maximum count in array. Change-Id: I097421908cdfc875679d84900f46e907833daca3 Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
2014-11-25drm/exynos: remove all codes relevant to dmabuf-syncsubmit/tizen/20141124.161713accepted/tizen/common/20141124.171414Inki Dae4-183/+0
This patch removes existing codes relevant to dmabuf-sync. For dmabuf-sync support, new codes will be added later. Change-Id: I1f794f95941519d8ef791f6fda01ab5f1e32807a Signed-off-by: Inki Dae <inki.dae@samsung.com>
2014-11-21devfreq: exynos4: Add sentinel into array to fix out-of-bound accesssubmit/tizen_common/20141124.090428submit/tizen/20141123.134900submit/tizen/20141121.110247Seung-Woo Kim1-0/+1
Without sentinel, of_match_node() to array causes out-of-bound memory access. So this patch adds sentinel into exynos4_busfreq_match. Change-Id: Iec2390fd367a22e6388eb97fae21eafc3836e206 Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
2014-11-21dma-buf: add dma-buf-test driverChanho Park2-1/+321
Change-Id: Ia7d3608d3ec033453147c1bb500aca144ee42902 Signed-off-by: Chanho Park <chanho61.park@samsung.com>
2014-11-21dma-buf: add fcntl system call supportInki Dae1-0/+29
This patch adds lock callback to dmabuf framework. And this callback will be called by fcntl request. With this patch, fcntl system call can be used by userspace application for they can use dmabuf sync mechanism. Change-Id: Id3631cbc21e84c986e2efe040881e401ade180e8 Signed-off-by: Inki Dae <inki.dae@samsung.com>
2014-11-21dma-buf/dmabuf-sync: add dmabuf sync frameworkInki Dae5-15/+1055
The DMA Buffer synchronization API provides buffer synchronization mechanism based on DMA buffer sharing machanism[1], dmafence and reservation frameworks[2]; i.e., buffer access control to CPU and DMA, and easy-to-use interfaces for device drivers and user application. And this API can be used for all dma devices using system memory as dma buffer, especially for most ARM based SoCs. For more details, please refer to Documentation/dma-buf-syc.txt [1] http://lwn.net/Articles/470339/ [2] https://lkml.org/lkml/2014/2/24/824 Change-Id: I3b2084a3c331fc06992fa8d2a4c71378e88b10b5 Signed-off-by: Inki Dae <inki.dae@samsung.com>
2014-11-21local: drm/exynos: fix dmabuf variable nameChanho Park2-3/+3
Change-Id: Ie106e49107d687d053259fa35f889374a8cc0924 Signed-off-by: Chanho Park <chanho61.park@samsung.com>
2014-11-21gpu/drm: fix compile error since backportedChanho Park2-51/+1
Change-Id: I5c9a62578057b164898c8f7880d0566e813dba65 Signed-off-by: Chanho Park <chanho61.park@samsung.com>
2014-11-21drm/vma: add access management helpersDavid Herrmann2-0/+156
The VMA offset manager uses a device-global address-space. Hence, any user can currently map any offset-node they want. They only need to guess the right offset. If we wanted per open-file offset spaces, we'd either need VM_NONLINEAR mappings or multiple "struct address_space" trees. As both doesn't really scale, we implement access management in the VMA manager itself. We use an rb-tree to store open-files for each VMA node. On each mmap call, GEM, TTM or the drivers must check whether the current user is allowed to map this file. We add a separate lock for each node as there is no generic lock available for the caller to protect the node easily. As we currently don't know whether an object may be used for mmap(), we have to do access management for all objects. If it turns out to slow down handle creation/deletion significantly, we can optimize it in several ways: - Most times only a single filp is added per bo so we could use a static "struct file *main_filp" which is checked/added/removed first before we fall back to the rbtree+drm_vma_offset_file. This could be even done lockless with rcu. - Let user-space pass a hint whether mmap() should be supported on the bo and avoid access-management if not. - .. there are probably more ideas once we have benchmarks .. v2: add drm_vma_node_verify_access() helper Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
2014-11-21drm/mm: add "best_match" flag to drm_mm_insert_node()David Herrmann6-36/+30
Add a "best_match" flag similar to the drm_mm_search_*() helpers so we can convert TTM to use them in follow up patches. We can also inline the non-generic helpers and move them into the header to allow compile-time optimizations. To make calls to drm_mm_{search,insert}_node() more readable, this converts the boolean argument to a flagset. There are pending patches that add additional flags for top-down allocators and more. v2: - use flag parameter instead of boolean "best_match" - convert *_search_free() helpers to also use flags argument Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com> Conflicts: drivers/gpu/drm/i915/i915_gem.c Change-Id: I77640db74616de3c9ae874531f71bbd81b89d5fa
2014-11-21drm/vma: provide drm_vma_node_unmap() helperDavid Herrmann2-10/+2
Instead of unmapping the nodes in TTM and GEM users manually, we provide a generic wrapper which does the correct thing for all vma-nodes. v2: remove bdev->dev_mapping test in ttm_bo_unmap_virtual_unlocked() as ttm_mem_io_free_vm() does nothing in that case (io_reserved_vm is 0). v4: Fix docbook comments v5: use drm_vma_node_size() Cc: Dave Airlie <airlied@redhat.com> Cc: Maarten Lankhorst <maarten.lankhorst@canonical.com> Cc: Thomas Hellstrom <thellstrom@vmware.com> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@gmail.com> Conflicts: drivers/gpu/drm/ttm/ttm_bo.c Change-Id: I4be1eeef8e5b4e81b5966449e2bf3691d8270aae
2014-11-21drm: add unified vma offset managerDavid Herrmann2-1/+283
If we want to map GPU memory into user-space, we need to linearize the addresses to not confuse mm-core. Currently, GEM and TTM both implement their own offset-managers to assign a pgoff to each object for user-space CPU access. GEM uses a hash-table, TTM uses an rbtree. This patch provides a unified implementation that can be used to replace both. TTM allows partial mmaps with a given offset, so we cannot use hashtables as the start address may not be known at mmap time. Hence, we use the rbtree-implementation of TTM. We could easily update drm_mm to use an rbtree instead of a linked list for it's object list and thus drop the rbtree from the vma-manager. However, this would slow down drm_mm object allocation for all other use-cases (rbtree insertion) and add another 4-8 bytes to each mm node. Hence, use the separate tree but allow for later migration. This is a rewrite of the 2012-proposal by David Airlie <airlied@linux.ie> v2: - fix Docbook integration - drop drm_mm_node_linked() and use drm_mm_node_allocated() - remove unjustified likely/unlikely usage (but keep for rbtree paths) - remove BUG_ON() as drm_mm already does that - clarify page-based vs. byte-based addresses - use drm_vma_node_reset() for initialization, too v4: - allow external locking via drm_vma_offset_un/lock_lookup() - add locked lookup helper drm_vma_offset_lookup_locked() v5: - fix drm_vma_offset_lookup() to correctly validate range-mismatches (fix (offset > start + pages)) - fix drm_vma_offset_exact_lookup() to actually do what it says - remove redundant vm_pages member (add drm_vma_node_size() helper) - remove unneeded goto - fix documentation Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@gmail.com> Conflicts: Documentation/DocBook/drm.tmpl drivers/gpu/drm/Makefile Change-Id: If3427d06b0f9b24c65268912bb75c1b90fe9ad26
2014-11-21local: fence: use smp_mb__before_atomic_incChanho Park1-2/+2
The smp_mb__before_atomic is hard to merge it because there is too many precedence patches. Thus, just use smp_mb__before_atomic_inc because it always convert to smb_mb. Change-Id: Ia31d488eaf218cc4585d9256457855e1a9d6b321 Signed-off-by: Chanho Park <chanho61.park@samsung.com>
2014-11-21drm/gem: completely close gem_open vs. gem_close racesDaniel Vetter1-11/+31
The gem flink name holds a reference onto the object itself, and this self-reference would prevent an flink'ed object from every being freed. To break that loop we remove the flink name when the last userspace handle disappears, i.e. when obj->handle_count reaches 0. Now in gem_open we drop the dev->object_name_lock between the flink name lookup and actually adding the handle. This means a concurrent gem_close of the last handle could result in the flink name getting reaped right inbetween, i.e. Thread 1 Thread 2 gem_open gem_close flink -> obj lookup handle_count drops to 0 remove flink name create_handle handle_count++ If someone now flinks this object again, we'll get a new flink name. We can close this race by removing the lock dropping and making the entire lookup+handle_create sequence atomic. Unfortunately to still be able to share the handle_create logic this requires a handle_create_tail function which drops the lock - we can't hold the object_name_lock while calling into a driver's ->gem_open callback. Note that for flink fixing this race isn't really important, since racing gem_open against gem_close is clearly a userspace bug. And no matter how the race ends, we won't leak any references. But with dma-buf where the userspace dma-buf fd itself is refcounted this is a valid sequence and hence we should fix it. Therefore this patch here is just a warm-up exercise (and for consistency between flink buffer sharing and dma-buf buffer sharing with self-imports). Also note that this extension of the critical section in gem_open protected by dev->object_name_lock only works because it's now a mutex: A spinlock would conflict with the potential memory allocation in idr_preload(). This is exercises by igt/gem_flink_race/flink_name. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com>
2014-11-21drm/gem: switch dev->object_name_lock to a mutexDaniel Vetter2-9/+13
I want to wrap the creation of a dma-buf from a gem object in it, so that the obj->export_dma_buf cache can be atomically filled in. Instead of creating a new mutex just for that variable I've figured I can reuse the existing dev->object_name_lock, especially since the new semantics will exactly mirror the flink obj->name already protected by that lock. v2: idr_preload/idr_preload_end is now an atomic section, so need to move the mutex locking outside. [airlied: fix up conflict with patch to make debugfs use lock] Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com> Conflicts: drivers/gpu/drm/drm_info.c Change-Id: Ic4ca630b9c6092c942208ee9a04409d4f6561fc0
2014-11-21drm/gem: make drm_gem_object_handle_unreference_unlocked staticDaniel Vetter1-1/+1
No one outside of drm should use this, the official interfaces are drm_gem_handle_create and drm_gem_handle_delete. The handle refcounting is purely an implementation detail of gem. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com>
2014-11-21drm/gem: fix up flink name create raceDaniel Vetter3-13/+22
This is the 2nd attempt, I've always been a bit dissatisified with the tricky nature of the first one: http://lists.freedesktop.org/archives/dri-devel/2012-July/025451.html The issue is that the flink ioctl can race with calling gem_close on the last gem handle. In that case we'll end up with a zero handle count, but an flink name (and it's corresponding reference). Which results in a neat space leak. In my first attempt I've solved this by rechecking the handle count. But fundamentally the issue is that ->handle_count isn't your usual refcount - it can be resurrected from 0 among other things. For those special beasts atomic_t often suggest way more ordering that it actually guarantees. To prevent being tricked by those hairy semantics take the easy way out and simply protect the handle with the existing dev->object_name_lock. With that change implemented it's dead easy to fix the flink vs. gem close reace: When we try to create the name we simply have to check whether there's still officially a gem handle around and if not refuse to create the flink name. Since the handle count decrement and flink name destruction is now also protected by that lock the reace is gone and we can't ever leak the flink reference again. Outside of the drm core only the exynos driver looks at the handle count, and tbh I have no idea why (it's just for debug dmesg output luckily). I've considered inlining the drm_gem_object_handle_free, but I plan to add more name-like things (like the exported dma_buf) to this scheme, so it's clearer to leave the handle freeing in its own function. This is exercised by the new gem_flink_race i-g-t testcase, which on my snb leaks gem objects at a rate of roughly 1k objects/s. v2: Fix up the error path handling in handle_create and make it more robust by simply calling object_handle_unreference. v3: Fix up the handle_unreference logic bug - atomic_dec_and_test retursn 1 for 0. Oops. v4: Squash in inlining of drm_gem_object_handle_reference as suggested by Dave Airlie and add a note that we now have a testcase. Cc: Dave Airlie <airlied@gmail.com> Cc: Inki Dae <inki.dae@samsung.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com>
2014-11-21drm/gem: WARN about unbalanced handle refcountsDaniel Vetter1-1/+1
Trying to drop a reference we don't have is a pretty serious bug. Trying to paper over it is an even worse offense. So scream into dmesg with a big WARN in case that ever happens. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com>
2014-11-21drm/gem: remove bogus NULL check from drm_gem_object_handle_unreference_unlockedDaniel Vetter1-3/+0
Calling this function with a NULL object is simply a bug, so papering over a NULL object not a good idea. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com>
2014-11-21drm/gem: move drm_gem_object_handle_unreference_unlocked into drm_gem.cDaniel Vetter1-35/+54
We have three callers of this function now and it's neither performance critical nor really small. So an inline function feels like overkill and unecessarily separates the different parts of the code. Since all callers of drm_gem_object_handle_free are now in drm_gem.c we can make that static (and remove the unused EXPORT_SYMBOL). To avoid a forward declaration move it (and drm_gem_object_free_bug) up a bit. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com>
2014-11-21drm/gem: add shmem get/put page helpersRob Clark1-0/+103
Basically just extracting some code duplicated in gma500, omapdrm, udl, and upcoming msm driver. Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
2014-11-21drm/gem: add drm_gem_create_mmap_offset_size()Rob Clark1-4/+24
Variant of drm_gem_create_mmap_offset() which doesn't make the assumption that virtual size and physical size (obj->size) are the same. This is needed in omapdrm to deal with tiled buffers. And lets us get rid of a duplicated and slightly modified version of drm_gem_create_mmap_offset() in omapdrm. Signed-off-by: Rob Clark <robdclark@gmail.com> Reviewed-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
2014-11-21drm/gem: create drm_gem_dumb_destroyDaniel Vetter41-177/+29
All the gem based kms drivers really want the same function to destroy a dumb framebuffer backing storage object. So give it to them and roll it out in all drivers. This still leaves the option open for kms drivers which don't use GEM for backing storage, but it does decently simplify matters for gem drivers. Acked-by: Inki Dae <inki.dae@samsung.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org> Cc: Ben Skeggs <skeggsb@gmail.com> Reviwed-by: Rob Clark <robdclark@gmail.com> Cc: Alex Deucher <alexdeucher@gmail.com> Acked-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com> Conflicts: drivers/gpu/drm/rcar-du/rcar_du_drv.c Change-Id: I991aad3f0745732f203a85ff8b5f43e328c045a6
2014-11-21drm/gem: fix mmap vma size calculationsDavid Herrmann1-1/+1
The VMA manager is page-size based so drm_vma_node_size() returns the size in pages. However, drm_gem_mmap_obj() requires the size in bytes. Apply PAGE_SHIFT so we no longer get EINVAL during mmaps due to too small buffers. This bug was introduced in commit: 0de23977cfeb5b357ec884ba15417ae118ff9e9b "drm/gem: convert to new unified vma manager" Fixes i915 gtt mmap failure reported by Sedat Dilek in: Re: linux-next: Tree for Jul 25 [ call-trace: drm | drm-intel related? ] Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Reported-by: Sedat Dilek <sedat.dilek@gmail.com> Tested-by: Sedat Dilek <sedat.dilek@gmail.com> Signed-off-by: Dave Airlie <airlied@gmail.com>
2014-11-21drm/gem: convert to new unified vma managerDavid Herrmann9-181/+58
Use the new vma manager instead of the old hashtable. Also convert all drivers to use the new convenience helpers. This drops all the (map_list.hash.key << PAGE_SHIFT) non-sense. Locking and access-management is exactly the same as before with an additional lock inside of the vma-manager, which strictly wouldn't be needed for gem. v2: - rebase on drm-next - init nodes via drm_vma_node_reset() in drm_gem.c v3: - fix tegra v4: - remove duplicate if (drm_vma_node_has_offset()) checks - inline now trivial drm_vma_node_offset_addr() calls v5: - skip node-reset on gem-init due to kzalloc() - do not allow mapping gem-objects with offsets (backwards compat) - remove unneccessary casts Cc: Inki Dae <inki.dae@samsung.com> Cc: Rob Clark <robdclark@gmail.com> Cc: Dave Airlie <airlied@redhat.com> Cc: Thierry Reding <thierry.reding@gmail.com> Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Acked-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@gmail.com>
2014-11-21drm/gem: simplify object initializationDavid Herrmann6-29/+18
drm_gem_object_init() and drm_gem_private_object_init() do exactly the same (except for shmem alloc) so make the first use the latter to reduce code duplication. Also drop the return code from drm_gem_private_object_init(). It seems unlikely that we will extend it any time soon so no reason to keep it around. This simplifies code paths in drivers, too. Last but not least, fix gma500 to call drm_gem_object_release() before freeing objects that were allocated via drm_gem_private_object_init(). That isn't actually necessary for now, but might be in the future. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com> Acked-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Dave Airlie <airlied@gmail.com>
2014-11-21drm: make drm_mm_init() return voidDavid Herrmann4-21/+5
There is no reason to return "int" as this function never fails. Furthermore, several drivers (ast, sis) already depend on this. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com>
2014-11-21drm/gem: add mutex lock when using drm_gem_mmap_objYoungJun Cho3-0/+291
The drm_gem_mmap_obj() has to be protected with dev->struct_mutex, but some caller functions do not. So it adds mutex lock to missing callers and adds assertion to check whether drm_gem_mmap_obj() is called with mutex lock or not. Signed-off-by: YoungJun Cho <yj44.cho@samsung.com> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@canonical.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rob Clark <robdclark@gmail.com> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@canonical.com> Signed-off-by: Dave Airlie <airlied@redhat.com> Conflicts: drivers/gpu/drm/drm_gem_cma_helper.c drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c Change-Id: Icb683c218b3455f113c073c33166faab5a7fcc4c
2014-11-21drm/gem: Split drm_gem_mmap() into object search and object mappingLaurent Pinchart1-31/+52
The drm_gem_mmap() function first finds the GEM object to be mapped based on the fake mmap offset and then maps the object. Split the object mapping code into a standalone drm_gem_mmap_obj() function that can be used to implement dma-buf mmap() operations. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Reviewed-by: Rob Clark <robdclark@gmail.com>