* [igt-dev] [PATCH i-g-t 0/6] Attempt to get rid of some globals
@ 2019-03-13 12:53 Michał Winiarski
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 1/6] tests/gem_exec_blt: Drop benchmark mode, use igt_sysfs Michał Winiarski
` (7 more replies)
0 siblings, 8 replies; 15+ messages in thread
From: Michał Winiarski @ 2019-03-13 12:53 UTC (permalink / raw)
To: igt-dev
Not everything... Bunch of stuff in intel_mmio is left untouched.
Let's see if I'm going in the right direction. The idea is to drop globals and
make some helpers a bit less i915 specific.
Michał Winiarski (6):
tests/gem_exec_blt: Drop benchmark mode, use igt_sysfs
lib/igt_device: Introduce igt_device_get_card_index
lib: Kill drm_get_card()
lib/igt_sysfs: Remove idx from sysfs_open
lib/igt_sysfs: Simplify obtaining sysfs path
lib/igt_device: Move intel_get_pci_device under igt_device
benchmarks/gem_latency.c | 4 +-
benchmarks/gem_wsim.c | 4 +-
debugger/debug_rdata.c | 7 +-
debugger/eudb.c | 8 +-
lib/drmtest.c | 40 ----------
lib/drmtest.h | 1 -
lib/igt_device.c | 98 ++++++++++++++++++++++++
lib/igt_device.h | 3 +
lib/igt_gt.c | 2 +-
lib/igt_kms.c | 7 +-
lib/igt_sysfs.c | 40 +++-------
lib/igt_sysfs.h | 4 +-
lib/intel_chipset.c | 51 -------------
lib/intel_chipset.h | 1 -
lib/intel_mmio.c | 4 +-
lib/ioctl_wrappers.c | 5 +-
lib/ioctl_wrappers.h | 2 +-
tests/i915/gem_concurrent_all.c | 12 +--
tests/i915/gem_cpu_reloc.c | 4 +-
tests/i915/gem_exec_blt.c | 117 +++++++++--------------------
tests/i915/gem_exec_capture.c | 2 +-
tests/i915/gem_exec_latency.c | 3 +-
tests/i915/gem_exec_parse.c | 4 +-
tests/i915/gem_mmap.c | 4 +-
tests/i915/gem_mmap_gtt.c | 10 +--
tests/i915/gem_pwrite.c | 4 +-
tests/i915/gem_shrink.c | 2 +-
tests/i915/i915_hangman.c | 4 +-
tests/i915/i915_pm_lpsp.c | 3 +-
tests/i915/i915_pm_rc6_residency.c | 2 +-
tests/i915/i915_pm_rpm.c | 6 +-
tests/i915/i915_pm_rps.c | 5 +-
tests/i915/i915_suspend.c | 17 +++--
tests/kms_flip.c | 2 +-
tests/perf.c | 6 +-
tests/perf_pmu.c | 2 +-
tests/prime_mmap.c | 4 +-
tests/vgem_basic.c | 2 +-
tools/intel_audio_dump.c | 9 ++-
tools/intel_backlight.c | 8 +-
tools/intel_display_poller.c | 8 +-
tools/intel_forcewaked.c | 10 ++-
tools/intel_gpu_frequency.c | 9 ++-
tools/intel_gpu_time.c | 8 +-
tools/intel_gtt.c | 8 +-
tools/intel_infoframes.c | 7 +-
tools/intel_l3_parity.c | 5 +-
tools/intel_lid.c | 9 ++-
tools/intel_panel_fitter.c | 8 +-
tools/intel_perf_counters.c | 3 +-
tools/intel_reg.c | 23 +++---
tools/intel_reg_checker.c | 8 +-
tools/intel_watermark.c | 23 +++---
53 files changed, 332 insertions(+), 310 deletions(-)
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 15+ messages in thread
* [igt-dev] [PATCH i-g-t 1/6] tests/gem_exec_blt: Drop benchmark mode, use igt_sysfs
2019-03-13 12:53 [igt-dev] [PATCH i-g-t 0/6] Attempt to get rid of some globals Michał Winiarski
@ 2019-03-13 12:53 ` Michał Winiarski
2019-03-13 12:58 ` Chris Wilson
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 2/6] lib/igt_device: Introduce igt_device_get_card_index Michał Winiarski
` (6 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Michał Winiarski @ 2019-03-13 12:53 UTC (permalink / raw)
To: igt-dev
The "benchmark" mode is no longer used.
While I'm here, let's also move things around and start to use
igt_sysfs, rather implementing own set of helpers.
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
tests/i915/gem_exec_blt.c | 117 ++++++++++++--------------------------
1 file changed, 35 insertions(+), 82 deletions(-)
diff --git a/tests/i915/gem_exec_blt.c b/tests/i915/gem_exec_blt.c
index 8d61dc87..0fcfdd4b 100644
--- a/tests/i915/gem_exec_blt.c
+++ b/tests/i915/gem_exec_blt.c
@@ -38,6 +38,7 @@
#include <sys/ioctl.h>
#include <sys/time.h>
#include "drm.h"
+#include "igt_sysfs.h"
#define OBJECT_SIZE 16384
@@ -181,19 +182,16 @@ static int dcmp(const void *A, const void *B)
return 0;
}
-static void run(int object_size, bool dumb)
+static void run(int fd, int object_size, bool dumb)
{
struct drm_i915_gem_execbuffer2 execbuf;
struct drm_i915_gem_exec_object2 exec[3];
struct drm_i915_gem_relocation_entry reloc[4];
uint32_t buf[20];
uint32_t handle, src, dst;
- int fd, len, count;
+ int len, count;
int ring;
- fd = drm_open_driver(DRIVER_INTEL);
- igt_require_gem(fd);
-
if (dumb)
handle = kmstest_dumb_create(fd, 32, 32, 32, NULL, NULL);
else
@@ -262,81 +260,36 @@ static void run(int object_size, bool dumb)
fflush(stdout);
}
gem_close(fd, handle);
-
- close(fd);
-}
-
-static int sysfs_read(const char *name)
-{
- char buf[4096];
- int sysfd;
- int len;
-
- sprintf(buf, "/sys/class/drm/card%d/%s",
- drm_get_card(), name);
- sysfd = open(buf, O_RDONLY);
- if (sysfd < 0)
- return -1;
-
- len = read(sysfd, buf, sizeof(buf)-1);
- close(sysfd);
- if (len < 0)
- return -1;
-
- buf[len] = '\0';
- return atoi(buf);
-}
-
-static int sysfs_write(const char *name, int value)
-{
- char buf[4096];
- int sysfd;
- int len;
-
- sprintf(buf, "/sys/class/drm/card%d/%s",
- drm_get_card(), name);
- sysfd = open(buf, O_WRONLY);
- if (sysfd < 0)
- return -1;
-
- len = sprintf(buf, "%d", value);
- len = write(sysfd, buf, len);
- close(sysfd);
-
- if (len < 0)
- return len;
-
- return 0;
}
-static void set_auto_freq(void)
+static void set_auto_freq(int sysfs)
{
- int min = sysfs_read("gt_RPn_freq_mhz");
- int max = sysfs_read("gt_RP0_freq_mhz");
+ int min = igt_sysfs_get_u32(sysfs, "gt_RPn_freq_mhz");
+ int max = igt_sysfs_get_u32(sysfs, "gt_RP0_freq_mhz");
if (max <= min)
return;
igt_debug("Setting min to %dMHz, and max to %dMHz\n", min, max);
- sysfs_write("gt_min_freq_mhz", min);
- sysfs_write("gt_max_freq_mhz", max);
+ igt_sysfs_set_u32(sysfs, "gt_min_freq_mhz", min);
+ igt_sysfs_set_u32(sysfs, "gt_max_freq_mhz", max);
}
-static void set_min_freq(void)
+static void set_min_freq(int sysfs)
{
- int min = sysfs_read("gt_RPn_freq_mhz");
+ int min = igt_sysfs_get_u32(sysfs, "gt_RPn_freq_mhz");
igt_require(min > 0);
igt_debug("Setting min/max to %dMHz\n", min);
- igt_require(sysfs_write("gt_min_freq_mhz", min) == 0 &&
- sysfs_write("gt_max_freq_mhz", min) == 0);
+ igt_require(igt_sysfs_set_u32(sysfs, "gt_min_freq_mhz", min) &&
+ igt_sysfs_set_u32(sysfs, "gt_max_freq_mhz", min));
}
-static void set_max_freq(void)
+static void set_max_freq(int sysfs)
{
- int max = sysfs_read("gt_RP0_freq_mhz");
+ int max = igt_sysfs_get_u32(sysfs, "gt_RP0_freq_mhz");
igt_require(max > 0);
igt_debug("Setting min/max to %dMHz\n", max);
- igt_require(sysfs_write("gt_max_freq_mhz", max) == 0 &&
- sysfs_write("gt_min_freq_mhz", max) == 0);
+ igt_require(igt_sysfs_set_u32(sysfs, "gt_max_freq_mhz", max) &&
+ igt_sysfs_set_u32(sysfs, "gt_min_freq_mhz", max));
}
@@ -344,7 +297,7 @@ int main(int argc, char **argv)
{
const struct {
const char *suffix;
- void (*func)(void);
+ void (*func)(int);
} rps[] = {
{ "", set_auto_freq },
{ "-min", set_min_freq },
@@ -352,44 +305,44 @@ int main(int argc, char **argv)
{ NULL, NULL },
}, *r;
int min = -1, max = -1;
- int i;
+ int fd, sysfs;
igt_subtest_init(argc, argv);
igt_skip_on_simulation();
- if (argc > 1) {
- for (i = 1; i < argc; i++) {
- int object_size = atoi(argv[i]);
- if (object_size)
- run((object_size + 3) & -4, false);
- }
- _exit(0); /* blergh */
- }
-
igt_fixture {
- min = sysfs_read("gt_min_freq_mhz");
- max = sysfs_read("gt_max_freq_mhz");
+ fd = drm_open_driver(DRIVER_INTEL);
+ igt_require_gem(fd);
+
+ sysfs = igt_sysfs_open(fd, NULL);
+ igt_require(sysfs >= 0);
+
+ min = igt_sysfs_get_u32(sysfs, "gt_min_freq_mhz");
+ max = igt_sysfs_get_u32(sysfs, "gt_max_freq_mhz");
}
for (r = rps; r->suffix; r++) {
- igt_fixture r->func();
+ igt_fixture r->func(sysfs);
igt_subtest_f("cold%s", r->suffix)
- run(OBJECT_SIZE, false);
+ run(fd, OBJECT_SIZE, false);
igt_subtest_f("normal%s", r->suffix)
- run(OBJECT_SIZE, false);
+ run(fd, OBJECT_SIZE, false);
igt_subtest_f("dumb-buf%s", r->suffix)
- run(OBJECT_SIZE, true);
+ run(fd, OBJECT_SIZE, true);
}
igt_fixture {
if (min > 0)
- sysfs_write("gt_min_freq_mhz", min);
+ igt_sysfs_set_u32(sysfs, "gt_min_freq_mhz", min);
if (max > 0)
- sysfs_write("gt_max_freq_mhz", max);
+ igt_sysfs_set_u32(sysfs, "gt_max_freq_mhz", max);
+
+ close(sysfs);
+ close(fd);
}
igt_exit();
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [igt-dev] [PATCH i-g-t 2/6] lib/igt_device: Introduce igt_device_get_card_index
2019-03-13 12:53 [igt-dev] [PATCH i-g-t 0/6] Attempt to get rid of some globals Michał Winiarski
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 1/6] tests/gem_exec_blt: Drop benchmark mode, use igt_sysfs Michał Winiarski
@ 2019-03-13 12:53 ` Michał Winiarski
2019-03-13 13:02 ` Chris Wilson
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 3/6] lib: Kill drm_get_card() Michał Winiarski
` (5 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Michał Winiarski @ 2019-03-13 12:53 UTC (permalink / raw)
To: igt-dev
And use it! But let's start small.
Rather than going with "and by the way, here's the card index" from
igt_sysfs_path, we're making things more explicit.
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
lib/igt_device.c | 19 +++++++++++++++++++
lib/igt_device.h | 2 ++
lib/igt_sysfs.c | 11 +++++++----
lib/igt_sysfs.h | 2 +-
tests/i915/i915_pm_rpm.c | 2 +-
5 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/lib/igt_device.c b/lib/igt_device.c
index 5b3722c8..08f39c8b 100644
--- a/lib/igt_device.c
+++ b/lib/igt_device.c
@@ -22,6 +22,8 @@
*
*/
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
#include "igt.h"
#include "igt_device.h"
@@ -84,3 +86,20 @@ void igt_device_drop_master(int fd)
"Failed to drop DRM master.\n");
}
}
+
+/**
+ * igt_device_get_card_index:
+ * @fd: the device
+ *
+ * Returns:
+ * Index (N) of /dev/dri/cardN or /dev/dri/renderDN corresponding with fd.
+ *
+ */
+int igt_device_get_card_index(int fd)
+{
+ struct stat st;
+
+ igt_fail_on(fstat(fd, &st) || !S_ISCHR(st.st_mode));
+
+ return minor(st.st_rdev);
+}
diff --git a/lib/igt_device.h b/lib/igt_device.h
index 2995f969..9d7dc2c3 100644
--- a/lib/igt_device.h
+++ b/lib/igt_device.h
@@ -31,4 +31,6 @@ void igt_device_set_master(int fd);
int __igt_device_drop_master(int fd);
void igt_device_drop_master(int fd);
+int igt_device_get_card_index(int fd);
+
#endif /* __IGT_DEVICE_H__ */
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index c57e4ae2..fd075cd6 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -41,6 +41,7 @@
#include "igt_core.h"
#include "igt_sysfs.h"
+#include "igt_device.h"
/**
* SECTION:igt_sysfs
@@ -96,7 +97,7 @@ static int writeN(int fd, const char *buf, int len)
* Returns:
* The directory path, or NULL on failure.
*/
-char *igt_sysfs_path(int device, char *path, int pathlen, int *idx)
+char *igt_sysfs_path(int device, char *path, int pathlen)
{
struct stat st;
@@ -125,8 +126,7 @@ char *igt_sysfs_path(int device, char *path, int pathlen, int *idx)
continue;
path[len] = '\0';
- if (idx)
- *idx = n;
+
return path;
}
@@ -148,9 +148,12 @@ int igt_sysfs_open(int device, int *idx)
{
char path[80];
- if (!igt_sysfs_path(device, path, sizeof(path), idx))
+ if (!igt_sysfs_path(device, path, sizeof(path)))
return -1;
+ if (idx)
+ *idx = igt_device_get_card_index(device);
+
return open(path, O_RDONLY);
}
diff --git a/lib/igt_sysfs.h b/lib/igt_sysfs.h
index 2ce5b7bd..b181a95f 100644
--- a/lib/igt_sysfs.h
+++ b/lib/igt_sysfs.h
@@ -28,7 +28,7 @@
#include <stdbool.h>
#include <stdarg.h>
-char *igt_sysfs_path(int device, char *path, int pathlen, int *idx);
+char *igt_sysfs_path(int device, char *path, int pathlen);
int igt_sysfs_open(int device, int *idx);
int igt_sysfs_open_parameters(int device);
bool igt_sysfs_set_parameter(int device,
diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
index 759c76ea..03de609c 100644
--- a/tests/i915/i915_pm_rpm.c
+++ b/tests/i915/i915_pm_rpm.c
@@ -962,7 +962,7 @@ static void sysfs_read_subtest(void)
{
char path[80];
- igt_require_f(igt_sysfs_path(drm_fd, path, sizeof(path), NULL),
+ igt_require_f(igt_sysfs_path(drm_fd, path, sizeof(path)),
"Can't find the sysfs directory\n");
walk_fs(path);
}
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [igt-dev] [PATCH i-g-t 3/6] lib: Kill drm_get_card()
2019-03-13 12:53 [igt-dev] [PATCH i-g-t 0/6] Attempt to get rid of some globals Michał Winiarski
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 1/6] tests/gem_exec_blt: Drop benchmark mode, use igt_sysfs Michał Winiarski
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 2/6] lib/igt_device: Introduce igt_device_get_card_index Michał Winiarski
@ 2019-03-13 12:53 ` Michał Winiarski
2019-03-13 13:05 ` Chris Wilson
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 4/6] lib/igt_sysfs: Remove idx from sysfs_open Michał Winiarski
` (4 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Michał Winiarski @ 2019-03-13 12:53 UTC (permalink / raw)
To: igt-dev
It's not operating on FD, and we've provided a nice reimplementation
that does. Let's use it instead.
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
lib/drmtest.c | 40 -------------------------------------
lib/drmtest.h | 1 -
tests/i915/i915_pm_rps.c | 5 +++--
tests/i915/i915_suspend.c | 17 ++++++++--------
tests/perf.c | 3 ++-
tools/intel_gpu_frequency.c | 9 ++++++---
6 files changed, 20 insertions(+), 55 deletions(-)
diff --git a/lib/drmtest.c b/lib/drmtest.c
index 6506791b..25eeab88 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -177,46 +177,6 @@ void gem_quiescent_gpu(int fd)
DROP_ACTIVE | DROP_RETIRE | DROP_IDLE | DROP_FREED);
}
-/**
- * drm_get_card:
- *
- * Get an i915 drm card index number for use in /dev or /sys. The minor index of
- * the legacy node is returned, not of the control or render node.
- *
- * Returns:
- * The i915 drm index or -1 on error
- */
-int drm_get_card(void)
-{
- char *name;
- int i, fd;
-
- for (i = 0; i < 16; i++) {
- int ret;
-
- ret = asprintf(&name, "/dev/dri/card%u", i);
- igt_assert(ret != -1);
-
- fd = open(name, O_RDWR);
- free(name);
-
- if (fd == -1)
- continue;
-
- if (!is_i915_device(fd) || !has_known_intel_chipset(fd)) {
- close(fd);
- continue;
- }
-
- close(fd);
- return i;
- }
-
- igt_skip("No intel gpu found\n");
-
- return -1;
-}
-
static int modprobe(const char *driver)
{
return igt_kmod_load(driver, "");
diff --git a/lib/drmtest.h b/lib/drmtest.h
index ca347a71..f4401ac9 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -71,7 +71,6 @@ void __set_forced_driver(const char *name);
*/
#define ALIGN(v, a) (((v) + (a)-1) & ~((a)-1))
-int drm_get_card(void);
int drm_open_driver(int chipset);
int drm_open_driver_master(int chipset);
int drm_open_driver_render(int chipset);
diff --git a/tests/i915/i915_pm_rps.c b/tests/i915/i915_pm_rps.c
index d20cd2d8..b4f45d5e 100644
--- a/tests/i915/i915_pm_rps.c
+++ b/tests/i915/i915_pm_rps.c
@@ -37,6 +37,7 @@
#include <sys/wait.h>
#include "igt.h"
+#include "igt_device.h"
#include "igt_dummyload.h"
IGT_TEST_DESCRIPTION("Render P-States tests - verify GPU frequency changes");
@@ -629,14 +630,14 @@ igt_main
igt_skip_on_simulation();
igt_fixture {
- const int device = drm_get_card();
struct sysfs_file *sysfs_file = sysfs_files;
- int ret;
+ int device, ret;
/* Use drm_open_driver to verify device existence */
drm_fd = drm_open_driver(DRIVER_INTEL);
igt_require_gem(drm_fd);
igt_require(gem_can_store_dword(drm_fd, 0));
+ device = igt_device_get_card_index(drm_fd);
do {
int val = -1;
diff --git a/tests/i915/i915_suspend.c b/tests/i915/i915_suspend.c
index cd7cf967..0d49fdcb 100644
--- a/tests/i915/i915_suspend.c
+++ b/tests/i915/i915_suspend.c
@@ -39,6 +39,7 @@
#include <drm.h>
+#include "igt_device.h"
#define OBJECT_SIZE (16*1024*1024)
@@ -101,7 +102,7 @@ test_fence_restore(int fd, bool tiled2untiled, bool hibernate)
}
static void
-test_debugfs_reader(bool hibernate)
+test_debugfs_reader(int fd, bool hibernate)
{
struct igt_helper_process reader = {};
reader.use_SIGKILL = true;
@@ -112,7 +113,7 @@ test_debugfs_reader(bool hibernate)
snprintf(tmp, sizeof(tmp) - 1,
"while true; do find %s/%i/ -type f ! -path \"*/crc/*\" | xargs cat > /dev/null 2>&1; done",
- dfs_base, drm_get_card());
+ dfs_base, igt_device_get_card_index(fd));
igt_assert(execl("/bin/sh", "sh", "-c", tmp, (char *) NULL) != -1);
}
@@ -131,7 +132,7 @@ test_debugfs_reader(bool hibernate)
}
static void
-test_sysfs_reader(bool hibernate)
+test_sysfs_reader(int fd, bool hibernate)
{
struct igt_helper_process reader = {};
reader.use_SIGKILL = true;
@@ -142,7 +143,7 @@ test_sysfs_reader(bool hibernate)
snprintf(tmp, sizeof(tmp) - 1,
"while true; do find %s%i*/ -type f | xargs cat > /dev/null 2>&1; done",
- dfs_base, drm_get_card());
+ dfs_base, igt_device_get_card_index(fd));
igt_assert(execl("/bin/sh", "sh", "-c", tmp, (char *) NULL) != -1);
}
@@ -212,10 +213,10 @@ igt_main
test_fence_restore(fd, false, false);
igt_subtest("debugfs-reader")
- test_debugfs_reader(false);
+ test_debugfs_reader(fd, false);
igt_subtest("sysfs-reader")
- test_sysfs_reader(false);
+ test_sysfs_reader(fd, false);
igt_subtest("shrink")
test_shrink(fd, SUSPEND_STATE_MEM);
@@ -230,10 +231,10 @@ igt_main
test_fence_restore(fd, false, true);
igt_subtest("debugfs-reader-hibernate")
- test_debugfs_reader(true);
+ test_debugfs_reader(fd, true);
igt_subtest("sysfs-reader-hibernate")
- test_sysfs_reader(true);
+ test_sysfs_reader(fd, true);
igt_subtest("forcewake-hibernate")
test_forcewake(fd, true);
diff --git a/tests/perf.c b/tests/perf.c
index 220c52ef..ac979a65 100644
--- a/tests/perf.c
+++ b/tests/perf.c
@@ -39,6 +39,7 @@
#include <math.h>
#include "igt.h"
+#include "igt_device.h"
#include "igt_sysfs.h"
#include "drm.h"
@@ -4034,7 +4035,7 @@ test_i915_ref_count(void)
drm_fd = __drm_open_driver(DRIVER_INTEL);
devid = intel_get_drm_devid(drm_fd);
- card = drm_get_card();
+ card = igt_device_get_card_index(drm_fd);
/* Note: these global variables are only initialized after calling
* init_sys_info()...
diff --git a/tools/intel_gpu_frequency.c b/tools/intel_gpu_frequency.c
index 80786ad9..52b11a98 100644
--- a/tools/intel_gpu_frequency.c
+++ b/tools/intel_gpu_frequency.c
@@ -28,6 +28,7 @@
#include <unistd.h>
#include "drmtest.h"
+#include "igt_device.h"
#include "intel_chipset.h"
#define VERSION "1.0"
@@ -280,10 +281,12 @@ int main(int argc, char *argv[])
{
bool write, fail, targets[MAX+1] = {false};
- int i, try = 1, set_freq[MAX+1] = {0};
+ int i, fd, try = 1, set_freq[MAX+1] = {0};
- devid = intel_get_drm_devid(drm_open_driver(DRIVER_INTEL));
- device = drm_get_card();
+ fd = drm_open_driver(DRIVER_INTEL);
+ devid = intel_get_drm_devid(fd);
+ device = igt_device_get_card_index(fd);
+ close(fd);
write = parse(argc, argv, targets, ARRAY_SIZE(targets), set_freq);
fail = write;
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [igt-dev] [PATCH i-g-t 4/6] lib/igt_sysfs: Remove idx from sysfs_open
2019-03-13 12:53 [igt-dev] [PATCH i-g-t 0/6] Attempt to get rid of some globals Michał Winiarski
` (2 preceding siblings ...)
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 3/6] lib: Kill drm_get_card() Michał Winiarski
@ 2019-03-13 12:53 ` Michał Winiarski
2019-03-13 13:08 ` Chris Wilson
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 5/6] lib/igt_sysfs: Simplify obtaining sysfs path Michał Winiarski
` (3 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Michał Winiarski @ 2019-03-13 12:53 UTC (permalink / raw)
To: igt-dev
Similar to sysfs_path - more explicit more better.
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
lib/igt_gt.c | 2 +-
lib/igt_kms.c | 7 ++++++-
lib/igt_sysfs.c | 8 ++------
lib/igt_sysfs.h | 2 +-
tests/i915/gem_exec_blt.c | 2 +-
tests/i915/gem_exec_capture.c | 2 +-
tests/i915/i915_hangman.c | 4 +---
tests/i915/i915_pm_rc6_residency.c | 2 +-
tests/perf.c | 3 ++-
tests/perf_pmu.c | 2 +-
tests/vgem_basic.c | 2 +-
tools/intel_l3_parity.c | 2 +-
12 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index c98a7553..59995243 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -76,7 +76,7 @@ static void eat_error_state(int dev)
{
int dir;
- dir = igt_sysfs_open(dev, NULL);
+ dir = igt_sysfs_open(dev);
if (dir < 0)
return;
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index e1eacc1e..8656ea11 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -52,6 +52,7 @@
#include "igt_aux.h"
#include "intel_chipset.h"
#include "igt_debugfs.h"
+#include "igt_device.h"
#include "igt_sysfs.h"
#include "sw_sync.h"
@@ -806,10 +807,14 @@ bool kmstest_force_connector(int drm_fd, drmModeConnector *connector,
break;
}
- dir = igt_sysfs_open(drm_fd, &idx);
+ dir = igt_sysfs_open(drm_fd);
if (dir < 0)
return false;
+ idx = igt_device_get_card_index(drm_fd);
+ if (idx < 0 || idx > 63)
+ return false;
+
if (asprintf(&path, "card%d-%s-%d/status",
idx,
kmstest_connector_type_str(connector->connector_type),
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index fd075cd6..13a2ee04 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -136,7 +136,6 @@ char *igt_sysfs_path(int device, char *path, int pathlen)
/**
* igt_sysfs_open:
* @device: fd of the device
- * @idx: optional pointer to store the card index of the opened device
*
* This opens the sysfs directory corresponding to device for use
* with igt_sysfs_set() and igt_sysfs_get().
@@ -144,16 +143,13 @@ char *igt_sysfs_path(int device, char *path, int pathlen)
* Returns:
* The directory fd, or -1 on failure.
*/
-int igt_sysfs_open(int device, int *idx)
+int igt_sysfs_open(int device)
{
char path[80];
if (!igt_sysfs_path(device, path, sizeof(path)))
return -1;
- if (idx)
- *idx = igt_device_get_card_index(device);
-
return open(path, O_RDONLY);
}
@@ -200,7 +196,7 @@ int igt_sysfs_open_parameters(int device)
{
int dir, params = -1;
- dir = igt_sysfs_open(device, ¶ms);
+ dir = igt_sysfs_open(device);
if (dir >= 0) {
params = openat(dir,
"device/driver/module/parameters",
diff --git a/lib/igt_sysfs.h b/lib/igt_sysfs.h
index b181a95f..c12e36d1 100644
--- a/lib/igt_sysfs.h
+++ b/lib/igt_sysfs.h
@@ -29,7 +29,7 @@
#include <stdarg.h>
char *igt_sysfs_path(int device, char *path, int pathlen);
-int igt_sysfs_open(int device, int *idx);
+int igt_sysfs_open(int device);
int igt_sysfs_open_parameters(int device);
bool igt_sysfs_set_parameter(int device,
const char *parameter,
diff --git a/tests/i915/gem_exec_blt.c b/tests/i915/gem_exec_blt.c
index 0fcfdd4b..00926e55 100644
--- a/tests/i915/gem_exec_blt.c
+++ b/tests/i915/gem_exec_blt.c
@@ -315,7 +315,7 @@ int main(int argc, char **argv)
fd = drm_open_driver(DRIVER_INTEL);
igt_require_gem(fd);
- sysfs = igt_sysfs_open(fd, NULL);
+ sysfs = igt_sysfs_open(fd);
igt_require(sysfs >= 0);
min = igt_sysfs_get_u32(sysfs, "gt_min_freq_mhz");
diff --git a/tests/i915/gem_exec_capture.c b/tests/i915/gem_exec_capture.c
index 56837dfc..4457496d 100644
--- a/tests/i915/gem_exec_capture.c
+++ b/tests/i915/gem_exec_capture.c
@@ -547,7 +547,7 @@ igt_main
igt_require(has_capture(fd));
igt_allow_hang(fd, 0, HANG_ALLOW_CAPTURE);
- dir = igt_sysfs_open(fd, NULL);
+ dir = igt_sysfs_open(fd);
igt_require(igt_sysfs_set(dir, "error", "Begone!"));
igt_require(safer_strlen(igt_sysfs_get(dir, "error")) > 0);
}
diff --git a/tests/i915/i915_hangman.c b/tests/i915/i915_hangman.c
index 4e515e3a..9a1d5889 100644
--- a/tests/i915/i915_hangman.c
+++ b/tests/i915/i915_hangman.c
@@ -262,14 +262,12 @@ igt_main
igt_skip_on_simulation();
igt_fixture {
- int idx;
-
device = drm_open_driver(DRIVER_INTEL);
igt_require_gem(device);
hang = igt_allow_hang(device, 0, HANG_ALLOW_CAPTURE);
- sysfs = igt_sysfs_open(device, &idx);
+ sysfs = igt_sysfs_open(device);
igt_assert(sysfs != -1);
igt_require(has_error_state(sysfs));
diff --git a/tests/i915/i915_pm_rc6_residency.c b/tests/i915/i915_pm_rc6_residency.c
index abc30ac6..1b52e4f5 100644
--- a/tests/i915/i915_pm_rc6_residency.c
+++ b/tests/i915/i915_pm_rc6_residency.c
@@ -208,7 +208,7 @@ igt_main
fd = drm_open_driver(DRIVER_INTEL);
devid = intel_get_drm_devid(fd);
- sysfs = igt_sysfs_open(fd, NULL);
+ sysfs = igt_sysfs_open(fd);
igt_require(has_rc6_residency("rc6"));
diff --git a/tests/perf.c b/tests/perf.c
index ac979a65..84555462 100644
--- a/tests/perf.c
+++ b/tests/perf.c
@@ -4112,7 +4112,8 @@ igt_main
igt_require_gem(drm_fd);
devid = intel_get_drm_devid(drm_fd);
- sysfs = igt_sysfs_open(drm_fd, &card);
+ card = igt_device_get_card_index(drm_fd);
+ sysfs = igt_sysfs_open(drm_fd);
igt_require(init_sys_info());
diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index aa5b9921..1a08f564 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -1275,7 +1275,7 @@ test_frequency(int gem_fd)
igt_spin_t *spin;
int fd, sysfs;
- sysfs = igt_sysfs_open(gem_fd, NULL);
+ sysfs = igt_sysfs_open(gem_fd);
igt_require(sysfs >= 0);
min_freq = igt_sysfs_get_u32(sysfs, "gt_RPn_freq_mhz");
diff --git a/tests/vgem_basic.c b/tests/vgem_basic.c
index 1a952c54..526636dd 100644
--- a/tests/vgem_basic.c
+++ b/tests/vgem_basic.c
@@ -262,7 +262,7 @@ static void test_dmabuf_fence_before(int fd)
static void test_sysfs_read(int fd)
{
- int dir = igt_sysfs_open(fd, NULL);
+ int dir = igt_sysfs_open(fd);
DIR *dirp = fdopendir(dir);
struct dirent *de;
diff --git a/tools/intel_l3_parity.c b/tools/intel_l3_parity.c
index d1a9bc44..d8c997af 100644
--- a/tools/intel_l3_parity.c
+++ b/tools/intel_l3_parity.c
@@ -191,7 +191,7 @@ int main(int argc, char *argv[])
assert(intel_register_access_init(intel_get_pci_device(), 0, device) == 0);
- dir = igt_sysfs_open(device, NULL);
+ dir = igt_sysfs_open(device);
for_each_slice(i) {
fd[i] = openat(dir, path[i], O_RDWR);
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [igt-dev] [PATCH i-g-t 5/6] lib/igt_sysfs: Simplify obtaining sysfs path
2019-03-13 12:53 [igt-dev] [PATCH i-g-t 0/6] Attempt to get rid of some globals Michał Winiarski
` (3 preceding siblings ...)
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 4/6] lib/igt_sysfs: Remove idx from sysfs_open Michał Winiarski
@ 2019-03-13 12:53 ` Michał Winiarski
2019-03-13 14:09 ` Chris Wilson
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 6/6] lib/igt_device: Move intel_get_pci_device under igt_device Michał Winiarski
` (2 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Michał Winiarski @ 2019-03-13 12:53 UTC (permalink / raw)
To: igt-dev
Now that we've extracted card index, we no longer have the need to
iterate over device nodes.
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
lib/igt_sysfs.c | 29 +++++++----------------------
1 file changed, 7 insertions(+), 22 deletions(-)
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 13a2ee04..974bf45a 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -100,6 +100,7 @@ static int writeN(int fd, const char *buf, int len)
char *igt_sysfs_path(int device, char *path, int pathlen)
{
struct stat st;
+ int ret;
if (device < 0)
return NULL;
@@ -107,30 +108,14 @@ char *igt_sysfs_path(int device, char *path, int pathlen)
if (fstat(device, &st) || !S_ISCHR(st.st_mode))
return NULL;
- for (int n = 0; n < 16; n++) {
- int len, ret, maj, min;
- FILE *file;
-
- len = snprintf(path, pathlen, "/sys/class/drm/card%d", n);
-
- sprintf(path + len, "/dev");
- file = fopen(path, "r");
- if (!file)
- continue;
-
- ret = fscanf(file, "%d:%d", &maj, &min);
- fclose(file);
+ snprintf(path, pathlen, "/sys/dev/char/%d:%d",
+ major(st.st_rdev), minor(st.st_rdev));
- if (ret != 2 || major(st.st_rdev) != maj ||
- minor(st.st_rdev) != min)
- continue;
-
- path[len] = '\0';
-
- return path;
- }
+ ret = access(path, F_OK);
+ if (ret)
+ return NULL;
- return NULL;
+ return path;
}
/**
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [igt-dev] [PATCH i-g-t 6/6] lib/igt_device: Move intel_get_pci_device under igt_device
2019-03-13 12:53 [igt-dev] [PATCH i-g-t 0/6] Attempt to get rid of some globals Michał Winiarski
` (4 preceding siblings ...)
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 5/6] lib/igt_sysfs: Simplify obtaining sysfs path Michał Winiarski
@ 2019-03-13 12:53 ` Michał Winiarski
2019-03-13 14:27 ` Chris Wilson
2019-03-13 14:06 ` [igt-dev] ✓ Fi.CI.BAT: success for Attempt to get rid of some globals Patchwork
2019-03-13 18:07 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
7 siblings, 1 reply; 15+ messages in thread
From: Michał Winiarski @ 2019-03-13 12:53 UTC (permalink / raw)
To: igt-dev
It allows us to make things a little bit more generic. Also, we now
require fd rather than doing guesswork when it comes to pci address.
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
---
benchmarks/gem_latency.c | 4 +-
benchmarks/gem_wsim.c | 4 +-
debugger/debug_rdata.c | 7 ++-
debugger/eudb.c | 8 ++--
lib/igt_device.c | 79 +++++++++++++++++++++++++++++++++
lib/igt_device.h | 1 +
lib/intel_chipset.c | 51 ---------------------
lib/intel_chipset.h | 1 -
lib/intel_mmio.c | 4 +-
lib/ioctl_wrappers.c | 5 ++-
lib/ioctl_wrappers.h | 2 +-
tests/i915/gem_concurrent_all.c | 12 ++---
tests/i915/gem_cpu_reloc.c | 4 +-
tests/i915/gem_exec_latency.c | 3 +-
tests/i915/gem_exec_parse.c | 4 +-
tests/i915/gem_mmap.c | 4 +-
tests/i915/gem_mmap_gtt.c | 10 ++---
tests/i915/gem_pwrite.c | 4 +-
tests/i915/gem_shrink.c | 2 +-
tests/i915/i915_pm_lpsp.c | 3 +-
tests/i915/i915_pm_rpm.c | 4 +-
tests/kms_flip.c | 2 +-
tests/prime_mmap.c | 4 +-
tools/intel_audio_dump.c | 9 +++-
tools/intel_backlight.c | 8 +++-
tools/intel_display_poller.c | 8 +++-
tools/intel_forcewaked.c | 10 +++--
tools/intel_gpu_time.c | 8 +++-
tools/intel_gtt.c | 8 +++-
tools/intel_infoframes.c | 7 ++-
tools/intel_l3_parity.c | 3 +-
tools/intel_lid.c | 9 +++-
tools/intel_panel_fitter.c | 8 +++-
tools/intel_perf_counters.c | 3 +-
tools/intel_reg.c | 23 +++++-----
tools/intel_reg_checker.c | 8 +++-
tools/intel_watermark.c | 23 ++++++----
37 files changed, 226 insertions(+), 131 deletions(-)
diff --git a/benchmarks/gem_latency.c b/benchmarks/gem_latency.c
index c3fc4bf0..09be68f7 100644
--- a/benchmarks/gem_latency.c
+++ b/benchmarks/gem_latency.c
@@ -44,6 +44,8 @@
#include <sys/resource.h>
#include "drm.h"
+#include "igt_device.h"
+
#define LOCAL_I915_EXEC_FENCE_IN (1<<16)
#define LOCAL_I915_EXEC_FENCE_OUT (1<<17)
@@ -456,7 +458,7 @@ static int run(int seconds,
if (gen < 6)
return IGT_EXIT_SKIP; /* Needs BCS timestamp */
- intel_register_access_init(intel_get_pci_device(), false, fd);
+ intel_register_access_init(igt_device_get_pci_dev(fd), false, fd);
if (gen == 6)
timestamp_reg = REG(RCS_TIMESTAMP);
diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
index afb9644d..ae585b8c 100644
--- a/benchmarks/gem_wsim.c
+++ b/benchmarks/gem_wsim.c
@@ -41,7 +41,6 @@
#include <limits.h>
#include <pthread.h>
-
#include "intel_chipset.h"
#include "intel_reg.h"
#include "drm.h"
@@ -50,6 +49,7 @@
#include "intel_io.h"
#include "igt_aux.h"
+#include "igt_device.h"
#include "igt_rand.h"
#include "igt_perf.h"
#include "sw_sync.h"
@@ -2223,7 +2223,7 @@ static void init_clocks(void)
uint32_t rcs_start, rcs_end;
double overhead, t;
- intel_register_access_init(intel_get_pci_device(), false, fd);
+ intel_register_access_init(igt_device_get_pci_dev(fd), false, fd);
if (verbose <= 1)
return;
diff --git a/debugger/debug_rdata.c b/debugger/debug_rdata.c
index 61d82d9e..db8a15da 100644
--- a/debugger/debug_rdata.c
+++ b/debugger/debug_rdata.c
@@ -29,7 +29,6 @@
#include <stdio.h>
#include <stdlib.h>
#include "intel_io.h"
-#include "intel_chipset.h"
struct eu_rdata {
union {
@@ -133,7 +132,11 @@ find_stuck_threads(void)
int main(int argc, char *argv[]) {
struct pci_device *pci_dev;
- pci_dev = intel_get_pci_device();
+ int fd;
+
+ fd = drm_open_driver(DRIVER_INTEL);
+ pci_dev = igt_device_get_pci_dev(fd);
+ close(fd);
intel_register_access_init(pci_dev, 1);
find_stuck_threads();
diff --git a/debugger/eudb.c b/debugger/eudb.c
index 866d4b52..6bd54727 100644
--- a/debugger/eudb.c
+++ b/debugger/eudb.c
@@ -42,7 +42,6 @@
#include "drm.h"
#include "i915_drm.h"
#include "drmtest.h"
-#include "intel_chipset.h"
#include "intel_bufmgr.h"
#include "intel_io.h"
#include "intel_batchbuffer.h"
@@ -506,7 +505,7 @@ int main(int argc, char* argv[]) {
struct pci_device *pci_dev;
volatile uint8_t *scratch = NULL;
int bits[64];
- int devid = -1, opt;
+ int devid = -1, opt, fd;
while ((opt = getopt(argc, argv, "cdr:pf?h")) != -1) {
switch (opt) {
@@ -533,7 +532,10 @@ int main(int argc, char* argv[]) {
}
}
- pci_dev = intel_get_pci_device();
+ fd = drm_open_driver(DRIVER_INTEL);
+ pci_dev = igt_device_get_pci_dev(fd);
+ close(fd);
+
if (devid == -1)
devid = pci_dev->device_id;
if (identify_device(devid)) {
diff --git a/lib/igt_device.c b/lib/igt_device.c
index 08f39c8b..eb44bc7c 100644
--- a/lib/igt_device.c
+++ b/lib/igt_device.c
@@ -26,6 +26,7 @@
#include <sys/sysmacros.h>
#include "igt.h"
#include "igt_device.h"
+#include "igt_sysfs.h"
int __igt_device_set_master(int fd)
{
@@ -103,3 +104,81 @@ int igt_device_get_card_index(int fd)
return minor(st.st_rdev);
}
+
+#define IGT_DEV_PATH_LEN 80
+
+static bool igt_device_is_pci(int fd)
+{
+ char path[IGT_DEV_PATH_LEN];
+ char link[IGT_DEV_PATH_LEN];
+ char *subsystem;
+ int len;
+
+ igt_assert_f(igt_sysfs_path(fd, path, sizeof(path)),
+ "Failed to find device sysfs path.\n");
+
+ strcat(path, "/device/subsystem");
+
+ if ((len = readlink(path, link, sizeof(link) - 1)) == -1)
+ return false;
+ link[len] = '\0';
+
+ subsystem = strrchr(link, '/') + 1;
+
+ return strcmp(subsystem, "pci") == 0;
+}
+
+static void igt_device_get_pci_addr(int fd, char *buf, int len)
+{
+ char path[IGT_DEV_PATH_LEN];
+ char link[IGT_DEV_PATH_LEN];
+ char *pci_addr;
+ int link_len;
+
+ igt_assert_f(igt_device_is_pci(fd), "This is not a PCI device.");
+
+ igt_assert_f(igt_sysfs_path(fd, path, sizeof(path)),
+ "Failed to find device sysfs path.\n");
+
+ strcat(path, "/device");
+
+ igt_assert_f((link_len = readlink(path, link, sizeof(link) - 1)) != -1,
+ "Failed to find device sysfs path.\n");
+ if (link_len)
+ link[link_len] = '\0';
+
+ pci_addr = strrchr(link, '/') + 1;
+
+ strncpy(buf, pci_addr, len - 1);
+ if (len)
+ buf[len] = '\0';
+}
+
+struct pci_device *igt_device_get_pci_dev(int fd)
+{
+ char pci_addr[IGT_DEV_PATH_LEN];
+ struct pci_device *pci_dev;
+ unsigned int domain, bus, device, function;
+ int err;
+
+ igt_device_get_pci_addr(fd, pci_addr, sizeof(pci_addr));
+
+ err = sscanf(pci_addr, "%4x:%2x:%2x.%2x",
+ &domain, &bus, &device, &function);
+ igt_assert_f(err == 4, "Unable to find device PCI address.");
+
+ err = pci_system_init();
+ igt_fail_on_f(err != 0, "Couldn't initialize PCI system\n");
+
+ pci_dev = pci_device_find_by_slot(domain,
+ bus,
+ device,
+ function);
+ igt_assert_f(pci_dev, "Couldn't find Intel graphics card\n");
+
+ err = pci_device_probe(pci_dev);
+ igt_fail_on_f(err != 0,
+ "Couldn't probe graphics card\n");
+
+ return pci_dev;
+}
diff --git a/lib/igt_device.h b/lib/igt_device.h
index 9d7dc2c3..db53b74c 100644
--- a/lib/igt_device.h
+++ b/lib/igt_device.h
@@ -32,5 +32,6 @@ int __igt_device_drop_master(int fd);
void igt_device_drop_master(int fd);
int igt_device_get_card_index(int fd);
+struct pci_device *igt_device_get_pci_dev(int fd);
#endif /* __IGT_DEVICE_H__ */
diff --git a/lib/intel_chipset.c b/lib/intel_chipset.c
index 4748a3fb..0577f77a 100644
--- a/lib/intel_chipset.c
+++ b/lib/intel_chipset.c
@@ -61,57 +61,6 @@
*/
enum pch_type intel_pch;
-/**
- * intel_get_pci_device:
- *
- * Looks up the main graphics pci device using libpciaccess.
- *
- * Returns:
- * The pci_device, exits the program on any failures.
- */
-struct pci_device *
-intel_get_pci_device(void)
-{
- struct pci_device *pci_dev;
- int error;
-
- error = pci_system_init();
- igt_fail_on_f(error != 0,
- "Couldn't initialize PCI system\n");
-
- /* Grab the graphics card. Try the canonical slot first, then
- * walk the entire PCI bus for a matching device. */
- pci_dev = pci_device_find_by_slot(0, 0, 2, 0);
- if (pci_dev == NULL || pci_dev->vendor_id != 0x8086) {
- struct pci_device_iterator *iter;
- struct pci_id_match match;
-
- match.vendor_id = 0x8086; /* Intel */
- match.device_id = PCI_MATCH_ANY;
- match.subvendor_id = PCI_MATCH_ANY;
- match.subdevice_id = PCI_MATCH_ANY;
-
- match.device_class = 0x3 << 16;
- match.device_class_mask = 0xff << 16;
-
- match.match_data = 0;
-
- iter = pci_id_match_iterator_create(&match);
- pci_dev = pci_device_next(iter);
- pci_iterator_destroy(iter);
- }
- igt_require_f(pci_dev, "Couldn't find Intel graphics card\n");
-
- error = pci_device_probe(pci_dev);
- igt_fail_on_f(error != 0,
- "Couldn't probe graphics card\n");
-
- if (pci_dev->vendor_id != 0x8086)
- errx(1, "Graphics card is non-intel");
-
- return pci_dev;
-}
-
/**
* intel_get_drm_devid:
* @fd: open i915 drm file descriptor
diff --git a/lib/intel_chipset.h b/lib/intel_chipset.h
index 40170b7b..dd31d3fb 100644
--- a/lib/intel_chipset.h
+++ b/lib/intel_chipset.h
@@ -31,7 +31,6 @@
#include <pciaccess.h>
#include <stdbool.h>
-struct pci_device *intel_get_pci_device(void);
uint32_t intel_get_drm_devid(int fd);
struct intel_device_info {
diff --git a/lib/intel_mmio.c b/lib/intel_mmio.c
index a5458aeb..5509c602 100644
--- a/lib/intel_mmio.c
+++ b/lib/intel_mmio.c
@@ -112,7 +112,7 @@ intel_mmio_use_dump_file(char *file)
*
* Sets up #igt_global_mmio to point at the mmio bar.
*
- * @pci_dev can be obtained from intel_get_pci_device().
+ * @pci_dev can be obtained from igt_device_get_pci_dev().
*/
void
intel_mmio_use_pci_bar(struct pci_device *pci_dev)
@@ -162,7 +162,7 @@ release_forcewake_lock(int fd)
*
* It also initializes #igt_global_mmio like intel_mmio_use_pci_bar().
*
- * @pci_dev can be obtained from intel_get_pci_device().
+ * @pci_dev can be obtained from igt_device_get_pci_dev().
*/
int
intel_register_access_init(struct pci_device *pci_dev, int safe, int fd)
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 39920f87..0c43eb3b 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -53,6 +53,7 @@
#include "intel_chipset.h"
#include "intel_io.h"
#include "igt_debugfs.h"
+#include "igt_device.h"
#include "igt_sysfs.h"
#include "config.h"
@@ -1096,9 +1097,9 @@ uint64_t gem_aperture_size(int fd)
*
* Returns: The mappable gtt address space size.
*/
-uint64_t gem_mappable_aperture_size(void)
+uint64_t gem_mappable_aperture_size(int fd)
{
- struct pci_device *pci_dev = intel_get_pci_device();
+ struct pci_device *pci_dev = igt_device_get_pci_dev(fd);
int bar;
if (intel_gen(pci_dev->device_id) < 3)
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index f0be2608..ad93daff 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -136,7 +136,7 @@ uint64_t gem_total_stolen_size(int fd);
uint64_t gem_available_aperture_size(int fd);
uint64_t gem_aperture_size(int fd);
uint64_t gem_global_aperture_size(int fd);
-uint64_t gem_mappable_aperture_size(void);
+uint64_t gem_mappable_aperture_size(int fd);
bool gem_has_softpin(int fd);
bool gem_has_exec_fence(int fd);
diff --git a/tests/i915/gem_concurrent_all.c b/tests/i915/gem_concurrent_all.c
index 6049372d..f719b0a1 100644
--- a/tests/i915/gem_concurrent_all.c
+++ b/tests/i915/gem_concurrent_all.c
@@ -1850,7 +1850,7 @@ igt_main
c->name, s->name, "small");
igt_subtest_group {
igt_fixture {
- count = num_buffers(gem_mappable_aperture_size()/4,
+ count = num_buffers(gem_mappable_aperture_size(fd)/4,
s, c, CHECK_RAM);
}
run_modes(name, c, modes, s, count);
@@ -1861,7 +1861,7 @@ igt_main
c->name, s->name, "thrash");
igt_subtest_group {
igt_fixture {
- count = num_buffers(gem_mappable_aperture_size(),
+ count = num_buffers(gem_mappable_aperture_size(fd),
s, c, CHECK_RAM);
}
run_modes(name, c, modes, s, count);
@@ -1893,7 +1893,7 @@ igt_main
c->name, s->name, "shrink");
igt_subtest_group {
igt_fixture {
- count = num_buffers(gem_mappable_aperture_size(),
+ count = num_buffers(gem_mappable_aperture_size(fd),
s, c, CHECK_RAM);
igt_fork_shrink_helper(fd);
@@ -1909,8 +1909,8 @@ igt_main
c->name, s->name, "swap");
igt_subtest_group {
igt_fixture {
- if (intel_get_avail_ram_mb() > gem_mappable_aperture_size()/(1024*1024)) {
- pin_sz = intel_get_avail_ram_mb() - gem_mappable_aperture_size()/(1024*1024);
+ if (intel_get_avail_ram_mb() > gem_mappable_aperture_size(fd)/(1024*1024)) {
+ pin_sz = intel_get_avail_ram_mb() - gem_mappable_aperture_size(fd)/(1024*1024);
igt_debug("Pinning %lld MiB\n", (long long)pin_sz);
pin_sz *= 1024 * 1024;
@@ -1924,7 +1924,7 @@ igt_main
igt_require(pinned);
}
- count = num_buffers(gem_mappable_aperture_size(),
+ count = num_buffers(gem_mappable_aperture_size(fd),
s, c, CHECK_RAM | CHECK_SWAP);
}
run_modes(name, c, modes, s, count);
diff --git a/tests/i915/gem_cpu_reloc.c b/tests/i915/gem_cpu_reloc.c
index 47099862..17c2fe11 100644
--- a/tests/i915/gem_cpu_reloc.c
+++ b/tests/i915/gem_cpu_reloc.c
@@ -283,7 +283,7 @@ igt_main
run_test(i915, 1);
igt_subtest("full") {
- uint64_t aper_size = gem_mappable_aperture_size();
+ uint64_t aper_size = gem_mappable_aperture_size(i915);
unsigned long count = aper_size / 4096 + 1;
intel_require_memory(count, 4096, CHECK_RAM);
@@ -292,7 +292,7 @@ igt_main
}
igt_subtest("forked") {
- uint64_t aper_size = gem_mappable_aperture_size();
+ uint64_t aper_size = gem_mappable_aperture_size(i915);
unsigned long count = aper_size / 4096 + 1;
int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
diff --git a/tests/i915/gem_exec_latency.c b/tests/i915/gem_exec_latency.c
index 6dd191ec..1b7b66f1 100644
--- a/tests/i915/gem_exec_latency.c
+++ b/tests/i915/gem_exec_latency.c
@@ -40,6 +40,7 @@
#include "drm.h"
+#include "igt_device.h"
#include "igt_sysfs.h"
#include "igt_vgem.h"
#include "igt_dummyload.h"
@@ -679,7 +680,7 @@ igt_main
if (ring_size > 1024)
ring_size = 1024;
- intel_register_access_init(intel_get_pci_device(), false, device);
+ intel_register_access_init(igt_device_get_pci_dev(device), false, device);
rcs_clock = clockrate(device, RCS_TIMESTAMP);
igt_info("RCS timestamp clock: %.0fKHz, %.1fns\n",
rcs_clock / 1e3, 1e9 / rcs_clock);
diff --git a/tests/i915/gem_exec_parse.c b/tests/i915/gem_exec_parse.c
index 62e8d0a5..f9e93ba1 100644
--- a/tests/i915/gem_exec_parse.c
+++ b/tests/i915/gem_exec_parse.c
@@ -30,6 +30,8 @@
#include <drm.h>
+#include "igt_device.h"
+
#ifndef I915_PARAM_CMD_PARSER_VERSION
#define I915_PARAM_CMD_PARSER_VERSION 28
#endif
@@ -530,7 +532,7 @@ igt_main
#undef REG
igt_fixture {
- intel_register_access_init(intel_get_pci_device(), 0, fd);
+ intel_register_access_init(igt_device_get_pci_dev(fd), 0, fd);
}
for (int i = 0; i < ARRAY_SIZE(lris); i++) {
diff --git a/tests/i915/gem_mmap.c b/tests/i915/gem_mmap.c
index 0ed15878..4e30fec1 100644
--- a/tests/i915/gem_mmap.c
+++ b/tests/i915/gem_mmap.c
@@ -53,10 +53,10 @@ test_huge_bo(int huge)
switch (huge) {
case -1:
- huge_object_size = gem_mappable_aperture_size() / 2;
+ huge_object_size = gem_mappable_aperture_size(fd) / 2;
break;
case 0:
- huge_object_size = gem_mappable_aperture_size() + PAGE_SIZE;
+ huge_object_size = gem_mappable_aperture_size(fd) + PAGE_SIZE;
break;
case 1:
huge_object_size = gem_aperture_size(fd) + PAGE_SIZE;
diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
index f6fbbe19..60c19d61 100644
--- a/tests/i915/gem_mmap_gtt.c
+++ b/tests/i915/gem_mmap_gtt.c
@@ -527,7 +527,7 @@ test_huge_bo(int fd, int huge, int tiling)
switch (huge) {
case -1:
- size = gem_mappable_aperture_size() / 2;
+ size = gem_mappable_aperture_size(fd) / 2;
/* Power of two fence size, natural fence
* alignment, and the guard page at the end
@@ -542,7 +542,7 @@ test_huge_bo(int fd, int huge, int tiling)
size /= 2;
break;
case 0:
- size = gem_mappable_aperture_size() + PAGE_SIZE;
+ size = gem_mappable_aperture_size(fd) + PAGE_SIZE;
break;
default:
size = gem_global_aperture_size(fd) + PAGE_SIZE;
@@ -623,13 +623,13 @@ test_huge_copy(int fd, int huge, int tiling_a, int tiling_b, int ncpus)
switch (huge) {
case -2:
- huge_object_size = gem_mappable_aperture_size() / 4;
+ huge_object_size = gem_mappable_aperture_size(fd) / 4;
break;
case -1:
- huge_object_size = gem_mappable_aperture_size() / 2;
+ huge_object_size = gem_mappable_aperture_size(fd) / 2;
break;
case 0:
- huge_object_size = gem_mappable_aperture_size() + PAGE_SIZE;
+ huge_object_size = gem_mappable_aperture_size(fd) + PAGE_SIZE;
break;
case 1:
huge_object_size = gem_global_aperture_size(fd) + PAGE_SIZE;
diff --git a/tests/i915/gem_pwrite.c b/tests/i915/gem_pwrite.c
index 696bd316..5cae121a 100644
--- a/tests/i915/gem_pwrite.c
+++ b/tests/i915/gem_pwrite.c
@@ -89,7 +89,7 @@ static void test_big_cpu(int fd, int scale, unsigned flags)
switch (scale) {
case 0:
- size = gem_mappable_aperture_size() + 4096;
+ size = gem_mappable_aperture_size(fd) + 4096;
break;
case 1:
size = gem_global_aperture_size(fd) + 4096;
@@ -151,7 +151,7 @@ static void test_big_gtt(int fd, int scale, unsigned flags)
igt_require(gem_mmap__has_wc(fd));
switch (scale) {
case 0:
- size = gem_mappable_aperture_size() + 4096;
+ size = gem_mappable_aperture_size(fd) + 4096;
break;
case 1:
size = gem_global_aperture_size(fd) + 4096;
diff --git a/tests/i915/gem_shrink.c b/tests/i915/gem_shrink.c
index c8e05814..73b6be72 100644
--- a/tests/i915/gem_shrink.c
+++ b/tests/i915/gem_shrink.c
@@ -409,7 +409,7 @@ igt_main
* we expect the shrinker to start purging objects,
* and possibly fail.
*/
- alloc_size = gem_mappable_aperture_size() / 2;
+ alloc_size = gem_mappable_aperture_size(fd) / 2;
num_processes = 1 + (mem_size / (alloc_size >> 20));
igt_info("Using %d processes and %'lluMiB per process\n",
diff --git a/tests/i915/i915_pm_lpsp.c b/tests/i915/i915_pm_lpsp.c
index b319dbe9..2897c949 100644
--- a/tests/i915/i915_pm_lpsp.c
+++ b/tests/i915/i915_pm_lpsp.c
@@ -30,6 +30,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include "igt_device.h"
static bool supports_lpsp(uint32_t devid)
{
@@ -210,7 +211,7 @@ igt_main
igt_require(supports_lpsp(devid));
- intel_register_access_init(intel_get_pci_device(), 0, drm_fd);
+ intel_register_access_init(igt_device_get_pci_dev(drm_fd), 0, drm_fd);
kmstest_set_vt_graphics_mode();
}
diff --git a/tests/i915/i915_pm_rpm.c b/tests/i915/i915_pm_rpm.c
index 03de609c..e82fa068 100644
--- a/tests/i915/i915_pm_rpm.c
+++ b/tests/i915/i915_pm_rpm.c
@@ -1368,7 +1368,7 @@ static void gem_evict_pwrite_subtest(void)
unsigned int num_trash_bos, n;
uint32_t buf;
- num_trash_bos = gem_mappable_aperture_size() / (1024*1024) + 1;
+ num_trash_bos = gem_mappable_aperture_size(drm_fd) / (1024*1024) + 1;
trash_bos = malloc(num_trash_bos * sizeof(*trash_bos));
igt_assert(trash_bos);
@@ -1412,7 +1412,7 @@ static bool device_in_pci_d3(void)
uint16_t val;
int rc;
- rc = pci_device_cfg_read_u16(intel_get_pci_device(), &val, 0xd4);
+ rc = pci_device_cfg_read_u16(igt_device_get_pci_dev(drm_fd), &val, 0xd4);
igt_assert_eq(rc, 0);
igt_debug("%s: PCI D3 state=%d\n", __func__, val & 0x3);
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index dfa5a69e..6ece1e53 100755
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -1224,7 +1224,7 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs,
/* 256 MB is usually the maximum mappable aperture,
* (make it 4x times that to ensure failure) */
if (o->flags & TEST_BO_TOOBIG) {
- bo_size = 4*gem_mappable_aperture_size();
+ bo_size = 4*gem_mappable_aperture_size(drm_fd);
igt_require(bo_size < gem_global_aperture_size(drm_fd));
}
diff --git a/tests/prime_mmap.c b/tests/prime_mmap.c
index fc985784..06a66cab 100644
--- a/tests/prime_mmap.c
+++ b/tests/prime_mmap.c
@@ -447,8 +447,8 @@ test_aperture_limit(void)
char *ptr1, *ptr2;
uint32_t handle1, handle2;
/* Two buffers the sum of which > mappable aperture */
- uint64_t size1 = (gem_mappable_aperture_size() * 7) / 8;
- uint64_t size2 = (gem_mappable_aperture_size() * 3) / 8;
+ uint64_t size1 = (gem_mappable_aperture_size(fd) * 7) / 8;
+ uint64_t size2 = (gem_mappable_aperture_size(fd) * 3) / 8;
handle1 = gem_create(fd, size1);
fill_bo(handle1, BO_SIZE);
diff --git a/tools/intel_audio_dump.c b/tools/intel_audio_dump.c
index 90260a2f..22c91a06 100644
--- a/tools/intel_audio_dump.c
+++ b/tools/intel_audio_dump.c
@@ -32,6 +32,7 @@
#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"
@@ -2464,8 +2465,12 @@ 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_dev(fd);
+ close(fd);
- pci_dev = intel_get_pci_device();
devid = pci_dev->device_id; /* XXX not true when mapping! */
do_self_tests();
@@ -2493,5 +2498,7 @@ 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 067fd418..827512be 100644
--- a/tools/intel_backlight.c
+++ b/tools/intel_backlight.c
@@ -30,8 +30,9 @@
#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 */
@@ -39,8 +40,11 @@
int main(int argc, char** argv)
{
uint32_t current, max;
+ int fd;
- intel_mmio_use_pci_bar(intel_get_pci_device());
+ fd = drm_open_driver(DRIVER_INTEL);
+ intel_mmio_use_pci_bar(igt_device_get_pci_dev(fd));
+ close(fd);
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 51f5b9a5..2cae88dd 100644
--- a/tools/intel_display_poller.c
+++ b/tools/intel_display_poller.c
@@ -36,6 +36,7 @@
#include "intel_io.h"
#include "intel_reg.h"
#include "igt_debugfs.h"
+#include "igt_device.h"
#include "drmtest.h"
#include "igt_aux.h"
@@ -971,6 +972,7 @@ 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[] = {
@@ -1046,7 +1048,8 @@ int main(int argc, char *argv[])
}
}
- devid = intel_get_pci_device()->device_id;
+ fd = drm_open_driver(DRIVER_INTEL);
+ devid = igt_device_get_pci_dev(fd)->device_id;
/*
* check if the requires registers are
@@ -1187,7 +1190,7 @@ int main(int argc, char *argv[])
break;
}
- intel_register_access_init(intel_get_pci_device(), 0, -1);
+ intel_register_access_init(igt_device_get_pci_dev(fd), 0, -1);
printf("%s?\n", test_name(test, pipe, bit, test_pixelcount));
@@ -1263,6 +1266,7 @@ 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 02fbf888..38e3f8fc 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,6 +65,7 @@ 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]);
@@ -80,24 +81,27 @@ int main(int argc, char *argv[])
INFO_PRINT("started daemon");
}
- ret = intel_register_access_init(intel_get_pci_device(), 1, -1);
+ fd = drm_open_driver(DRIVER_INTEL);
+ ret = intel_register_access_init(igt_device_get_pci_dev(fd), 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(intel_get_pci_device(), 1, -1);
+ ret = intel_register_access_init(igt_device_get_pci_dev(fd), 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 56d65fe0..c271b964 100644
--- a/tools/intel_gpu_time.c
+++ b/tools/intel_gpu_time.c
@@ -34,8 +34,9 @@
#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
@@ -66,8 +67,11 @@ int main(int argc, char **argv)
struct timeval start, end;
static struct rusage rusage;
int status;
+ int fd;
- intel_mmio_use_pci_bar(intel_get_pci_device());
+ fd = drm_open_driver(DRIVER_INTEL);
+ intel_mmio_use_pci_bar(igt_device_get_pci_dev(fd));
+ close(fd);
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 311694ba..6649d194 100644
--- a/tools/intel_gtt.c
+++ b/tools/intel_gtt.c
@@ -34,6 +34,8 @@
#include <pciaccess.h>
#include <unistd.h>
+#include "drmtest.h"
+#include "igt_device.h"
#include "intel_io.h"
#include "intel_chipset.h"
@@ -140,13 +142,17 @@ 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;
- pci_dev = intel_get_pci_device();
+ fd = drm_open_driver(DRIVER_INTEL);
+ pci_dev = igt_device_get_pci_dev(fd);
+ close(fd);
+
devid = pci_dev->device_id;
if (IS_GEN2(devid)) {
diff --git a/tools/intel_infoframes.c b/tools/intel_infoframes.c
index 2ef5d4fd..8dd29116 100644
--- a/tools/intel_infoframes.c
+++ b/tools/intel_infoframes.c
@@ -30,6 +30,7 @@
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
+#include "igt_device.h"
#include "intel_io.h"
#include "intel_chipset.h"
#include "drmtest.h"
@@ -1081,6 +1082,7 @@ printf("Options:\n"
int main(int argc, char *argv[])
{
int opt;
+ int fd;
int ret = 0;
Transcoder transcoder = TRANSC_INVALID;
DipType dip = DIP_INVALID;
@@ -1107,7 +1109,10 @@ 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");
- pci_dev = intel_get_pci_device();
+ fd = drm_open_driver(DRIVER_INTEL);
+ pci_dev = igt_device_get_pci_dev(fd);
+ close(fd);
+
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 d8c997af..206bdbb6 100644
--- a/tools/intel_l3_parity.c
+++ b/tools/intel_l3_parity.c
@@ -36,6 +36,7 @@
#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"
@@ -189,7 +190,7 @@ int main(int argc, char *argv[])
if (intel_gen(devid) < 7 || IS_VALLEYVIEW(devid))
exit(77);
- assert(intel_register_access_init(intel_get_pci_device(), 0, device) == 0);
+ assert(intel_register_access_init(igt_device_get_pci_dev(device), 0, device) == 0);
dir = igt_sysfs_open(device);
diff --git a/tools/intel_lid.c b/tools/intel_lid.c
index 37c6ba5e..e29c10d1 100644
--- a/tools/intel_lid.c
+++ b/tools/intel_lid.c
@@ -37,9 +37,10 @@
#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 */
@@ -118,8 +119,11 @@ out:
int main(int argc, char **argv)
{
int swf14, acpi_lid;
+ int fd;
- intel_mmio_use_pci_bar(intel_get_pci_device());
+ fd = drm_open_driver(DRIVER_INTEL);
+ intel_mmio_use_pci_bar(igt_device_get_pci_dev(fd));
+ close(fd);
while (1) {
swf14 = INREG(SWF14);
@@ -142,5 +146,6 @@ 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 137ef61a..7ceedc0a 100644
--- a/tools/intel_panel_fitter.c
+++ b/tools/intel_panel_fitter.c
@@ -30,6 +30,7 @@
#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"
@@ -273,13 +274,17 @@ 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");
- pci_dev = intel_get_pci_device();
+ fd = drm_open_driver(DRIVER_INTEL);
+ pci_dev = igt_device_get_pci_dev(fd);
+ close(fd);
+
intel_register_access_init(pci_dev, 0, -1);
devid = pci_dev->device_id;
@@ -343,5 +348,6 @@ 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 50c4bce6..59550ae3 100644
--- a/tools/intel_perf_counters.c
+++ b/tools/intel_perf_counters.c
@@ -45,6 +45,7 @@
#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"
@@ -483,7 +484,7 @@ main(int argc, char **argv)
if (oacontrol) {
/* Forcewake */
- intel_register_access_init(intel_get_pci_device(), 0, fd);
+ intel_register_access_init(igt_device_get_pci_dev(fd), 0, fd);
/* Enable performance counters */
intel_register_write(OACONTROL,
diff --git a/tools/intel_reg.c b/tools/intel_reg.c
index 1247b70b..0de6bdc9 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,15 +274,6 @@ 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)
@@ -1015,6 +1006,13 @@ 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");
@@ -1026,7 +1024,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "--devid without --mmio\n");
return EXIT_FAILURE;
}
- config.pci_dev = intel_get_pci_device();
+ config.pci_dev = igt_device_get_pci_dev(config.fd);
config.devid = config.pci_dev->device_id;
}
@@ -1050,8 +1048,7 @@ int main(int argc, char *argv[])
free(config.mmiofile);
- if (config.fd >= 0)
- close(config.fd);
+ close(config.fd);
return ret;
}
diff --git a/tools/intel_reg_checker.c b/tools/intel_reg_checker.c
index 6bde63ec..d69c4e92 100644
--- a/tools/intel_reg_checker.c
+++ b/tools/intel_reg_checker.c
@@ -26,6 +26,8 @@
#include <err.h>
#include <string.h>
#include <stdbool.h>
+#include "drmtest.h"
+#include "igt_device.h"
#include "intel_io.h"
#include "intel_chipset.h"
@@ -342,8 +344,12 @@ 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_dev(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 e71c3d9c..90ca900b 100644
--- a/tools/intel_watermark.c
+++ b/tools/intel_watermark.c
@@ -29,12 +29,14 @@
#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)
{
@@ -249,7 +251,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(intel_get_pci_device(), 0, -1);
+ intel_register_access_init(igt_device_get_pci_dev(fd), 0, -1);
for (pipe = 0; pipe < num_pipes; pipe++) {
int num_planes = skl_num_planes(devid, pipe);
@@ -469,7 +471,7 @@ static void ilk_wm_dump(void)
int num_pipes = intel_gen(devid) >= 7 ? 3 : 2;
struct ilk_wm wm = {};
- intel_register_access_init(intel_get_pci_device(), 0, -1);
+ intel_register_access_init(igt_device_get_pci_dev(fd), 0, -1);
for (i = 0; i < num_pipes; i++) {
dspcntr[i] = read_reg(0x70180 + i * 0x1000);
@@ -619,7 +621,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, -1);
+ intel_register_access_init(igt_device_get_pci_dev(fd), 0, -1);
dsparb = read_reg(0x70030);
dsparb2 = read_reg(0x70060);
@@ -835,7 +837,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, -1);
+ intel_register_access_init(igt_device_get_pci_dev(fd), 0, -1);
dspacntr = read_reg(0x70180);
dspbcntr = read_reg(0x71180);
@@ -921,7 +923,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, -1);
+ intel_register_access_init(igt_device_get_pci_dev(fd), 0, -1);
dsparb = read_reg(0x70030);
fw1 = read_reg(0x70034);
@@ -992,7 +994,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, -1);
+ intel_register_access_init(igt_device_get_pci_dev(fd), 0, -1);
dsparb = read_reg(0x70030);
fw1 = read_reg(0x70034);
@@ -1082,7 +1084,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, -1);
+ intel_register_access_init(igt_device_get_pci_dev(fd), 0, -1);
dsparb = read_reg(0x70030);
instpm = read_reg(0x20c0);
@@ -1151,7 +1153,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, -1);
+ intel_register_access_init(igt_device_get_pci_dev(fd), 0, -1);
dsparb = read_reg(0x70030);
mem_mode = read_reg(0x20cc);
@@ -1226,7 +1228,8 @@ static void gen2_wm_dump(void)
int main(int argc, char *argv[])
{
- devid = intel_get_pci_device()->device_id;
+ fd = drm_open_driver(DRIVER_INTEL);
+ devid = igt_device_get_pci_dev(fd)->device_id;
if (intel_gen(devid) >= 9) {
skl_wm_dump();
@@ -1250,5 +1253,7 @@ int main(int argc, char *argv[])
return 1;
}
+ close(fd);
+
return 0;
}
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [igt-dev] [PATCH i-g-t 1/6] tests/gem_exec_blt: Drop benchmark mode, use igt_sysfs
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 1/6] tests/gem_exec_blt: Drop benchmark mode, use igt_sysfs Michał Winiarski
@ 2019-03-13 12:58 ` Chris Wilson
0 siblings, 0 replies; 15+ messages in thread
From: Chris Wilson @ 2019-03-13 12:58 UTC (permalink / raw)
To: Michał Winiarski, igt-dev
Quoting Michał Winiarski (2019-03-13 12:53:27)
> The "benchmark" mode is no longer used.
> While I'm here, let's also move things around and start to use
> igt_sysfs, rather implementing own set of helpers.
>
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [igt-dev] [PATCH i-g-t 2/6] lib/igt_device: Introduce igt_device_get_card_index
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 2/6] lib/igt_device: Introduce igt_device_get_card_index Michał Winiarski
@ 2019-03-13 13:02 ` Chris Wilson
0 siblings, 0 replies; 15+ messages in thread
From: Chris Wilson @ 2019-03-13 13:02 UTC (permalink / raw)
To: Michał Winiarski, igt-dev
Quoting Michał Winiarski (2019-03-13 12:53:28)
> And use it! But let's start small.
> Rather than going with "and by the way, here's the card index" from
> igt_sysfs_path, we're making things more explicit.
>
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
> ---
> lib/igt_device.c | 19 +++++++++++++++++++
> lib/igt_device.h | 2 ++
> lib/igt_sysfs.c | 11 +++++++----
> lib/igt_sysfs.h | 2 +-
> tests/i915/i915_pm_rpm.c | 2 +-
> 5 files changed, 30 insertions(+), 6 deletions(-)
>
> diff --git a/lib/igt_device.c b/lib/igt_device.c
> index 5b3722c8..08f39c8b 100644
> --- a/lib/igt_device.c
> +++ b/lib/igt_device.c
> @@ -22,6 +22,8 @@
> *
> */
>
> +#include <sys/stat.h>
> +#include <sys/sysmacros.h>
> #include "igt.h"
> #include "igt_device.h"
>
> @@ -84,3 +86,20 @@ void igt_device_drop_master(int fd)
> "Failed to drop DRM master.\n");
> }
> }
> +
> +/**
> + * igt_device_get_card_index:
> + * @fd: the device
> + *
> + * Returns:
> + * Index (N) of /dev/dri/cardN or /dev/dri/renderDN corresponding with fd.
> + *
> + */
> +int igt_device_get_card_index(int fd)
> +{
> + struct stat st;
> +
> + igt_fail_on(fstat(fd, &st) || !S_ISCHR(st.st_mode));
I wonder... My desire for internal_assert() grows stronger so that we
can distinguish between test failures (igt_assert) and programming
failures, of which I'd class this.
> +
> + return minor(st.st_rdev);
Hmm. Render nodes?
Ok, you mention it returns the high values for renderD.
> +}
> diff --git a/lib/igt_device.h b/lib/igt_device.h
> index 2995f969..9d7dc2c3 100644
> --- a/lib/igt_device.h
> +++ b/lib/igt_device.h
> @@ -31,4 +31,6 @@ void igt_device_set_master(int fd);
> int __igt_device_drop_master(int fd);
> void igt_device_drop_master(int fd);
>
> +int igt_device_get_card_index(int fd);
> +
> #endif /* __IGT_DEVICE_H__ */
> diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
> index c57e4ae2..fd075cd6 100644
> --- a/lib/igt_sysfs.c
> +++ b/lib/igt_sysfs.c
> @@ -41,6 +41,7 @@
>
> #include "igt_core.h"
> #include "igt_sysfs.h"
> +#include "igt_device.h"
>
> /**
> * SECTION:igt_sysfs
> @@ -96,7 +97,7 @@ static int writeN(int fd, const char *buf, int len)
> * Returns:
> * The directory path, or NULL on failure.
> */
> -char *igt_sysfs_path(int device, char *path, int pathlen, int *idx)
> +char *igt_sysfs_path(int device, char *path, int pathlen)
And not a single tear was shed. But there appears to be random comments
above still referring to @idx.
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [igt-dev] [PATCH i-g-t 3/6] lib: Kill drm_get_card()
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 3/6] lib: Kill drm_get_card() Michał Winiarski
@ 2019-03-13 13:05 ` Chris Wilson
0 siblings, 0 replies; 15+ messages in thread
From: Chris Wilson @ 2019-03-13 13:05 UTC (permalink / raw)
To: Michał Winiarski, igt-dev
Quoting Michał Winiarski (2019-03-13 12:53:29)
> It's not operating on FD, and we've provided a nice reimplementation
> that does. Let's use it instead.
>
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
> static void
> -test_debugfs_reader(bool hibernate)
> +test_debugfs_reader(int fd, bool hibernate)
> {
> struct igt_helper_process reader = {};
> reader.use_SIGKILL = true;
> @@ -112,7 +113,7 @@ test_debugfs_reader(bool hibernate)
>
> snprintf(tmp, sizeof(tmp) - 1,
> "while true; do find %s/%i/ -type f ! -path \"*/crc/*\" | xargs cat > /dev/null 2>&1; done",
> - dfs_base, drm_get_card());
> + dfs_base, igt_device_get_card_index(fd));
> igt_assert(execl("/bin/sh", "sh", "-c", tmp, (char *) NULL) != -1);
* blinks
I didn't see this.
> diff --git a/tools/intel_gpu_frequency.c b/tools/intel_gpu_frequency.c
> index 80786ad9..52b11a98 100644
> --- a/tools/intel_gpu_frequency.c
> +++ b/tools/intel_gpu_frequency.c
> @@ -28,6 +28,7 @@
> #include <unistd.h>
>
> #include "drmtest.h"
> +#include "igt_device.h"
> #include "intel_chipset.h"
>
> #define VERSION "1.0"
> @@ -280,10 +281,12 @@ int main(int argc, char *argv[])
> {
>
> bool write, fail, targets[MAX+1] = {false};
> - int i, try = 1, set_freq[MAX+1] = {0};
> + int i, fd, try = 1, set_freq[MAX+1] = {0};
>
> - devid = intel_get_drm_devid(drm_open_driver(DRIVER_INTEL));
> - device = drm_get_card();
> + fd = drm_open_driver(DRIVER_INTEL);
> + devid = intel_get_drm_devid(fd);
> + device = igt_device_get_card_index(fd);
> + close(fd);
Weird. Generally this tool should just die, but it should just walk
sysfs and find the i915 nodes.
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [igt-dev] [PATCH i-g-t 4/6] lib/igt_sysfs: Remove idx from sysfs_open
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 4/6] lib/igt_sysfs: Remove idx from sysfs_open Michał Winiarski
@ 2019-03-13 13:08 ` Chris Wilson
0 siblings, 0 replies; 15+ messages in thread
From: Chris Wilson @ 2019-03-13 13:08 UTC (permalink / raw)
To: Michał Winiarski, igt-dev
Quoting Michał Winiarski (2019-03-13 12:53:30)
> Similar to sysfs_path - more explicit more better.
>
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
> diff --git a/tests/perf.c b/tests/perf.c
> index ac979a65..84555462 100644
> --- a/tests/perf.c
> +++ b/tests/perf.c
> @@ -4112,7 +4112,8 @@ igt_main
> igt_require_gem(drm_fd);
>
> devid = intel_get_drm_devid(drm_fd);
> - sysfs = igt_sysfs_open(drm_fd, &card);
> + card = igt_device_get_card_index(drm_fd);
As demonstrated here, anybody using card is doing it wrong.
Care to kill this off with an
openat(sysfs, "metrics/%s/id") ?
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 15+ messages in thread
* [igt-dev] ✓ Fi.CI.BAT: success for Attempt to get rid of some globals
2019-03-13 12:53 [igt-dev] [PATCH i-g-t 0/6] Attempt to get rid of some globals Michał Winiarski
` (5 preceding siblings ...)
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 6/6] lib/igt_device: Move intel_get_pci_device under igt_device Michał Winiarski
@ 2019-03-13 14:06 ` Patchwork
2019-03-13 18:07 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
7 siblings, 0 replies; 15+ messages in thread
From: Patchwork @ 2019-03-13 14:06 UTC (permalink / raw)
To: Michał Winiarski; +Cc: igt-dev
== Series Details ==
Series: Attempt to get rid of some globals
URL : https://patchwork.freedesktop.org/series/57934/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_5737 -> IGTPW_2603
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/57934/revisions/1/mbox/
Known issues
------------
Here are the changes found in IGTPW_2603 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@amdgpu/amd_basic@userptr:
- fi-kbl-8809g: PASS -> DMESG-WARN [fdo#108965]
* igt@amdgpu/amd_cs_nop@fork-gfx0:
- fi-icl-u2: NOTRUN -> SKIP [fdo#109315] +17
* igt@gem_ctx_create@basic-files:
- fi-gdg-551: NOTRUN -> SKIP [fdo#109271] +106
* igt@gem_exec_basic@gtt-bsd2:
- fi-byt-clapper: NOTRUN -> SKIP [fdo#109271] +57
* igt@gem_exec_basic@readonly-bsd1:
- fi-snb-2520m: NOTRUN -> SKIP [fdo#109271] +57
- fi-icl-u2: NOTRUN -> SKIP [fdo#109276] +7
* igt@gem_exec_parse@basic-allowed:
- fi-icl-u2: NOTRUN -> SKIP [fdo#109289] +1
* igt@i915_selftest@live_contexts:
- fi-icl-u2: NOTRUN -> DMESG-FAIL [fdo#108569]
* igt@i915_selftest@live_execlists:
- fi-apl-guc: PASS -> INCOMPLETE [fdo#103927] / [fdo#109720]
* igt@kms_addfb_basic@addfb25-y-tiled-small:
- fi-byt-n2820: NOTRUN -> SKIP [fdo#109271] +56
* igt@kms_busy@basic-flip-a:
- fi-gdg-551: NOTRUN -> FAIL [fdo#103182] +1
* igt@kms_busy@basic-flip-c:
- fi-blb-e6850: NOTRUN -> SKIP [fdo#109271] / [fdo#109278]
- fi-byt-clapper: NOTRUN -> SKIP [fdo#109271] / [fdo#109278]
- fi-gdg-551: NOTRUN -> SKIP [fdo#109271] / [fdo#109278]
- fi-snb-2520m: NOTRUN -> SKIP [fdo#109271] / [fdo#109278]
- fi-byt-n2820: NOTRUN -> SKIP [fdo#109271] / [fdo#109278]
* igt@kms_chamelium@dp-edid-read:
- fi-icl-u2: NOTRUN -> SKIP [fdo#109316] +2
* igt@kms_chamelium@hdmi-edid-read:
- fi-hsw-peppy: NOTRUN -> SKIP [fdo#109271] +46
* igt@kms_chamelium@vga-hpd-fast:
- fi-icl-u2: NOTRUN -> SKIP [fdo#109309] +1
* igt@kms_force_connector_basic@prune-stale-modes:
- fi-icl-u2: NOTRUN -> SKIP [fdo#109285] +3
* igt@kms_frontbuffer_tracking@basic:
- fi-hsw-peppy: NOTRUN -> DMESG-FAIL [fdo#102614] / [fdo#107814]
- fi-byt-clapper: NOTRUN -> FAIL [fdo#103167]
* igt@kms_pipe_crc_basic@hang-read-crc-pipe-c:
- fi-blb-e6850: NOTRUN -> SKIP [fdo#109271] +48
* igt@runner@aborted:
- fi-apl-guc: NOTRUN -> FAIL [fdo#108622] / [fdo#109720]
#### Possible fixes ####
* igt@gem_exec_suspend@basic-s3:
- fi-blb-e6850: INCOMPLETE [fdo#107718] -> PASS
[fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103182]: https://bugs.freedesktop.org/show_bug.cgi?id=103182
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#107814]: https://bugs.freedesktop.org/show_bug.cgi?id=107814
[fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569
[fdo#108622]: https://bugs.freedesktop.org/show_bug.cgi?id=108622
[fdo#108965]: https://bugs.freedesktop.org/show_bug.cgi?id=108965
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109276]: https://bugs.freedesktop.org/show_bug.cgi?id=109276
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#109289]: https://bugs.freedesktop.org/show_bug.cgi?id=109289
[fdo#109309]: https://bugs.freedesktop.org/show_bug.cgi?id=109309
[fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
[fdo#109316]: https://bugs.freedesktop.org/show_bug.cgi?id=109316
[fdo#109720]: https://bugs.freedesktop.org/show_bug.cgi?id=109720
Participating hosts (41 -> 41)
------------------------------
Additional (6): fi-hsw-peppy fi-icl-u2 fi-snb-2520m fi-gdg-551 fi-byt-n2820 fi-byt-clapper
Missing (6): fi-kbl-soraka fi-ilk-m540 fi-bxt-dsi fi-hsw-4200u fi-ctg-p8600 fi-bdw-samus
Build changes
-------------
* IGT: IGT_4883 -> IGTPW_2603
CI_DRM_5737: d5bb7d77aa77996702426496078a597f30bead58 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_2603: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2603/
IGT_4883: b25e06d6ddf2e42044cd9c93b613cbc7339a8c33 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2603/
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [igt-dev] [PATCH i-g-t 5/6] lib/igt_sysfs: Simplify obtaining sysfs path
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 5/6] lib/igt_sysfs: Simplify obtaining sysfs path Michał Winiarski
@ 2019-03-13 14:09 ` Chris Wilson
0 siblings, 0 replies; 15+ messages in thread
From: Chris Wilson @ 2019-03-13 14:09 UTC (permalink / raw)
To: Michał Winiarski, igt-dev
Quoting Michał Winiarski (2019-03-13 12:53:31)
> Now that we've extracted card index, we no longer have the need to
> iterate over device nodes.
>
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
> ---
> lib/igt_sysfs.c | 29 +++++++----------------------
> 1 file changed, 7 insertions(+), 22 deletions(-)
>
> diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
> index 13a2ee04..974bf45a 100644
> --- a/lib/igt_sysfs.c
> +++ b/lib/igt_sysfs.c
> @@ -100,6 +100,7 @@ static int writeN(int fd, const char *buf, int len)
> char *igt_sysfs_path(int device, char *path, int pathlen)
> {
> struct stat st;
> + int ret;
>
> if (device < 0)
> return NULL;
> @@ -107,30 +108,14 @@ char *igt_sysfs_path(int device, char *path, int pathlen)
> if (fstat(device, &st) || !S_ISCHR(st.st_mode))
> return NULL;
>
> - for (int n = 0; n < 16; n++) {
> - int len, ret, maj, min;
> - FILE *file;
> -
> - len = snprintf(path, pathlen, "/sys/class/drm/card%d", n);
> -
> - sprintf(path + len, "/dev");
> - file = fopen(path, "r");
> - if (!file)
> - continue;
> -
> - ret = fscanf(file, "%d:%d", &maj, &min);
> - fclose(file);
> + snprintf(path, pathlen, "/sys/dev/char/%d:%d",
> + major(st.st_rdev), minor(st.st_rdev));
Neat.
> - if (ret != 2 || major(st.st_rdev) != maj ||
> - minor(st.st_rdev) != min)
> - continue;
> -
> - path[len] = '\0';
> -
> - return path;
> - }
> + ret = access(path, F_OK);
> + if (ret)
> + return NULL;
You don't even need to keep ret.
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [igt-dev] [PATCH i-g-t 6/6] lib/igt_device: Move intel_get_pci_device under igt_device
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 6/6] lib/igt_device: Move intel_get_pci_device under igt_device Michał Winiarski
@ 2019-03-13 14:27 ` Chris Wilson
0 siblings, 0 replies; 15+ messages in thread
From: Chris Wilson @ 2019-03-13 14:27 UTC (permalink / raw)
To: Michał Winiarski, igt-dev
Quoting Michał Winiarski (2019-03-13 12:53:32)
> +#define IGT_DEV_PATH_LEN 80
> +
> +static bool igt_device_is_pci(int fd)
> +{
> + char path[IGT_DEV_PATH_LEN];
> + char link[IGT_DEV_PATH_LEN];
> + char *subsystem;
> + int len;
> +
> + igt_assert_f(igt_sysfs_path(fd, path, sizeof(path)),
> + "Failed to find device sysfs path.\n");
> +
> + strcat(path, "/device/subsystem");
> +
> + if ((len = readlink(path, link, sizeof(link) - 1)) == -1)
> + return false;
> + link[len] = '\0';
> +
> + subsystem = strrchr(link, '/') + 1;
> +
> + return strcmp(subsystem, "pci") == 0;
> +}
> +
> +static void igt_device_get_pci_addr(int fd, char *buf, int len)
> +{
> + char path[IGT_DEV_PATH_LEN];
> + char link[IGT_DEV_PATH_LEN];
> + char *pci_addr;
> + int link_len;
> +
> + igt_assert_f(igt_device_is_pci(fd), "This is not a PCI device.");
> +
> + igt_assert_f(igt_sysfs_path(fd, path, sizeof(path)),
> + "Failed to find device sysfs path.\n");
> +
not
dir = igt_sysfs_dir(fd);
readlinkat(dir, "device", ...)
?
> + strcat(path, "/device");
> +
> + igt_assert_f((link_len = readlink(path, link, sizeof(link) - 1)) != -1,
> + "Failed to find device sysfs path.\n");
igt_ignore_warn()
Less with the asserts, just return an error so that the routines are
more reusable.
> + if (link_len)
> + link[link_len] = '\0';
> +
> + pci_addr = strrchr(link, '/') + 1;
> +
> + strncpy(buf, pci_addr, len - 1);
> + if (len)
Eek, but now you said len-1 may have been -1!!!
> + buf[len] = '\0';
> +}
> +
> +struct pci_device *igt_device_get_pci_dev(int fd)
I would resist the urge to contract.
igt_device_get_pci_device()
igt_device_get_pci (maybe)
> +{
> + char pci_addr[IGT_DEV_PATH_LEN];
> + struct pci_device *pci_dev;
> + unsigned int domain, bus, device, function;
> + int err;
> +
> + igt_device_get_pci_addr(fd, pci_addr, sizeof(pci_addr));
> +
> + err = sscanf(pci_addr, "%4x:%2x:%2x.%2x",
> + &domain, &bus, &device, &function);
> + igt_assert_f(err == 4, "Unable to find device PCI address.");
Include pci_addr in the error message.
"Unable to extract PCI device address from '%s'\n", pci_addr;
Are we always going to have PCI addresses? I guess even TB presents as
[e]PCI. Hmm, there's a is-pci? above.
> + err = pci_system_init();
> + igt_fail_on_f(err != 0, "Couldn't initialize PCI system\n");
Fail? Requires, I'd say. We require libpciaccess support.
> + pci_dev = pci_device_find_by_slot(domain,
> + bus,
> + device,
> + function);
As always with libpciaccess, one is left asking there has to be a better
way.
> + igt_assert_f(pci_dev, "Couldn't find Intel graphics card\n");
This would be require, ... And not "Intel" specific anymore.
> + err = pci_device_probe(pci_dev);
> + igt_fail_on_f(err != 0,
> + "Couldn't probe graphics card\n");
and this would be assert. But imo, it would be nicer to return NULL. At
least provide an option to get the pci_device without asserting.
> +
> + return pci_dev;
> +}
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 15+ messages in thread
* [igt-dev] ✗ Fi.CI.IGT: failure for Attempt to get rid of some globals
2019-03-13 12:53 [igt-dev] [PATCH i-g-t 0/6] Attempt to get rid of some globals Michał Winiarski
` (6 preceding siblings ...)
2019-03-13 14:06 ` [igt-dev] ✓ Fi.CI.BAT: success for Attempt to get rid of some globals Patchwork
@ 2019-03-13 18:07 ` Patchwork
7 siblings, 0 replies; 15+ messages in thread
From: Patchwork @ 2019-03-13 18:07 UTC (permalink / raw)
To: Michał Winiarski; +Cc: igt-dev
== Series Details ==
Series: Attempt to get rid of some globals
URL : https://patchwork.freedesktop.org/series/57934/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_5737_full -> IGTPW_2603_full
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with IGTPW_2603_full absolutely need to be
verified manually.
If you think the reported changes have nothing to do with the changes
introduced in IGTPW_2603_full, please notify your bug team to allow them
to document this new failure mode, which will reduce false positives in CI.
External URL: https://patchwork.freedesktop.org/api/1.0/series/57934/revisions/1/mbox/
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in IGTPW_2603_full:
### IGT changes ###
#### Possible regressions ####
* igt@gem_shrink@reclaim:
- shard-kbl: PASS -> FAIL
- shard-snb: NOTRUN -> FAIL
- shard-hsw: PASS -> FAIL
- shard-glk: PASS -> FAIL
- shard-apl: PASS -> FAIL
#### Warnings ####
* igt@kms_plane_scaling@pipe-b-scaler-with-rotation:
- shard-glk: SKIP [fdo#109271] / [fdo#109278] -> FAIL +1
#### Suppressed ####
The following results come from untrusted machines, tests, or statuses.
They do not affect the overall result.
* {igt@kms_plane@pixel-format-pipe-a-planes}:
- shard-kbl: PASS -> FAIL
- shard-glk: SKIP [fdo#109271] -> FAIL
Known issues
------------
Here are the changes found in IGTPW_2603_full that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_ctx_param@invalid-param-set:
- shard-snb: NOTRUN -> FAIL [fdo#109674]
* igt@gem_exec_schedule@preempt-other-chain-blt:
- shard-snb: NOTRUN -> SKIP [fdo#109271] +106
* igt@i915_pm_rpm@dpms-lpsp:
- shard-kbl: NOTRUN -> SKIP [fdo#109271] +32
* igt@kms_atomic_transition@1x-modeset-transitions-nonblocking:
- shard-apl: PASS -> FAIL [fdo#109660]
- shard-kbl: PASS -> FAIL [fdo#109660]
* igt@kms_atomic_transition@3x-modeset-transitions:
- shard-glk: NOTRUN -> SKIP [fdo#109271] / [fdo#109278]
* igt@kms_color@pipe-a-degamma:
- shard-glk: NOTRUN -> FAIL [fdo#104782] / [fdo#108145]
* igt@kms_color@pipe-b-legacy-gamma:
- shard-glk: PASS -> FAIL [fdo#104782] +1
* igt@kms_cursor_crc@cursor-128x128-suspend:
- shard-glk: NOTRUN -> FAIL [fdo#103232] +1
* igt@kms_cursor_crc@cursor-256x256-dpms:
- shard-apl: PASS -> FAIL [fdo#103232]
* igt@kms_cursor_crc@cursor-alpha-opaque:
- shard-kbl: PASS -> FAIL [fdo#109350]
- shard-apl: PASS -> FAIL [fdo#109350]
* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-onoff:
- shard-apl: PASS -> FAIL [fdo#103167] +2
- shard-kbl: PASS -> FAIL [fdo#103167] +1
* igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-move:
- shard-glk: NOTRUN -> FAIL [fdo#103167]
* igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-onoff:
- shard-glk: PASS -> FAIL [fdo#103167] +8
* igt@kms_frontbuffer_tracking@psr-2p-scndscrn-spr-indfb-draw-render:
- shard-glk: NOTRUN -> SKIP [fdo#109271] +11
* igt@kms_pipe_crc_basic@hang-read-crc-pipe-c:
- shard-apl: PASS -> DMESG-WARN [fdo#103558] / [fdo#105602] +15
* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-f:
- shard-kbl: NOTRUN -> SKIP [fdo#109271] / [fdo#109278] +2
* igt@kms_plane_alpha_blend@pipe-a-alpha-7efc:
- shard-kbl: NOTRUN -> FAIL [fdo#108145] / [fdo#108590]
* igt@kms_psr@basic:
- shard-apl: NOTRUN -> SKIP [fdo#109271] +4
* igt@kms_rotation_crc@multiplane-rotation:
- shard-kbl: PASS -> INCOMPLETE [fdo#103665]
* igt@kms_setmode@basic:
- shard-apl: PASS -> FAIL [fdo#99912]
* igt@kms_universal_plane@cursor-fb-leak-pipe-d:
- shard-snb: NOTRUN -> SKIP [fdo#109271] / [fdo#109278] +9
* igt@kms_universal_plane@universal-plane-pipe-a-functional:
- shard-glk: PASS -> FAIL [fdo#103166]
* igt@runner@aborted:
- shard-apl: NOTRUN -> ( 6 FAIL ) [fdo#109373]
* igt@testdisplay:
- shard-apl: PASS -> INCOMPLETE [fdo#103927]
#### Possible fixes ####
* igt@kms_busy@extended-modeset-hang-newfb-with-reset-render-c:
- shard-hsw: DMESG-WARN [fdo#107956] -> PASS
* igt@kms_ccs@pipe-b-crc-sprite-planes-basic:
- shard-glk: FAIL [fdo#108145] -> PASS
* igt@kms_color@pipe-c-legacy-gamma:
- shard-apl: FAIL [fdo#104782] -> PASS
* igt@kms_cursor_crc@cursor-256x256-sliding:
- shard-kbl: FAIL [fdo#103232] -> PASS +1
* igt@kms_cursor_crc@cursor-64x64-suspend:
- shard-kbl: FAIL [fdo#103191] / [fdo#103232] -> PASS
* igt@kms_cursor_crc@cursor-size-change:
- shard-apl: FAIL [fdo#103232] -> PASS +2
* igt@kms_cursor_legacy@2x-long-cursor-vs-flip-atomic:
- shard-hsw: FAIL [fdo#105767] -> PASS
* igt@kms_flip@flip-vs-expired-vblank-interruptible:
- shard-glk: FAIL [fdo#102887] / [fdo#105363] -> PASS
* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-mmap-cpu:
- shard-apl: FAIL [fdo#103167] -> PASS
* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-fullscreen:
- shard-glk: FAIL [fdo#103167] -> PASS
* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
- shard-apl: DMESG-WARN [fdo#103558] / [fdo#105602] -> PASS +1
* {igt@kms_plane@plane-position-covered-pipe-a-planes}:
- shard-glk: FAIL [fdo#110038] -> PASS
- shard-apl: FAIL [fdo#110038] -> PASS +1
* igt@kms_universal_plane@universal-plane-pipe-a-functional:
- shard-apl: FAIL [fdo#103166] -> PASS
* igt@kms_vblank@pipe-c-ts-continuation-dpms-suspend:
- shard-kbl: INCOMPLETE [fdo#103665] -> PASS +1
* igt@kms_vblank@pipe-c-ts-continuation-suspend:
- shard-apl: FAIL [fdo#104894] -> PASS +1
- shard-kbl: FAIL [fdo#104894] -> PASS
* igt@perf@rc6-disable:
- shard-kbl: FAIL [fdo#103179] -> PASS
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#102887]: https://bugs.freedesktop.org/show_bug.cgi?id=102887
[fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103179]: https://bugs.freedesktop.org/show_bug.cgi?id=103179
[fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
[fdo#103558]: https://bugs.freedesktop.org/show_bug.cgi?id=103558
[fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#104782]: https://bugs.freedesktop.org/show_bug.cgi?id=104782
[fdo#104894]: https://bugs.freedesktop.org/show_bug.cgi?id=104894
[fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
[fdo#105602]: https://bugs.freedesktop.org/show_bug.cgi?id=105602
[fdo#105767]: https://bugs.freedesktop.org/show_bug.cgi?id=105767
[fdo#107956]: https://bugs.freedesktop.org/show_bug.cgi?id=107956
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#108590]: https://bugs.freedesktop.org/show_bug.cgi?id=108590
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109350]: https://bugs.freedesktop.org/show_bug.cgi?id=109350
[fdo#109373]: https://bugs.freedesktop.org/show_bug.cgi?id=109373
[fdo#109660]: https://bugs.freedesktop.org/show_bug.cgi?id=109660
[fdo#109674]: https://bugs.freedesktop.org/show_bug.cgi?id=109674
[fdo#110033]: https://bugs.freedesktop.org/show_bug.cgi?id=110033
[fdo#110037]: https://bugs.freedesktop.org/show_bug.cgi?id=110037
[fdo#110038]: https://bugs.freedesktop.org/show_bug.cgi?id=110038
[fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912
Participating hosts (10 -> 5)
------------------------------
Missing (5): shard-skl pig-hsw-4770r pig-glk-j5005 shard-iclb pig-skl-6260u
Build changes
-------------
* IGT: IGT_4883 -> IGTPW_2603
* Piglit: piglit_4509 -> None
CI_DRM_5737: d5bb7d77aa77996702426496078a597f30bead58 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_2603: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2603/
IGT_4883: b25e06d6ddf2e42044cd9c93b613cbc7339a8c33 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2603/
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2019-03-13 18:07 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-13 12:53 [igt-dev] [PATCH i-g-t 0/6] Attempt to get rid of some globals Michał Winiarski
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 1/6] tests/gem_exec_blt: Drop benchmark mode, use igt_sysfs Michał Winiarski
2019-03-13 12:58 ` Chris Wilson
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 2/6] lib/igt_device: Introduce igt_device_get_card_index Michał Winiarski
2019-03-13 13:02 ` Chris Wilson
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 3/6] lib: Kill drm_get_card() Michał Winiarski
2019-03-13 13:05 ` Chris Wilson
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 4/6] lib/igt_sysfs: Remove idx from sysfs_open Michał Winiarski
2019-03-13 13:08 ` Chris Wilson
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 5/6] lib/igt_sysfs: Simplify obtaining sysfs path Michał Winiarski
2019-03-13 14:09 ` Chris Wilson
2019-03-13 12:53 ` [igt-dev] [PATCH i-g-t 6/6] lib/igt_device: Move intel_get_pci_device under igt_device Michał Winiarski
2019-03-13 14:27 ` Chris Wilson
2019-03-13 14:06 ` [igt-dev] ✓ Fi.CI.BAT: success for Attempt to get rid of some globals Patchwork
2019-03-13 18:07 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox