aboutsummaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/exynos/exynos_drm_gem.c
AgeCommit message (Collapse)AuthorFilesLines
2015-09-30drm/exynos: cleanup line feed in exynos_drm_gem_get_ioctlJoonyoung Shim1-1/+2
The beginning of statement in function is next line of a brace. Signed-off-by: Joonyoung Shim <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2015-09-30drm/exynos: cleanup function calling written twiceJoonyoung Shim1-33/+23
By if statment, some function callings are written twice. It needs several line feed by indentation in if statment. Make to one function calling from outside if statment. Signed-off-by: Joonyoung Shim <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2015-09-30drm/exynos: staticize exynos_drm_gem_init()Joonyoung Shim1-2/+1
The exynos_drm_gem_init() is used only in exynos_drm_gem.c file. Make it static and don't export it. Signed-off-by: Joonyoung Shim <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2015-09-30drm/exynos: remove unnecessary NULL assignmentJoonyoung Shim1-3/+0
They will be freed right or was freed already, so NULL assignment is unnecessary. Signed-off-by: Joonyoung Shim <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2015-09-30drm/exynos: fix missed calling of drm_prime_gem_destroy()Joonyoung Shim1-4/+5
When obj->import_attach is existed, code calling drm_prime_gem_destroy() was removed from commit 67e93c808b48 ("drm/exynos: stop copying sg table"), and it's a fault. The drm_prime_gem_destroy() is cleanup function which GEM drivers need to call when they use drm_gem_prime_import() to import dma-bufs, so exynos-drm driver using drm_gem_prime_import() needs calling drm_prime_gem_destroy(). Signed-off-by: Joonyoung Shim <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2015-09-30drm/exynos: fix layering violation of addressJoonyoung Shim1-1/+2
There is no guarantee that DMA addresses are the same as physical addresses, but dma_to_pfn() knows how to convert a dma_addr_t to a PFN which can then be converted to a struct page. Suggested-by: Russell King <[email protected]> Signed-off-by: Joonyoung Shim <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2015-09-11Merge tag 'media/v4.3-2' of ↵Linus Torvalds1-97/+0
git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media Pull media updates from Mauro Carvalho Chehab: "A series of patches that move part of the code used to allocate memory from the media subsystem to the mm subsystem" [ The mm parts have been acked by VM people, and the series was apparently in -mm for a while - Linus ] * tag 'media/v4.3-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: [media] drm/exynos: Convert g2d_userptr_get_dma_addr() to use get_vaddr_frames() [media] media: vb2: Remove unused functions [media] media: vb2: Convert vb2_dc_get_userptr() to use frame vector [media] media: vb2: Convert vb2_vmalloc_get_userptr() to use frame vector [media] media: vb2: Convert vb2_dma_sg_get_userptr() to use frame vector [media] vb2: Provide helpers for mapping virtual addresses [media] media: omap_vout: Convert omap_vout_uservirt_to_phys() to use get_vaddr_pfns() [media] mm: Provide new get_vaddr_frames() helper [media] vb2: Push mmap_sem down to memops
2015-08-31drm/exynos: fix build warning to exynos_drm_gem.cInki Dae1-1/+1
Signed-off-by: Inki Dae <[email protected]>
2015-08-16[media] drm/exynos: Convert g2d_userptr_get_dma_addr() to use get_vaddr_frames()Jan Kara1-97/+0
Convert g2d_userptr_get_dma_addr() to pin pages using get_vaddr_frames(). This removes the knowledge about vmas and mmap_sem locking from exynos driver. Also it fixes a problem that the function has been mapping user provided address without holding mmap_sem. Acked-by: Inki Dae <[email protected]> Signed-off-by: Jan Kara <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
2015-08-16drm/exynos: merge exynos_drm_buf.c to exynos_drm_gem.cJoonyoung Shim1-74/+135
The struct exynos_drm_gem_obj can have fields of the struct exynos_drm_gem_buf then don't need to use exynos_drm_buf.c file. Signed-off-by: Joonyoung Shim <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2015-08-16drm/exynos: use prime helpersJoonyoung Shim1-0/+79
The dma-buf codes of exynos drm is almost same with prime helpers. A difference is that consider DMA_NONE when import dma-buf, but it's wrong and we don't consider it any more, so we can use prime interface. Signed-off-by: Joonyoung Shim <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2015-08-16drm/exynos: remove function roundup_gem_sizeJoonyoung Shim1-8/+1
The function roundup_gem_size can be merged in exynos_drm_gem_create. Signed-off-by: Joonyoung Shim <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2015-08-16drm/exynos: remove function update_vm_cache_attrJoonyoung Shim1-17/+11
The function update_vm_cache_attr can be merged in exynos_drm_gem_mmap. Signed-off-by: Joonyoung Shim <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2015-08-16drm/exynos: remove function check_gem_flagsJoonyoung Shim1-18/+5
The function check_gem_flags is too simple, so it's better to move codes in each consumer functions. Signed-off-by: Joonyoung Shim <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2015-08-16drm/exynos: use ERR_PTR instead of NULL in exynos_drm_gem_initJoonyoung Shim1-4/+4
For more correct error information. Signed-off-by: Joonyoung Shim <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2015-08-16drm/exynos: stop copying sg tableJoonyoung Shim1-3/+0
Already struct exynos_drm_gem_buf has pages of the buffer, so we don't need to copy from sg table of the buffer to sg table of dma-buf attachment, just can make sg table from pages of the buffer. Signed-off-by: Joonyoung Shim <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2015-08-16drm/exynos: remove function exynos_drm_gem_map_bufJoonyoung Shim1-24/+12
The exynos_drm_gem_map_buf can be merged in exynos_drm_gem_fault. Signed-off-by: Joonyoung Shim <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2015-08-16drm/exynos: remove mutex locking in pagefault handlerJoonyoung Shim1-5/+0
There is no reason to use mutex locking in pagefault handler. Signed-off-by: Joonyoung Shim <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2015-08-16drm/exynos: remove function convert_to_vm_err_msgJoonyoung Shim1-24/+10
The convert_to_vm_err_msg is called just once by exynos_drm_gem_fault, so it's simple not to use the function. Signed-off-by: Joonyoung Shim <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2015-08-16drm/exynos: stop using sgtable in page fault handlerJoonyoung Shim1-13/+1
Already struct exynos_drm_gem_buf has pages of the buffer when buffer is created, so just can use pages in page fault handler, we don't have to make sgtable of the buffer. But this needs to construct pages of the buffer that is imported from dma-buf prime. Signed-off-by: Joonyoung Shim <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2014-09-20drm/exynos: use drm generic mmap interfaceInki Dae1-73/+16
This patch removes DRM_EXYNOS_GEM_MMAP ictrl feature specific to Exynos drm and instead uses drm generic mmap. We had used the interface specific to Exynos drm to do mmap directly, not to use demand paging which maps each page with physical memory at page fault handler. We don't need the specific mmap interface because the drm generic mmap which uses vm offset manager stuff can also do mmap directly. This patch makes a userspace region to be mapped with whole physical memory region allocated by userspace request when mmap system call is requested. Changelog v2: - do not set VM_IO, VM_DONTEXPEND and VM_DONTDUMP. These flags were already set by drm_gem_mmap - do not include <linux/anon_inodes.h>, which isn't needed anymore. Signed-off-by: Inki Dae <[email protected]>
2014-09-20drm/exynos: remove DRM_EXYNOS_GEM_MAP_OFFSET ioctlInki Dae1-17/+0
This interface and relevant codes aren't used anymore. Signed-off-by: Inki Dae <[email protected]>
2014-08-03drm/exynos: Remove unused variable in exynos_drm_gem.cSachin Kamat1-3/+0
'exynos_gem_obj' is not used in the function. Remove it. Signed-off-by: Sachin Kamat <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2014-06-02drm/exynos: allocate non-contigous buffers when iommu is enabledRahul Sharma1-12/+10
Allow to allocate non-contigous buffers when iommu is enabled. Currently, it tries to allocates contigous buffer which consistently fail for large buffers and then fall back to non contigous. Apart from being slow, this implementation is also very noisy and fills the screen with alloc fail logs. Signed-off-by: Rahul Sharma <[email protected]> Reviewed-by: Sachin Kamat <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2014-01-29Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linuxLinus Torvalds1-61/+13
Pull drm updates from Dave Airlie: "Been a bit busy, first week of kids school, and waiting on other trees to go in before I could send this, so its a bit later than I'd normally like. Highlights: - core: timestamp fixes, lots of misc cleanups - new drivers: bochs virtual vga - vmwgfx: major overhaul for their nextgen virt gpu. - i915: runtime D3 on HSW, watermark fixes, power well work, fbc fixes, bdw is no longer prelim. - nouveau: gk110/208 acceleration, more pm groundwork, old overlay support - radeon: dpm rework and clockgating for CIK, pci config reset, big endian fixes - tegra: panel support and DSI support, build as module, prime. - armada, omap, gma500, rcar, exynos, mgag200, cirrus, ast: fixes - msm: hdmi support for mdp5" * 'drm-next' of git://people.freedesktop.org/~airlied/linux: (595 commits) drm/nouveau: resume display if any later suspend bits fail drm/nouveau: fix lock unbalance in nouveau_crtc_page_flip drm/nouveau: implement hooks for needed for drm vblank timestamping support drm/nouveau/disp: add a method to fetch info needed by drm vblank timestamping drm/nv50: fill in crtc mode struct members from crtc_mode_fixup drm/radeon/dce8: workaround for atom BlankCrtc table drm/radeon/DCE4+: clear bios scratch dpms bit (v2) drm/radeon: set si_notify_smc_display_change properly drm/radeon: fix DAC interrupt handling on DCE5+ drm/radeon: clean up active vram sizing drm/radeon: skip async dma init on r6xx drm/radeon/runpm: don't runtime suspend non-PX cards drm/radeon: add ring to fence trace functions drm/radeon: add missing trace point drm/radeon: fix VMID use tracking drm: ast,cirrus,mgag200: use drm_can_sleep drm/gma500: Lock struct_mutex around cursor updates drm/i915: Fix the offset issue for the stolen GEM objects DRM: armada: fix missing DRM_KMS_FB_HELPER select drm/i915: Decouple GPU error reporting from ring initialisation ...
2014-01-07drm/exynos: use a new anon file for exynos gem mmaperInki Dae1-61/+13
This patch resolves potential deadlock issue that can be incurred by changing file->f_op and filp->private_data to exynos specific mapper ops and gem object temporarily. To resolve this issue, this patch creates a new anon file dedicated to exynos specific mmaper, and making it used instead of existing one. Signed-off-by: Inki Dae <[email protected]> Signed-off-by: Kyungmin Park <[email protected]>
2013-12-19Merge branch 'master' into for-nextJiri Kosina1-5/+0
Sync with Linus' tree to be able to apply fixes on top of newer things in tree (efi-stub). Signed-off-by: Jiri Kosina <[email protected]>
2013-12-02drm: fix typos in comment in /gpu/drm/exynosMasanari Iida1-1/+1
Correct spelling typo in drivers/gpu/drm/exynos Signed-off-by: Masanari Iida <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
2013-10-09drm: kill ->gem_init_object() and friendsDavid Herrmann1-5/+0
All drivers embed gem-objects into their own buffer objects. There is no reason to keep drm_gem_object_alloc(), gem->driver_private and ->gem_init_object() anymore. New drivers are highly encouraged to do the same. There is no benefit in allocating gem-objects separately. Cc: Dave Airlie <[email protected]> Cc: Alex Deucher <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Jerome Glisse <[email protected]> Cc: Rob Clark <[email protected]> Cc: Inki Dae <[email protected]> Cc: Ben Skeggs <[email protected]> Cc: Patrik Jakobsson <[email protected]> Signed-off-by: David Herrmann <[email protected]> Acked-by: Alex Deucher <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2013-09-05drm/exynos: Consider fallback option to allocation failVikas Sajjan1-0/+13
To address the case where physically contiguous memory MAY NOT be a mandatory requirement for framebuffer for the application calling exynos_drm_gem_dumb_create, the patch adds a feature to get non physically contiguous memory for framebuffer, if physically contiguous memory allocation fails and if IOMMU is supported. Signed-off-by: Vikas Sajjan <[email protected]> Signed-off-by: Arun Kumar <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2013-09-05drm/exynos: Remove redundant error messagesSachin Kamat1-3/+1
kzalloc already has built-in error messages. Hence remove additional ones. Signed-off-by: Sachin Kamat <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2013-08-21drm/gem: fix up flink name create raceDaniel Vetter1-1/+1
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 <[email protected]> Cc: Inki Dae <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2013-08-07drm/gem: create drm_gem_dumb_destroyDaniel Vetter1-20/+0
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 <[email protected]> Acked-by: Laurent Pinchart <[email protected]> Cc: Intel Graphics Development <[email protected]> Cc: Ben Skeggs <[email protected]> Reviwed-by: Rob Clark <[email protected]> Cc: Alex Deucher <[email protected]> Acked-by: Patrik Jakobsson <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2013-07-25drm/gem: convert to new unified vma managerDavid Herrmann1-8/+6
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 <[email protected]> Cc: Rob Clark <[email protected]> Cc: Dave Airlie <[email protected]> Cc: Thierry Reding <[email protected]> Signed-off-by: David Herrmann <[email protected]> Acked-by: Patrik Jakobsson <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
2013-07-04drm/exynos: fix not to remain exynos_gem_obj as a leakYoungJun Cho1-4/+5
The exynos_drm_gem_create() only calls drm_gem_object_release() when exynos_drm_alloc_buf() is failed, and exynos_gem_obj remains as a leak, which is allocated in exynos_drm_gem_init(). So this patch fixes it not to remain as a leak. Signed-off-by: YoungJun Cho <[email protected]> Signed-off-by: Seung-Woo Kim <[email protected]> Signed-off-by: Kyungmin Park <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2013-06-28drm/exynos: make sure to handle an error case to vm_mmap callInki Dae1-3/+3
vm_mmap function returns unsigned long so addr type should be unsigned long. a pointer or address variable is required to use unsigned long or uint64_t type for 64bits address support. So this patch makes sure that addr has unsigned long type and also exynos_drm_gem_mmap_ioctl returns correct error type. Signed-off-by: Inki Dae <[email protected]> Signed-off-by: Kyungmin Park <[email protected]>
2013-06-28drm/exynos: Remove tracking log functionsYoungJun Cho1-23/+0
This patch removes tracking log functions which were used to debug in the early development stage and are not so important as were. So remove them for code clean up. Signed-off-by: YoungJun Cho <[email protected]> Signed-off-by: Seung-Woo Kim <[email protected]> Signed-off-by: Inki Dae <[email protected]>
2013-04-29drm/exynos: do not use generic flags to dumbInki Dae1-1/+2
This patch removes the use of dumb flags from driver. As Dave pointed out, the dumb flags are not driver specific so this should be removed from driver. Signed-off-by: Inki Dae <[email protected]> Signed-off-by: Kyungmin Park <[email protected]>
2013-03-20drm/exynos: Add a new function to get gem buffer sizeInki Dae1-0/+21
This patch adds a new function to get gem buffer size. And this funtion could be used for g2d driver or others can get gem buffer size to check if the buffer is valid or not. Signed-off-by: Inki Dae <[email protected]> Signed-off-by: Kyungmin Park <[email protected]>
2013-02-21drm/exynos: fix wrong pointer access at vm close.YoungJun Cho1-12/+21
This patch fixes wrong pointer access issue to filp->f_op and filp->private_data. The exynos_drm_gem_mmap_ioctl() changes filp->f_op and filp->private_data temporarily and restore them to use original ones in exynos_drm_gem_mmap_buffer() but there was no lock between the changing and the restoring so wrong pointer access to filp->f_op and filp->private_data was induced by vm close callback. So this patch uses mutex lock properly to resolve this issue. Signed-off-by: YoungJun Cho <[email protected]> Signed-off-by: Inki Dae <[email protected]> Signed-off-by: Kyungmin Park <[email protected]>
2013-01-04drm/exynos: change file license to GPLInki Dae1-18/+4
This patch changes file license to GPL Most of exynos files had been copied from some random file and not updated correctly. So this patch corrects the file license. Signed-off-by: Inki Dae <[email protected]> Signed-off-by: Kyungmin Park <[email protected]>
2012-12-13drm/exynos: use DMA_ATTR_NO_KERNEL_MAPPING attributeInki Dae1-1/+1
Changelog v3: just code cleanup. Changelog v2: fix argument to dma_mmap_attr function. - use pages instead of kvaddr because kvaddr is 0 with DMA_ATTR_NO_KERNEL_MAPPING. Changelog v1: When gem allocation is requested, kernel space mapping isn't needed. But if need, such as console framebuffer, the physical pages would be mapped with kernel space though vmap function. Signed-off-by: Inki Dae <[email protected]> Signed-off-by: Kyungmin Park <[email protected]>
2012-12-05drm/exynos: remove 'pages' and 'page_size' elements in exynos gem bufferPrathyush K1-24/+13
Changelog v2: Removed redundant check for invalid sgl. Added check for valid page_offset in the beginning of exynos_drm_gem_map_buf. Changelog v1: The 'pages' structure is not required since we can use the 'sgt'. Even for CONTIG buffers, a SGT is created (which will have just one sgl). This SGT can be used during mmap instead of 'pages'. The 'page_size' element of the structure is also not used anywhere and is removed. This patch also fixes a memory leak where the 'pages' structure was being allocated during gem buffer allocation but not being freed during deallocate. Signed-off-by: Prathyush K <[email protected]> Signed-off-by: Inki Dae <[email protected]> Signed-off-by: Kyungmin Park <[email protected]>
2012-12-04drm/exynos: add vm_ops to specific gem mmaperInki Dae1-5/+70
Changelog v3: use drm_file's file object instead of gem object's - gem object's file represents the shmem storage so process-unique file object should be used instead. Changelog v2: call mutex_lock before drm_vm_open_locked is called. Changelog v1: This patch makes it takes a reference to gem object when specific gem mmap is requested. For this, it sets dev->driver->gem_vm_ops to vma->vm_ops. And this patch is based on exynos-drm-next-iommu branch of git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos Signed-off-by: Inki Dae <[email protected]> Signed-off-by: Kyungmin Park <[email protected]>
2012-12-04drm/exynos: add userptr feature for g2d moduleInki Dae1-0/+123
This patch adds userptr feautre for G2D module. The userptr means user space address allocated by malloc(). And the purpose of this feature is to make G2D's dma able to access the user space region. To user this feature, user should flag G2D_BUF_USRPTR to offset variable of struct drm_exynos_g2d_cmd and fill struct drm_exynos_g2d_userptr with user space address and size for it and then should set a pointer to drm_exynos_g2d_userptr object to data variable of struct drm_exynos_g2d_cmd. The last bit of offset variable is used to check if the cmdlist's buffer type is userptr or not. If userptr, the g2d driver gets user space address and size and then gets pages through get_user_pages(). (another case is counted as gem handle) Below is sample codes: static void set_cmd(struct drm_exynos_g2d_cmd *cmd, unsigned long offset, unsigned long data) { cmd->offset = offset; cmd->data = data; } static int solid_fill_test(int x, int y, unsigned long userptr) { struct drm_exynos_g2d_cmd cmd_gem[5]; struct drm_exynos_g2d_userptr g2d_userptr; unsigned int gem_nr = 0; ... g2d_userptr.userptr = userptr; g2d_userptr.size = x * y * 4; set_cmd(&cmd_gem[gem_nr++], DST_BASE_ADDR_REG | G2D_BUF_USERPTR, (unsigned long)&g2d_userptr); ... } int main(int argc, char **argv) { unsigned long addr; ... addr = malloc(x * y * 4); ... solid_fill_test(x, y, addr); ... } And next, the pages are mapped with iommu table and the device address is set to cmdlist so that G2D's dma can access it. As you may know, the pages from get_user_pages() are pinned. In other words, they CAN NOT be migrated and also swapped out. So the dma access would be safe. But the use of userptr feature has performance overhead so this patch also has memory pool to the userptr feature. Please, assume that user sends cmdlist filled with userptr and size every time to g2d driver, and the get_user_pages funcion will be called every time. The memory pool has maximum 64MB size and the userptr that user had ever sent, is holded in the memory pool. This meaning is that if the userptr from user is same as one in the memory pool, device address to the userptr in the memory pool is set to cmdlist. And last, the pages from get_user_pages() will be freed once user calls free() and the dma access is completed. Actually, get_user_pages() takes 2 reference counts if the user process has never accessed user region allocated by malloc(). Then, if the user calls free(), the page reference count becomes 1 and becomes 0 with put_page() call. And the reverse holds as well. This means how the pages backed are used by dma and freed. This patch is based on "drm/exynos: add iommu support for g2d", https://patchwork.kernel.org/patch/1629481/ Signed-off-by: Inki Dae <[email protected]> Signed-off-by: Kyungmin Park <[email protected]>
2012-12-04drm: exynos: fix for mapping of dma buffersRahul Sharma1-3/+25
This patch fixes the problem of mapping contigous and non contigous dma buffers. Currently page struct is calculated from the buf->dma_addr which is not the physical address. It is replaced by buf->pages which points to the page struct of the first page of contigous memory chunk. This gives the correct page frame number for mapping. Non-contigous dma buffers are described using SG table and SG lists. Each valid SG List is pointing to a single page or group of pages which are physically contigous. Current implementation just maps the first page of each SG List and leave the other pages unmapped, leading to a crash. Given solution finds the page struct for the faulting page through parsing SG table and map it. Signed-off-by: Rahul Sharma <[email protected]> Signed-off-by: Inki Dae <[email protected]> Signed-off-by: Kyungmin Park <[email protected]>
2012-12-04drm/exynos: remove EXYNOS_BO_NONCONTIG type checking.Inki Dae1-16/+0
With iommu support, non-continuous buffer also is supported so this patch removes these checking from exynos_drm_gem_get/put_dma_addr funciton. This patch is based on the below patch set, "drm/exynos: add iommu support for -next". http://www.spinics.net/lists/dri-devel/msg29041.html Signed-off-by: Inki Dae <[email protected]> Signed-off-by: Kyungmin Park <[email protected]>
2012-12-04drm/exynos: add iommu support for g2dInki Dae1-5/+5
Chagelog v2: removed unnecessary structure, struct g2d_gem_node. Chagelog v1: This patch adds iommu support for g2d driver. For this, it adds subdrv_probe/remove callback to enable or disable g2d iommu. And with this patch, in case of using g2d iommu, we can get or put device address to a gem handle from user through exynos_drm_gem_get/put_dma_addr(). Actually, these functions take a reference to a gem handle so that the gem object used by g2d dma is released properly. And runqueue_node has a pointer to drm_file object of current process to manage gem handles to owner. This patch is based on the below patch set, "drm/exynos: add iommu support for -next". http://www.spinics.net/lists/dri-devel/msg29041.html Signed-off-by: Inki Dae <[email protected]> Signed-off-by: Kyungmin Park <[email protected]>
2012-11-29drm/exynos: add iommu support for exynos drm frameworkInki Dae1-195/+15
Changelog v4: - fix condition to drm_iommu_detach_device funtion. Changelog v3: - add dma_parms->max_segment_size setting of drm_device->dev. - use devm_kzalloc instead of kzalloc. Changelog v2: - fix iommu attach condition. . check archdata.dma_ops of drm device instead of subdrv device's one. - code clean to exynos_drm_iommu.c file. . remove '#ifdef CONFIG_ARM_DMA_USE_IOMMU' from exynos_drm_iommu.c and add it to driver/gpu/drm/exynos/Kconfig. Changelog v1: This patch adds iommu support for exynos drm framework with dma mapping api. In this patch, we used dma mapping api to allocate physical memory and maps it with iommu table and removed some existing codes and added new some codes for iommu support. GEM allocation requires one device object to use dma mapping api so this patch uses one iommu mapping for all sub drivers. In other words, all sub drivers have same iommu mapping. Signed-off-by: Inki Dae <[email protected]> Signed-off-by: Kyungmin Park <[email protected]>
2012-10-09mm: kill vma flag VM_RESERVED and mm->reserved_vm counterKonstantin Khlebnikov1-1/+1
A long time ago, in v2.4, VM_RESERVED kept swapout process off VMA, currently it lost original meaning but still has some effects: | effect | alternative flags -+------------------------+--------------------------------------------- 1| account as reserved_vm | VM_IO 2| skip in core dump | VM_IO, VM_DONTDUMP 3| do not merge or expand | VM_IO, VM_DONTEXPAND, VM_HUGETLB, VM_PFNMAP 4| do not mlock | VM_IO, VM_DONTEXPAND, VM_HUGETLB, VM_PFNMAP This patch removes reserved_vm counter from mm_struct. Seems like nobody cares about it, it does not exported into userspace directly, it only reduces total_vm showed in proc. Thus VM_RESERVED can be replaced with VM_IO or pair VM_DONTEXPAND | VM_DONTDUMP. remap_pfn_range() and io_remap_pfn_range() set VM_IO|VM_DONTEXPAND|VM_DONTDUMP. remap_vmalloc_range() set VM_DONTEXPAND | VM_DONTDUMP. [[email protected]: drivers/vfio/pci/vfio_pci.c fixup] Signed-off-by: Konstantin Khlebnikov <[email protected]> Cc: Alexander Viro <[email protected]> Cc: Carsten Otte <[email protected]> Cc: Chris Metcalf <[email protected]> Cc: Cyrill Gorcunov <[email protected]> Cc: Eric Paris <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Morris <[email protected]> Cc: Jason Baron <[email protected]> Cc: Kentaro Takeda <[email protected]> Cc: Matt Helsley <[email protected]> Cc: Nick Piggin <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Robert Richter <[email protected]> Cc: Suresh Siddha <[email protected]> Cc: Tetsuo Handa <[email protected]> Cc: Venkatesh Pallipadi <[email protected]> Acked-by: Linus Torvalds <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>