loader: check if the kernel driver is amdgpu

This allows using drm-shim for an emulated driver in AMD GPU host.

Otherwise we need to set MESA_LOADER_DRIVER_OVERRIDE to the emulated
driver in order to make it working.

Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Acked-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41779>
This commit is contained in:
Juan A. Suarez Romero 2026-05-23 13:18:17 +02:00 committed by Marge Bot
parent 60d7aa4cb5
commit ddd12f2f3e
2 changed files with 12 additions and 1 deletions

View file

@ -124,6 +124,16 @@ loader_get_kernel_driver_name(int fd)
return driver;
}
bool
amd_predicate(int fd, const char *driver)
{
char *kernel_driver = loader_get_kernel_driver_name(fd);
bool ret = kernel_driver && (strcmp(kernel_driver, "amdgpu") == 0);
free(kernel_driver);
return ret;
}
bool
iris_predicate(int fd, const char *driver)
{

View file

@ -44,6 +44,7 @@ static const int vmwgfx_chip_ids[] = {
#undef CHIPSET
};
bool amd_predicate(int fd, const char *driver);
bool iris_predicate(int fd, const char *driver);
bool nouveau_zink_predicate(int fd, const char *driver);
@ -59,7 +60,7 @@ static const struct {
{ 0x8086, "iris", NULL, -1, iris_predicate },
{ 0x1002, "r300", r300_chip_ids, ARRAY_SIZE(r300_chip_ids) },
{ 0x1002, "r600", r600_chip_ids, ARRAY_SIZE(r600_chip_ids) },
{ 0x1002, "radeonsi", NULL, -1 },
{ 0x1002, "radeonsi", NULL, -1, amd_predicate },
{ 0x10de, "nouveau", NULL, -1, nouveau_zink_predicate },
{ 0x10de, "zink", NULL, -1, nouveau_zink_predicate },
{ 0x1af4, "virtio_gpu", virtio_gpu_chip_ids, ARRAY_SIZE(virtio_gpu_chip_ids) },