Commit Graph

258 Commits (362b5b0a886bdfbb92d2f78708ac7a67ee449b2d)

Author SHA1 Message Date
Eric Engestrom 360292c7ab fix various typos
Saw a couple of typos fixes in the patch DragonFlyBSD carries [1], so
I ran codespell (a spell checker for code) on the whole repo.

[1] https://github.com/DragonFlyBSD/DPorts/blob/master/graphics/libdrm/files/patch-xf86drm.c

Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2019-04-17 18:23:25 +01:00
Marek Olšák f19afaa519 amdgpu: add a faster BO list API
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
2019-01-16 16:39:25 -05:00
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
Christian König 1cc17744b9 amdgpu: fix high VA mask
That constant needs to be 64bits.

Fixes: amdgpu: use the high VA range if possible v2

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-01-23 11:17:43 +01:00
Christoph Haag 3509e7cd2b meson: fix the install path of amdgpu.ids
Signed-off-by: Dylan Baker <dylan.c.baker@intel.com>
2018-01-18 10:13:43 -08:00
Michel Dänzer 57d3d4c968 amdgpu: Don't print error message if parse_one_line returned -EAGAIN
It means it just didn't find an entry for the GPU in the amdgpu.ids file.

Fixes spurious

 amdgpu_parse_asic_ids: Cannot parse ASIC IDs: Resource temporarily unavailable

error messages in that case.

Reported-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2018-01-15 10:01:39 +01:00
Dylan Baker 5f7deb5078 Add meson build system
This patch adds a complete meson build system, including tests and
install. It has the necessary hooks to allow it be used as a subproject
for other meson based builds such as mesa.

Signed-off-by: Dylan Baker <dylan.c.baker@intel.com>
Reviewed-and-tested-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2018-01-12 09:40:48 -08:00
Christian König 07ea20d5be amdgpu: use the high VA range if possible v2
Retire the low range on Vega10 this frees up everything below 0xffff800000000000 for HMM.

v2: keep the 32bit range working.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2018-01-09 17:15:09 +01:00
Christian König a8e436de5d amdgpu: fix 32bit VA manager max address
The range is exclusive not inclusive.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2018-01-09 17:15:02 +01:00
Bas Nieuwenhuizen 5889f6ba1a amdgpu: Add syncobj reset & signal wrappers.
Signed-off-by: Dave Airlie <airlied@redhat.com>
2017-12-18 09:51:50 +10:00
Michel Dänzer f05a2b4cb1 amdgpu: Only remember the device's marketing name
There's no point in keeping around the full table of marketing names,
when amdgpu_get_marketing_name only ever returns the device's marketing
name.

Acked-by: Slava Abramov <slava.abramov@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-12-05 12:50:20 +01:00
Michel Dänzer 5219809a32 amdgpu: Simplify error handling in parse_one_line
* Move empty/commented line check before the strdup and return -EAGAIN
  directly
* Initialize r = -EAGAIN and remove redundant assignments
* Set r = -ENOMEM if last strdup fails, and remove redundant goto

Acked-by: Slava Abramov <slava.abramov@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-12-05 12:49:13 +01:00
Michel Dänzer 85c6b0b00a amdgpu: Clean up amdgpu_parse_asic_ids error handling
* Move error message printing into amdgpu_parse_asic_ids and make it
  return void
* Print only "Invalid format" error message if parse_one_line returns
  -EINVAL
* Use strerror instead of printing the (negative) error code in hex

Acked-by: Slava Abramov <slava.abramov@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-12-01 16:52:01 +01:00
Michel Dänzer f71e95108d amdgpu: Add amdgpu_cs_create_syncobj2 to amdgpu-symbol-check
Fixes make check. Trivial.
2017-11-30 15:52:50 +01:00
David Mao 1749d56ea0 amdgpu: Adding amdgpu_cs_create_syncobj2 to create syncobj as signaled initially
Signed-off-by: David Mao <david.mao@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2017-11-29 22:05:25 -05:00
Christian König 931f01964a Revert "amdgpu: fix 32bit VA manager max address"
This reverts commit 944f6665de.

Accidentially pushed an imcomplete patch.

Signed-off-by: Christian König <christian.koenig@amd.com>
2017-11-09 10:36:10 +01:00
Christian König 0c2481edf7 Revert "amdgpu: use the high VA range if possible"
This reverts commit 6c0ea4b0c5.

Accidentially pushed an incomplete patch.

Signed-off-by: Christian König <christian.koenig@amd.com>
2017-11-09 10:35:44 +01:00
Christian König 6c0ea4b0c5 amdgpu: use the high VA range if possible
This frees up the low range for HMM.

Signed-off-by: Christian König <christian.koenig@amd.com>
2017-11-08 16:12:56 +01:00
Christian König 944f6665de amdgpu: fix 32bit VA manager max address
The range is exclusive not inclusive.

Signed-off-by: Christian König <christian.koenig@amd.com>
2017-11-08 16:12:29 +01:00
Christian König a844925c8a amdgpu: sanitize 64bit VA manager
Adding the extra reservation of the 32bit space to the 64bit manager is
complete nonsense and just a waste of memory and CPU cycles.

Signed-off-by: Christian König <christian.koenig@amd.com>
2017-11-08 16:11:40 +01:00
Christian König 4b4ccaac2e amdpgu: fix coding style in amdgpu_vamgr.c
No functional change.

Signed-off-by: Christian König <christian.koenig@amd.com>
2017-11-07 15:13:30 +01:00
Andrey Grodzovsky f3091bac21 amdgpu: Fix wrappers for AMDGPU_VM IOCTL.
Rmove amdgpu_context_handle from the interface and use
amdgpu_device_handle instead. Uupdate VMID reservation test
accordingly.

Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
2017-11-03 13:07:30 +01:00
Marek Olšák 76c325ee7d amdgpu: fix 32-bit build 2017-10-31 15:48:23 +01:00
Andrey Grodzovsky 9b38ea82fc amdgpu: Add wrappers for AMDGPU_VM IOCTL.
v2:
Rename wrappers to match the IOCTL naming, fix
identation and fix make check error.

Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
2017-10-27 18:25:53 +02:00
Andres Rodriguez 35bc82cee9 amdgpu: implement context priority for amdgpu_cs_ctx_create2 v3
Add a new context creation function that allows specifying the context
priority.

A high priority context has the potential of starving lower priority
contexts. The current kernel driver implementation allows only apps
that hold CAP_SYS_NICE or DRM_MASTER to acquire a priority above
AMDGPU_CTX_PRIORITY_NORMAL.

v2: corresponding changes for kernel patch v2
v3: Fixed 'make check' symbol error

Signed-off-by: Andres Rodriguez <andresx7@gmail.com>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
2017-10-20 21:51:02 +02:00
Marek Olšák c74d461404 amdgpu: add amdgpu_cs_fence_to_handle
v2: update amdgpu-symbol-check

Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
2017-10-12 20:35:57 +02:00
Marek Olšák 59aa57b363 amdgpu: add amdgpu_cs_syncobj_wait
v2: update amdgpu-symbol-check

Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
2017-10-12 20:35:57 +02:00
Marek Olšák b6e24501a1 amdgpu: add sync_file import and export functions
v2: update amdgpu-symbol-check

Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
2017-10-12 20:35:57 +02:00
Rob Herring 011fd913b4 Android: move libraries to /vendor
As part of Treble project in Android O, all the device specific files have
to be located in a separate vendor partition. This is done by setting
LOCAL_PROPRIETARY_MODULE (the name is misleading). This change will not
break existing platforms without a vendor partition as it will just move
files to /system/vendor.

Signed-off-by: Rob Herring <robh@kernel.org>
2017-10-09 09:22:35 -05:00
Marek Olšák 1dd84e01a9 amdgpu: print error messages when amdgpu_device_initialize is failing
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-09-28 22:48:26 +02:00
Jan Vesely d55d0804f9 amdgpu: Do not write beyond allocated memory when parsing ids
Fixes crash when/usr/share/libdrm/amdgpu.ids contains ASIC_ID_TABLE_NUM_ENTRIES + 1 entries.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102432
Fixes: 7e6bf88cac (amdgpu: move asic id table to a separate file)
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2017-09-04 23:48:54 -04:00
Chih-Wei Huang a0531e76f6 android: amdgpu: fix build break
Define two macros to avoid building errors.

Fixes: 7e6bf88cac (amdgpu: move asic id table to a separate file)

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
2017-08-21 13:05:13 +01: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
Dave Airlie e12af382b5 amdgpu: add new symbols to tests. 2017-07-19 00:40:38 +01:00
Dave Airlie 22790a65d4 drm/amdgpu: add new low overhead command submission API. (v2)
This just sends chunks to the kernel API for a single command
stream.

This should provide a more future proof and extensible API
for command submission.

v2: use amdgpu_bo_list_handle, add two helper functions to
access bo and context internals.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2017-07-19 00:33:14 +01:00
Dave Airlie 69532d0188 drm/amdgpu: add syncobj create/destroy/import/export apis
These are just wrappers using the amdgpu device handle.

Acked-by: Chunming Zhou <david1.zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2017-07-19 00:32:53 +01:00
Xiaojie Yuan 7e6bf88cac amdgpu: move asic id table to a separate file
v2: fix an off by one error and leading white spaces
v3: use thread safe strtok_r(); initialize len before calling getline();
    change printf() to drmMsg(); add initial amdgpu.ids
v4: integrate some recent internal changes, including format changes
v5: fix line number for empty/commented lines; realloc to save memory;
    indentation changes
v6: remove a line error
v7: [Michel Dänzer]
* Move amdgpu.ids to new data directory
* Remove placeholder entries from amdgpu.ids
* Set libdrmdatadir variable in configure.ac instead of Makefile.am
  [Emil Velikov]
* Use isblank() instead of open-coding it [Emil Velikov]
* Don't leak asic_id_table memory if realloc fails [Emil Velikov]
* Check and bump table_max_size at the beginning of the while loop [Emil
  Velikov]
* Initialize table_max_size to the number of entries in data/amdgpu.ids
v8: [Michel Dänzer]
* Make sure amdgpu_asic_id.c gets rebuilt when amdgpu.ids changes

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Samuel Li <Samuel.Li@amd.com>
2017-06-13 10:21:39 +09:00
Michel Dänzer 87dac00db3 amdgpu: Add .editorconfig file for amdgpu coding style
The .editorconfig file in the toplevel directory doesn't match.

Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-06-13 10:20:16 +09:00
Nicolai Hähnle 41be41f99e amdgpu: add missing extern "C" headers
Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Alex Xie <AlexBin.Xie@amd.com>
2017-05-16 15:45:45 +02:00
Edward O'Callaghan 00aa2c1881 amdgpu: Use the canonical form in branch predicate
Suggested-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2017-05-03 21:36:02 +10: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
Nicolai Hähnle d8d45a4938 amdgpu: add the interface of waiting multiple fences
Signed-off-by: Junwei Zhang <Jerry.Zhang@amd.com>
[v2: allow returning the first signaled fence index]
Signed-off-by: monk.liu <Monk.Liu@amd.com>
[v3:
 - cleanup *status setting
 - fix amdgpu symbols check
v4: simplify return from amdgpu_cs_wait_fences (suggested
    by Edward O'Callaghan)]
Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com> (v1)
Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com> (v1)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-04-18 21:05:00 +02:00
Samuel Pitoiset 047aba1697 amdgpu: allow to query GPU sensor related information
This exposes amdgpu_query_sensor_info().

v2: - add amdgpu_query_sensor_info() to the symbols list

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-04-07 17:58:54 +02:00
Emil Velikov f5995751b0 amdgpu: add amdgpu_bo_va_op_raw to the symbol check
Otherwise the make check will rightfully fail.

Fixes: 4e369f25a9 ("amdgpu: add amdgpu_bo_va_op_raw")
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2017-04-03 17:46:06 +01: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
Christian König f684bb109f amdgpu: stop reading CC_RB_BACKEND_DISABLE on Vega10
Follow up to 'drm: don't access deprecated register on Vega10'.

The same information is available in enabled_rb_pipes_mask and reading that
register can cause GRBM bus problems.

Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
2017-03-27 21:42:07 +02:00
Huang Rui 99908bfd4c amdgpu: don't read registers not present on Vega10
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-27 21:42:07 +02:00
Alex Xie fe7cb34eda amdgpu: vamgr can be a struct instead of a pointer
vamgr is an integral part of amdgpu_device. We don't need to calloc and free it.
This can save CPU time, reduce heap fragmentation.

Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Alex Xie <AlexBin.Xie@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
[Grazvydas Ignotas: rebase, correct a typo in commit message]
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2017-02-02 15:22:53 -05:00