radeon: get device id from the kernel, use it in cs_print
This allow external tools to know for which asics a cs is destinated to.main
parent
2612371a62
commit
320811b282
|
@ -43,6 +43,11 @@
|
||||||
#include "xf86drm.h"
|
#include "xf86drm.h"
|
||||||
#include "radeon_drm.h"
|
#include "radeon_drm.h"
|
||||||
|
|
||||||
|
struct radeon_cs_manager_gem {
|
||||||
|
struct radeon_cs_manager base;
|
||||||
|
uint32_t device_id;
|
||||||
|
};
|
||||||
|
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
struct cs_reloc_gem {
|
struct cs_reloc_gem {
|
||||||
uint32_t handle;
|
uint32_t handle;
|
||||||
|
@ -330,8 +335,11 @@ static int cs_gem_need_flush(struct radeon_cs_int *cs)
|
||||||
|
|
||||||
static void cs_gem_print(struct radeon_cs_int *cs, FILE *file)
|
static void cs_gem_print(struct radeon_cs_int *cs, FILE *file)
|
||||||
{
|
{
|
||||||
|
struct radeon_cs_manager_gem *csm;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
csm = (struct radeon_cs_manager_gem *)cs->csm;
|
||||||
|
fprintf(file, "VENDORID:DEVICEID 0x%04X:0x%04X\n", 0x1002, csm->device_id);
|
||||||
for (i = 0; i < cs->cdw; i++) {
|
for (i = 0; i < cs->cdw; i++) {
|
||||||
fprintf(file, "0x%08X\n", cs->packets[i]);
|
fprintf(file, "0x%08X\n", cs->packets[i]);
|
||||||
}
|
}
|
||||||
|
@ -349,18 +357,31 @@ static struct radeon_cs_funcs radeon_cs_gem_funcs = {
|
||||||
cs_gem_print,
|
cs_gem_print,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int radeon_get_device_id(int fd, uint32_t *device_id)
|
||||||
|
{
|
||||||
|
struct drm_radeon_info info;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
*device_id = 0;
|
||||||
|
info.request = RADEON_INFO_DEVICE_ID;
|
||||||
|
info.value = device_id;
|
||||||
|
r = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info,
|
||||||
|
sizeof(struct drm_radeon_info));
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
struct radeon_cs_manager *radeon_cs_manager_gem_ctor(int fd)
|
struct radeon_cs_manager *radeon_cs_manager_gem_ctor(int fd)
|
||||||
{
|
{
|
||||||
struct radeon_cs_manager *csm;
|
struct radeon_cs_manager_gem *csm;
|
||||||
|
|
||||||
csm = (struct radeon_cs_manager*)calloc(1,
|
csm = calloc(1, sizeof(struct radeon_cs_manager_gem));
|
||||||
sizeof(struct radeon_cs_manager));
|
|
||||||
if (csm == NULL) {
|
if (csm == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
csm->funcs = &radeon_cs_gem_funcs;
|
csm->base.funcs = &radeon_cs_gem_funcs;
|
||||||
csm->fd = fd;
|
csm->base.fd = fd;
|
||||||
return csm;
|
radeon_get_device_id(fd, &csm->device_id);
|
||||||
|
return &csm->base;
|
||||||
}
|
}
|
||||||
|
|
||||||
void radeon_cs_manager_gem_dtor(struct radeon_cs_manager *csm)
|
void radeon_cs_manager_gem_dtor(struct radeon_cs_manager *csm)
|
||||||
|
|
Loading…
Reference in New Issue