summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2019-03-27 20:52:52 +0200
committerVille Syrjälä <ville.syrjala@linux.intel.com>2019-03-29 22:23:27 +0200
commite408d569973b610ba4aafdba016c48b25e563468 (patch)
treee3e1050d63918d053369c7669b62097d501a0451 /tools
parent1ac3264e0370134d06e2cff211c0da4aa5c7d83b (diff)
Revert "lib/igt_device: Move intel_get_pci_device under igt_device"
One significant usecase for intel_reg/etc. is to be able to examine the hardware state *before* loading the driver. If the tool forces the driver to load we've totally lost that capability. This reverts commit 8ae86621d6fff60b6e20c6b0f9b336785c935b0f. Cc: Michał Winiarski <michal.winiarski@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Acked-by: Jani Nikula <jani.nikula@intel.com> Acked-by: Michał Winiarski <michal.winiarski@intel.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/intel_audio_dump.c9
-rw-r--r--tools/intel_backlight.c8
-rw-r--r--tools/intel_display_poller.c8
-rw-r--r--tools/intel_forcewaked.c10
-rw-r--r--tools/intel_gpu_time.c8
-rw-r--r--tools/intel_gtt.c8
-rw-r--r--tools/intel_infoframes.c7
-rw-r--r--tools/intel_l3_parity.c3
-rw-r--r--tools/intel_lid.c9
-rw-r--r--tools/intel_panel_fitter.c8
-rw-r--r--tools/intel_perf_counters.c3
-rw-r--r--tools/intel_reg.c23
-rw-r--r--tools/intel_reg_checker.c8
-rw-r--r--tools/intel_watermark.c23
14 files changed, 40 insertions, 95 deletions
diff --git a/tools/intel_audio_dump.c b/tools/intel_audio_dump.c
index 350a21d9..90260a2f 100644
--- a/tools/intel_audio_dump.c
+++ b/tools/intel_audio_dump.c
@@ -32,7 +32,6 @@
#include <string.h>
#include <err.h>
#include <arpa/inet.h>
-#include "igt_device.h"
#include "intel_io.h"
#include "intel_reg.h"
#include "intel_chipset.h"
@@ -2465,12 +2464,8 @@ static void dump_braswell(void)
int main(int argc, char **argv)
{
struct pci_device *pci_dev;
- int fd;
-
- fd = drm_open_driver(DRIVER_INTEL);
- pci_dev = igt_device_get_pci_device(fd);
- close(fd);
+ pci_dev = intel_get_pci_device();
devid = pci_dev->device_id; /* XXX not true when mapping! */
do_self_tests();
@@ -2498,7 +2493,5 @@ int main(int argc, char **argv)
dump_eaglelake();
}
- close(fd);
-
return 0;
}
diff --git a/tools/intel_backlight.c b/tools/intel_backlight.c
index fc45d985..067fd418 100644
--- a/tools/intel_backlight.c
+++ b/tools/intel_backlight.c
@@ -30,9 +30,8 @@
#include <stdio.h>
#include <string.h>
-#include "drmtest.h"
-#include "igt_device.h"
#include "intel_io.h"
+#include "intel_chipset.h"
#include "intel_reg.h"
/* XXX PCH only today */
@@ -40,11 +39,8 @@
int main(int argc, char** argv)
{
uint32_t current, max;
- int fd;
- fd = drm_open_driver(DRIVER_INTEL);
- intel_mmio_use_pci_bar(igt_device_get_pci_device(fd));
- close(fd);
+ intel_mmio_use_pci_bar(intel_get_pci_device());
current = INREG(BLC_PWM_CPU_CTL) & BACKLIGHT_DUTY_CYCLE_MASK;
max = INREG(BLC_PWM_PCH_CTL2) >> 16;
diff --git a/tools/intel_display_poller.c b/tools/intel_display_poller.c
index 293574f2..51f5b9a5 100644
--- a/tools/intel_display_poller.c
+++ b/tools/intel_display_poller.c
@@ -36,7 +36,6 @@
#include "intel_io.h"
#include "intel_reg.h"
#include "igt_debugfs.h"
-#include "igt_device.h"
#include "drmtest.h"
#include "igt_aux.h"
@@ -972,7 +971,6 @@ int main(int argc, char *argv[])
uint32_t a, b;
enum test test = TEST_INVALID;
const int count = ARRAY_SIZE(min)/2;
- int fd;
for (;;) {
static const struct option long_options[] = {
@@ -1048,8 +1046,7 @@ int main(int argc, char *argv[])
}
}
- fd = drm_open_driver(DRIVER_INTEL);
- devid = igt_device_get_pci_device(fd)->device_id;
+ devid = intel_get_pci_device()->device_id;
/*
* check if the requires registers are
@@ -1190,7 +1187,7 @@ int main(int argc, char *argv[])
break;
}
- intel_register_access_init(igt_device_get_pci_device(fd), 0, -1);
+ intel_register_access_init(intel_get_pci_device(), 0, -1);
printf("%s?\n", test_name(test, pipe, bit, test_pixelcount));
@@ -1266,7 +1263,6 @@ int main(int argc, char *argv[])
}
intel_register_access_fini();
- close(fd);
if (quit)
return 0;
diff --git a/tools/intel_forcewaked.c b/tools/intel_forcewaked.c
index 7d32337a..02fbf888 100644
--- a/tools/intel_forcewaked.c
+++ b/tools/intel_forcewaked.c
@@ -34,8 +34,8 @@
#include <stdlib.h>
#include <syslog.h>
#include <unistd.h>
-#include "igt_device.h"
#include "intel_io.h"
+#include "intel_chipset.h"
#include "drmtest.h"
bool daemonized;
@@ -65,7 +65,6 @@ is_alive(void) {
int main(int argc, char *argv[])
{
int ret;
- int fd;
if (argc > 2 || (argc == 2 && !strncmp(argv[1], "-h", 2))) {
help(argv[1]);
@@ -81,27 +80,24 @@ int main(int argc, char *argv[])
INFO_PRINT("started daemon");
}
- fd = drm_open_driver(DRIVER_INTEL);
- ret = intel_register_access_init(igt_device_get_pci_device(fd), 1, -1);
+ ret = intel_register_access_init(intel_get_pci_device(), 1, -1);
if (ret) {
INFO_PRINT("Couldn't init register access\n");
exit(1);
} else {
INFO_PRINT("Forcewake locked\n");
}
-
while(1) {
if (!is_alive()) {
INFO_PRINT("gpu reset? restarting daemon\n");
intel_register_access_fini();
- ret = intel_register_access_init(igt_device_get_pci_device(fd), 1, -1);
+ 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(fd);
INFO_PRINT("Forcewake unlock\n");
if (daemonized) {
diff --git a/tools/intel_gpu_time.c b/tools/intel_gpu_time.c
index 0fc73f92..56d65fe0 100644
--- a/tools/intel_gpu_time.c
+++ b/tools/intel_gpu_time.c
@@ -34,9 +34,8 @@
#include <sys/resource.h>
#include <sys/wait.h>
-#include "drmtest.h"
-#include "igt_device.h"
#include "intel_io.h"
+#include "intel_chipset.h"
#include "intel_reg.h"
#define SAMPLES_PER_SEC 10000
@@ -67,11 +66,8 @@ int main(int argc, char **argv)
struct timeval start, end;
static struct rusage rusage;
int status;
- int fd;
- fd = drm_open_driver(DRIVER_INTEL);
- intel_mmio_use_pci_bar(igt_device_get_pci_device(fd));
- close(fd);
+ intel_mmio_use_pci_bar(intel_get_pci_device());
if (argc == 1) {
fprintf(stderr, "usage: %s cmd [args...]\n", argv[0]);
diff --git a/tools/intel_gtt.c b/tools/intel_gtt.c
index 5740e794..311694ba 100644
--- a/tools/intel_gtt.c
+++ b/tools/intel_gtt.c
@@ -34,8 +34,6 @@
#include <pciaccess.h>
#include <unistd.h>
-#include "drmtest.h"
-#include "igt_device.h"
#include "intel_io.h"
#include "intel_chipset.h"
@@ -142,17 +140,13 @@ int main(int argc, char **argv)
{
struct pci_device *pci_dev;
unsigned int start, gtt_size;
- int fd;
int flag[] = {
PCI_DEV_MAP_FLAG_WRITE_COMBINE,
PCI_DEV_MAP_FLAG_WRITABLE,
0
}, f;
- fd = drm_open_driver(DRIVER_INTEL);
- pci_dev = igt_device_get_pci_device(fd);
- close(fd);
-
+ pci_dev = intel_get_pci_device();
devid = pci_dev->device_id;
if (IS_GEN2(devid)) {
diff --git a/tools/intel_infoframes.c b/tools/intel_infoframes.c
index 9129572a..2ef5d4fd 100644
--- a/tools/intel_infoframes.c
+++ b/tools/intel_infoframes.c
@@ -30,7 +30,6 @@
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
-#include "igt_device.h"
#include "intel_io.h"
#include "intel_chipset.h"
#include "drmtest.h"
@@ -1082,7 +1081,6 @@ printf("Options:\n"
int main(int argc, char *argv[])
{
int opt;
- int fd;
int ret = 0;
Transcoder transcoder = TRANSC_INVALID;
DipType dip = DIP_INVALID;
@@ -1109,10 +1107,7 @@ 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");
- fd = drm_open_driver(DRIVER_INTEL);
- pci_dev = igt_device_get_pci_device(fd);
- close(fd);
-
+ pci_dev = intel_get_pci_device();
intel_register_access_init(pci_dev, 0, -1);
intel_check_pch();
diff --git a/tools/intel_l3_parity.c b/tools/intel_l3_parity.c
index e2e4503a..d8c997af 100644
--- a/tools/intel_l3_parity.c
+++ b/tools/intel_l3_parity.c
@@ -36,7 +36,6 @@
#include <getopt.h>
#include "intel_chipset.h"
#include "intel_io.h"
-#include "igt_device.h"
#include "igt_sysfs.h"
#include "drmtest.h"
#include "config.h"
@@ -190,7 +189,7 @@ int main(int argc, char *argv[])
if (intel_gen(devid) < 7 || IS_VALLEYVIEW(devid))
exit(77);
- assert(intel_register_access_init(igt_device_get_pci_device(device), 0, device) == 0);
+ assert(intel_register_access_init(intel_get_pci_device(), 0, device) == 0);
dir = igt_sysfs_open(device);
diff --git a/tools/intel_lid.c b/tools/intel_lid.c
index 447790d9..37c6ba5e 100644
--- a/tools/intel_lid.c
+++ b/tools/intel_lid.c
@@ -37,10 +37,9 @@
#include <sys/stat.h>
#include <sys/types.h>
-#include "drmtest.h"
-#include "igt_device.h"
#include "intel_io.h"
#include "intel_reg.h"
+#include "intel_chipset.h"
#define SWF14_LID_STATUS_CLOSED (1<<29) /* 0 here means open */
@@ -119,11 +118,8 @@ out:
int main(int argc, char **argv)
{
int swf14, acpi_lid;
- int fd;
- fd = drm_open_driver(DRIVER_INTEL);
- intel_mmio_use_pci_bar(igt_device_get_pci_device(fd));
- close(fd);
+ intel_mmio_use_pci_bar(intel_get_pci_device());
while (1) {
swf14 = INREG(SWF14);
@@ -146,6 +142,5 @@ int main(int argc, char **argv)
}
sleep(2);
}
-
return 0;
}
diff --git a/tools/intel_panel_fitter.c b/tools/intel_panel_fitter.c
index 06f4ac59..137ef61a 100644
--- a/tools/intel_panel_fitter.c
+++ b/tools/intel_panel_fitter.c
@@ -30,7 +30,6 @@
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
-#include "igt_device.h"
#include "intel_io.h"
#include "intel_chipset.h"
#include "intel_reg.h"
@@ -274,17 +273,13 @@ int main (int argc, char *argv[])
bool do_disable = false, do_dump = false, do_usage = false;
struct pci_device *pci_dev;
uint32_t devid;
- int fd;
printf("WARNING:\n"
"This tool is a workaround for people that don't have a Kernel "
"with overscan compensation properties: it is just a temporary "
"solution that may or may not work. Use it at your own risk.\n");
- fd = drm_open_driver(DRIVER_INTEL);
- pci_dev = igt_device_get_pci_device(fd);
- close(fd);
-
+ pci_dev = intel_get_pci_device();
intel_register_access_init(pci_dev, 0, -1);
devid = pci_dev->device_id;
@@ -348,6 +343,5 @@ int main (int argc, char *argv[])
out:
intel_register_access_fini();
-
return ret;
}
diff --git a/tools/intel_perf_counters.c b/tools/intel_perf_counters.c
index 105a0924..50c4bce6 100644
--- a/tools/intel_perf_counters.c
+++ b/tools/intel_perf_counters.c
@@ -45,7 +45,6 @@
#include "drm.h"
#include "i915_drm.h"
#include "drmtest.h"
-#include "igt_device.h"
#include "intel_io.h"
#include "intel_bufmgr.h"
#include "intel_batchbuffer.h"
@@ -484,7 +483,7 @@ main(int argc, char **argv)
if (oacontrol) {
/* Forcewake */
- intel_register_access_init(igt_device_get_pci_device(fd), 0, fd);
+ intel_register_access_init(intel_get_pci_device(), 0, fd);
/* Enable performance counters */
intel_register_write(OACONTROL,
diff --git a/tools/intel_reg.c b/tools/intel_reg.c
index 305323b6..1247b70b 100644
--- a/tools/intel_reg.c
+++ b/tools/intel_reg.c
@@ -33,9 +33,9 @@
#include <unistd.h>
#include "igt.h"
-#include "igt_device.h"
#include "igt_gt.h"
#include "intel_io.h"
+#include "intel_chipset.h"
#include "intel_reg_spec.h"
@@ -274,6 +274,15 @@ static int register_srm(struct config *config, struct reg *reg,
int fd, i;
uint32_t val;
+ if (config->fd == -1) {
+ config->fd = __drm_open_driver(DRIVER_INTEL);
+ if (config->fd == -1) {
+ fprintf(stderr, "Error opening driver: %s",
+ strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ }
+
fd = config->fd;
engine = find_engine(reg->engine);
if (engine == NULL)
@@ -1006,13 +1015,6 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}
- config.fd = __drm_open_driver(DRIVER_INTEL);
- if (config.fd == -1) {
- fprintf(stderr, "Error opening driver: %s",
- strerror(errno));
- exit(EXIT_FAILURE);
- }
-
if (config.mmiofile) {
if (!config.devid) {
fprintf(stderr, "--mmio requires --devid\n");
@@ -1024,7 +1026,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "--devid without --mmio\n");
return EXIT_FAILURE;
}
- config.pci_dev = igt_device_get_pci_device(config.fd);
+ config.pci_dev = intel_get_pci_device();
config.devid = config.pci_dev->device_id;
}
@@ -1048,7 +1050,8 @@ int main(int argc, char *argv[])
free(config.mmiofile);
- close(config.fd);
+ if (config.fd >= 0)
+ close(config.fd);
return ret;
}
diff --git a/tools/intel_reg_checker.c b/tools/intel_reg_checker.c
index 0ed26029..6bde63ec 100644
--- a/tools/intel_reg_checker.c
+++ b/tools/intel_reg_checker.c
@@ -26,8 +26,6 @@
#include <err.h>
#include <string.h>
#include <stdbool.h>
-#include "drmtest.h"
-#include "igt_device.h"
#include "intel_io.h"
#include "intel_chipset.h"
@@ -344,12 +342,8 @@ check_dpfc_control_sa(void)
int main(int argc, char** argv)
{
struct pci_device *dev;
- int fd;
-
- fd = drm_open_driver(DRIVER_INTEL);
- dev = igt_device_get_pci_device(fd);
- close(fd);
+ dev = intel_get_pci_device();
devid = dev->device_id;
intel_mmio_use_pci_bar(dev);
diff --git a/tools/intel_watermark.c b/tools/intel_watermark.c
index 2dc4307c..e71c3d9c 100644
--- a/tools/intel_watermark.c
+++ b/tools/intel_watermark.c
@@ -29,14 +29,12 @@
#include <stdbool.h>
#include <err.h>
#include <string.h>
-#include "igt_device.h"
#include "intel_io.h"
#include "intel_chipset.h"
#include "drmtest.h"
static uint32_t display_base;
static uint32_t devid;
-static int fd;
static uint32_t read_reg(uint32_t addr)
{
@@ -251,7 +249,7 @@ static void skl_wm_dump(void)
uint32_t plane_ctl[num_pipes][max_planes];
uint32_t wm_linetime[num_pipes];
- intel_register_access_init(igt_device_get_pci_device(fd), 0, -1);
+ intel_register_access_init(intel_get_pci_device(), 0, -1);
for (pipe = 0; pipe < num_pipes; pipe++) {
int num_planes = skl_num_planes(devid, pipe);
@@ -471,7 +469,7 @@ static void ilk_wm_dump(void)
int num_pipes = intel_gen(devid) >= 7 ? 3 : 2;
struct ilk_wm wm = {};
- intel_register_access_init(igt_device_get_pci_device(fd), 0, -1);
+ intel_register_access_init(intel_get_pci_device(), 0, -1);
for (i = 0; i < num_pipes; i++) {
dspcntr[i] = read_reg(0x70180 + i * 0x1000);
@@ -621,7 +619,7 @@ static void vlv_wm_dump(void)
uint32_t dsp_ss_pm, ddr_setup2;
struct gmch_wm wms[MAX_PLANE] = {};
- intel_register_access_init(igt_device_get_pci_device(fd), 0, -1);
+ intel_register_access_init(intel_get_pci_device(), 0, -1);
dsparb = read_reg(0x70030);
dsparb2 = read_reg(0x70060);
@@ -837,7 +835,7 @@ static void g4x_wm_dump(void)
uint32_t mi_arb_state;
struct gmch_wm wms[MAX_PLANE] = {};
- intel_register_access_init(igt_device_get_pci_device(fd), 0, -1);
+ intel_register_access_init(intel_get_pci_device(), 0, -1);
dspacntr = read_reg(0x70180);
dspbcntr = read_reg(0x71180);
@@ -923,7 +921,7 @@ static void gen4_wm_dump(void)
uint32_t mi_arb_state;
struct gmch_wm wms[MAX_PLANE] = {};
- intel_register_access_init(igt_device_get_pci_device(fd), 0, -1);
+ intel_register_access_init(intel_get_pci_device(), 0, -1);
dsparb = read_reg(0x70030);
fw1 = read_reg(0x70034);
@@ -994,7 +992,7 @@ static void pnv_wm_dump(void)
uint32_t cbr;
struct gmch_wm wms[MAX_PLANE] = {};
- intel_register_access_init(igt_device_get_pci_device(fd), 0, -1);
+ intel_register_access_init(intel_get_pci_device(), 0, -1);
dsparb = read_reg(0x70030);
fw1 = read_reg(0x70034);
@@ -1084,7 +1082,7 @@ static void gen3_wm_dump(void)
uint32_t mi_arb_state;
struct gmch_wm wms[MAX_PLANE] = {};
- intel_register_access_init(igt_device_get_pci_device(fd), 0, -1);
+ intel_register_access_init(intel_get_pci_device(), 0, -1);
dsparb = read_reg(0x70030);
instpm = read_reg(0x20c0);
@@ -1153,7 +1151,7 @@ static void gen2_wm_dump(void)
uint32_t mi_state;
struct gmch_wm wms[MAX_PLANE] = {};
- intel_register_access_init(igt_device_get_pci_device(fd), 0, -1);
+ intel_register_access_init(intel_get_pci_device(), 0, -1);
dsparb = read_reg(0x70030);
mem_mode = read_reg(0x20cc);
@@ -1228,8 +1226,7 @@ static void gen2_wm_dump(void)
int main(int argc, char *argv[])
{
- fd = drm_open_driver(DRIVER_INTEL);
- devid = igt_device_get_pci_device(fd)->device_id;
+ devid = intel_get_pci_device()->device_id;
if (intel_gen(devid) >= 9) {
skl_wm_dump();
@@ -1253,7 +1250,5 @@ int main(int argc, char *argv[])
return 1;
}
- close(fd);
-
return 0;
}