ac/info: move pci bus info in a struct
And add a validity flag because there's no way to tell if they're valid, unless for the caller of drmGetDevice2. Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20645>
This commit is contained in:
@@ -607,10 +607,11 @@ bool ac_query_gpu_info(int fd, void *dev_p, struct radeon_info *info)
|
||||
fprintf(stderr, "amdgpu: drmGetDevice2 failed.\n");
|
||||
return false;
|
||||
}
|
||||
info->pci_domain = devinfo->businfo.pci->domain;
|
||||
info->pci_bus = devinfo->businfo.pci->bus;
|
||||
info->pci_dev = devinfo->businfo.pci->dev;
|
||||
info->pci_func = devinfo->businfo.pci->func;
|
||||
info->pci.domain = devinfo->businfo.pci->domain;
|
||||
info->pci.bus = devinfo->businfo.pci->bus;
|
||||
info->pci.dev = devinfo->businfo.pci->dev;
|
||||
info->pci.func = devinfo->businfo.pci->func;
|
||||
info->pci.valid = true;
|
||||
drmFreeDevice(&devinfo);
|
||||
|
||||
assert(info->drm_major == 3);
|
||||
@@ -1399,10 +1400,14 @@ void ac_compute_device_uuid(struct radeon_info *info, char *uuid, size_t size)
|
||||
* required would get rid of part of the little entropy we have.
|
||||
* */
|
||||
memset(uuid, 0, size);
|
||||
uint_uuid[0] = info->pci_domain;
|
||||
uint_uuid[1] = info->pci_bus;
|
||||
uint_uuid[2] = info->pci_dev;
|
||||
uint_uuid[3] = info->pci_func;
|
||||
if (!info->pci.valid) {
|
||||
fprintf(stderr,
|
||||
"ac_compute_device_uuid's output is based on invalid pci bus info.\n");
|
||||
}
|
||||
uint_uuid[0] = info->pci.domain;
|
||||
uint_uuid[1] = info->pci.bus;
|
||||
uint_uuid[2] = info->pci.dev;
|
||||
uint_uuid[3] = info->pci.func;
|
||||
}
|
||||
|
||||
void ac_print_gpu_info(struct radeon_info *info, FILE *f)
|
||||
@@ -1457,8 +1462,11 @@ void ac_print_gpu_info(struct radeon_info *info, FILE *f)
|
||||
}
|
||||
|
||||
fprintf(f, "Identification:\n");
|
||||
fprintf(f, " pci (domain:bus:dev.func): %04x:%02x:%02x.%x\n", info->pci_domain, info->pci_bus,
|
||||
info->pci_dev, info->pci_func);
|
||||
if (info->pci.valid)
|
||||
fprintf(f, " pci (domain:bus:dev.func): %04x:%02x:%02x.%x\n", info->pci.domain, info->pci.bus,
|
||||
info->pci.dev, info->pci.func);
|
||||
else
|
||||
fprintf(f, " pci (domain:bus:dev.func): unknown\n");
|
||||
fprintf(f, " pci_id = 0x%x\n", info->pci_id);
|
||||
fprintf(f, " pci_rev_id = 0x%x\n", info->pci_rev_id);
|
||||
fprintf(f, " family = %i\n", info->family);
|
||||
|
||||
@@ -73,10 +73,13 @@ struct radeon_info {
|
||||
|
||||
/* Identification. */
|
||||
/* PCI info: domain:bus:dev:func */
|
||||
uint32_t pci_domain;
|
||||
uint32_t pci_bus;
|
||||
uint32_t pci_dev;
|
||||
uint32_t pci_func;
|
||||
struct {
|
||||
uint32_t domain;
|
||||
uint32_t bus;
|
||||
uint32_t dev;
|
||||
uint32_t func;
|
||||
bool valid;
|
||||
} pci;
|
||||
|
||||
uint32_t pci_id;
|
||||
uint32_t pci_rev_id;
|
||||
|
||||
@@ -158,9 +158,12 @@ ac_check_profile_state(const struct radeon_info *info)
|
||||
char data[128];
|
||||
int n;
|
||||
|
||||
if (!info->pci.valid)
|
||||
return false; /* Unknown but optimistic. */
|
||||
|
||||
snprintf(path, sizeof(path),
|
||||
"/sys/bus/pci/devices/%04x:%02x:%02x.%x/power_dpm_force_performance_level",
|
||||
info->pci_domain, info->pci_bus, info->pci_dev, info->pci_func);
|
||||
info->pci.domain, info->pci.bus, info->pci.dev, info->pci.func);
|
||||
|
||||
FILE *f = fopen(path, "r");
|
||||
if (!f)
|
||||
|
||||
@@ -440,7 +440,7 @@ radv_rmv_fill_device_info(struct radv_physical_device *device, struct vk_rmv_dev
|
||||
strncpy(info->device_name, rad_info->marketing_name, sizeof(info->device_name) - 1);
|
||||
info->pcie_family_id = rad_info->family_id;
|
||||
info->pcie_revision_id = rad_info->pci_rev_id;
|
||||
info->pcie_device_id = rad_info->pci_dev;
|
||||
info->pcie_device_id = rad_info->pci.dev;
|
||||
info->minimum_shader_clock = 0;
|
||||
info->maximum_shader_clock = rad_info->max_gpu_freq_mhz;
|
||||
info->vram_type = memory_type_from_vram_type(rad_info->vram_type);
|
||||
|
||||
@@ -171,7 +171,7 @@ rra_dump_asic_info(struct radeon_info *rad_info, FILE *output)
|
||||
.mem_ops_per_clk = ac_memory_ops_per_clock(rad_info->vram_type),
|
||||
.bus_width = rad_info->memory_bus_width,
|
||||
|
||||
.device_id = rad_info->pci_dev,
|
||||
.device_id = rad_info->pci.dev,
|
||||
.rev_id = rad_info->pci_rev_id,
|
||||
};
|
||||
|
||||
|
||||
@@ -232,13 +232,13 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
|
||||
case PIPE_CAP_UMA:
|
||||
return 0;
|
||||
case PIPE_CAP_PCI_GROUP:
|
||||
return r300screen->info.pci_domain;
|
||||
return r300screen->info.pci.domain;
|
||||
case PIPE_CAP_PCI_BUS:
|
||||
return r300screen->info.pci_bus;
|
||||
return r300screen->info.pci.bus;
|
||||
case PIPE_CAP_PCI_DEVICE:
|
||||
return r300screen->info.pci_dev;
|
||||
return r300screen->info.pci.dev;
|
||||
case PIPE_CAP_PCI_FUNCTION:
|
||||
return r300screen->info.pci_func;
|
||||
return r300screen->info.pci.func;
|
||||
default:
|
||||
return u_pipe_screen_get_param_defaults(pscreen, param);
|
||||
}
|
||||
|
||||
@@ -522,13 +522,13 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
|
||||
case PIPE_CAP_MULTISAMPLE_Z_RESOLVE:
|
||||
return rscreen->b.gfx_level >= R700;
|
||||
case PIPE_CAP_PCI_GROUP:
|
||||
return rscreen->b.info.pci_domain;
|
||||
return rscreen->b.info.pci.domain;
|
||||
case PIPE_CAP_PCI_BUS:
|
||||
return rscreen->b.info.pci_bus;
|
||||
return rscreen->b.info.pci.bus;
|
||||
case PIPE_CAP_PCI_DEVICE:
|
||||
return rscreen->b.info.pci_dev;
|
||||
return rscreen->b.info.pci.dev;
|
||||
case PIPE_CAP_PCI_FUNCTION:
|
||||
return rscreen->b.info.pci_func;
|
||||
return rscreen->b.info.pci.func;
|
||||
|
||||
case PIPE_CAP_MAX_COMBINED_HW_ATOMIC_COUNTERS:
|
||||
if (rscreen->b.family >= CHIP_CEDAR && rscreen->has_atomics)
|
||||
|
||||
@@ -1276,8 +1276,8 @@ bool r600_common_screen_init(struct r600_common_screen *rscreen,
|
||||
|
||||
if (rscreen->debug_flags & DBG_INFO) {
|
||||
printf("pci (domain:bus:dev.func): %04x:%02x:%02x.%x\n",
|
||||
rscreen->info.pci_domain, rscreen->info.pci_bus,
|
||||
rscreen->info.pci_dev, rscreen->info.pci_func);
|
||||
rscreen->info.pci.domain, rscreen->info.pci.bus,
|
||||
rscreen->info.pci.dev, rscreen->info.pci.func);
|
||||
printf("pci_id = 0x%x\n", rscreen->info.pci_id);
|
||||
printf("family = %i (%s)\n", rscreen->info.family,
|
||||
r600_get_family_name(rscreen));
|
||||
|
||||
@@ -387,13 +387,13 @@ static int si_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
|
||||
case PIPE_CAP_VIDEO_MEMORY:
|
||||
return sscreen->info.vram_size_kb >> 10;
|
||||
case PIPE_CAP_PCI_GROUP:
|
||||
return sscreen->info.pci_domain;
|
||||
return sscreen->info.pci.domain;
|
||||
case PIPE_CAP_PCI_BUS:
|
||||
return sscreen->info.pci_bus;
|
||||
return sscreen->info.pci.bus;
|
||||
case PIPE_CAP_PCI_DEVICE:
|
||||
return sscreen->info.pci_dev;
|
||||
return sscreen->info.pci.dev;
|
||||
case PIPE_CAP_PCI_FUNCTION:
|
||||
return sscreen->info.pci_func;
|
||||
return sscreen->info.pci.func;
|
||||
|
||||
default:
|
||||
return u_pipe_screen_get_param_defaults(pscreen, param);
|
||||
|
||||
Reference in New Issue
Block a user