aboutsummaryrefslogtreecommitdiffstats
path: root/amdgpu/amdgpu_bo.c
Commit message (Collapse)AuthorAgeFilesLines
* amdgpu: Add BO handle to table in amdgpu_bo_createMichel Dänzer2019-07-011-20/+12
| | | | | | | | | Simplifies its callers. dev->bo_table_mutex is now always held when amdgpu_bo_create is called (this was already the case in amdgpu_bo_import). Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
* amdgpu: Pass file descriptor directly to amdgpu_close_kms_handleMichel Dänzer2019-07-011-20/+15
| | | | | | | | | And propagate drmIoctl's return value. This allows replacing all remaining open-coded DRM_IOCTL_GEM_CLOSE ioctl calls with amdgpu_close_kms_handle calls. Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
* amdgpu: add a faster BO list APIMarek Olšák2019-01-161-0/+34
| | | | | Reviewed-by: Chunming Zhou <david1.zhou@amd.com> Signed-off-by: Marek Olšák <marek.olsak@amd.com>
* amdgpu: annotate public functionsLucas De Marchi2018-09-191-52/+52
| | | | | | | | | | | | | | | | | | | | | | | This was done with: nm --dynamic --defined-only build/amdgpu/libdrm_amdgpu.so | \ grep amdgpu_ | \ cut -d' ' -f3 > /tmp/a.txt while read sym; do read f func line _ <<<$(cscope -d -L -1 $sym) if [ ! -z "$f" ]; then line=$((line-1)) sed -i "${line}s/^/drm_public /" $f fi done < /tmp/a.txt Then the alignment of function arguments were manually fixed all over. The idea here will be to switch the default visibility to hidden so we don't export symbols we shouldn't. Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> Acked-by: Eric Engestrom <eric.engestrom@intel.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
* amdgpu: remove invalid check in amdgpu_bo_allocChristian König2018-09-181-7/+2
| | | | | | | | | The heap is checked by the kernel and not libdrm, to make it even worse it prevented allocating resources other than VRAM and GTT. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
* amdgpu: amdgpu_bo_inc_ref don't return dummy intQiang Yu2018-09-031-2/+1
| | | | | | Signed-off-by: Qiang Yu <Qiang.Yu@amd.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>
* amdgpu: add amdgpu_bo_inc_ref() function.Qiang Yu2018-09-031-0/+6
| | | | | | | | For Pro OGL be able to work with upstream libdrm. Signed-off-by: Qiang Yu <Qiang.Yu@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
* amdgpu: add error return value for finding bo by cpu mapping (v2)Junwei Zhang2018-09-011-2/+4
| | | | | | | | | | If nothing is found, error should be returned. v2: udpate the error value different from parameter check Signed-off-by: Junwei Zhang <Jerry.Zhang@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
* amdgpu: add a function to create amdgpu bo internally (v4)Junwei Zhang2018-08-171-105/+106
| | | | | | | | | | | a helper function to create and initialize amdgpu bo v2: update error handling: add label and free bo v3: update error handling: separate each error label v4: update error handling and rebase Signed-off-by: Junwei Zhang <Jerry.Zhang@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>
* amdgpu: free flink bo in bo importJunwei Zhang2018-08-171-0/+5
| | | | | | | | Fix potential memory leak when handle flink bo in bo import. Free the flink bo after bo import and in error handling. Signed-off-by: Junwei Zhang <Jerry.Zhang@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>
* amdgpu: Eliminate void* arithmetic in amdgpu_find_bo_by_cpu_mappingMichel Dänzer2018-08-171-2/+3
| | | | | | | | | | | | | | | | | | | | | Arithmetic using void* pointers isn't defined by the C standard, only as a GCC extension. Avoids compiler warnings: ../../amdgpu/amdgpu_bo.c: In function ‘amdgpu_find_bo_by_cpu_mapping’: ../../amdgpu/amdgpu_bo.c:554:48: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith] if (cpu >= bo->cpu_ptr && cpu < (bo->cpu_ptr + bo->alloc_size)) ^ ../../amdgpu/amdgpu_bo.c:561:23: warning: pointer of type ‘void *’ used in subtraction [-Wpointer-arith] *offset_in_bo = cpu - bo->cpu_ptr; ^ v2: Use uintptr_t instead of char*, don't change function signature (Junwei Zhang) Fixes: 4d454424e1f2 ("amdgpu: add a function to find bo by cpu mapping (v2)") Reviewed-by: Christian König <christian.koenig@amd.com> Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
* amdgpu: Use uint32_t i in amdgpu_find_bo_by_cpu_mappingMichel Dänzer2018-08-151-1/+1
| | | | | | | | | | | | | | | | | | The compiler points out that an int doesn't work as intended if dev->bo_handles.max_key > INT_MAX: ../../amdgpu/amdgpu_bo.c: In function ‘amdgpu_find_bo_by_cpu_mapping’: ../../amdgpu/amdgpu_bo.c:550:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare] for (i = 0; i < dev->bo_handles.max_key; i++) { ^ ../../amdgpu/amdgpu_bo.c:558:8: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare] if (i < dev->bo_handles.max_key) { ^ Fixes: 4d454424e1f2 ("amdgpu: add a function to find bo by cpu mapping (v2)") Reviewed-by: Christian König <christian.koenig@amd.com> Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
* amdgpu: add a function to find bo by cpu mapping (v2)Junwei Zhang2018-08-081-0/+39
| | | | | | | | | Userspace needs to know if the user memory is from BO or malloc. v2: update mutex range and rebase Signed-off-by: Junwei Zhang <Jerry.Zhang@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>
* amdgpu: add bo from user memory to handle tableJunwei Zhang2018-08-081-1/+10
| | | | | | | | When create bo from user memory, add it to handle table for future query. Signed-off-by: Junwei Zhang <Jerry.Zhang@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>
* amdgpu: always add all BOs to handle tableChristian König2018-08-071-10/+4
| | | | | | | | This way we can always find a BO structure by its handle. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-and-Tested-by: Junwei Zhang <Jerry.Zhang@amd.com>
* amdgpu: use handle table for flink namesChristian König2018-08-071-13/+13
| | | | | | | | Instead of the hash use the handle table. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-and-Tested-by: Junwei Zhang <Jerry.Zhang@amd.com>
* amdgpu: use handle table for KMS handlesChristian König2018-08-071-9/+10
| | | | | | | | Instead of the hash use the handle table. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-and-Tested-by: Junwei Zhang <Jerry.Zhang@amd.com>
* amdgpu: add amdgpu_bo_handle_type_kms_noimportMarek Olšák2018-07-251-0/+4
| | | | | Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>
* Revert "amdgpu: don't call add_handle_to_table for KMS BO exports"Michel Dänzer2018-07-111-1/+1
| | | | | | | | | | | | | This reverts commit fe0488aa13c35952b9f3f37ff2c74b6b858e8e73. It caused messages like amdgpu 0000:23:00.0: bo 000000007dce0b3e va 0x0000101800-0x000010181f conflict with 0x0000101800-0x0000101820 in dmesg, and eventually a Xorg crash while running piglit. Evidently, such BOs can actually be re-imported by other means than via a KMS handle.
* amdgpu: don't call add_handle_to_table for KMS BO exportsMarek Olšák2018-07-101-1/+1
| | | | Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
* libdrm: amdgpu: Adding DRM_RDWR flag in amdgpu_bo_exportSatyajit2018-03-221-2/+3
| | | | | | | | | | | | | Currently while exporting prime handle to fd read write access is not granted. mmap fails because of this. mmap was not supported on prime initially. Here is link to related discussion https://lists.freedesktop.org/archives/dri-devel/2017-February/131840.html Adding the DRM_RDWR flag in amdgpu_bo_export to support mmap. Signed-off-by: Satyajit <satyajit.sahu@amd.com> Acked-by: Christian König <christian.koenig@amd.com>
* meson,configure: include config.h automaticallyEric Engestrom2018-03-201-4/+0
| | | | | | | | | This will prevent any more missing `#include "config.h"` bug, at the cost of having to recompile some files that didn't need to be when changing build options. Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
* amdgpu: merge and cleanup amdgpu_bo_freeMonk Liu2017-08-081-23/+29
| | | | | | | | | | since bo_reference and bo_internal_free are all only used by bo_free, so we just merge them together Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Monk Liu <monk.liu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
* amdgpu: fix race issue between two bo functions(v2)Monk Liu2017-08-081-4/+1
| | | | | | | | | | | | | | there is race issue between two threads on amdgpu_bo_reference and amdgpu_bo_import, this patch tends to fix it by moving the pthread_mutex_lock out of bo_free_internal and move to bo_reference to cover the update_reference part. The mutex_unlock in bo_import should also cover bo refcount increasement. Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Monk Liu <monk.liu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
* amdgpu: fix missing mutex unlock before returnMonk Liu2017-08-071-0/+1
| | | | | | Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Monk Liu <monk.liu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
* amdgpu/: concisely && consistently check null ptrs in canonical formEdward O'Callaghan2017-04-191-1/+1
| | | | | | | | | | Be consistent and use the canonical form while sanity checking null pointers, also combine a few branches for brevity. v2: rebase on top of 'add amdgpu_cs_wait_fences' series. Signed-off-by: Edward O'Callaghan <funfunctor@folklore1984.net> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
* amdgpu: add REPLACE and CLEAR checking for VA op (v2)Junwei Zhang2017-04-031-1/+2
| | | | | | | | | | v2: fix indent Signed-off-by: Junwei Zhang <Jerry.Zhang@amd.com> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Acked-by: Emil Velikov <emil.velikov@collabora.com>
* amdgpu: add amdgpu_bo_va_op_rawNicolai Hähnle2017-04-031-5/+20
| | | | | | | | | | This variant allows the caller full control over flags and size, and allows passing a NULL bo (for PRT support). Cc: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Cc: Jerry Zhang <Jerry.Zhang@amd.com> Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>
* amdgpu: validate user memory for userptrChunming Zhou2016-01-201-1/+2
| | | | | Signed-off-by: Chunming Zhou <David1.Zhou@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>
* amdgpu: drop address patching logicsmonk.liu2016-01-201-10/+1
| | | | | | | we don't support non-page-aligned cpu pointer anymore Signed-off-by: monk.liu <monk.liu@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>
* amdgpu: Cleanly handle ENOMEM on result in amdgpu_bo_list_create()Tom St Denis2015-10-221-2/+9
| | | | | | | | Move the allocation of result prior to the IOCTL so we can cleanly backtrack if the allocation fails. Signed-off-by: Tom St Denis <tom.stdenis@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
* amdgpu: use EINVAL instead of EBADMSG in amdgpu_bo_cpu_unmap()Jonathan Gray2015-09-021-1/+1
| | | | | | | | | | EBADMSG is a streams errno. OpenBSD does not implement streams and does include the streams errnos, this commit fixes the build on OpenBSD. None of the callers of this function check the return value for -EBADMSG. Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
* amdgpu: serialize drmPrimeFDToHandleChristian König2015-08-251-4/+5
| | | | | | | Fixes the same problem as "intel: Serialize drmPrimeFDToHandle with struct_mutex". Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com> Signed-off-by: Christian König <christian.koenig@amd.com>
* amdgpu: hide the final internal functions from global namespaceEmil Velikov2015-08-131-1/+1
| | | | | | | | | | Thus the only symbols that we export are the ones officially provided by the API. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
* amdgpu: cosmetic chances in license boilerplateEmil Velikov2015-08-131-0/+1
| | | | | | | Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
* amdgpu: add amdgpu_bo_va_op for va map/unmap support v3Jammy Zhou2015-08-051-97/+33
| | | | | | | | | | | | The following interfaces are changed accordingly: - amdgpu_bo_alloc - amdgpu_create_bo_from_user_mem v2: update the interfaces v3: remove virtual_mc_base_address from amdgpu_bo Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>
* amdgpu: add base_preferred parameter to amdgpu_vamgr_find_vaKen Wang2015-08-051-1/+1
| | | | | | | | base_preferred parameter is added to amdgpu_vamgr_find_va so UMD can specify preferred va address when allocating. Signed-off-by: Ken Wang <Qingqing.Wang@amd.com> Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
* amdgpu: do NULL check for bo handle in amdgpu_bo_query_infoJammy Zhou2015-08-051-0/+4
| | | | | Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>
* amdgpu: cleanup VA IOCTL handlingChristian König2015-08-051-16/+16
| | | | | Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
* amdgpu: remove flink export workaround v2Christian König2015-08-051-6/+0
| | | | | | | | | Alternative solution to Mareks patch to stop causing trouble with render nodes. v2: rebased Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
* amdgpu: explicitly unmap GPU mapping on BO destructionChristian König2015-08-051-24/+57
| | | | | | | That exercises the IOCTL and stops relying us on implicit unmapping. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
* amdgpu: fix double mutex_unlock in amdgpu_bo_importMarek Olšák2015-08-051-1/+1
| | | | | | | The handles array is used below, which is followed by another unlock, so remove the first one. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
* amdgpu: use alloca and malloc in critical codepaths (v2)Marek Olšák2015-08-051-9/+21
| | | | | | | | And don't clear the memory when it's unnecessary. v2: use malloc for arrays that can be big Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
* amdgpu: allow exporting KMS handles with render nodesMarek Olšák2015-08-051-3/+5
| | | | Reviewed-by: Christian König <christian.koenig@amd.com>
* amdgpu: stop checking flag masksChristian König2015-08-051-2/+2
| | | | | | | | The kernel is responsible for parameter checking, not libdrm. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Monk Liu <monk.liu@amd.com>
* amdgpu: make vamgr globalKen Wang2015-08-051-2/+2
| | | | | | | | | This is the first sub-patch of va interface task, the va task is about adding more va management interfaces for UMD, by design, the vamgr should be per-process rather than per-device. Signed-off-by: Ken Wang <Qingqing.Wang@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>
* amdgpu: add helper for VM mapping v2Christian König2015-08-051-62/+44
| | | | | | | | Less code and also provides the map_size parameter. v2: Also set offset_in_bo, use *_handle defines. Signed-off-by: Christian König <christian.koenig@amd.com>
* amdgpu: remove bo_vas hash table v2Christian König2015-08-051-11/+0
| | | | | | | | Not used any more. v2: Keep accidental removed lines. Signed-off-by: Christian König <christian.koenig@amd.com>
* amdgpu: add amdgpu_bo_list_update interface v2Jammy Zhou2015-08-051-0/+35
| | | | | | | | v2: some minor improvement Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>
* amdgpu: replace alloca with calloc v2Jammy Zhou2015-08-051-3/+8
| | | | | | | | | | | use heap memory instead of stack memory to avoid potential stack overflow when a large number of resources are used for the bo_list. v2: some minor improvement Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>