Synchronize drm.h, drm_mode.h and drm_fourcc.h to drm-next.
Generated using make headers_install
Generated from drm-next branch commit 2a084f4ad727244768b919455aa9dc1c04630487
Signed-off-by: Simon Ser <contact@emersion.fr>
Those haven't been updated in the last two years and have been replaced by
IGT test cases: https://gitlab.freedesktop.org/drm/igt-gpu-tools
Signed-off-by: Christian König <christian.koenig@amd.com>
Some older Vega APUs don't provide a very useful string. If we have
a string in amdgpu.ids use that, but fallback to /proc/cpuinfo.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
The string will generally have a CPU and GPU component, so if both
are found split it up. Make sure that it starts with AMD to be
consistent.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
This commit adds essential parameter validation to several key
functions in amdgpu_bo.c to prevent null pointer dereferences
that were causing segmentation faults and improve overall code
robustness.
The changes address the following crash scenario:
Received signal SIGSEGV.
Stack trace:
#0 [fatal_sig_handler+0x17b]
#1 [__sigaction+0x50]
#2 [amdgpu_bo_alloc+0x37]
#3 [__igt_unique____real_main461+0x7d5]
#4 [main+0x2d]
#5 [__libc_init_first+0x90]
#6 [__libc_start_main+0x80]
#7 [_start+0x25]
Changes made:
1. amdgpu_bo_alloc():
- Validate alloc_buffer and buf_handle parameters
- Return -EINVAL if either is NULL
- Prevents null pointer dereference in memset and subsequent operations
2. amdgpu_bo_set_metadata():
- Validate info parameter
- Return -EINVAL if info is NULL
- Prevents accessing invalid metadata structure
3. amdgpu_bo_query_info():
- Validate info parameter in addition to existing bo->handle check
- Return -EINVAL if info is NULL
- Prevents writing to invalid info pointer
4. amdgpu_bo_list_create():
- Validate resources parameter
- Return -EINVAL if resources is NULL when number_of_resources > 0
- Prevents invalid memory access during resource array processing
These changes ensure proper error handling when callers pass invalid
null pointers, preventing potential segmentation faults and making
the API more robust against programming errors. The validation occurs
early in each function to minimize performance impact.
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
The correct marketing name is encoded in the model name field
that is read from the hardware on an APU. Try to read from /proc/cpuinfo
when an APU is found to identify such hardware.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Its contents is the same as drmFauxBusInfo. While it is technically an
API breaking change, libdrm with the relevant changes has been released
only recently and there are issues with quering DRM nodes that are on
the faux bus, which result in crashes, so it is unlikely that there are
users that depend on the new API.
Signed-off-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
The name string is allocated on the heap, so the memcmp() function will
not return 0 even though two nodes share the same device name.
Also, the device info will not be populated when counting the available
drm devices. For example, using drmGetDevices2(0, NULL, 0). In that
case, drmGetDevices2() will eventually crash in drmDevicesEqual() while
merging nodes belonging to the same device due to passing null pointers
to memcmp().
This change adds faux device name to businfo. The businfo is populated
regardless whether device info is needed, which is needed to make the
drmGetDevices2(0, NULL, 0) case work. drmFauxBusInfo can also be used
with the memcmp() function to match the other cases in drmDevicesEqual().
Signed-off-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
This prevents text editors that trim trailing whitespace automatically
from making unrelated changes.
Signed-off-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Linux 6.14 included a new type of bus, the "faux" bus [1].
The next version of Linux (v6.16) will move the VKMS driver to the faux
bus. See kernel commit 5686601908d8 ("drm/vkms: convert to use
faux_device") for more details.
Add support for the faux bus so drmGetDeviceFromDevId(), drmGetDevices()
and drmGetDevices2() return the devices on it.
[1] https://lore.kernel.org/all/2025021023-sandstorm-precise-9f5d@gregkh/
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
The inline function is_power_of_two should be set as static since it's
only called in pattern.c, otherwise it will encounter below build error.
[114/136] Linking target tests/modetest/modetest
FAILED: tests/modetest/modetest
cc -o tests/modetest/modetest tests/modetest/modetest.p/buffers.c.o tests/modetest/modetest.p/cursor.c.o tests/modetest/modetest.p/modetest.c.o -Wl,--as-needed -Wl,--no-undefined -fno-omit-frame-pointer '-Wl,-rpath,$ORIGIN/../..' -Wl,-rpath-link,/home/ray/repo/drm/build/ -Wl,--start-group libdrm.so.2.125.0 tests/util/libutil.a -lm -pthread /usr/lib/x86_64-linux-gnu/libcairo.so -Wl,--end-group
/usr/bin/ld: tests/util/libutil.a.p/pattern.c.o: in function `check_yuv':
/home/ray/repo/drm/build/../tests/util/pattern.c:1989: undefined reference to `is_power_of_two'
/usr/bin/ld: /home/ray/repo/drm/build/../tests/util/pattern.c:1990: undefined reference to `is_power_of_two'
/usr/bin/ld: /home/ray/repo/drm/build/../tests/util/pattern.c:1991: undefined reference to `is_power_of_two'
collect2: error: ld returned 1 exit status
Signed-off-by: Huang Rui <ray.huang@amd.com>
Add a new field userq_num_hqds to drm_amdgpu_info_hw_ip to expose the
number of available hardware queue descriptors (HQDs) for user queues.
This allows userspace to query the maximum number of user queues that
can be created for a particular IP block.
the patch link in driver side:
https://lists.freedesktop.org/archives/amd-gfx/2025-June/126686.htmlhttps://lists.freedesktop.org/archives/amd-gfx/2025-July/126981.html
v2: rename userq_num_hqds to userq_num_slots (Marek)
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Add seed argument for modetest noise patterns. If no seed is provided
the current time will be used as seed.
The used seed will be printed so the noise pattern can be reproduced.
Signed-off-by: Emil Svendsen <emas@bang-olufsen.dk>
Add three new test patterns:
- noise: random black and white pixels
- noise-color: random color pixels
- black-white: alternate between black and white pixels
These patterns are useful for measuring radiated emissions for EMC
compliance tests.
Signed-off-by: Emil Svendsen <emas@bang-olufsen.dk>
Synchronize drm.h, drm_mode.h and drm_fourcc.h to drm-next.
Generated using make headers_install.
Generated from drm-next branch commit 04c8970771b4f1f39bb8453a2eeb188c4d5edbd6
Signed-off-by: Simon Ser <contact@emersion.fr>
buildah tried to pull the arm64 variant of the arm32v7/debian:bookworm
container:
* choosing an image from manifest list docker://arm32v7/debian:bookworm: no image found in image index for architecture "arm64", variant "v8", OS "linux"
Signed-off-by: Simon Ser <contact@emersion.fr>
py39-docutils doesn't exist in the package repositories, likely
because the Python version has been upgraded. Let's not hardcode
the Python version in the package name.
Signed-off-by: Simon Ser <contact@emersion.fr>
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>
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.htmlhttps://lists.freedesktop.org/archives/amd-gfx/2025-April/122780.htmlhttps://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>
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>
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>
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>
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
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>
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>
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>
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>
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.