Commit graph

7169 commits

Author SHA1 Message Date
Sunil Khatri
614f8d7391 drm/amdgpu: add UAPI to query if user queues are supported
add uapi support for user queues query inline with kernel
changes.

https://lists.freedesktop.org/archives/amd-gfx/2025-April/122559.html

Reviewed-by: Marek Olšák marek.olsak@amd.com
Reviewed-by: Yogesh Mohan Marimuthu yogesh.mohanmarimuthu@amd.com
Reviewed-by: Alex Deucher alexander.deucher@amd.com
Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
2025-04-30 18:56:07 +05:30
Arunpravin Paneer Selvam
15e174c1ed amdgpu: Add queue id support to the user queue wait IOCTL
Add queue id support to the user queue wait IOCTL
drm_amdgpu_userq_wait structure.

This is required to retrieve the wait user queue and maintain
the fence driver references in it so that the user queue in
the same context releases their reference to the fence drivers
at some point before queue destruction.

Otherwise, we would gather those references until we
don't have any more space left and crash.

Signed-off-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
Suggested-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2025-04-18 20:51:59 +05:30
Jie1zhang
fdf384d4b5 amdgpu: Add queue priority and secure flags support for user queues
This patch extends the user queue creation API to support:
1. Queue priority levels (normal low, low, normal high, high)
   - High priority is restricted to admin-only
2. Secure queue flag for protected content access

The changes include:
- Adding a `flags` parameter to `amdgpu_create_userqueue()`
- Defining priority and security flags in `amdgpu_drm.h`
- Updating the `drm_amdgpu_userq_in` struct to replace padding with flags
- Documenting the new flags field

Related driver patches provided by Alex:
https://lists.freedesktop.org/archives/amd-gfx/2025-April/122782.html
https://lists.freedesktop.org/archives/amd-gfx/2025-April/122780.html
https://lists.freedesktop.org/archives/amd-gfx/2025-April/122786.html

Cc: Koenig, Christian <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>

Signed-off-by: Jesse.Zhang <Jesse.zhang@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2025-04-14 15:37:51 +08:00
Arvind Yadav
43e8a3f86a amdgpu: Add amdgpu userqueue IOCTL functions
This patch adds new IOCTL functions to support
userqueue create, remove, signal and wait etc.

v2:(Marek)
 - Add csa support for SDMA queue.
 - Addressed's review comments.
 - Removed raw2/op2 ioctl.
 - Added syncobj_timeline_handles in amdgpu_userq_wait IOCTL.

v3:(Yogesh)
 - Rename timeline* objects as per UAPI review (Arvind).

v4: (Marek)
 - Drop AMDGPU_USERQ_BO_WRITE as this should not be a global option
   of the IOCTL, It should be option per buffer. Hence adding separate
   array for read and write BO handles. (Arun)

 - Modify num_fences to __u16, flags changed to __u16 and placed
   the num_fences next to flags for optimal padding and size. (Arun)

v5:(Marek/Pierre-Eric)
  - add more detail params description for signal and wait IOCTL calls.
  - Remove the unused structure fields in signal and wait structs.
  - Add separate array of read and write for BO handles. (Arun)

  - Removes the unused flags parameter from the
	amdgpu_create_userqueue IOCTL. (Arvind)

v6:(Pierre-Eric)
  - Remove unused headers. (Arvind)

  - Modify the function parameter names and struct
    field names as per the review comments. (Arun)

v7:(Marek)
  - Modify the structure field name and comments. (Arun)

  - Rename vm_timeline_syncobj and add comment for
    vm_timeline_point.
  - Remove GDS buffer support from MQD. (Arvind)

v8:(Pierre-Eric)
  - Modify the function parameter names.
  - Added new function in amdgpu-symbols.txt (Arvind)

v9:(Marek)
  - Use the drm signal/wait structure as the parameter. (Arun)

Cc: Deucher, Alexander <alexander.deucher@amd.com>
Cc: Koenig, Christian <christian.koenig@amd.com>
Cc: Sharma, Shashank <shashank.sharma@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Signed-off-by: Arvind Yadav <arvind.yadav@amd.com>
Signed-off-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
2025-04-10 10:03:07 -04:00
Arvind Yadav
72d3140428 amdgpu: UAPI for AMDGPU usermode queues
This patch adds UAPI interface changes for AMDGPU usermode
queues, semaphore and new AMDGPU GEM domain for doorbells.
Usermode queues allow a userspace process to create
and submit its graphics/compute/sdma work directly to the GPU.

v2:(Marek)
 - Add csa support for SDMA queue.
 - Rename UAPI objects and struct as per UAPI review. (Shashank)

v3:(Yogesh)
 - Rename UAPI timeline* objects as per UAPI review. (Arvind)

v4: (Marek)
 - Drop AMDGPU_USERQ_BO_WRITE as this should not be a global option
   of the IOCTL, It should be option per buffer. Hence adding separate
   array for read and write BO handles. (Arun)
 - Modify num_fences to __u16, flags changed to __u16 and placed
   the num_fences next to flags for optimal padding and size. (Arun)

 - Fix 32-bit holes issue in sturct drm_amdgpu_gem_va as per
   UAPI review (Arvind).

v5:(Marek/Pierre-Eric)
  - add more detail params description for signal and wait IOCTL calls.
  - Remove the unused structure fields in signal and wait structs.
  - Add separate array of read and write for BO handles. (Arun)

  - Removes the unused flags parameter from the usermode queue UAPI structure
  - Clarify comments on top of drm_amdgpu_userq_in
  - Clarify comment for queue_id (in)
  - Clarify comment for mqd
  - Clarify comment for compute MQD size
  - Clarify comment for queue_id (out)
  - Adds padding variables in userqueue in/out structures. (Shashank)

v6:(Pierre-Eric)
  - Modify the function parameter names and struct
    field names as per the review comments. (Arun)

v7:(Marek)
  - Modify the structure field name and comments. (Arun)

  - Rename vm_timeline_syncobj and add comment for
    vm_timeline_point.
  - Remove GDS buffer support from MQD. (Arvind)

v8:(Pierre-Eric)
  - Modify the function parameter names.

Cc: Koenig, Christian <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Signed-off-by: Shashank Sharma <shashank.sharma@amd.com>
Signed-off-by: Arvind Yadav <arvind.yadav@amd.com>
Signed-off-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
2025-04-10 10:03:07 -04:00
Shashank Sharma
5d7d7c4318 drm/amdgpu: add new AMDGPU_INFO subquery for userqueue metadata
This patch:
- adds a new subquery (AMDGPU_INFO_UQ_FW_AREAS) in AMDGPU_INFO_IOCTL
  to get the size and alignment of shadow and csa objects from the
  kernel. This information is required for a userqueue consumer (like
  MESA/libdrm) to create the userqueue metadata objects properly.
- also adds supporting metadata structures and a high level wrapper
  function (amdgpu_query_uq_metadata_info) to the query, to make it
  easy to use.

The corresponding kernel changes for this UAPI extension can be found
in amd-gfx mailing list, link:
https://patchwork.freedesktop.org/patch/621390/?series=139715&rev=2

This patch adds support only for the GFX IP, and the other engines may
be supported in subsequent development.

V2: fix the build error due to exporting of helper function
V3: make an entry for amdgpu_query_uq_metadata_info in
    amdgpu-symbols.txt
V4: Rename the subquery to AMDGPU_INFO_UQ_FW_AREAS (Marek, Pierre-Eric)
V5: Addressed review comments (Pierre-Eric):
    - Fix the API comment to match the new IOCTL name
    - remove the unused uq_metadata parameter

Cc: Marek Olsak <marek.olsak@amd.com>
Cc: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian Koenig <christian.koenig@amd.com>
Cc: Arvind Yadav <arvind.yadav@amd.com>
Reviewed-by: Marek Olsak <marek.olsak@amd.com>
Signed-off-by: Shashank Sharma <shashank.sharma@amd.com>
2025-04-10 13:20:00 +00:00
Daniel van Vugt
d387ec976f xf86drm: Handle NULL in drmCopyVersion
Just as it is already handled in the caller, `drmGetVersion`.

I'm not sure what the offending driver is, but the Ubuntu incidents
seem to be coming from a dual Intel/Nvidia machine. And they show
it is `card1` so I'm guessing `nvidia-drm` is the offender.

Related: https://bugs.launchpad.net/bugs/2104352
2025-03-27 17:43:05 +08:00
Alex Deucher
a7eb2cfd53 amdgpu: add new marketing names
Updated client names.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2025-01-17 17:26:15 -05:00
Simon Ser
c7684a957a xf86drm: deprecate drmAvailable()
Signed-off-by: Simon Ser <contact@emersion.fr>
References: https://gitlab.freedesktop.org/mesa/drm/-/issues/113
2025-01-09 14:08:03 +00:00
Alex Deucher
e7d4b1df2d amdgpu: add new marketing names
Updated from 6.3 branch.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2024-12-18 13:15:57 -05:00
Alex Deucher
1f140f7d65 amdgpu: add new marketing names
Updated from 6.2 branch.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2024-12-18 13:11:38 -05:00
Matt Turner
38ec7dbd4d build: bump version to 2.4.124 2024-12-04 13:30:30 -05:00
Rob Barnes
f314a43f14 modetest: Make modetest availble to vendor on Android
Make modetest available to vendors on Android. libdrm_util and
libdrm_test_headers is also made available to vendors since these are
depenencies of modetest. This results in the module target
modetest.vendor being availble to vendor modules.

Signed-off-by: Rob Barnes <robbarnes at google.com>
2024-10-29 10:49:10 -06:00
Mauro Rossi
e68e9b8013 android: add genrule for generated_static_table_fourcc.h
Fixes the following building error:

external/libdrm/xf86drm.c:158:10: fatal error: 'generated_static_table_fourcc.h' file not found
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Change-Id: I1b0cac498ed63ebec6e8c03629bbf4a1b6a9618d
Reviewed-by: Mauro Rossi <issor.oruam@gmail.com>
2024-10-20 12:26:53 +02:00
Marek Olšák
50da61eebd xf86drm: print AMD modifiers properly
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
2024-10-15 19:49:05 -04:00
Alan Coopersmith
c0a08f06ae include/drm/README: update drm-next link to use gitlab instead of cgit 2024-09-29 17:47:51 -07:00
Dmitry Baryshkov
0a1162e2af modetest: add support for YUV422 and YUV444 plane format
Currently modetest supports only the YUV420 and YVU420 planar YCbCr
plane formats (aka YV12 and YU12). Extend the code to add support for
YUV422 / YVU422 and YUV444 / YVU444 plane formats.

Reviewed-by: Marijn Suijten <marijn.suijten@somainline.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2024-09-23 21:11:29 +02:00
Dmitry Baryshkov
38c043dca2 modetest: simplify planar YUV handling
In preparation to adding more planar YUV formats, introduce X, Y
subsampling ratios and use them to calculate plane offsets and buffer
size.

Reviewed-by: Marijn Suijten <marijn.suijten@somainline.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2024-09-23 21:11:29 +02:00
Simon Ser
bea14386bc build: simplify Linux system check
No need for contains() here.

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-09-08 09:15:08 +00:00
Marijn Suijten
887fec2c28
tests/util: Call drmGetDevices2() instead of drmOpen()ing all modules
Whenever `util_open()` is called to open a device for the first matching
module, it will skip devices for the `nvidia_drm` kernel module which
is not in the list.  We could add this module for now, but keeping this
list of DRM modules up to date is cumbersome.

At the same time walking a list of modules and calling `drmOpen()` for
each of them is incredibly expensive (when the user doesn't explicitly
specify one with `-M`), as each each call opens every DRM node just
to see if they are associated to the requested module.  And for no
good reason: all we want is the first `DRM_NODE_PRIMARY` (which is what
`drmOpen()` also returns) to use by default.

For example on the `"msm"` driver, which used to be the 9th in the
modules list, all nodes are opened for the 9th time before e.g.
`modetest` returns a useful result, which takes ages unless the user
painstakingly provides the module for the currently known device on
the cmdline.

This is very simply solved by calling `drmGetDevices(2)()`, which
iterates through all DRM nodes only once and allows us to immediately
find + `open()` the first device that has a PRIMARY node.  A random
search for the error shows that this was also attempted in (a fork of?)
kmscube:
https://git.ti.com/cgit/glsdk/kmscube/commit/?id=456cabc661caac5c60729751d45efd668faa8e97

Finally we add a `drmIsKMS()` check to make sure we only include primary
nodes that actually support rendering, and also print the values from
`drmGetVersion()` on success to make it easier to identify the device.

In the future we could extrapolate this feature by letting query
commands like `modetest -c` list connectors for every device/module, not
just the first PRIMARY node that we found.
2024-09-03 13:30:41 +02:00
Matt Turner
25dec5b91f build: bump version to 2.4.123 2024-08-26 13:10:22 -07:00
Mark Collins
f3f56f41bb Disable ioctl signed overload for Bionic libc
Bionic libc ships with `ioctl` that has two signatures, one with an
unsigned `request` parameter and one with a signed request parameter.

This leads to compilation failing due to `__typeof__(ioctl)` being used
by DRM which fails to resolve which overload to use, this has been fixed
by defining `BIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD` on Android.

Signed-off-by: Mark Collins <mark@igalia.com>
2024-08-22 18:45:38 +00:00
Su Hong Koo
88db611498 tests: Make modetest and proptest cc_binary in Android.bp
Change module type of modetest and proptest from cc_test to cc_binary,
as neither are tests.

Signed-off-by: Su Hong Koo <sukoo@google.com>
2024-08-01 10:09:05 -04:00
Daniel Stone
b0815faac0 libs: Tie DSO minor versions to libdrm version
There is an excellent writeup explaining this requirement here:
    https://gitlab.freedesktop.org/wayland/wayland/-/issues/175

In short, for mixed environments such as the Steam Runtime and other
container-like environments, choosing which libdrm to link into the
client's address space is a hard problem. If the runtime has a newer
libdrm than the host, then it should be preferred, because the client
may be using newly-added symbols. But if the host has a newer libdrm,
then that should be used, because drivers may be depending on those.

Bumping the DSO minor version is transparent to all users because apps
only link against the major version, e.g. DT_NEEDED libdrm.so.2; the
fact that libdrm.so.2 is a link to libdrm.so.2.122.0 is a detail known
only to the loader, but it does let a smart runtime make better
decisions.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2024-08-01 13:28:41 +01:00
Jiyong Park
4bd09d78df Enable GPU in crosvm
When the GPU feature is turned on in crosvm, these modules are added as
dependencies. Since crosvm is included in the virt APEX, add the APEX to
the apex_available properties of the modules to make them available in
the APEX.
2024-07-30 10:54:34 -04:00
Jiyong Park
d9043a256f add crosvm to com.android.virt
To do so, crosvm and its dependencies have the apex_available property
set to "//apex_available:platform", "com.android.virt" to explicitly
acknowledge the joining.
2024-07-30 10:54:34 -04:00
Jason Macnak
f22956a4e9 Adds libdrm_headers
... as being able to use cc_library in header_libs is not
intended and does not work on all branches which blocks
aosp/1497292.
2024-07-30 10:54:34 -04:00
Inseob Kim
460f7907de Export include dirs with -isystem
drm_property_type_is function in xf86drmMode.h file can cause compiler
error because it performs unsigned to signed conversion. Some Android.mk
modules have been avoiding this by adding "-isystem external/libdrm"
flag, because warnings from system headers are suppressed.

This changes exported_include_dirs to export_system_include_dirs
to workaround the potential error with the same manner above.
2024-07-30 10:54:34 -04:00
Jason Macnak
dcb14fe0c6 Makes libdrm available on host
... to make drm format header visible for host wayland server.

Adds -Wno-implicit-function-declaration for vasprintf() on
xf86drm.c:2965.

Adds -Wno-int-conversion for drm_mmap() on libdrm_macros.h:60.

Also, drive-by alphabetize cflags.
2024-07-30 10:54:34 -04:00
Jerry Zhang
6aa6411c5a Make libdrm recovery_available 2024-07-30 10:54:34 -04:00
John Stultz
c2b5759a2f Android.bp: Add include exports for android dir
This forward ports Stefan Schake's patch
32ee9c0e05 "android: Add missing include exports" to the
Android.bp file.
2024-07-30 10:54:34 -04:00
Elliott Hughes
aef24b66d9 readdir_r is deprecated.
Add -Wno-deprecated-declarations to suppress compiler warning about
using readdir_r, which is deprecated.
2024-07-30 10:54:34 -04:00
Su Hong Koo
aefb5fa987 Delete all Makefile.sources files
Delete all Makefile.sources as all the makefiles that use them have
been replaced with Android.*.bp files for Soong.
2024-07-30 10:54:23 -04:00
Dan Willemsen
21ac1816a4 Convert to Android.bp
See build/soong/README.md for more information about Soong.

Removes BOARD_GPU_DRIVERS, which wasn't affecting anything, since none
of the HAVE_* macros are defined. Even if they were, we'd prefer to
compile all of them so that a single library can support multiple
boards.
2024-07-29 14:47:30 -04:00
Alex Deucher
11cafdd8d6 amdgpu: add new marketing names
Updated from 6.1 branch.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2024-07-11 21:46:17 -04:00
Alex Deucher
5e1e7c4d71 amdgpu: add new marketing names
https://www.amd.com/en/processors/ryzen-processors-laptop-business
https://www.amd.com/en/products/ryzen-pro-processors-laptop

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2024-07-11 21:31:50 -04:00
Enrico Weigelt, metux IT consult
b065dbc5cc Fix FTBS on undefined clock_gettime() and asprintf()
Some platforms (eg. SunOS) explicitly need extra symbols in order to define
those functions. There're many files needing the __EXTENSIONS__ symbol,
so doing this on a global scale.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-06-27 02:07:00 +02:00
Simon Ser
ad78bb591d build: bump version to 2.4.122
Signed-off-by: Simon Ser <contact@emersion.fr>
2024-06-26 10:13:31 +02:00
Simon Ser
998d2a2e81 Sync headers with drm-next
Synchronize drm_fourcc.h and drm_mode.h to drm-next.

Generated using make headers_install.
Generated from drm-next branch commit 541b1b0a8fc235bca355921eb7f3f59a8efa3e9a

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-06-26 08:08:40 +00:00
Enrico Weigelt, metux IT consult
a97bd7b4ac ci: upgrade FreeBSD VM to 14.1
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-06-25 12:57:01 +02:00
Enrico Weigelt, metux IT consult
d096affbaa ci: upgrade debian container to bookworm
Buster is oldoldstable and EOL in a few days. Bookworm is the current stable.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-06-25 12:56:11 +02:00
Enrico Weigelt, metux IT consult
589f8e86f1 etnaviv: fix FTBS on undefined linux/* headers on non-Linux platforms.
Using C standard headers instead.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-06-25 10:41:35 +02:00
Enrico Weigelt, metux IT consult
b7338fc842 freedreno: fix FTBS on non-Linux platforms (unused header)
The <linux/fb.h> header only exists on Linux, but isn't used anymore,
so drop it entirely.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-06-24 17:44:54 +00:00
Enrico Weigelt, metux IT consult
90c1a35f2a fix FTBS on FreeBSD (or non-Linux in general)
Several drivers still including <linux/stddef.h>, but not using anything
from it, thus breaking build on non-Linux platforms (eg. FreeBSD).
Since not needed at all, just stop including it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-06-24 17:24:28 +00:00
Enrico Weigelt, metux IT consult
0cd18d0dfb OpenBSD: fix FTBS on misspelled and missing variables
../xf86drm.c:4622:9: error: use of undeclared identifier 'written'; did you mean 'write'?
    if (written + 1 > max_node_length)
        ^~~~~~~
        write

../xf86drm.c:4624:21: error: use of undeclared identifier 'sbuf'; did you mean 'sbrk'?
    if (stat(node, &sbuf))
                    ^~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-06-24 12:57:51 +02:00
Nicolas Caramelli
7f20912b1b Remove libm in libdrm dependencies
Signed-off-by: Nicolas Caramelli <caramelli.devel@gmail.com>
2024-06-02 22:09:56 +00:00
Marek Olšák
70c4f836cc Bump version to 2.4.121 2024-06-01 13:31:41 -04:00
Marek Olšák
93d037cdd4 amdgpu: sync amdgpu_drm.h 2024-06-01 13:27:04 -04:00
Flora Cui
37265ab0ad tests/amdgpu: fix compile error with gcc14
../../drm/tests/amdgpu/shader_code.h:114:9: error: initialization of
‘const uint32_t *’ {aka ‘const unsigned int *’} from incompatible
pointer type ‘const uint32_t (*)[10][6]’ {aka ‘const unsigned int
(*)[10][6]’} [-Wincompatible-pointer-types]
  114 |         ps_##_ps##_shader_patchinfo_code_gfx##_n, \
      |         ^~~
../../drm/tests/amdgpu/shader_code.h:119:10: note: in expansion of macro
‘SHADER_PS_INFO’
  119 |         {SHADER_PS_INFO(const, 9), SHADER_PS_INFO(tex, 9)},
      |          ^~~~~~~~~~~~~~

Signed-off-by: Flora Cui <flora.cui@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2024-05-27 10:37:25 +08:00
Flora Cui
cee441f32d tests/amdgpu: fix compile error with gcc7.5
fix commit cc3c80c6("tests/amdgpu: refactor dispatch/draw test")
../../SOURCES/drm/tests/amdgpu/shader_code.h:113:2: error: initializer
element is not constant
  ps_##_ps##_shader_patchinfo_code_size_gfx##_n, \
	    ^

Signed-off-by: Flora Cui <flora.cui@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2024-05-27 10:37:18 +08:00