Skip to contentSkip to conversation

Remove global igt_global_mmio

PATCH Superseded Daniel Mrzyglod 3 participants 9 messages Apr 10, 2019 Library code

v2 of 12 Superseded Latest is v12 →

lore
Share & tools
lore
#0 lore raw

v2 cover Remove global igt_global_mmio

This patchset remove global igt_global_mmio pointer and structures. Motivation for this patch is to move global pointers. Current behaviour limit no of concurrent PCI device. In a future there will be multiple PCI devices.

v2: fixed bugs pointed out in review

Cc Katarzyna Dec <[email protected]>
Cc Michal Winiarski <[email protected]>

Daniel Mrzyglod (2):
lib/igt_device: add igt_map_bar_region
lib/intel_mmio: Remove global igt_global_mmio

Michał Winiarski (1):
lib/igt_device: add igt_device_get_pci_addr by fd

 benchmarks/gem_latency.c      |  11 +-
 benchmarks/gem_wsim.c         |   8 +-
 lib/igt_device.c              | 156 ++++++++++++++++++++
 lib/igt_device.h              |   3 +
 lib/intel_io.h                |  93 +++++++-----
 lib/intel_iosf.c              |  82 +++++++----
 lib/intel_mmio.c              | 206 +++++++++++++++-----------
 tests/i915/gem_exec_latency.c |  10 +-
 tests/i915/gem_exec_parse.c   |  14 +-
 tests/i915/i915_pm_lpsp.c     |   8 +-
 tools/intel_audio_dump.c      | 267 +++++++++++++++++-----------------
 tools/intel_backlight.c       |  13 +-
 tools/intel_display_poller.c  |  13 +-
 tools/intel_forcewaked.c      |  11 +-
 tools/intel_gpu_time.c        |   7 +-
 tools/intel_infoframes.c      |  74 +++++-----
 tools/intel_l3_parity.c       |  12 +-
 tools/intel_lid.c             |   5 +-
 tools/intel_panel_fitter.c    |  29 ++--
 tools/intel_perf_counters.c   |  11 +-
 tools/intel_reg.c             |  33 +++--
 tools/intel_reg_checker.c     |   6 +-
 tools/intel_watermark.c       |  37 ++---
 23 files changed, 686 insertions(+), 423 deletions(-)
Signature · 6 lines
2.20.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw

PATCH v2 1/3 lib/igt_device: add igt_device_get_pci_addr by fd

From: Michał Winiarski <[email protected]>

This function get us in easy way pci adress.
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.

---
 lib/igt_device.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_device.h |   2 +
 2 files changed, 124 insertions(+)
lib/igt_device.c +122 -0
index 08f39c8b..f3d2a9f5 100644
@@ -21,11 +21,14 @@
  * IN THE SOFTWARE.
  *
  */
+#include <sys/types.h>
+#include <fcntl.h>
 
 #include <sys/stat.h>
 #include <sys/sysmacros.h>
 #include "igt.h"
 #include "igt_device.h"
+#include "igt_sysfs.h"
 
 int __igt_device_set_master(int fd)
 {
@@ -103,3 +106,122 @@ 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 *subsystem;
+	int sysfs;
+	int len;
+
+	sysfs = igt_sysfs_open(fd);
+	if (sysfs == -1)
+		return false;
+
+	len = readlinkat(sysfs, "device/subsystem", path, sizeof(path) - 1);
+	if (len == -1)
+		return false;
+	path[len] = '\0';
+
+	subsystem = strrchr(path, '/');
+	if (!subsystem)
+		return false;
+
+	return strcmp(subsystem, "/pci") == 0;
+}
+
+struct igt_pci_addr {
+	unsigned int domain;
+	unsigned int bus;
+	unsigned int device;
+	unsigned int function;
+};
+
+static int igt_device_get_pci_addr(int fd, struct igt_pci_addr *pci)
+{
+	char path[IGT_DEV_PATH_LEN];
+	char *buf;
+	int sysfs;
+	int len;
+
+	if (!igt_device_is_pci(fd))
+		return -ENODEV;
+
+	sysfs = igt_sysfs_open(fd);
+	if (sysfs == -1)
+		return -ENOENT;
+
+	len = readlinkat(sysfs, "device", path, sizeof(path) - 1);
+	if (len == -1)
+		return -ENOENT;
+	path[len] = '\0';
+
+	buf = strrchr(path, '/');
+	if (!buf)
+		return -ENOENT;
+
+	if (sscanf(buf, "/%4x:%2x:%2x.%2x",
+		   &pci->domain, &pci->bus,
+		   &pci->device, &pci->function) != 4) {
+		igt_warn("Unable to extract PCI device address from '%s'\n", buf);
+		return -ENOENT;
+	}
+
+	return 0;
+}
+
+static struct pci_device *__igt_device_get_pci_device(int fd)
+{
+	struct igt_pci_addr pci_addr;
+	struct pci_device *pci_dev;
+
+	if (igt_device_get_pci_addr(fd, &pci_addr)) {
+		igt_warn("Unable to find device PCI address\n");
+		return NULL;
+	}
+
+	if (pci_system_init()) {
+		igt_warn("Couldn't initialize PCI system\n");
+		return NULL;
+	}
+
+	pci_dev = pci_device_find_by_slot(pci_addr.domain,
+					  pci_addr.bus,
+					  pci_addr.device,
+					  pci_addr.function);
+	if (!pci_dev) {
+		igt_warn("Couldn't find PCI device %04x:%02x:%02x:%02x\n",
+			 pci_addr.domain, pci_addr.bus,
+			 pci_addr.device, pci_addr.function);
+		return NULL;
+	}
+
+	if (pci_device_probe(pci_dev)) {
+		igt_warn("Couldn't probe PCI device\n");
+		return NULL;
+	}
+
+	return pci_dev;
+}
+
+/**
+ * igt_device_get_pci_device:
+ *
+ * @fd: the device
+ *
+ * Looks up the main graphics pci device using libpciaccess.
+ *
+ * Returns:
+ * The pci_device, skips the test on any failures.
+ */
+struct pci_device *igt_device_get_pci_device(int fd)
+{
+	struct pci_device *pci_dev;
+
+	pci_dev = __igt_device_get_pci_device(fd);
+	igt_require(pci_dev);
+
+	return pci_dev;
+}
lib/igt_device.h +2 -0
index 9d7dc2c3..860b3a8a 100644
@@ -25,6 +25,7 @@
 #ifndef __IGT_DEVICE_H__
 #define __IGT_DEVICE_H__
 
+#include <stdint.h>
 int __igt_device_set_master(int fd);
 void igt_device_set_master(int fd);
 
@@ -32,5 +33,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_device(int fd);
 
 #endif /* __IGT_DEVICE_H__ */
Signature · 6 lines
2.20.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#2 lore raw

Re: [igt-dev] [PATCH i-g-t v2 1/3] lib/igt_device: add igt_device_get_pci_addr by fd

Quoting Daniel Mrzyglod (2019-04-10 09:28:37)

Quoted 42 lines

From: Michał Winiarski <[email protected]>

This function get us in easy way pci adress.
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.

---
 lib/igt_device.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_device.h |   2 +
 2 files changed, 124 insertions(+)
lib/igt_device.c +8 -0
index 08f39c8b..f3d2a9f5 100644
@@ -21,11 +21,14 @@
  * IN THE SOFTWARE.
  *
  */
+#include <sys/types.h>
+#include <fcntl.h>
 
 #include <sys/stat.h>
 #include <sys/sysmacros.h>
 #include "igt.h"
 #include "igt_device.h"
+#include "igt_sysfs.h"
 
 int __igt_device_set_master(int fd)
 {
@@ -103,3 +106,122 @@ 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)
+{

lib/igt_device.c int igt_device_get_card_index(int fd) · line 123

Quoted 10 lines
lib/igt_device.c +10 -0
+       char path[IGT_DEV_PATH_LEN];
+       char *subsystem;
+       int sysfs;
+       int len;
+
+       sysfs = igt_sysfs_open(fd);
+       if (sysfs == -1)
+               return false;
+
+       len = readlinkat(sysfs, "device/subsystem", path, sizeof(path) - 1);

close(sysfs);

Quoted 23 lines
lib/igt_device.c +23 -0
+       if (len == -1)
+               return false;
+       path[len] = '\0';
+
+       subsystem = strrchr(path, '/');
+       if (!subsystem)
+               return false;
+
+       return strcmp(subsystem, "/pci") == 0;
+}
+
+struct igt_pci_addr {
+       unsigned int domain;
+       unsigned int bus;
+       unsigned int device;
+       unsigned int function;
+};
+
+static int igt_device_get_pci_addr(int fd, struct igt_pci_addr *pci)
+{
+       char path[IGT_DEV_PATH_LEN];
+       char *buf;
+       int sysfs;

lib/igt_device.c int igt_device_get_card_index(int fd) · line 156

Quoted 10 lines
lib/igt_device.c +10 -0
+       int len;
+
+       if (!igt_device_is_pci(fd))
+               return -ENODEV;
+
+       sysfs = igt_sysfs_open(fd);
+       if (sysfs == -1)
+               return -ENOENT;
+
+       len = readlinkat(sysfs, "device", path, sizeof(path) - 1);

close(sysfs);

lib/igt_device.c int igt_device_get_card_index(int fd) · line 168

Quoted 12 lines
lib/igt_device.c +12 -0
+       if (len == -1)
+               return -ENOENT;
+       path[len] = '\0';
+
+       buf = strrchr(path, '/');
+       if (!buf)
+               return -ENOENT;
+
+       if (sscanf(buf, "/%4x:%2x:%2x.%2x",
+                  &pci->domain, &pci->bus,
+                  &pci->device, &pci->function) != 4) {
+               igt_warn("Unable to extract PCI device address from '%s'\n", buf);

buf includes '/' here, not the prettiest.

lib/igt_device.c int igt_device_get_card_index(int fd) · line 173

Quoted 5 lines
lib/igt_device.c +5 -0
+               return -ENOENT;
+       }
+
+       return 0;
+}

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#3 lore raw

PATCH v2 2/3 lib/igt_device: add igt_map_bar_region

In reply to Daniel Mrzyglod

This function use sysfs to map particular mmio region.

---
 lib/igt_device.c | 38 ++++++++++++++++++++++++++++++++++++--
 lib/igt_device.h |  1 +
 2 files changed, 37 insertions(+), 2 deletions(-)
lib/igt_device.c +36 -2
index f3d2a9f5..9dec6106 100644
@@ -148,11 +148,9 @@ static int igt_device_get_pci_addr(int fd, struct igt_pci_addr *pci)
 
 	if (!igt_device_is_pci(fd))
 		return -ENODEV;
-
 	sysfs = igt_sysfs_open(fd);
 	if (sysfs == -1)
 		return -ENOENT;
-
 	len = readlinkat(sysfs, "device", path, sizeof(path) - 1);
 	if (len == -1)
 		return -ENOENT;
@@ -225,3 +223,39 @@ struct pci_device *igt_device_get_pci_device(int fd)
 
 	return pci_dev;
 }
+
+/**
+ * igt_device_map_pci_bar_region:
+ *
+ * @fd: the device
+ * @mmio_bar: bar to be mapped
+ * @mmio_size: bar size
+ *
+ * Returns:
+ * The pointer for mmapped bar
+ */
+void *igt_device_map_pci_bar_region(int fd, int  mmio_bar, int mmio_size)
+{
+	struct igt_pci_addr pci_addr;
+	char *filepath = NULL;
+	int newfd;
+	void *igt_mmio = NULL;
+	if (igt_device_get_pci_addr(fd, &pci_addr)) {
+		igt_warn("Unable to find device PCI address\n");
+		return NULL;
+	}
+
+	asprintf(&filepath, "/sys/devices/pci%.4x:%.2x/%.4x:%.2x:%.2x.%.1x/resource%.1x",
+		 pci_addr.domain, pci_addr.bus, pci_addr.domain, pci_addr.bus,
+		 pci_addr.device, pci_addr.function, mmio_bar);
+
+	newfd = open(filepath, O_RDWR | O_SYNC);
+	igt_mmio = mmap(0, mmio_size, PROT_READ | PROT_WRITE, MAP_SHARED, newfd, 0);
+	free(filepath);
+	close(newfd);
+
+	igt_fail_on_f(igt_mmio == MAP_FAILED,
+		      "Couldn't map MMIO region\n");
+
+	return igt_mmio;
+}
lib/igt_device.h +1 -0
index 860b3a8a..6ffc1d5e 100644
@@ -34,5 +34,6 @@ void igt_device_drop_master(int fd);
 
 int igt_device_get_card_index(int fd);
 struct pci_device *igt_device_get_pci_device(int fd);
+void *igt_device_map_pci_bar_region(int fd, int  mmio_bar, int mmio_size);
 
 #endif /* __IGT_DEVICE_H__ */
Signature · 6 lines
2.20.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#4 lore raw

Re: [igt-dev] [PATCH i-g-t v2 2/3] lib/igt_device: add igt_map_bar_region

Quoting Daniel Mrzyglod (2019-04-10 09:28:38)

lib/igt_device.c struct pci_device *igt_device_get_pci_device(int fd) · line 242

Quoted 6 lines
lib/igt_device.c +6 -0
+void *igt_device_map_pci_bar_region(int fd, int  mmio_bar, int mmio_size)
+{
+       struct igt_pci_addr pci_addr;
+       char *filepath = NULL;
+       int newfd;
+       void *igt_mmio = NULL;

Consider what does need initialising and whitespace carefully.

lib/igt_device.c struct pci_device *igt_device_get_pci_device(int fd) · line 255

Quoted 13 lines
lib/igt_device.c +13 -0
+       if (igt_device_get_pci_addr(fd, &pci_addr)) {
+               igt_warn("Unable to find device PCI address\n");
+               return NULL;
+       }
+
+       asprintf(&filepath, "/sys/devices/pci%.4x:%.2x/%.4x:%.2x:%.2x.%.1x/resource%.1x",
+                pci_addr.domain, pci_addr.bus, pci_addr.domain, pci_addr.bus,
+                pci_addr.device, pci_addr.function, mmio_bar);
+
+       newfd = open(filepath, O_RDWR | O_SYNC);
+       igt_mmio = mmap(0, mmio_size, PROT_READ | PROT_WRITE, MAP_SHARED, newfd, 0);
+       free(filepath);
+       close(newfd);

Stick to the onion. Make it a habit.

lib/igt_device.c struct pci_device *igt_device_get_pci_device(int fd) · line 258

Quoted 3 lines
lib/igt_device.c +3 -0
+
+       igt_fail_on_f(igt_mmio == MAP_FAILED,
+                     "Couldn't map MMIO region\n");

Bonus points for saying what couldn't be mmapped.

But don't use igt_fail if not inside a test.
-Chris
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#5 lore raw

PATCH v2 3/3 lib/intel_mmio: Remove global igt_global_mmio

In reply to Daniel Mrzyglod

In future tests there will be multiple PCI devices run at once. It's good for them to have different mmio space.

---
 benchmarks/gem_latency.c      |  11 +-
 benchmarks/gem_wsim.c         |   8 +-
 lib/intel_io.h                |  93 +++++++-----
 lib/intel_iosf.c              |  82 +++++++----
 lib/intel_mmio.c              | 206 +++++++++++++++-----------
 tests/i915/gem_exec_latency.c |  10 +-
 tests/i915/gem_exec_parse.c   |  14 +-
 tests/i915/i915_pm_lpsp.c     |   8 +-
 tools/intel_audio_dump.c      | 267 +++++++++++++++++-----------------
 tools/intel_backlight.c       |  13 +-
 tools/intel_display_poller.c  |  13 +-
 tools/intel_forcewaked.c      |  11 +-
 tools/intel_gpu_time.c        |   7 +-
 tools/intel_infoframes.c      |  74 +++++-----
 tools/intel_l3_parity.c       |  12 +-
 tools/intel_lid.c             |   5 +-
 tools/intel_panel_fitter.c    |  29 ++--
 tools/intel_perf_counters.c   |  11 +-
 tools/intel_reg.c             |  33 +++--
 tools/intel_reg_checker.c     |   6 +-
 tools/intel_watermark.c       |  37 ++---
 21 files changed, 527 insertions(+), 423 deletions(-)
benchmarks/gem_latency.c +8 -3
index c3fc4bf0..ea58098d 100644
@@ -43,6 +43,7 @@
 #include <sys/poll.h>
 #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)
@@ -55,9 +56,12 @@
 static int done;
 static int fd;
 static volatile uint32_t *timestamp_reg;
+struct mmio_data igt_global_mmio;
 
-#define REG(x) (volatile uint32_t *)((volatile char *)igt_global_mmio + x)
-#define REG_OFFSET(x) ((volatile char *)(x) - (volatile char *)igt_global_mmio)
+#define REG(x) \
+	(volatile uint32_t *)((volatile char *)igt_global_mmio.igt_mmio + x)
+#define REG_OFFSET(x) \
+	((volatile char *)(x) - (volatile char *)igt_global_mmio.igt_mmio)
 
 #if defined(__USE_XOPEN2K) && defined(gen7_safe_mmio)
 static pthread_spinlock_t timestamp_lock;
@@ -456,7 +460,8 @@ 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_device(fd), false, fd,
+				   &igt_global_mmio);
 
 	if (gen == 6)
 		timestamp_reg = REG(RCS_TIMESTAMP);
benchmarks/gem_wsim.c +6 -2
index afb9644d..274182a3 100644
@@ -50,6 +50,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"
@@ -57,6 +58,7 @@
 
 #include "ewma.h"
 
+struct mmio_data igt_global_mmio;
 #define LOCAL_I915_EXEC_FENCE_IN              (1<<16)
 #define LOCAL_I915_EXEC_FENCE_OUT             (1<<17)
 
@@ -229,7 +231,8 @@ static int fd;
 #define SEQNO_OFFSET(engine) (SEQNO_IDX(engine) * sizeof(uint32_t))
 
 #define RCS_TIMESTAMP (0x2000 + 0x358)
-#define REG(x) (volatile uint32_t *)((volatile char *)igt_global_mmio + x)
+#define REG(x) \
+	(volatile uint32_t *)((volatile char *)igt_global_mmio.igt_mmio + x)
 
 static const char *ring_str_map[NUM_ENGINES] = {
 	[RCS] = "RCS",
@@ -2223,7 +2226,8 @@ 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_device(fd), false, fd,
+				   &igt_global_mmio);
 
 	if (verbose <= 1)
 		return;
lib/intel_io.h +57 -36

113 lines not on this page · raw message

lib/intel_iosf.c +50 -32

203 lines not on this page · raw message

lib/intel_mmio.c +118 -88

430 lines not on this page · raw message

tests/i915/gem_exec_latency.c +7 -3
index 39f441d2..6e62d298 100644
@@ -41,6 +41,7 @@
 #include "drm.h"
 
 #include "igt_sysfs.h"
+#include "igt_device.h"
 #include "igt_vgem.h"
 #include "igt_dummyload.h"
 #include "igt_stats.h"
@@ -61,6 +62,7 @@
 
 static unsigned int ring_size;
 static double rcs_clock;
+struct mmio_data igt_global_mmio;
 
 static void
 poll_ring(int fd, unsigned ring, const char *name)
@@ -129,8 +131,9 @@ static void latency_on_ring(int fd,
 	uint64_t offset;
 	double gpu_latency;
 	int i, j;
+	void *igt_mmio = igt_global_mmio.igt_mmio;
 
-	reg = (volatile uint32_t *)((volatile char *)igt_global_mmio + RCS_TIMESTAMP);
+	reg = (volatile uint32_t *)((volatile char *)igt_mmio + RCS_TIMESTAMP);
 
 	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(&obj[1]);
@@ -645,7 +648,7 @@ static double clockrate(int i915, int reg)
 	if (igt_ioctl(i915, DRM_IOCTL_I915_GETPARAM, &gp) == 0)
 		return cs_timestamp_freq;
 
-	mmio = (volatile uint32_t *)((volatile char *)igt_global_mmio + reg);
+	mmio = (volatile uint32_t *)((volatile char *)igt_global_mmio.igt_mmio + reg);
 
 	t_start = igt_nsec_elapsed(&tv);
 	r_start = *mmio;
@@ -666,6 +669,7 @@ igt_main
 	const struct intel_execution_engine *e;
 	int device = -1;
 
+
 	igt_fixture {
 		device = drm_open_driver(DRIVER_INTEL);
 		igt_require_gem(device);
@@ -680,7 +684,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_device(device), false, device, &igt_global_mmio);
 		rcs_clock = clockrate(device, RCS_TIMESTAMP);
 		igt_info("RCS timestamp clock: %.0fKHz, %.1fns\n",
 			 rcs_clock / 1e3, 1e9 / rcs_clock);
tests/i915/gem_exec_parse.c +8 -6
index 62e8d0a5..79b42af3 100644
@@ -27,7 +27,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <errno.h>
-
+#include "igt_device.h"
 #include <drm.h>
 
 #ifndef I915_PARAM_CMD_PARSER_VERSION
@@ -57,6 +57,7 @@
 #define   PIPE_CONTROL_LRI_POST_OP (1<<23)
 
 static int parser_version;
+struct mmio_data igt_global_mmio;
 
 static int command_parser_version(int fd)
 {
@@ -284,9 +285,9 @@ test_lri(int fd, uint32_t handle, struct test_lri *test)
 		  test->name, test->reg, test->test_val,
 		  expected_errno, expect);
 
-	intel_register_write(test->reg, test->init_val);
+	intel_register_write(&igt_global_mmio, test->reg, test->init_val);
 
-	igt_assert_eq_u32((intel_register_read(test->reg) &
+	igt_assert_eq_u32((intel_register_read(&igt_global_mmio, test->reg) &
 			   test->read_mask),
 			  test->init_val);
 
@@ -296,7 +297,7 @@ test_lri(int fd, uint32_t handle, struct test_lri *test)
 		   expected_errno);
 	gem_sync(fd, handle);
 
-	igt_assert_eq_u32((intel_register_read(test->reg) &
+	igt_assert_eq_u32((intel_register_read(&igt_global_mmio, test->reg) &
 			   test->read_mask),
 			  expect);
 }
@@ -430,6 +431,7 @@ igt_main
 	uint32_t handle;
 	int fd;
 
+
 	igt_fixture {
 		fd = drm_open_driver(DRIVER_INTEL);
 		igt_require_gem(fd);
@@ -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_device(fd), 0, fd, &igt_global_mmio);
 		}
 
 		for (int i = 0; i < ARRAY_SIZE(lris); i++) {
@@ -543,7 +545,7 @@ igt_main
 		}
 
 		igt_fixture {
-			intel_register_access_fini();
+			intel_register_access_fini(&igt_global_mmio);
 		}
 	}
 
tests/i915/i915_pm_lpsp.c +5 -3
index b319dbe9..bfbd23dd 100644
@@ -30,6 +30,8 @@
 #include <fcntl.h>
 #include <unistd.h>
 
+#include "igt_device.h"
+struct mmio_data igt_global_mmio;
 
 static bool supports_lpsp(uint32_t devid)
 {
@@ -40,7 +42,7 @@ static bool lpsp_is_enabled(int drm_fd)
 {
 	uint32_t val;
 
-	val = INREG(HSW_PWR_WELL_CTL2);
+	val = INREG(&igt_global_mmio, HSW_PWR_WELL_CTL2);
 	return !(val & HSW_PWR_WELL_STATE_ENABLED);
 }
 
@@ -210,7 +212,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_device(drm_fd), 0, drm_fd, &igt_global_mmio);
 
 		kmstest_set_vt_graphics_mode();
 	}
@@ -227,7 +229,7 @@ igt_main
 	igt_fixture {
 		int i;
 
-		intel_register_access_fini();
+		intel_register_access_fini(&igt_global_mmio);
 		for (i = 0; i < drm_res->count_connectors; i++)
 			drmModeFreeConnector(drm_connectors[i]);
 		drmModeFreeResources(drm_res);
tools/intel_audio_dump.c +134 -133

850 lines not on this page · raw message

tools/intel_backlight.c +7 -6
index 067fd418..3e193124 100644
@@ -35,15 +35,16 @@
 #include "intel_reg.h"
 
 /* XXX PCH only today */
+struct mmio_data igt_global_mmio;
 
 int main(int argc, char** argv)
 {
 	uint32_t current, max;
 
-	intel_mmio_use_pci_bar(intel_get_pci_device());
+	intel_mmio_use_pci_bar(intel_get_pci_device(), -1, &igt_global_mmio);
 
-	current = INREG(BLC_PWM_CPU_CTL) & BACKLIGHT_DUTY_CYCLE_MASK;
-	max = INREG(BLC_PWM_PCH_CTL2) >> 16;
+	current = INREG(&igt_global_mmio, BLC_PWM_CPU_CTL) & BACKLIGHT_DUTY_CYCLE_MASK;
+	max = INREG(&igt_global_mmio, BLC_PWM_PCH_CTL2) >> 16;
 
 	printf ("current backlight value: %d%%\n", current * 100 / max);
 
@@ -51,9 +52,9 @@ int main(int argc, char** argv)
 		uint32_t v = atoi (argv[1]) * max / 100;
 		if (v > max)
 			v = max;
-		OUTREG(BLC_PWM_CPU_CTL,
-		       (INREG(BLC_PWM_CPU_CTL) &~ BACKLIGHT_DUTY_CYCLE_MASK) | v);
-		(void) INREG(BLC_PWM_CPU_CTL);
+		OUTREG(&igt_global_mmio, BLC_PWM_CPU_CTL,
+		       (INREG(&igt_global_mmio, BLC_PWM_CPU_CTL) &~ BACKLIGHT_DUTY_CYCLE_MASK) | v);
+		(void) INREG(&igt_global_mmio, BLC_PWM_CPU_CTL);
 		printf ("set backlight to %d%%\n", v * 100 / max);
 	}
 
tools/intel_display_poller.c +7 -6
index 51f5b9a5..15646243 100644
@@ -63,6 +63,7 @@ static uint16_t pipe_offset[3] = { 0, 0x1000, 0x2000, };
 #define PIPE_REG(pipe, reg_a) (pipe_offset[(pipe)] + (reg_a))
 
 static volatile bool quit;
+struct mmio_data igt_global_mmio;
 
 static void sighandler(int x)
 {
@@ -71,22 +72,22 @@ static void sighandler(int x)
 
 static uint16_t read_reg_16(uint32_t reg)
 {
-	return INREG16(vlv_offset + reg);
+	return INREG16(&igt_global_mmio, vlv_offset + reg);
 }
 
 static uint32_t read_reg(uint32_t reg)
 {
-	return INREG(vlv_offset + reg);
+	return INREG(&igt_global_mmio, vlv_offset + reg);
 }
 
 static void write_reg_16(uint32_t reg, uint16_t val)
 {
-	OUTREG16(vlv_offset + reg, val);
+	OUTREG16(&igt_global_mmio, vlv_offset + reg, val);
 }
 
 static void write_reg(uint32_t reg, uint32_t val)
 {
-	OUTREG(vlv_offset + reg, val);
+	OUTREG(&igt_global_mmio, vlv_offset + reg, val);
 }
 
 static char pipe_name(int pipe)
@@ -1187,7 +1188,7 @@ int main(int argc, char *argv[])
 		break;
 	}
 
-	intel_register_access_init(intel_get_pci_device(), 0, -1);
+	intel_register_access_init(intel_get_pci_device(), 0, -1, &igt_global_mmio);
 
 	printf("%s?\n", test_name(test, pipe, bit, test_pixelcount));
 
@@ -1262,7 +1263,7 @@ int main(int argc, char *argv[])
 		assert(0);
 	}
 
-	intel_register_access_fini();
+	intel_register_access_fini(&igt_global_mmio);
 
 	if (quit)
 		return 0;
tools/intel_forcewaked.c +6 -5
index 02fbf888..f833dfce 100644
@@ -39,6 +39,7 @@
 #include "drmtest.h"
 
 bool daemonized;
+struct mmio_data igt_global_mmio;
 
 #define INFO_PRINT(...) \
 	do { \
@@ -59,7 +60,7 @@ help(char *prog) {
 static int
 is_alive(void) {
 	/* Read the timestamp, which should *almost* always be !0 */
-	return (intel_register_read(0x2358) != 0);
+	return (intel_register_read(&igt_global_mmio, 0x2358) != 0);
 }
 
 int main(int argc, char *argv[])
@@ -80,7 +81,7 @@ int main(int argc, char *argv[])
 		INFO_PRINT("started daemon");
 	}
 
-	ret = intel_register_access_init(intel_get_pci_device(), 1, -1);
+	ret = intel_register_access_init(intel_get_pci_device(), 1, -1, &igt_global_mmio);
 	if (ret) {
 		INFO_PRINT("Couldn't init register access\n");
 		exit(1);
@@ -90,14 +91,14 @@ int main(int argc, char *argv[])
 	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);
+			intel_register_access_fini(&igt_global_mmio);
+			ret = intel_register_access_init(intel_get_pci_device(), 1, -1, &igt_global_mmio);
 			if (ret)
 				INFO_PRINT("Reg access init fail\n");
 		}
 		sleep(1);
 	}
-	intel_register_access_fini();
+	intel_register_access_fini(&igt_global_mmio);
 	INFO_PRINT("Forcewake unlock\n");
 
 	if (daemonized) {
tools/intel_gpu_time.c +4 -3
index 56d65fe0..58326643 100644
@@ -41,6 +41,7 @@
 #define SAMPLES_PER_SEC             10000
 
 static volatile int goddo;
+struct mmio_data igt_global_mmio;
 
 static pid_t spawn(char **argv)
 {
@@ -67,7 +68,7 @@ int main(int argc, char **argv)
 	static struct rusage rusage;
 	int status;
 
-	intel_mmio_use_pci_bar(intel_get_pci_device());
+	intel_mmio_use_pci_bar(intel_get_pci_device(), -1, &igt_global_mmio);
 
 	if (argc == 1) {
 		fprintf(stderr, "usage: %s cmd [args...]\n", argv[0]);
@@ -86,8 +87,8 @@ int main(int argc, char **argv)
 	while (!goddo) {
 		uint32_t ring_head, ring_tail;
 
-		ring_head = INREG(LP_RING + RING_HEAD) & HEAD_ADDR;
-		ring_tail = INREG(LP_RING + RING_TAIL) & TAIL_ADDR;
+		ring_head = INREG(&igt_global_mmio, LP_RING + RING_HEAD) & HEAD_ADDR;
+		ring_tail = INREG(&igt_global_mmio, LP_RING + RING_TAIL) & TAIL_ADDR;
 
 		if (ring_tail == ring_head)
 			ring_idle++;
tools/intel_infoframes.c +38 -36

228 lines not on this page · raw message

tools/intel_l3_parity.c +7 -5
index d8c997af..88158632 100644
@@ -37,6 +37,7 @@
 #include "intel_chipset.h"
 #include "intel_io.h"
 #include "igt_sysfs.h"
+#include "igt_device.h"
 #include "drmtest.h"
 #include "config.h"
 #include <libudev.h>
@@ -53,6 +54,7 @@ static inline int num_banks(void) {
 	default: return 2;
 	}
 }
+struct mmio_data igt_global_mmio;
 #define NUM_SUBBANKS 8
 #define BYTES_PER_BANK (128 << 10)
 /* Each row addresses [up to] 4b. This multiplied by the number of subbanks
@@ -189,7 +191,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_device(device), 0, device, &igt_global_mmio) == 0);
 
 	dir = igt_sysfs_open(device);
 
@@ -211,7 +213,7 @@ int main(int argc, char *argv[])
 	 * now. Just be aware of this if for some reason a hang is reported
 	 * when using this tool.
 	 */
-	dft = intel_register_read(0xb038);
+	dft = intel_register_read(&igt_global_mmio, 0xb038);
 
 	while (1) {
 		int c, option_index = 0;
@@ -357,10 +359,10 @@ int main(int argc, char *argv[])
 				assert(i < 2);
 				dft |= i << 1; /* slice */
 				dft |= 1 << 0; /* enable */
-				intel_register_write(0xb038, dft);
+				intel_register_write(&igt_global_mmio, 0xb038, dft);
 				break;
 			case 'u':
-				intel_register_write(0xb038, dft & ~(1<<0));
+				intel_register_write(&igt_global_mmio, 0xb038, dft & ~(1<<0));
 				break;
 			case 'L':
 				break;
@@ -369,7 +371,7 @@ int main(int argc, char *argv[])
 		}
 	}
 
-	intel_register_access_fini();
+	intel_register_access_fini(&igt_global_mmio);
 	if (action == 'l')
 		exit(EXIT_SUCCESS);
 
tools/intel_lid.c +3 -2
index 37c6ba5e..32db9dd2 100644
@@ -51,6 +51,7 @@ enum lid_status {
 
 #define ACPI_BUTTON "/proc/acpi/button/"
 #define ACPI_LID "/proc/acpi/button/lid/"
+struct mmio_data igt_global_mmio;
 
 static int i830_lvds_acpi_lid_state(void)
 {
@@ -119,10 +120,10 @@ int main(int argc, char **argv)
 {
 	int swf14, acpi_lid;
 
-	intel_mmio_use_pci_bar(intel_get_pci_device());
+	intel_mmio_use_pci_bar(intel_get_pci_device(), -1, &igt_global_mmio);
 
 	while (1) {
-		swf14 = INREG(SWF14);
+		swf14 = INREG(&igt_global_mmio, SWF14);
 
 		printf("Intel LVDS Lid status:\n");
 		printf("\tSWF14(0x%x) : %s\n", swf14,
tools/intel_panel_fitter.c +15 -14
index 137ef61a..a50f42e8 100644
@@ -36,6 +36,7 @@
 #include "drmtest.h"
 
 int gen;
+struct mmio_data igt_global_mmio;
 
 uint32_t HTOTAL[]     = { 0x60000, 0x61000, 0x62000 };
 uint32_t VTOTAL[]     = { 0x6000C, 0x6100C, 0x6200C };
@@ -84,12 +85,12 @@ static void read_pipe_info(int intel_pipe, struct pipe_info *info)
 {
 	uint32_t conf, vtotal, htotal, src, ctrl1, win_sz;
 
-	conf   = INREG(PIPECONF[intel_pipe]);
-	htotal = INREG(HTOTAL[intel_pipe]);
-	vtotal = INREG(VTOTAL[intel_pipe]);
-	src    = INREG(PIPESRC[intel_pipe]);
-	ctrl1  = INREG(PF_CTRL1[intel_pipe]);
-	win_sz = INREG(PF_WIN_SZ[intel_pipe]);
+	conf   = INREG(&igt_global_mmio, PIPECONF[intel_pipe]);
+	htotal = INREG(&igt_global_mmio, HTOTAL[intel_pipe]);
+	vtotal = INREG(&igt_global_mmio, VTOTAL[intel_pipe]);
+	src    = INREG(&igt_global_mmio, PIPESRC[intel_pipe]);
+	ctrl1  = INREG(&igt_global_mmio, PF_CTRL1[intel_pipe]);
+	win_sz = INREG(&igt_global_mmio, PF_WIN_SZ[intel_pipe]);
 
 	info->enabled = (conf & PIPECONF_ENABLE) ? true : false;
 	info->tot_width = (htotal & HTOTAL_ACTIVE_MASK) + 1;
@@ -232,24 +233,24 @@ static int change_screen_size(int intel_pipe, int x, int y)
 			assert(0);
 		}
 	}
-	OUTREG(PF_CTRL1[intel_pipe], ctrl1_val);
+	OUTREG(&igt_global_mmio, PF_CTRL1[intel_pipe], ctrl1_val);
 
 	win_pos_val = pos_x << 16;
 	win_pos_val |= pos_y;
-	OUTREG(PF_WIN_POS[intel_pipe], win_pos_val);
+	OUTREG(&igt_global_mmio, PF_WIN_POS[intel_pipe], win_pos_val);
 
 	win_sz_val = dst_width << 16;
 	win_sz_val |= dst_height;
-	OUTREG(PF_WIN_SZ[intel_pipe], win_sz_val);
+	OUTREG(&igt_global_mmio, PF_WIN_SZ[intel_pipe], win_sz_val);
 
 	return 0;
 }
 
 static int disable_panel_fitter(int intel_pipe)
 {
-	OUTREG(PF_CTRL1[intel_pipe], 0);
-	OUTREG(PF_WIN_POS[intel_pipe], 0);
-	OUTREG(PF_WIN_SZ[intel_pipe], 0);
+	OUTREG(&igt_global_mmio, PF_CTRL1[intel_pipe], 0);
+	OUTREG(&igt_global_mmio, PF_WIN_POS[intel_pipe], 0);
+	OUTREG(&igt_global_mmio, PF_WIN_SZ[intel_pipe], 0);
 	return 0;
 }
 
@@ -280,7 +281,7 @@ int main (int argc, char *argv[])
 	       "solution that may or may not work. Use it at your own risk.\n");
 
 	pci_dev = intel_get_pci_device();
-	intel_register_access_init(pci_dev, 0, -1);
+	intel_register_access_init(pci_dev, 0, -1, &igt_global_mmio);
 	devid = pci_dev->device_id;
 
 	if (!HAS_PCH_SPLIT(devid)) {
@@ -342,6 +343,6 @@ int main (int argc, char *argv[])
 	}
 
 out:
-	intel_register_access_fini();
+	intel_register_access_fini(&igt_global_mmio);
 	return ret;
 }
tools/intel_perf_counters.c +7 -4
index 50c4bce6..23b8f8b1 100644
@@ -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"
@@ -323,6 +324,8 @@ struct intel_batchbuffer *batch;
 # define OACONTROL_COUNTER_SELECT_SHIFT 2
 # define PERFORMANCE_COUNTER_ENABLE     (1 << 0)
 
+struct mmio_data igt_global_mmio;
+
 static void
 gen5_get_counters(void)
 {
@@ -483,10 +486,10 @@ 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_device(fd), 0, fd, &igt_global_mmio);
 
 		/* Enable performance counters */
-		intel_register_write(OACONTROL,
+		intel_register_write(&igt_global_mmio, OACONTROL,
 			counter_format << OACONTROL_COUNTER_SELECT_SHIFT |
 			PERFORMANCE_COUNTER_ENABLE);
 	}
@@ -520,10 +523,10 @@ main(int argc, char **argv)
 
 	if (oacontrol) {
 		/* Disable performance counters */
-		intel_register_write(OACONTROL, 0);
+		intel_register_write(&igt_global_mmio, OACONTROL, 0);
 
 		/* Forcewake */
-		intel_register_access_fini();
+		intel_register_access_fini(&igt_global_mmio);
 	}
 
 	free(totals);
tools/intel_reg.c +17 -16
index 1247b70b..e816bb9f 100644
@@ -39,6 +39,7 @@
 
 #include "intel_reg_spec.h"
 
+struct mmio_data igt_global_mmio;
 
 #ifdef HAVE_SYS_IO_H
 #include <sys/io.h>
@@ -364,7 +365,7 @@ static int read_register(struct config *config, struct reg *reg, uint32_t *valp)
 		if (reg->engine)
 			val = register_srm(config, reg, NULL);
 		else
-			val = INREG(reg->mmio_offset + reg->addr);
+			val = INREG(&igt_global_mmio, reg->mmio_offset + reg->addr);
 		break;
 	case PORT_PORTIO_VGA:
 		iopl(3);
@@ -372,7 +373,7 @@ static int read_register(struct config *config, struct reg *reg, uint32_t *valp)
 		iopl(0);
 		break;
 	case PORT_MMIO_VGA:
-		val = INREG8(reg->addr);
+		val = INREG8(&igt_global_mmio, reg->addr);
 		break;
 	case PORT_BUNIT:
 	case PORT_PUNIT:
@@ -389,7 +390,7 @@ static int read_register(struct config *config, struct reg *reg, uint32_t *valp)
 				reg->port_desc.name);
 			return -1;
 		}
-		val = intel_iosf_sb_read(reg->port_desc.port, reg->addr);
+		val = intel_iosf_sb_read(&igt_global_mmio, reg->port_desc.port, reg->addr);
 		break;
 	default:
 		fprintf(stderr, "port %d not supported\n", reg->port_desc.port);
@@ -424,7 +425,7 @@ static int write_register(struct config *config, struct reg *reg, uint32_t val)
 		if (reg->engine) {
 			register_srm(config, reg, &val);
 		} else {
-			OUTREG(reg->mmio_offset + reg->addr, val);
+			OUTREG(&igt_global_mmio, reg->mmio_offset + reg->addr, val);
 		}
 		break;
 	case PORT_PORTIO_VGA:
@@ -443,7 +444,7 @@ static int write_register(struct config *config, struct reg *reg, uint32_t val)
 				val, reg->port_desc.name);
 			return -1;
 		}
-		OUTREG8(reg->addr, val);
+		OUTREG8(&igt_global_mmio, reg->addr, val);
 		break;
 	case PORT_BUNIT:
 	case PORT_PUNIT:
@@ -460,7 +461,7 @@ static int write_register(struct config *config, struct reg *reg, uint32_t val)
 				reg->port_desc.name);
 			return -1;
 		}
-		intel_iosf_sb_write(reg->port_desc.port, reg->addr, val);
+		intel_iosf_sb_write(&igt_global_mmio, reg->port_desc.port, reg->addr, val);
 		break;
 	default:
 		fprintf(stderr, "port %d not supported\n", reg->port_desc.port);
@@ -554,9 +555,9 @@ static int intel_reg_read(struct config *config, int argc, char *argv[])
 	}
 
 	if (config->mmiofile)
-		intel_mmio_use_dump_file(config->mmiofile);
+		intel_mmio_use_dump_file(&igt_global_mmio, config->mmiofile);
 	else
-		intel_register_access_init(config->pci_dev, 0, -1);
+		intel_register_access_init(config->pci_dev, 0, config->fd, &igt_global_mmio);
 
 	for (i = 1; i < argc; i++) {
 		struct reg reg;
@@ -572,7 +573,7 @@ static int intel_reg_read(struct config *config, int argc, char *argv[])
 		}
 	}
 
-	intel_register_access_fini();
+	intel_register_access_fini(&igt_global_mmio);
 
 	return EXIT_SUCCESS;
 }
@@ -586,7 +587,7 @@ static int intel_reg_write(struct config *config, int argc, char *argv[])
 		return EXIT_FAILURE;
 	}
 
-	intel_register_access_init(config->pci_dev, 0, -1);
+	intel_register_access_init(config->pci_dev, 0, config->fd, &igt_global_mmio);
 
 	for (i = 1; i < argc; i += 2) {
 		struct reg reg;
@@ -611,7 +612,7 @@ static int intel_reg_write(struct config *config, int argc, char *argv[])
 		write_register(config, &reg, val);
 	}
 
-	intel_register_access_fini();
+	intel_register_access_fini(&igt_global_mmio);
 
 	return EXIT_SUCCESS;
 }
@@ -622,9 +623,9 @@ static int intel_reg_dump(struct config *config, int argc, char *argv[])
 	int i;
 
 	if (config->mmiofile)
-		intel_mmio_use_dump_file(config->mmiofile);
+		intel_mmio_use_dump_file(&igt_global_mmio, config->mmiofile);
 	else
-		intel_register_access_init(config->pci_dev, 0, -1);
+		intel_register_access_init(config->pci_dev, 0, config->fd, &igt_global_mmio);
 
 	for (i = 0; i < config->regcount; i++) {
 		reg = &config->regs[i];
@@ -636,7 +637,7 @@ static int intel_reg_dump(struct config *config, int argc, char *argv[])
 		dump_register(config, &config->regs[i]);
 	}
 
-	intel_register_access_fini();
+	intel_register_access_fini(&igt_global_mmio);
 
 	return EXIT_SUCCESS;
 }
@@ -650,10 +651,10 @@ static int intel_reg_snapshot(struct config *config, int argc, char *argv[])
 		return EXIT_FAILURE;
 	}
 
-	intel_mmio_use_pci_bar(config->pci_dev);
+	intel_mmio_use_pci_bar(config->pci_dev, config->fd, &igt_global_mmio);
 
 	/* XXX: error handling */
-	if (write(1, igt_global_mmio, config->pci_dev->regions[mmio_bar].size) == -1)
+	if (write(1, igt_global_mmio.igt_mmio, config->pci_dev->regions[mmio_bar].size) == -1)
 		fprintf(stderr, "Error writing snapshot: %s", strerror(errno));
 
 	if (config->verbosity > 0)
tools/intel_reg_checker.c +4 -2
index 6bde63ec..2112fdcb 100644
@@ -26,16 +26,18 @@
 #include <err.h>
 #include <string.h>
 #include <stdbool.h>
+#include "igt_device.h"
 #include "intel_io.h"
 #include "intel_chipset.h"
 
 static uint32_t devid;
 static int gen;
+struct mmio_data igt_global_mmio;
 
 static uint32_t
 read_and_print_reg(const char *name, uint32_t reg)
 {
-	uint32_t val = INREG(reg);
+	uint32_t val = INREG(&igt_global_mmio, reg);
 
 	printf("%s (0x%x): 0x%08x\n", name, reg, val);
 
@@ -345,7 +347,7 @@ int main(int argc, char** argv)
 
 	dev = intel_get_pci_device();
 	devid = dev->device_id;
-	intel_mmio_use_pci_bar(dev);
+	intel_mmio_use_pci_bar(dev, -1, &igt_global_mmio);
 
 	if (IS_GEN7(devid))
 		gen = 7;
tools/intel_watermark.c +19 -18
index e71c3d9c..f602e015 100644
@@ -35,10 +35,11 @@
 
 static uint32_t display_base;
 static uint32_t devid;
+struct mmio_data igt_global_mmio;
 
 static uint32_t read_reg(uint32_t addr)
 {
-	return INREG(display_base + addr);
+	return INREG(&igt_global_mmio, display_base + addr);
 }
 
 struct gmch_wm {
@@ -249,7 +250,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(intel_get_pci_device(), 0, -1, &igt_global_mmio);
 
 	for (pipe = 0; pipe < num_pipes; pipe++) {
 		int num_planes = skl_num_planes(devid, pipe);
@@ -469,7 +470,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(intel_get_pci_device(), 0, -1, &igt_global_mmio);
 
 	for (i = 0; i < num_pipes; i++) {
 		dspcntr[i] = read_reg(0x70180 + i * 0x1000);
@@ -505,7 +506,7 @@ static void ilk_wm_dump(void)
 	if (IS_BROADWELL(devid) || IS_HASWELL(devid))
 		wm_misc = read_reg(0x45260);
 
-	intel_register_access_fini();
+	intel_register_access_fini(&igt_global_mmio);
 
 	for (i = 0; i < num_pipes; i++)
 		printf("    WM_PIPE_%c = 0x%08x\n", pipe_name(i), wm_pipe[i]);
@@ -619,7 +620,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(intel_get_pci_device(), 0, -1, &igt_global_mmio);
 
 	dsparb = read_reg(0x70030);
 	dsparb2 = read_reg(0x70060);
@@ -650,13 +651,13 @@ static void vlv_wm_dump(void)
 
 		ddl3 = read_reg(0x70058);
 
-		intel_punit_read(0x36, &dsp_ss_pm);
-		intel_punit_read(0x139, &ddr_setup2);
+		intel_punit_read(&igt_global_mmio, 0x36, &dsp_ss_pm);
+		intel_punit_read(&igt_global_mmio, 0x139, &ddr_setup2);
 	} else {
 		fw7 = read_reg(0x7007c);
 	}
 
-	intel_register_access_fini();
+	intel_register_access_fini(&igt_global_mmio);
 
 	printf("        FW1 = 0x%08x\n", fw1);
 	printf("        FW2 = 0x%08x\n", fw2);
@@ -835,7 +836,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(intel_get_pci_device(), 0, -1, &igt_global_mmio);
 
 	dspacntr = read_reg(0x70180);
 	dspbcntr = read_reg(0x71180);
@@ -846,7 +847,7 @@ static void g4x_wm_dump(void)
 	mi_display_power_down = read_reg(0x20e0);
 	mi_arb_state = read_reg(0x20e4);
 
-	intel_register_access_fini();
+	intel_register_access_fini(&igt_global_mmio);
 
 	printf("             DSPACNTR = 0x%08x\n", dspacntr);
 	printf("             DSPBCNTR = 0x%08x\n", dspbcntr);
@@ -921,7 +922,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(intel_get_pci_device(), 0, -1, &igt_global_mmio);
 
 	dsparb = read_reg(0x70030);
 	fw1 = read_reg(0x70034);
@@ -930,7 +931,7 @@ static void gen4_wm_dump(void)
 	mi_display_power_down = read_reg(0x20e0);
 	mi_arb_state = read_reg(0x20e4);
 
-	intel_register_access_fini();
+	intel_register_access_fini(&igt_global_mmio);
 
 	printf("                  FW1 = 0x%08x\n", fw1);
 	printf("                  FW2 = 0x%08x\n", fw2);
@@ -992,7 +993,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(intel_get_pci_device(), 0, -1, &igt_global_mmio);
 
 	dsparb = read_reg(0x70030);
 	fw1 = read_reg(0x70034);
@@ -1002,7 +1003,7 @@ static void pnv_wm_dump(void)
 	mi_display_power_down = read_reg(0x20e0);
 	mi_arb_state = read_reg(0x20e4);
 
-	intel_register_access_fini();
+	intel_register_access_fini(&igt_global_mmio);
 
 	printf("               DSPARB = 0x%08x\n", dsparb);
 	printf("                  FW1 = 0x%08x\n", fw1);
@@ -1082,7 +1083,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(intel_get_pci_device(), 0, -1, &igt_global_mmio);
 
 	dsparb = read_reg(0x70030);
 	instpm = read_reg(0x20c0);
@@ -1090,7 +1091,7 @@ static void gen3_wm_dump(void)
 	fw_blc_self = read_reg(0x20e0);
 	mi_arb_state = read_reg(0x20e4);
 
-	intel_register_access_fini();
+	intel_register_access_fini(&igt_global_mmio);
 
 	printf("      DSPARB = 0x%08x\n", dsparb);
 	printf("      FW_BLC = 0x%016" PRIx64 "\n", fw_blc);
@@ -1151,7 +1152,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(intel_get_pci_device(), 0, -1, &igt_global_mmio);
 
 	dsparb = read_reg(0x70030);
 	mem_mode = read_reg(0x20cc);
@@ -1159,7 +1160,7 @@ static void gen2_wm_dump(void)
 	fw_blc_self = read_reg(0x20e0);
 	mi_state = read_reg(0x20e4);
 
-	intel_register_access_fini();
+	intel_register_access_fini(&igt_global_mmio);
 
 	printf("     DSPARB = 0x%08x\n", dsparb);
 	printf("   MEM_MODE = 0x%08x\n", mem_mode);
Signature · 6 lines
2.20.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#6 lore raw

Re: [igt-dev] [PATCH i-g-t v2 3/3] lib/intel_mmio: Remove global igt_global_mmio

Quoting Daniel Mrzyglod (2019-04-10 09:28:39)

Quoted 2 lines

In future tests there will be multiple PCI devices run at once. It's good for them to have different mmio space.

Split it again.

*Return* the mmio addr from the library function. Convert users over fro global to local, one at a time. Remove global.
-Chris
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#7 lore raw

[igt-dev] ✓ Fi.CI.BAT: success for Remove global igt_global_mmio (rev2)

In reply to Daniel Mrzyglod
== Series Details ==

== Series Details ==

Series: Remove global igt_global_mmio (rev2)
URL : https://patchwork.freedesktop.org/series/59008/
State : success

== Summary ==

CI Bug Log - changes from IGT_4937 -> IGTPW_2834
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/59008/revisions/2/mbox/

Known issues
------------

Here are the changes found in IGTPW_2834 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@amdgpu/amd_cs_nop@fork-compute0:
- fi-blb-e6850: NOTRUN -> SKIP [fdo#109271] +18

* igt@amdgpu/amd_cs_nop@sync-fork-compute0:
- fi-icl-u3: NOTRUN -> SKIP [fdo#109315] +17

* igt@gem_exec_basic@gtt-bsd1:
- fi-icl-u3: NOTRUN -> SKIP [fdo#109276] +7

* igt@gem_exec_parse@basic-rejected:
- fi-icl-u3: NOTRUN -> SKIP [fdo#109289] +1

* igt@i915_pm_rpm@module-reload:
- fi-glk-dsi: NOTRUN -> DMESG-WARN [fdo#105538] / [fdo#107732] / [fdo#109513]

* igt@i915_selftest@live_contexts:
- fi-icl-u3: NOTRUN -> DMESG-FAIL [fdo#108569]

* igt@kms_chamelium@hdmi-edid-read:
- fi-hsw-peppy: NOTRUN -> SKIP [fdo#109271] +46
- fi-icl-u3: NOTRUN -> SKIP [fdo#109284] +8

* igt@kms_force_connector_basic@force-edid:
- fi-glk-dsi: NOTRUN -> SKIP [fdo#109271] +8

* igt@kms_force_connector_basic@prune-stale-modes:
- fi-icl-u3: NOTRUN -> SKIP [fdo#109285] +3

* igt@kms_frontbuffer_tracking@basic:
- fi-hsw-peppy: NOTRUN -> DMESG-FAIL [fdo#102614] / [fdo#107814]
- fi-glk-dsi: NOTRUN -> FAIL [fdo#103167]

* igt@runner@aborted:
- fi-glk-dsi: NOTRUN -> FAIL [k.org#202321]
- fi-apl-guc: NOTRUN -> FAIL [fdo#108622] / [fdo#109720]

#### Possible fixes ####

* igt@i915_module_load@reload:
- fi-blb-e6850: INCOMPLETE [fdo#107718] -> PASS

* igt@i915_selftest@live_hangcheck:
- {fi-icl-u2}: INCOMPLETE [fdo#108569] -> PASS
- fi-bxt-dsi: INCOMPLETE [fdo#103927] -> PASS

* igt@kms_cursor_legacy@basic-flip-before-cursor-varying-size:
- fi-glk-dsi: INCOMPLETE [fdo#103359] / [k.org#198133] -> PASS

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103359]: https://bugs.freedesktop.org/show_bug.cgi?id=103359
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#105538]: https://bugs.freedesktop.org/show_bug.cgi?id=105538
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#107732]: https://bugs.freedesktop.org/show_bug.cgi?id=107732
[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#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109276]: https://bugs.freedesktop.org/show_bug.cgi?id=109276
[fdo#109284]: https://bugs.freedesktop.org/show_bug.cgi?id=109284
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#109289]: https://bugs.freedesktop.org/show_bug.cgi?id=109289
[fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
[fdo#109513]: https://bugs.freedesktop.org/show_bug.cgi?id=109513
[fdo#109720]: https://bugs.freedesktop.org/show_bug.cgi?id=109720
[k.org#198133]: https://bugzilla.kernel.org/show_bug.cgi?id=198133
[k.org#202321]: https://bugzilla.kernel.org/show_bug.cgi?id=202321

Participating hosts (48 -> 43)
------------------------------

Additional (2): fi-hsw-peppy fi-icl-u3
Missing (7): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-bdw-samus

Build changes
-------------

* IGT: IGT_4937 -> IGTPW_2834

CI_DRM_5897: 7d07e025e78603d6270bc115fdb6c1efea6e66a5 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_2834: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2834/
IGT_4937: 256c6107ee127d2ff07d23dfeb3b8d828cb43b37 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2834/
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#8 lore raw

[igt-dev] ✓ Fi.CI.IGT: success for Remove global igt_global_mmio (rev2)

In reply to Daniel Mrzyglod
== Series Details ==

== Series Details ==

Series: Remove global igt_global_mmio (rev2)
URL : https://patchwork.freedesktop.org/series/59008/
State : success

== Summary ==

CI Bug Log - changes from IGT_4937_full -> IGTPW_2834_full
====================================================

Summary
-------

**WARNING**

Minor unknown changes coming with IGTPW_2834_full need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in IGTPW_2834_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/59008/revisions/2/mbox/

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in IGTPW_2834_full:

### IGT changes ###

#### Warnings ####

* igt@syncobj_wait@wait-for-submit-delayed-submit:
- shard-snb: ( 2 PASS ) -> PASS +40

Known issues
------------

Here are the changes found in IGTPW_2834_full that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_exec_flush@basic-batch-kernel-default-cmd:
- shard-glk: NOTRUN -> SKIP [fdo#109271] +11

* igt@gem_softpin@noreloc-s3:
- shard-kbl: PASS -> DMESG-WARN [fdo#108566]

* igt@gem_tiled_swapping@non-threaded:
- shard-hsw: PASS -> DMESG-WARN [fdo#108686]

* igt@gem_workarounds@suspend-resume-context:
- shard-kbl: PASS -> INCOMPLETE [fdo#103665]

* igt@kms_atomic_transition@3x-modeset-transitions:
- shard-kbl: NOTRUN -> SKIP [fdo#109271] / [fdo#109278] +1

* igt@kms_concurrent@pipe-d:
- shard-hsw: NOTRUN -> SKIP [fdo#109271] / [fdo#109278] +2

* igt@kms_cursor_legacy@cursor-vs-flip-legacy:
- shard-hsw: PASS -> FAIL [fdo#103355]

* igt@kms_flip@2x-flip-vs-expired-vblank-interruptible:
- shard-glk: PASS -> FAIL [fdo#105363] +1

* igt@kms_frontbuffer_tracking@fbcpsr-2p-primscrn-spr-indfb-draw-pwrite:
- shard-kbl: NOTRUN -> SKIP [fdo#109271] +37

* igt@kms_frontbuffer_tracking@psr-2p-scndscrn-pri-indfb-draw-pwrite:
- shard-hsw: NOTRUN -> SKIP [fdo#109271] +28

* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-d:
- shard-glk: NOTRUN -> SKIP [fdo#109271] / [fdo#109278] +1

* igt@kms_plane@pixel-format-pipe-c-planes-source-clamping:
- shard-glk: PASS -> SKIP [fdo#109271]

* igt@kms_plane_alpha_blend@pipe-c-alpha-opaque-fb:
- shard-glk: NOTRUN -> FAIL [fdo#108145]

* igt@kms_plane_scaling@pipe-b-scaler-with-rotation:
- shard-glk: PASS -> SKIP [fdo#109271] / [fdo#109278]

* igt@kms_psr@psr2_primary_render:
- shard-apl: NOTRUN -> SKIP [fdo#109271] +9

* igt@kms_rotation_crc@multiplane-rotation-cropping-top:
- shard-kbl: PASS -> FAIL [fdo#109016]

* igt@kms_universal_plane@universal-plane-gen9-features-pipe-f:
- shard-apl: NOTRUN -> SKIP [fdo#109271] / [fdo#109278]

* igt@kms_vblank@pipe-c-ts-continuation-modeset-rpm:
- shard-kbl: NOTRUN -> FAIL [fdo#104894]
- shard-apl: PASS -> FAIL [fdo#104894]

* igt@kms_vblank@pipe-c-ts-continuation-suspend:
- shard-apl: PASS -> DMESG-WARN [fdo#108566] +4

#### Possible fixes ####

* igt@gem_eio@hibernate:
- shard-kbl: DMESG-WARN [fdo#103558] / [fdo#105602] -> PASS +3

* igt@gem_eio@in-flight-suspend:
- shard-apl: DMESG-WARN [fdo#108566] -> PASS +3

* igt@i915_pm_lpsp@screens-disabled:
- shard-hsw: FAIL -> PASS

* igt@i915_pm_rpm@system-suspend-execbuf:
- shard-kbl: INCOMPLETE [fdo#103665] / [fdo#107807] -> PASS

* igt@kms_cursor_crc@cursor-256x85-sliding:
- shard-apl: FAIL [fdo#103232] -> PASS

* igt@kms_cursor_legacy@2x-long-flip-vs-cursor-legacy:
- shard-glk: FAIL [fdo#104873] -> PASS

* igt@kms_cursor_legacy@cursor-vs-flip-toggle:
- shard-hsw: FAIL [fdo#103355] -> PASS

* igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-draw-render:
- shard-hsw: SKIP [fdo#109271] -> PASS

* igt@kms_plane_scaling@pipe-a-scaler-with-clipping-clamping:
- shard-glk: SKIP [fdo#109271] / [fdo#109278] -> PASS

* igt@kms_rotation_crc@multiplane-rotation:
- shard-kbl: INCOMPLETE [fdo#103665] -> PASS

* igt@kms_setmode@basic:
- shard-apl: FAIL [fdo#99912] -> PASS

#### Warnings ####

* igt@gem_exec_schedule@smoketest-render:
- shard-snb: ( 2 SKIP ) [fdo#109271] -> SKIP [fdo#109271] +39

* igt@kms_plane_alpha_blend@pipe-a-alpha-7efc:
- shard-snb: ( 2 SKIP ) [fdo#109271] / [fdo#109278] -> SKIP [fdo#109271] / [fdo#109278]

[fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
[fdo#103355]: https://bugs.freedesktop.org/show_bug.cgi?id=103355
[fdo#103558]: https://bugs.freedesktop.org/show_bug.cgi?id=103558
[fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
[fdo#104873]: https://bugs.freedesktop.org/show_bug.cgi?id=104873
[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#107807]: https://bugs.freedesktop.org/show_bug.cgi?id=107807
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
[fdo#108686]: https://bugs.freedesktop.org/show_bug.cgi?id=108686
[fdo#109016]: https://bugs.freedesktop.org/show_bug.cgi?id=109016
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912

Participating hosts (7 -> 5)
------------------------------

Missing (2): shard-skl shard-iclb

Build changes
-------------

* IGT: IGT_4937 -> IGTPW_2834

CI_DRM_5897: 7d07e025e78603d6270bc115fdb6c1efea6e66a5 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_2834: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2834/
IGT_4937: 256c6107ee127d2ff07d23dfeb3b8d828cb43b37 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2834/
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev