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>
diff --git a/tests/i915/gem_concurrent_all.c b/tests/i915/gem_concurrent_all.c
index f719b0a..6049372 100644
--- a/tests/i915/gem_concurrent_all.c
+++ b/tests/i915/gem_concurrent_all.c
@@ -1850,7 +1850,7 @@
 				 c->name, s->name, "small");
 			igt_subtest_group {
 				igt_fixture {
-					count = num_buffers(gem_mappable_aperture_size(fd)/4,
+					count = num_buffers(gem_mappable_aperture_size()/4,
 							    s, c, CHECK_RAM);
 				}
 				run_modes(name, c, modes, s, count);
@@ -1861,7 +1861,7 @@
 				 c->name, s->name, "thrash");
 			igt_subtest_group {
 				igt_fixture {
-					count = num_buffers(gem_mappable_aperture_size(fd),
+					count = num_buffers(gem_mappable_aperture_size(),
 							    s, c, CHECK_RAM);
 				}
 				run_modes(name, c, modes, s, count);
@@ -1893,7 +1893,7 @@
 				 c->name, s->name, "shrink");
 			igt_subtest_group {
 				igt_fixture {
-					count = num_buffers(gem_mappable_aperture_size(fd),
+					count = num_buffers(gem_mappable_aperture_size(),
 							    s, c, CHECK_RAM);
 
 					igt_fork_shrink_helper(fd);
@@ -1909,8 +1909,8 @@
 				 c->name, s->name, "swap");
 			igt_subtest_group {
 				igt_fixture {
-					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);
+					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);
 
 						igt_debug("Pinning %lld MiB\n", (long long)pin_sz);
 						pin_sz *= 1024 * 1024;
@@ -1924,7 +1924,7 @@
 						igt_require(pinned);
 					}
 
-					count = num_buffers(gem_mappable_aperture_size(fd),
+					count = num_buffers(gem_mappable_aperture_size(),
 							    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 17c2fe1..4709986 100644
--- a/tests/i915/gem_cpu_reloc.c
+++ b/tests/i915/gem_cpu_reloc.c
@@ -283,7 +283,7 @@
 		run_test(i915, 1);
 
 	igt_subtest("full") {
-		uint64_t aper_size = gem_mappable_aperture_size(i915);
+		uint64_t aper_size = gem_mappable_aperture_size();
 		unsigned long count = aper_size / 4096 + 1;
 
 		intel_require_memory(count, 4096, CHECK_RAM);
@@ -292,7 +292,7 @@
 	}
 
 	igt_subtest("forked") {
-		uint64_t aper_size = gem_mappable_aperture_size(i915);
+		uint64_t aper_size = gem_mappable_aperture_size();
 		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 a8fc353..39f441d 100644
--- a/tests/i915/gem_exec_latency.c
+++ b/tests/i915/gem_exec_latency.c
@@ -40,7 +40,6 @@
 
 #include "drm.h"
 
-#include "igt_device.h"
 #include "igt_sysfs.h"
 #include "igt_vgem.h"
 #include "igt_dummyload.h"
@@ -681,7 +680,7 @@
 		if (ring_size > 1024)
 			ring_size = 1024;
 
-		intel_register_access_init(igt_device_get_pci_device(device), false, device);
+		intel_register_access_init(intel_get_pci_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 d3b848e..62e8d0a 100644
--- a/tests/i915/gem_exec_parse.c
+++ b/tests/i915/gem_exec_parse.c
@@ -30,8 +30,6 @@
 
 #include <drm.h>
 
-#include "igt_device.h"
-
 #ifndef I915_PARAM_CMD_PARSER_VERSION
 #define I915_PARAM_CMD_PARSER_VERSION       28
 #endif
@@ -532,7 +530,7 @@
 #undef REG
 
 		igt_fixture {
-			intel_register_access_init(igt_device_get_pci_device(fd), 0, fd);
+			intel_register_access_init(intel_get_pci_device(), 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 227ae7c..1f5348d 100644
--- a/tests/i915/gem_mmap.c
+++ b/tests/i915/gem_mmap.c
@@ -53,10 +53,10 @@
 
 	switch (huge) {
 	case -1:
-		huge_object_size = gem_mappable_aperture_size(fd) / 2;
+		huge_object_size = gem_mappable_aperture_size() / 2;
 		break;
 	case 0:
-		huge_object_size = gem_mappable_aperture_size(fd) + PAGE_SIZE;
+		huge_object_size = gem_mappable_aperture_size() + 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 639de19..58922ee 100644
--- a/tests/i915/gem_mmap_gtt.c
+++ b/tests/i915/gem_mmap_gtt.c
@@ -562,7 +562,7 @@
 
 	switch (huge) {
 	case -1:
-		size = gem_mappable_aperture_size(fd) / 2;
+		size = gem_mappable_aperture_size() / 2;
 
 		/* Power of two fence size, natural fence
 		 * alignment, and the guard page at the end
@@ -577,7 +577,7 @@
 			size /= 2;
 		break;
 	case 0:
-		size = gem_mappable_aperture_size(fd) + PAGE_SIZE;
+		size = gem_mappable_aperture_size() + PAGE_SIZE;
 		break;
 	default:
 		size = gem_global_aperture_size(fd) + PAGE_SIZE;
@@ -658,13 +658,13 @@
 
 	switch (huge) {
 	case -2:
-		huge_object_size = gem_mappable_aperture_size(fd) / 4;
+		huge_object_size = gem_mappable_aperture_size() / 4;
 		break;
 	case -1:
-		huge_object_size = gem_mappable_aperture_size(fd) / 2;
+		huge_object_size = gem_mappable_aperture_size() / 2;
 		break;
 	case 0:
-		huge_object_size = gem_mappable_aperture_size(fd) + PAGE_SIZE;
+		huge_object_size = gem_mappable_aperture_size() + 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 5cae121..696bd31 100644
--- a/tests/i915/gem_pwrite.c
+++ b/tests/i915/gem_pwrite.c
@@ -89,7 +89,7 @@
 
 	switch (scale) {
 	case 0:
-		size = gem_mappable_aperture_size(fd) + 4096;
+		size = gem_mappable_aperture_size() + 4096;
 		break;
 	case 1:
 		size = gem_global_aperture_size(fd) + 4096;
@@ -151,7 +151,7 @@
 	igt_require(gem_mmap__has_wc(fd));
 	switch (scale) {
 	case 0:
-		size = gem_mappable_aperture_size(fd) + 4096;
+		size = gem_mappable_aperture_size() + 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 f71a1fc..3e8b8f2 100644
--- a/tests/i915/gem_shrink.c
+++ b/tests/i915/gem_shrink.c
@@ -413,7 +413,7 @@
 		 * we expect the shrinker to start purging objects,
 		 * and possibly fail.
 		 */
-		alloc_size = gem_mappable_aperture_size(fd) / 2;
+		alloc_size = gem_mappable_aperture_size() / 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 4e7ce39..b319dbe 100644
--- a/tests/i915/i915_pm_lpsp.c
+++ b/tests/i915/i915_pm_lpsp.c
@@ -30,7 +30,6 @@
 #include <fcntl.h>
 #include <unistd.h>
 
-#include "igt_device.h"
 
 static bool supports_lpsp(uint32_t devid)
 {
@@ -211,7 +210,7 @@
 
 		igt_require(supports_lpsp(devid));
 
-		intel_register_access_init(igt_device_get_pci_device(drm_fd), 0, drm_fd);
+		intel_register_access_init(intel_get_pci_device(), 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 18adaf6..03de609 100644
--- a/tests/i915/i915_pm_rpm.c
+++ b/tests/i915/i915_pm_rpm.c
@@ -1368,7 +1368,7 @@
 	unsigned int num_trash_bos, n;
 	uint32_t buf;
 
-	num_trash_bos = gem_mappable_aperture_size(drm_fd) / (1024*1024) + 1;
+	num_trash_bos = gem_mappable_aperture_size() / (1024*1024) + 1;
 	trash_bos = malloc(num_trash_bos * sizeof(*trash_bos));
 	igt_assert(trash_bos);
 
@@ -1412,7 +1412,7 @@
 	uint16_t val;
 	int rc;
 
-	rc = pci_device_cfg_read_u16(igt_device_get_pci_device(drm_fd), &val, 0xd4);
+	rc = pci_device_cfg_read_u16(intel_get_pci_device(), &val, 0xd4);
 	igt_assert_eq(rc, 0);
 
 	igt_debug("%s: PCI D3 state=%d\n", __func__, val & 0x3);