Path: blob/21.2-virgl/src/intel/dev/intel_dev_info.c
7086 views
/*1* Copyright © 2020 Intel Corporation2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*/2223#include <stdio.h>24#include <stdlib.h>25#include <stdarg.h>26#include <inttypes.h>2728#include <sys/types.h>29#include <sys/stat.h>30#include <fcntl.h>31#include <unistd.h>3233#include <xf86drm.h>3435#include "intel_device_info.h"3637static int38error(char *fmt, ...)39{40va_list ap;41va_start(ap, fmt);42vfprintf(stderr, fmt, ap);43va_end(ap);4445return EXIT_FAILURE;46}4748int49main(int argc, char *argv[])50{51drmDevicePtr devices[8];52int max_devices;5354max_devices = drmGetDevices2(0, devices, ARRAY_SIZE(devices));55if (max_devices < 1)56return error("Not device found");5758for (int i = 0; i < max_devices; i++) {59struct intel_device_info devinfo;60const char *path = devices[i]->nodes[DRM_NODE_RENDER];61int fd = open(path, O_RDWR | O_CLOEXEC);6263if (fd < 0)64continue;6566bool success = intel_get_device_info_from_fd(fd, &devinfo);67close(fd);6869if (!success)70continue;7172fprintf(stdout, "%s:\n", path);7374fprintf(stdout, " name: %s\n", intel_get_device_name(devinfo.chipset_id));75fprintf(stdout, " gen: %u\n", devinfo.ver);76fprintf(stdout, " PCI id: 0x%x\n", devinfo.chipset_id);77fprintf(stdout, " revision: %u\n", devinfo.revision);7879const char *subslice_name = devinfo.ver >= 12 ? "dualsubslice" : "subslice";80uint32_t n_s = 0, n_ss = 0, n_eus = 0;81for (unsigned s = 0; s < devinfo.num_slices; s++) {82n_s += (devinfo.slice_masks & (1u << s)) ? 1 : 0;83for (unsigned ss = 0; ss < devinfo.num_subslices[s]; ss++) {84fprintf(stdout, " slice%u.%s%u: ", s, subslice_name, ss);85if (intel_device_info_subslice_available(&devinfo, s, ss)) {86n_ss++;87for (unsigned eu = 0; eu < devinfo.num_eu_per_subslice; eu++) {88n_eus += intel_device_info_eu_available(&devinfo, s, ss, eu) ? 1 : 0;89fprintf(stdout, "%s", intel_device_info_eu_available(&devinfo, s, ss, eu) ? "1" : "0");90}91} else {92fprintf(stderr, "fused");93}94fprintf(stdout, "\n");95}96}97fprintf(stdout, " slices: %u\n", n_s);98fprintf(stdout, " %s: %u\n", subslice_name, n_ss);99fprintf(stdout, " EU per %s: %u\n", subslice_name, devinfo.num_eu_per_subslice);100fprintf(stdout, " EUs: %u\n", n_eus);101fprintf(stdout, " EU threads: %u\n", n_eus * devinfo.num_thread_per_eu);102103fprintf(stdout, " LLC: %u\n", devinfo.has_llc);104fprintf(stdout, " threads per EU: %u\n", devinfo.num_thread_per_eu);105fprintf(stdout, " L3 banks: %u\n", devinfo.l3_banks);106fprintf(stdout, " max VS threads: %u\n", devinfo.max_vs_threads);107fprintf(stdout, " max TCS threads: %u\n", devinfo.max_tcs_threads);108fprintf(stdout, " max TES threads: %u\n", devinfo.max_tes_threads);109fprintf(stdout, " max GS threads: %u\n", devinfo.max_gs_threads);110fprintf(stdout, " max WM threads: %u\n", devinfo.max_wm_threads);111fprintf(stdout, " max CS threads: %u\n", devinfo.max_cs_threads);112fprintf(stdout, " timestamp frequency: %" PRIu64 "\n", devinfo.timestamp_frequency);113}114115return EXIT_SUCCESS;116}117118119