Commit 538091ce authored by Chris Wilson's avatar Chris Wilson 😣

tools: Stop opening the driver just to find the debugfs

Since the tools want to work without the module loaded, remove the
assumption that we want to load the driver to find debugfs.
Signed-off-by: Chris Wilson's avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Ville Syrjälä's avatarVille Syrjala <ville.syrjala@linux.intel.com>
parent 9fb5344b
......@@ -150,19 +150,22 @@ char *igt_debugfs_path(int device, char *path, int pathlen)
const char *debugfs_root;
int idx;
if (fstat(device, &st)) {
igt_debug("Couldn't stat FD for DRM device: %s\n", strerror(errno));
return NULL;
}
if (!S_ISCHR(st.st_mode)) {
igt_debug("FD for DRM device not a char device!\n");
return NULL;
}
debugfs_root = igt_debugfs_mount();
igt_assert(debugfs_root);
memset(&st, 0, sizeof(st));
if (device != -1) { /* if no fd, we presume we want dri/0 */
if (fstat(device, &st)) {
igt_debug("Couldn't stat FD for DRM device: %m\n");
return NULL;
}
if (!S_ISCHR(st.st_mode)) {
igt_debug("FD for DRM device not a char device!\n");
return NULL;
}
}
idx = minor(st.st_rdev);
snprintf(path, pathlen, "%s/dri/%d/name", debugfs_root, idx);
if (stat(path, &st))
......
......@@ -965,7 +965,6 @@ int main(int argc, char *argv[])
int pipe = 0, bit = 0, target_scanline = 0, target_fuzz = 1;
bool test_pixelcount = false;
uint32_t devid;
int drm_fd;
uint32_t min[2*128] = {};
uint32_t max[2*128] = {};
uint32_t a, b;
......@@ -1187,10 +1186,7 @@ int main(int argc, char *argv[])
break;
}
/* Just to make sure we open the right debugfs files */
drm_fd = drm_open_driver_master(DRIVER_INTEL);
intel_register_access_init(intel_get_pci_device(), 0, drm_fd);
intel_register_access_init(intel_get_pci_device(), 0, -1);
printf("%s?\n", test_name(test, pipe, bit, test_pixelcount));
......@@ -1267,8 +1263,6 @@ int main(int argc, char *argv[])
intel_register_access_fini();
close(drm_fd);
if (quit)
return 0;
......
......@@ -64,7 +64,6 @@ is_alive(void) {
int main(int argc, char *argv[])
{
int drm_fd;
int ret;
if (argc > 2 || (argc == 2 && !strncmp(argv[1], "-h", 2))) {
......@@ -81,10 +80,7 @@ int main(int argc, char *argv[])
INFO_PRINT("started daemon");
}
/* Just to make sure we open the right debugfs files */
drm_fd = drm_open_driver_master(DRIVER_INTEL);
ret = intel_register_access_init(intel_get_pci_device(), 1, drm_fd);
ret = intel_register_access_init(intel_get_pci_device(), 1, -1);
if (ret) {
INFO_PRINT("Couldn't init register access\n");
exit(1);
......@@ -95,14 +91,13 @@ int main(int argc, char *argv[])
if (!is_alive()) {
INFO_PRINT("gpu reset? restarting daemon\n");
intel_register_access_fini();
ret = intel_register_access_init(intel_get_pci_device(), 1, drm_fd);
ret = intel_register_access_init(intel_get_pci_device(), 1, -1);
if (ret)
INFO_PRINT("Reg access init fail\n");
}
sleep(1);
}
intel_register_access_fini();
close(drm_fd);
INFO_PRINT("Forcewake unlock\n");
if (daemonized) {
......
......@@ -409,7 +409,6 @@ usage(const char *appname)
int main(int argc, char **argv)
{
uint32_t devid;
int drm_fd;
struct pci_device *pci_dev;
struct ring render_ring = {
.name = "render",
......@@ -510,11 +509,8 @@ int main(int argc, char **argv)
top_bits_sorted[i] = &top_bits[i];
}
/* Just to make sure we open the right debugfs files */
drm_fd = drm_open_driver(DRIVER_INTEL);
/* Grab access to the registers */
intel_register_access_init(pci_dev, 0, drm_fd);
intel_register_access_init(pci_dev, 0, -1);
ring_init(&render_ring);
if (IS_GEN4(devid) || IS_GEN5(devid))
......@@ -717,6 +713,5 @@ int main(int argc, char **argv)
fclose(output);
intel_register_access_fini();
close(drm_fd);
return 0;
}
......@@ -46,7 +46,7 @@ int verbosity_level = 3; /* by default capture logs at max verbosity */
uint32_t produced, consumed;
uint64_t total_bytes_written;
int num_buffers = NUM_SUBBUFS;
int relay_fd, drm_fd, outfile_fd = -1;
int relay_fd, outfile_fd = -1;
uint32_t test_duration, max_filesize;
pthread_cond_t underflow_cond, overflow_cond;
bool stop_logging, discard_oldlogs, capturing_stopped;
......@@ -58,7 +58,7 @@ static void guc_log_control(bool enable_logging)
uint64_t val;
int ret;
control_fd = igt_debugfs_open(drm_fd, CONTROL_FILE_NAME, O_WRONLY);
control_fd = igt_debugfs_open(-1, CONTROL_FILE_NAME, O_WRONLY);
igt_assert_f(control_fd >= 0, "couldn't open the guc log control file\n");
val = enable_logging ? ((verbosity_level << 4) | 0x1) : 0;
......@@ -227,7 +227,7 @@ static void init_flusher_thread(void)
static void open_relay_file(void)
{
relay_fd = igt_debugfs_open(drm_fd, RELAY_FILE_NAME, O_RDONLY);
relay_fd = igt_debugfs_open(-1, RELAY_FILE_NAME, O_RDONLY);
igt_assert_f(relay_fd >= 0, "couldn't open the guc log file\n");
/* Purge the old/boot-time logs from the relay buffer.
......@@ -373,9 +373,6 @@ int main(int argc, char **argv)
process_command_line(argc, argv);
/* Just to make sure we open the right debugfs files */
drm_fd = drm_open_driver_master(DRIVER_INTEL);
init_main_thread();
/* Use a separate thread for flushing the logs to a file on disk.
......@@ -436,6 +433,5 @@ int main(int argc, char **argv)
free(read_buffer);
close(relay_fd);
close(outfile_fd);
close(drm_fd);
igt_exit();
}
......@@ -1081,7 +1081,6 @@ printf("Options:\n"
int main(int argc, char *argv[])
{
int opt;
int drm_fd;
int ret = 0;
Transcoder transcoder = TRANSC_INVALID;
DipType dip = DIP_INVALID;
......@@ -1108,11 +1107,8 @@ int main(int argc, char *argv[])
printf("WARNING: This is just a debugging tool! Don't expect it to work"
" perfectly: the Kernel might undo our changes.\n");
/* Just to make sure we open the right debugfs files */
drm_fd = drm_open_driver_master(DRIVER_INTEL);
pci_dev = intel_get_pci_device();
intel_register_access_init(pci_dev, 0, drm_fd);
intel_register_access_init(pci_dev, 0, -1);
intel_check_pch();
if (IS_GEN4(pci_dev->device_id))
......@@ -1261,6 +1257,5 @@ int main(int argc, char *argv[])
out:
intel_register_access_fini();
close(drm_fd);
return ret;
}
......@@ -266,7 +266,7 @@ static void print_usage(void)
int main (int argc, char *argv[])
{
int opt, drm_fd;
int opt;
int ret = 0;
char intel_pipe = '\0';
int x = 0, y = 0;
......@@ -279,11 +279,8 @@ int main (int argc, char *argv[])
"with overscan compensation properties: it is just a temporary "
"solution that may or may not work. Use it at your own risk.\n");
/* Just to make sure we open the right debugfs files */
drm_fd = drm_open_driver_master(DRIVER_INTEL);
pci_dev = intel_get_pci_device();
intel_register_access_init(pci_dev, 0, drm_fd);
intel_register_access_init(pci_dev, 0, -1);
devid = pci_dev->device_id;
if (!HAS_PCH_SPLIT(devid)) {
......@@ -346,6 +343,5 @@ int main (int argc, char *argv[])
out:
intel_register_access_fini();
close(drm_fd);
return ret;
}
......@@ -58,7 +58,6 @@ struct config {
struct pci_device *pci_dev;
char *mmiofile;
uint32_t devid;
int drm_fd;
/* read: number of registers to read */
uint32_t count;
......@@ -411,7 +410,7 @@ static int intel_reg_read(struct config *config, int argc, char *argv[])
if (config->mmiofile)
intel_mmio_use_dump_file(config->mmiofile);
else
intel_register_access_init(config->pci_dev, 0, config->drm_fd);
intel_register_access_init(config->pci_dev, 0, -1);
for (i = 1; i < argc; i++) {
struct reg reg;
......@@ -441,7 +440,7 @@ static int intel_reg_write(struct config *config, int argc, char *argv[])
return EXIT_FAILURE;
}
intel_register_access_init(config->pci_dev, 0, config->drm_fd);
intel_register_access_init(config->pci_dev, 0, -1);
for (i = 1; i < argc; i += 2) {
struct reg reg;
......@@ -479,7 +478,7 @@ static int intel_reg_dump(struct config *config, int argc, char *argv[])
if (config->mmiofile)
intel_mmio_use_dump_file(config->mmiofile);
else
intel_register_access_init(config->pci_dev, 0, config->drm_fd);
intel_register_access_init(config->pci_dev, 0, -1);
for (i = 0; i < config->regcount; i++) {
reg = &config->regs[i];
......@@ -879,9 +878,6 @@ int main(int argc, char *argv[])
config.devid = config.pci_dev->device_id;
}
/* Just to make sure we open the right debugfs files */
config.drm_fd = __drm_open_driver(DRIVER_INTEL);
if (read_reg_spec(&config) < 0) {
return EXIT_FAILURE;
}
......
......@@ -34,7 +34,6 @@
static uint32_t display_base;
static uint32_t devid;
static int drm_fd;
static uint32_t read_reg(uint32_t addr)
{
......@@ -143,7 +142,7 @@ static void ilk_wm_dump(void)
int num_pipes = is_gen7_plus(devid) ? 3 : 2;
struct ilk_wm wm = {};
intel_register_access_init(intel_get_pci_device(), 0, drm_fd);
intel_register_access_init(intel_get_pci_device(), 0, -1);
for (i = 0; i < num_pipes; i++) {
dspcntr[i] = read_reg(0x70180 + i * 0x1000);
......@@ -291,7 +290,7 @@ static void vlv_wm_dump(void)
uint32_t dsp_ss_pm, ddr_setup2;
struct gmch_wm wms[MAX_PLANE] = {};
intel_register_access_init(intel_get_pci_device(), 0, drm_fd);
intel_register_access_init(intel_get_pci_device(), 0, -1);
dsparb = read_reg(0x70030);
dsparb2 = read_reg(0x70060);
......@@ -507,7 +506,7 @@ static void g4x_wm_dump(void)
uint32_t mi_arb_state;
struct gmch_wm wms[MAX_PLANE] = {};
intel_register_access_init(intel_get_pci_device(), 0, drm_fd);
intel_register_access_init(intel_get_pci_device(), 0, -1);
dspacntr = read_reg(0x70180);
dspbcntr = read_reg(0x71180);
......@@ -593,7 +592,7 @@ static void gen4_wm_dump(void)
uint32_t mi_arb_state;
struct gmch_wm wms[MAX_PLANE] = {};
intel_register_access_init(intel_get_pci_device(), 0, drm_fd);
intel_register_access_init(intel_get_pci_device(), 0, -1);
dsparb = read_reg(0x70030);
fw1 = read_reg(0x70034);
......@@ -664,7 +663,7 @@ static void pnv_wm_dump(void)
uint32_t cbr;
struct gmch_wm wms[MAX_PLANE] = {};
intel_register_access_init(intel_get_pci_device(), 0, drm_fd);
intel_register_access_init(intel_get_pci_device(), 0, -1);
dsparb = read_reg(0x70030);
fw1 = read_reg(0x70034);
......@@ -754,7 +753,7 @@ static void gen3_wm_dump(void)
uint32_t mi_arb_state;
struct gmch_wm wms[MAX_PLANE] = {};
intel_register_access_init(intel_get_pci_device(), 0, drm_fd);
intel_register_access_init(intel_get_pci_device(), 0, -1);
dsparb = read_reg(0x70030);
instpm = read_reg(0x20c0);
......@@ -823,7 +822,7 @@ static void gen2_wm_dump(void)
uint32_t mi_state;
struct gmch_wm wms[MAX_PLANE] = {};
intel_register_access_init(intel_get_pci_device(), 0, drm_fd);
intel_register_access_init(intel_get_pci_device(), 0, -1);
dsparb = read_reg(0x70030);
mem_mode = read_reg(0x20cc);
......@@ -900,9 +899,6 @@ int main(int argc, char *argv[])
{
devid = intel_get_pci_device()->device_id;
/* Just to make sure we open the right debugfs files */
drm_fd = drm_open_driver_master(DRIVER_INTEL);
if (IS_VALLEYVIEW(devid) || IS_CHERRYVIEW(devid)) {
display_base = 0x180000;
vlv_wm_dump();
......@@ -923,7 +919,5 @@ int main(int argc, char *argv[])
return 1;
}
close(drm_fd);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment