Commit Graph

35 Commits (361d4bffd322f2743f8b5ce4a81ed0482105afac)

Author SHA1 Message Date
Eric Engestrom 0926f0af54 meson,configure: include config.h automatically
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>
2018-03-20 18:19:26 +00:00
Monk Liu 687d250797 amdgpu: merge and cleanup amdgpu_bo_free
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>
2017-08-08 12:16:20 -04:00
Monk Liu 2a89ae5d7a amdgpu: fix race issue between two bo functions(v2)
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>
2017-08-08 12:00:11 -04:00
Monk Liu 4d24415594 amdgpu: fix missing mutex unlock before return
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>
2017-08-07 15:00:06 -04:00
Edward O'Callaghan 7cfcd5ef4b amdgpu/: concisely && consistently check null ptrs in canonical form
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>
2017-04-19 18:08:10 +10:00
Junwei Zhang eead591107 amdgpu: add REPLACE and CLEAR checking for VA op (v2)
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>
2017-04-03 18:32:12 +02:00
Nicolai Hähnle 4e369f25a9 amdgpu: add amdgpu_bo_va_op_raw
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>
2017-04-03 10:11:24 +02:00
Chunming Zhou f06c992819 amdgpu: validate user memory for userptr
Signed-off-by: Chunming Zhou <David1.Zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
2016-01-20 02:14:46 +01:00
monk.liu 50386e09db amdgpu: drop address patching logics
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>
2016-01-20 02:14:46 +01:00
Tom St Denis b176372af4 amdgpu: Cleanly handle ENOMEM on result in amdgpu_bo_list_create()
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>
2015-10-22 12:36:55 -04:00
Jonathan Gray 949c325c50 amdgpu: use EINVAL instead of EBADMSG in amdgpu_bo_cpu_unmap()
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>
2015-09-02 10:00:25 -04:00
Christian König a5ea0c64c5 amdgpu: serialize drmPrimeFDToHandle
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>
2015-08-25 10:27:45 -04:00
Emil Velikov bddf4df4a1 amdgpu: hide the final internal functions from global namespace
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>
2015-08-13 17:43:36 +01:00
Emil Velikov a30da8e9b3 amdgpu: cosmetic chances in license boilerplate
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>
2015-08-13 17:43:27 +01:00
Jammy Zhou 8aeffcc1cf amdgpu: add amdgpu_bo_va_op for va map/unmap support v3
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>
2015-08-05 13:47:52 -04:00
Ken Wang 5b01908d1c amdgpu: add base_preferred parameter to amdgpu_vamgr_find_va
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>
2015-08-05 13:47:52 -04:00
Jammy Zhou bef8b6097c amdgpu: do NULL check for bo handle in amdgpu_bo_query_info
Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
2015-08-05 13:47:51 -04:00
Christian König 933091e1d6 amdgpu: cleanup VA IOCTL handling
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-08-05 13:47:51 -04:00
Christian König 804048ff65 amdgpu: remove flink export workaround v2
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>
2015-08-05 13:47:51 -04:00
Christian König 9f16c733f1 amdgpu: explicitly unmap GPU mapping on BO destruction
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>
2015-08-05 13:47:51 -04:00
Marek Olšák 201b09a443 amdgpu: fix double mutex_unlock in amdgpu_bo_import
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>
2015-08-05 13:47:51 -04:00
Marek Olšák 34e1250e37 amdgpu: use alloca and malloc in critical codepaths (v2)
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>
2015-08-05 13:47:51 -04:00
Marek Olšák 908f34e70c amdgpu: allow exporting KMS handles with render nodes
Reviewed-by: Christian König <christian.koenig@amd.com>
2015-08-05 13:47:51 -04:00
Christian König 942a5dbe6c amdgpu: stop checking flag masks
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>
2015-08-05 13:47:50 -04:00
Ken Wang 322d02d025 amdgpu: make vamgr global
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>
2015-08-05 13:47:50 -04:00
Christian König 12a23b1964 amdgpu: add helper for VM mapping v2
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>
2015-08-05 13:47:50 -04:00
Christian König d5c0b2a172 amdgpu: remove bo_vas hash table v2
Not used any more.

v2: Keep accidental removed lines.

Signed-off-by: Christian König <christian.koenig@amd.com>
2015-08-05 13:47:50 -04:00
Jammy Zhou 7244698ddc amdgpu: add amdgpu_bo_list_update interface v2
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>
2015-08-05 13:47:50 -04:00
Jammy Zhou 3f1ca0f939 amdgpu: replace alloca with calloc v2
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>
2015-08-05 13:47:49 -04:00
Jammy Zhou 241cf6d105 amdgpu: validate the upper limit of virtual address v2
Only 8GB virtual address space is used by default now

v2: use -ENOSPC for the error case

Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
2015-08-05 13:47:49 -04:00
Jammy Zhou 14070057d8 amdgpu: fix 32-on-64 support (v2)
0xffffffff was appended to the higher 32bit with (intptr_t) when use
32bit libdrm_amdgpu.so with 64bit kernel, and it caused segmentation
fault for 32bit application.

v2: switch to uintptr_t

Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2015-08-05 13:47:49 -04:00
Christian König 6dc2eaf2cc amdgpu: add public bo list interface v3
v2: cleanup comments and function parameter
v3: rebased on internal branch

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2015-08-05 13:47:49 -04:00
monk.liu cc01c3cb5a amdgpu: add missing mutex lock/unlock pair
Signed-off-by: monk.liu <monk.liu@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2015-08-05 13:47:48 -04:00
monk.liu 2f2c8ac0f4 amdgpu: support non-page-aligned userptr
Signed-off-by: monk.liu <monk.liu@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2015-08-05 13:47:48 -04:00
Alex Deucher 0936139536 drm: add libdrm_amdgpu (v7)
This is the new ioctl wrapper used by the new admgpu driver.
It's primarily used by xf86-video-amdgpu and mesa.

v2: fix amdgpu_drm.h install
v3: Integrate some of the sugestions from Emil:
    clean up Makefile.am, configure.ac
    capitalize header guards
    fix _FILE_OFFSET_BITS with config.h
    use drm_mmap/drm_munmap
    Remove unused ARRAY_SIZE macro
    use shared list implementation
    use shared math implementation
    use drmGetNodeTypeFromFd helper
v4: remove unused tiling defines
v5: include amdgpu.h in Makefile.am
v6: update amdgpu_drm.h
v7: libdrm.h -> libdrm_macros.h

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2015-08-05 13:47:48 -04:00