mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2025-12-20 03:30:22 +01:00
amdgpu: add env support for amdgpu.ids path
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.
This commit is contained in:
parent
a8e5e10a87
commit
c3c7fb21aa
2 changed files with 22 additions and 4 deletions
|
|
@ -49,3 +49,12 @@ Then use ninja to build and install:
|
||||||
|
|
||||||
If you are installing into a system location you will need to run install
|
If you are installing into a system location you will need to run install
|
||||||
separately, and as root.
|
separately, and as root.
|
||||||
|
|
||||||
|
AMDGPU ASIC table file
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
The AMDGPU driver requires the `amdgpu.ids` file. It is usually located at
|
||||||
|
`$PREFIX/share/libdrm`, but it is possible to specify an alternative path
|
||||||
|
during runtime by setting the `AMDGPU_ASIC_ID_TABLE_PATH` environment
|
||||||
|
variable with the full path (including the file name) of the alternative
|
||||||
|
file.
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,11 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// secure_getenv requires _GNU_SOURCE
|
||||||
|
#ifndef _GNU_SOURCE
|
||||||
|
#define _GNU_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
@ -168,10 +173,14 @@ void amdgpu_parse_asic_ids(struct amdgpu_device *dev)
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
int line_num = 1;
|
int line_num = 1;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
const char *amdgpu_asic_id_table_path = secure_getenv("AMDGPU_ASIC_ID_TABLE_PATH");
|
||||||
|
|
||||||
fp = fopen(AMDGPU_ASIC_ID_TABLE, "r");
|
if (amdgpu_asic_id_table_path == NULL || amdgpu_asic_id_table_path[0] == '\0')
|
||||||
|
amdgpu_asic_id_table_path = AMDGPU_ASIC_ID_TABLE;
|
||||||
|
|
||||||
|
fp = fopen(amdgpu_asic_id_table_path, "r");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
fprintf(stderr, "%s: %s\n", AMDGPU_ASIC_ID_TABLE,
|
fprintf(stderr, "%s: %s\n", amdgpu_asic_id_table_path,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
goto get_cpu;
|
goto get_cpu;
|
||||||
}
|
}
|
||||||
|
|
@ -188,7 +197,7 @@ void amdgpu_parse_asic_ids(struct amdgpu_device *dev)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
drmMsg("%s version: %s\n", AMDGPU_ASIC_ID_TABLE, line);
|
drmMsg("%s version: %s\n", amdgpu_asic_id_table_path, line);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -206,7 +215,7 @@ void amdgpu_parse_asic_ids(struct amdgpu_device *dev)
|
||||||
|
|
||||||
if (r == -EINVAL) {
|
if (r == -EINVAL) {
|
||||||
fprintf(stderr, "Invalid format: %s: line %d: %s\n",
|
fprintf(stderr, "Invalid format: %s: line %d: %s\n",
|
||||||
AMDGPU_ASIC_ID_TABLE, line_num, line);
|
amdgpu_asic_id_table_path, line_num, line);
|
||||||
} else if (r && r != -EAGAIN) {
|
} else if (r && r != -EAGAIN) {
|
||||||
fprintf(stderr, "%s: Cannot parse ASIC IDs: %s\n",
|
fprintf(stderr, "%s: Cannot parse ASIC IDs: %s\n",
|
||||||
__func__, strerror(-r));
|
__func__, strerror(-r));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue