Commit Graph

206 Commits (597725e9511f8c0405fdd8d92d749bce58c0bce3)

Author SHA1 Message Date
Emil Velikov 99c3540dd4 *-symbols-check: error out when using unset variables
It will make bugs like the one fixed with previous patch dead obvious.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
2018-10-04 14:39:27 +01:00
Emil Velikov 660643e498 automake: set NM before running the tests
Set/export the NM variable since it may not be set already.

Fixes: 4f08bfe96d ("*-symbol-check: Don't hard-code nm executable")
Cc: Heiko Becker <heirecka@exherbo.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
2018-10-04 14:39:06 +01:00
Lucas De Marchi 1e3fcc495b autotools: make symbols hidden by default
Now that symbols that should be exported are annotated accordingly, make
all the rest hidden by default.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Acked-by: Eric Engestrom <eric.engestrom@intel.com>
2018-09-19 22:46:45 -07:00
Lucas De Marchi ba808253bc meson: make symbols hidden by default
Now that symbols that should be exported are annotated accordingly, make
all the rest hidden by default.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
2018-09-19 22:46:45 -07:00
Lucas De Marchi e15e3a65b8 amdgpu: annotate public functions
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>
2018-09-19 22:46:45 -07:00
Christian König c40bd3cbf8 amdgpu: remove invalid check in amdgpu_bo_alloc
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>
2018-09-18 14:53:30 +02:00
Qiang Yu 580bd83fb4 amdgpu: amdgpu_bo_inc_ref don't return dummy int
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>
2018-09-03 12:37:32 +02:00
Qiang Yu 937d62ea69 amdgpu: add amdgpu_bo_inc_ref() function.
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>
2018-09-03 10:55:53 +02:00
Junwei Zhang f177251088 amdgpu: add error return value for finding bo by cpu mapping (v2)
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>
2018-09-01 11:57:34 +02:00
Michel Dänzer f3d90e8db4 amdgpu-symbol-check: Add amdgpu_find_bo_by_cpu_mapping
Fixes: 4d454424e1 ("amdgpu: add a function to find bo by cpu mapping
                      (v2)"
2018-08-27 11:50:55 +02:00
Junwei Zhang f31fd57c60 amdgpu: add a function to create amdgpu bo internally (v4)
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>
2018-08-17 12:55:11 +02:00
Junwei Zhang 3d8b6ea664 amdgpu: free flink bo in bo import
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>
2018-08-17 12:54:36 +02:00
Michel Dänzer c6493f360e amdgpu: Eliminate void* arithmetic in amdgpu_find_bo_by_cpu_mapping
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: 4d454424e1 ("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>
2018-08-17 09:12:42 +02:00
Christian König bc4c9f4422 amdgpu: fix off by one in handle_table_insert
Stupid me, max_key must always be larger than key.

Signed-off-by: Christian König <christian.koenig@amd.com>
Bugzilla: https://bugs.freedesktop.org/107552
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
2018-08-16 08:50:04 +02:00
Michel Dänzer 1e12c16d76 amdgpu: Use uint32_t i in amdgpu_find_bo_by_cpu_mapping
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: 4d454424e1 ("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>
2018-08-15 10:34:59 +02:00
Junwei Zhang 4d454424e1 amdgpu: add a function to find bo by cpu mapping (v2)
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>
2018-08-08 12:37:49 +02:00
Junwei Zhang f49dccbb24 amdgpu: add bo from user memory to handle table
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>
2018-08-08 12:37:49 +02:00
Mike Lothian 649d4e60fa libdrm: Fix amdgpu build failure
Use the correct files to build libdrm_amdgpu.

Signed-of-by: Mike Lothian <mike@fireburn.co.uk>
Fixes: d6cb0ee408 ("amdgpu: remove the hash table implementation")
Cc: Christian König <christian.koenig@amd.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2018-08-07 13:58:21 +01:00
Christian König cbf0bb7f19 amdgpu: always add all BOs to handle table
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>
2018-08-07 13:27:39 +02:00
Christian König d6cb0ee408 amdgpu: remove the hash table implementation
Not used any more.

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>
2018-08-07 13:27:33 +02:00
Christian König 9a38e850a5 amdgpu: use handle table for flink names
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>
2018-08-07 13:27:28 +02:00
Christian König bde850bc32 amdgpu: use handle table for KMS handles
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>
2018-08-07 13:27:22 +02:00
Christian König 52370cc6eb amdgpu: add handle table implementation v2
The kernel handles are dense and the kernel always tries to use the
lowest free id. Use this to implement a more efficient handle table
by using a resizeable array instead of a hash.

v2: add handle_table_fini function, extra key checks,
    fix typo in function name

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>
2018-08-07 13:27:16 +02:00
Christian König 7aa1a51133 amdgpu: stop using the hash table for fd_tab
We have so few devices that just walking a linked list is probably
faster.

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>
2018-08-07 13:26:59 +02:00
Marek Olšák 9c979e0ec4 amdgpu: add amdgpu_bo_handle_type_kms_noimport
Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
2018-07-25 17:21:44 -04:00
Christian König 4fa33e45e6 amdgpu: make sure to set CLOEXEC on duplicated FDs
Otherwise we leak file descriptors into child processes.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-and-Tested-by: Junwei Zhang <Jerry.Zhang@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2018-07-17 16:48:08 +02:00
Michel Dänzer 7e4501027c Revert "amdgpu: don't call add_handle_to_table for KMS BO exports"
This reverts commit fe0488aa13.

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.
2018-07-11 15:43:59 +02:00
Marek Olšák fe0488aa13 amdgpu: don't call add_handle_to_table for KMS BO exports
Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
2018-07-10 23:26:23 -04:00
Jan Vesely c1f2d9b900 amdgpu: Destroy fd_hash table when the last device is removed.
Fixes memory leak on module unload.
Analogous to mesa commit of the same name.
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-05-25 12:12:00 -04:00
Jan Vesely 52ef6fbaf1 amdgpu/util_hash_table: Add helper function to count the number of entries in hash table
Analogous to the mesa commit of the same name.
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-05-25 12:12:00 -04:00
Jan Vesely 712fa0f3f4 amdgpu: Take a lock before removing devices from fd_tab hash table.
Close the file descriptors under lock as well.
v2: close fds after removing from hash table

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-05-25 12:12:00 -04:00
Michel Dänzer bc9c789073 amdgpu: Deinitialize vamgr_high{,_32}
Fixes memory leaks.

Reviewed-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
2018-04-27 16:42:26 +02:00
Satyajit b81d44d587 libdrm: amdgpu: Adding DRM_RDWR flag in amdgpu_bo_export
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>
2018-03-22 09:59:07 +01:00
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
Eric Engestrom 5236de6cc1 meson: use pkg-config to detect libatomic_ops
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2018-03-09 17:12:02 +00:00
Sabre Shao a5329cd990 drm/amdgpu: Remove IB count checking
Signed-off-by: Sabre Shao <Sabre.Shao@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2018-03-08 20:06:28 -05:00
Marek Olšák 666d59d86b Revert "amdgpu:support 16 ibs per submit for PAL/SRIOV"
This reverts commit 924f856a90.

Wrong patch.
2018-03-08 20:04:01 -05:00
Qiang Yu 924f856a90 amdgpu:support 16 ibs per submit for PAL/SRIOV
to support SRIOV and MCBP, need 16 IBs per submit

Signed-off-by: Qiang Yu <Qiang.Yu@amd.com>
Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-03-08 15:01:23 -05:00
Christian König bca585b02f amdgpu: fix "add AMDGPU_VA_RANGE_HIGH"
The range is stored as exclusive, not inclusive. Subtracts one to get
the inclusive interval for the calculation. This fixes crashes when 32bit
addresses are in use.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
2018-02-28 20:04:32 +01:00
Christian König ff0da7b323 amdgpu: add AMDGPU_VA_RANGE_HIGH
Return high addresses if requested and available.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2018-02-28 13:27:43 +01:00
Christian König cd8a80493b amdgpu: mostly revert "use the high VA range if possible v2"
This reverts commit 07ea20d5be.

Unfortunately it turned out that this change broke some corner cases in
Mesa.

Revert it for now, but keep the high range in separate VA managers.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2018-02-28 13:27:38 +01:00
Heiko Becker 4f08bfe96d *-symbol-check: Don't hard-code nm executable
Helpful if your nm executable has a prefix based on the
architecture, for example.

Signed-off-by: Heiko Becker <heirecka@exherbo.org>
Cc: Timo Gurr <timo.gurr@gmail.com>
[Eric: v2: rebase and add Meson support]
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2018-02-23 17:53:08 +00:00
Andrey Grodzovsky 33a2851ab9 amdgpu: Fix mistake in initial hole size calculation.
Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
2018-02-19 09:32:17 -05:00
Michel Dänzer 03f80b9f6a amdgpu: Add amdgpu_query_sw_info to amdgpu-symbol-check
Fixes make check. Trivial.
2018-02-12 15:47:55 +01:00
Marek Olšák ad5b702fec amdgpu: add amdgpu_query_sw_info for querying high bits of 32-bit address space
Reviewed-by: Christian König <christian.koenig@amd.com>
2018-02-09 20:30:16 +01:00
Chunming Zhou 69f9faeee6 amdgpu: clean up non list code path for vamgr v2
v2: Add missing "goto out"

Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Tested-by: Michel Dänzer <michel.daenzer@amd.com>
2018-02-09 17:28:32 +08:00
Michel Dänzer fa35b51f63 Revert "amdgpu: clean up non list code path for vamgr"
This reverts commit 41b94a3fb6.

It caused crashes with radeonsi in at least glxgears and Xorg.
2018-02-08 09:50:53 +01:00
Chunming Zhou 41b94a3fb6 amdgpu: clean up non list code path for vamgr
Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
2018-02-08 14:52:23 +08:00
Chunming Zhou d07be74a4a amdgpu: fix inefficient vamgr algorithm
issue: UMD allocates top 4GB, but don't do anything, just reserve top 4GB space,
but the performance of VP13 drops from 162fps to 99fps.

root cause:
our va hole list of vamgr is too long by time going.

fix:
reusing old hole as much as possible can make the list shortest.

result:
performance recovers as non-list path, next patch will remove non-list code path.

Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
2018-02-08 14:35:47 +08:00
Eric Engestrom 089d45456b remove unnecessary double-semicolon
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2018-01-29 15:41:52 +00:00