Since glibc-2.43:
For ISO C23, the functions bsearch, memchr, strchr, strpbrk, strrchr,
strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr that return pointers
into their input arrays now have definitions as macros that return a
pointer to a const-qualified type when the input argument is a pointer
to a const-qualified type.
fixes:
tests/modetest/modetest.c: In function 'parse_connector':
tests/modetest/modetest.c:1997:22: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1997 | endp = strpbrk(p, ",@:");
| ^
Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
Since glibc-2.43:
For ISO C23, the functions bsearch, memchr, strchr, strpbrk, strrchr,
strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr that return pointers
into their input arrays now have definitions as macros that return a
pointer to a const-qualified type when the input argument is a pointer
to a const-qualified type.
fixes:
amdgpu/amdgpu_asic_id.c: In function 'find_asic_id_table':
amdgpu/amdgpu_asic_id.c:249:19: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
249 | file_name = strrchr(AMDGPU_ASIC_ID_TABLE, '/');
| ^
Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
This fixes a build error with Tegra.
Fixes: 8cc2d09c ("amdgpu: reserve half of the addr space to implement a workaround for PRT")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
On GFX6-GFX12, except GFX9, SMEM loads on NULL PRT pages would just
fault and hang the GPU. The better workaround that we found is to split
the address space in two equal parts "LOW"/"HIGH", here's more details:
To workaround that, the driver splits the total VA space in half, so
that a single bit controls whether it's the "HIGH" or the "LOW"
address space. Every sparse residency buffer allocations that might
be used with SMEM get two allocations:
- the "HIGH" address space is mapped normally and its VA is returned
to the application.
- the "LOW" address space is explicitly mapped to a zero-initialized
buffer when it's allocated or when it's unmapped.
Other buffer allocations are always allocated in the "LOW" address.
The driver also creates a zero-allocated BO that will be used to map
partially resident buffers at creation and when explicitly unmapped.
The size is arbitrary but it seems that allocating 8MiB is perfectly
reasonable and fast enough in most cases. This BO is marked as
read-only for the GPU because the backend compilers don't use SMEM
stores.
For example this makes the "LOW" half of the HIGH VA range like
[0xffff800100000000,0xffffbfffffbfe000], and the "HIGH" half is left
for PRT.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Check the return value of asprintf() in drmGetFormatModifierNameFromNvidia(),
drmGetFormatModifierNameFromAmlogic(), and drmGetFormatModifierNameFromVivante()
to avoid leaving pointers uninitialized on allocation failure.
asprintf() returns -1 on failure and does not guarantee the output pointer
is set to NULL, which could lead to undefined behavior if the pointer is
used subsequently. Set the pointer to NULL explicitly on failure.
Fixes: -Wunused-result warnings from GCC
Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
The modifiers for DRM_FORMAT_MOD_VENDOR_APPLE are simple and cna be
represented in a static table. Add "APPLE" as pattern.
Signed-off-by: Janne Grunau <j@jannau.net>
When adding support for defining extra paths for the `amdgpu.ids`
file using an environment variable, the patch used a call to
secure_getenv(), which is only available in GNU. This breaks the
build in NetBSD systems.
This patch adds conditional compilation to use secure_getenv()
only when compiling against the GNU libraries.
Fix c3c7fb21aa (note_3229411)
Signed-off-by: Sergio Costas Rodriguez <sergio.costas@canonical.com>
Synchronize drm.h, drm_mode.h and drm_fourcc.h to drm-next.
Generated using make headers_install
Generated from drm-next branch commit 0692602defb0c273f80dec9c564ca50726404aca
Signed-off-by: Simon Ser <contact@emersion.fr>
The header shipped with libdrm was missing blob resources, context_init,
syncobj support, and capset definitions.
Update to the current version from Linux, which was last modified in 6.16.
Signed-off-by: Val Packett <val@invisiblethingslab.com>
The buffer size is calculated using pixels, not bytes as it should. The
result is often correct, though, as the stride is aligned to page size,
but there are still many cases where the size ends up being wrong.
Fix this by not calculating the size at all, as in that case
DRM_OMAP_GEM_INFO ioctl is used to get the correct size from the kernel.
This is better in any case as then the userspace library doesn't need to
know how the tiled buffers need to be aligned.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Andrew Davis <afd@ti.com>
After a change in the patch, the environment variable name for
the `amdgpu.ids` file paths changed to plurar form, but the
documentation wasn't updated.
This patch fixes it.
This patch allows to specify several colon-separated paths where
to search for the `amdgpu.ids` file in the AMDGPU_ASIC_ID_TABLE_PATH
environment variable.
In some cases, like when building a Snap application that uses
libdrm, the `amdgpu.ids` file isn't directly available at the
compiling place, but inside a mounted folder. This forces each
application to link/bind the file from the current place
(usually at the $SNAP/gnome-platform/usr/share/libdrm/amdgpu.ids)
which is cumbersome.
This patch allows to set an environment variable, called
AMDGPU_ASIC_ID_TABLE_PATH, where the file will be also searched
if it isn't located in the default, meson-configured, path.
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>