summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-04-08 11:56:57 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2010-04-08 12:17:31 +0100
commit95374225e865da3a30153f73e8bb536700d15459 (patch)
treeab8797a6f255a0d76e5d8e7439b8fe4a9b34ca90
parentcd64e193299be4b9733a5e804cedd99e2072830f (diff)
Enable compilation on non-Intel, non-DRM systems.
A few of the tools can be performed post-mortem from a different system, so it is useful to be able to compile those tools on those foreign systems. Obviously, any program to interact with the PCI device or talk to GEM will fail on a non-Intel system. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--benchmarks/Makefile.am17
-rw-r--r--configure.ac7
-rw-r--r--lib/Makefile.am19
-rw-r--r--lib/instdone.c6
-rw-r--r--lib/instdone.h4
-rw-r--r--lib/intel_batchbuffer.c47
-rw-r--r--lib/intel_batchbuffer.h4
-rw-r--r--lib/intel_drm.c57
-rw-r--r--lib/intel_gpu_tools.h21
-rw-r--r--lib/intel_mmio.c (renamed from lib/intel_gpu_tools.c)98
-rw-r--r--lib/intel_pci.c71
-rw-r--r--tests/gem_bad_address.c1
-rw-r--r--tests/gem_bad_batch.c1
-rw-r--r--tests/gem_bad_blit.c7
-rw-r--r--tests/gem_pread_after_blit.c13
-rw-r--r--tests/gem_ringfill.c5
-rw-r--r--tests/gem_tiled_blits.c50
-rw-r--r--tests/gem_tiled_pread.c50
-rw-r--r--tools/intel_audio_dump.c4
-rw-r--r--tools/intel_error_decode.c14
-rw-r--r--tools/intel_gpu_dump.c16
-rw-r--r--tools/intel_gpu_time.c2
-rw-r--r--tools/intel_gpu_top.c14
-rw-r--r--tools/intel_gtt.c6
-rw-r--r--tools/intel_lid.c2
-rw-r--r--tools/intel_reg_dumper.c9
-rw-r--r--tools/intel_reg_read.c2
-rw-r--r--tools/intel_reg_snapshot.c6
-rw-r--r--tools/intel_reg_write.c2
29 files changed, 309 insertions, 246 deletions
diff --git a/benchmarks/Makefile.am b/benchmarks/Makefile.am
index 3196b2c2..6829bbef 100644
--- a/benchmarks/Makefile.am
+++ b/benchmarks/Makefile.am
@@ -1,8 +1,15 @@
-bin_PROGRAMS = \
- intel_upload_blit_large \
- intel_upload_blit_large_gtt \
- intel_upload_blit_large_map \
- intel_upload_blit_small
+NULL=#
+
+bin_PROGRAMS = $(NULL)
+
+if HAVE_DRM
+bin_PROGRAMS += \
+ intel_upload_blit_large \
+ intel_upload_blit_large_gtt \
+ intel_upload_blit_large_map \
+ intel_upload_blit_small \
+ $(NULL)
+endif
BENCHMARK_LIBS = \
../lib/libintel_tools.la \
diff --git a/configure.ac b/configure.ac
index 8af20dbf..3ab2a8dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,7 +40,12 @@ AC_PROG_LIBTOOL
AC_PROG_CC
AM_PROG_CC_C_O
-PKG_CHECK_MODULES(DRM, [libdrm_intel >= 2.4.6])
+PKG_CHECK_MODULES(DRM, [libdrm_intel >= 2.4.6], have_drm=yes, have_drm=no)
+if test "x$have_drm" = "xyes"; then
+ AC_DEFINE([HAVE_DRM], 1, [Define to 1 if we have DRM support])
+fi
+AM_CONDITIONAL(HAVE_DRM, test "x$have_drm" = "xyes")
+
PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10])
dnl Use lots of warning flags with GCC
diff --git a/lib/Makefile.am b/lib/Makefile.am
index eb3eba76..0c9380d5 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,16 +1,25 @@
+NULL=#
+
+AM_CFLAGS = $(WARN_CFLAGS) -I$(srcdir)/..
libintel_tools_la_SOURCES = \
- intel_batchbuffer.c \
intel_batchbuffer.h \
intel_chipset.h \
- intel_gpu_tools.c \
intel_gpu_tools.h \
+ intel_mmio.c \
+ intel_pci.c \
intel_reg.h \
instdone.c \
instdone.h \
- drmtest.c \
drmtest.h
+if HAVE_DRM
+libintel_tools_la_SOURCES += \
+ intel_batchbuffer.c \
+ intel_drm.c \
+ drmtest.c \
+ $(NULL)
+AM_CFLAGS += $(DRM_CFLAGS)
+endif
+
noinst_LTLIBRARIES = libintel_tools.la
-AM_CFLAGS = $(DRM_CFLAGS) $(WARN_CFLAGS) \
- -I$(srcdir)/..
diff --git a/lib/instdone.c b/lib/instdone.c
index d77061fa..722fb039 100644
--- a/lib/instdone.c
+++ b/lib/instdone.c
@@ -25,9 +25,11 @@
*
*/
-#include "intel_gpu_tools.h"
#include "instdone.h"
+#include "intel_chipset.h"
+#include "intel_reg.h"
+
struct instdone_bit instdone_bits[MAX_INSTDONE_BITS];
int num_instdone_bits = 0;
@@ -133,7 +135,7 @@ init_g4x_instdone1(void)
}
void
-init_instdone_definitions(void)
+init_instdone_definitions(uint32_t devid)
{
if (IS_GEN6(devid)) {
/* Now called INSTDONE_1 in the docs. */
diff --git a/lib/instdone.h b/lib/instdone.h
index ed34f833..c86a54a7 100644
--- a/lib/instdone.h
+++ b/lib/instdone.h
@@ -25,6 +25,8 @@
*
*/
+#include <stdint.h>
+
#define MAX_INSTDONE_BITS 100
struct instdone_bit {
@@ -36,4 +38,4 @@ struct instdone_bit {
extern struct instdone_bit instdone_bits[MAX_INSTDONE_BITS];
extern int num_instdone_bits;
-void init_instdone_definitions(void);
+void init_instdone_definitions(uint32_t devid);
diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 1e3148ab..ae5150e9 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -30,9 +30,13 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
+
#include "drm.h"
#include "intel_batchbuffer.h"
#include "intel_bufmgr.h"
+#include "intel_chipset.h"
+#include "intel_reg.h"
+#include <i915_drm.h>
void
intel_batchbuffer_reset(struct intel_batchbuffer *batch)
@@ -137,3 +141,46 @@ intel_batchbuffer_data(struct intel_batchbuffer *batch,
memcpy(batch->ptr, data, bytes);
batch->ptr += bytes;
}
+
+void
+intel_copy_bo(struct intel_batchbuffer *batch,
+ drm_intel_bo *dst_bo, drm_intel_bo *src_bo,
+ int width, int height, uint32_t devid)
+{
+ uint32_t src_tiling, dst_tiling, swizzle;
+ uint32_t src_pitch, dst_pitch;
+ uint32_t cmd_bits = 0;
+
+ drm_intel_bo_get_tiling(src_bo, &src_tiling, &swizzle);
+ drm_intel_bo_get_tiling(dst_bo, &dst_tiling, &swizzle);
+
+ src_pitch = width * 4;
+ if (IS_965(devid) && src_tiling != I915_TILING_NONE) {
+ src_pitch /= 4;
+ cmd_bits |= XY_SRC_COPY_BLT_SRC_TILED;
+ }
+
+ dst_pitch = width * 4;
+ if (IS_965(devid) && dst_tiling != I915_TILING_NONE) {
+ dst_pitch /= 4;
+ cmd_bits |= XY_SRC_COPY_BLT_DST_TILED;
+ }
+
+ BEGIN_BATCH(8);
+ OUT_BATCH(XY_SRC_COPY_BLT_CMD |
+ XY_SRC_COPY_BLT_WRITE_ALPHA |
+ XY_SRC_COPY_BLT_WRITE_RGB |
+ cmd_bits);
+ OUT_BATCH((3 << 24) | /* 32 bits */
+ (0xcc << 16) | /* copy ROP */
+ dst_pitch);
+ OUT_BATCH(0); /* dst x1,y1 */
+ OUT_BATCH((height << 16) | width); /* dst x2,y2 */
+ OUT_RELOC(dst_bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
+ OUT_BATCH(0); /* src x1,y1 */
+ OUT_BATCH(src_pitch);
+ OUT_RELOC(src_bo, I915_GEM_DOMAIN_RENDER, 0, 0);
+ ADVANCE_BATCH();
+
+ intel_batchbuffer_flush(batch);
+}
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index 5b4ab930..fcd9ceb6 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -115,4 +115,8 @@ intel_batchbuffer_emit_mi_flush(struct intel_batchbuffer *batch)
intel_batchbuffer_emit_dword(batch, MI_FLUSH);
}
+void intel_copy_bo(struct intel_batchbuffer *batch,
+ drm_intel_bo *dst_bo, drm_intel_bo *src_bo,
+ int width, int height, uint32_t devid);
+
#endif
diff --git a/lib/intel_drm.c b/lib/intel_drm.c
new file mode 100644
index 00000000..ca5e4738
--- /dev/null
+++ b/lib/intel_drm.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright © 2008 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <err.h>
+#include <assert.h>
+#include <sys/ioctl.h>
+#include <sys/fcntl.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+
+#include "intel_gpu_tools.h"
+#include "i915_drm.h"
+
+uint32_t
+intel_get_drm_devid(int fd)
+{
+ int ret;
+ struct drm_i915_getparam gp;
+ uint32_t devid;
+
+ gp.param = I915_PARAM_CHIPSET_ID;
+ gp.value = (int *)&devid;
+
+ ret = ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+ assert(ret == 0);
+
+ return devid;
+}
diff --git a/lib/intel_gpu_tools.h b/lib/intel_gpu_tools.h
index 259fd9a9..0251031a 100644
--- a/lib/intel_gpu_tools.h
+++ b/lib/intel_gpu_tools.h
@@ -25,19 +25,18 @@
*
*/
+#include <stdint.h>
#include <sys/types.h>
#include <pciaccess.h>
-#include "i915_drm.h"
-#include "intel_batchbuffer.h"
+
#include "intel_chipset.h"
#include "intel_reg.h"
-extern struct pci_device *pci_dev;
-extern uint32_t devid;
-extern void *mmio;
-
#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
+extern void *mmio;
+void intel_get_mmio(struct pci_device *pci_dev);
+
static inline uint32_t
INREG(uint32_t reg)
{
@@ -50,10 +49,8 @@ OUTREG(uint32_t reg, uint32_t val)
*(volatile uint32_t *)((volatile char *)mmio + reg) = val;
}
-void intel_get_pci_device(void);
-void intel_get_mmio(void);
-void intel_get_drm_devid(int fd);
-void intel_copy_bo(struct intel_batchbuffer *batch,
- drm_intel_bo *dst_bo, drm_intel_bo *src_bo,
- int width, int height);
+struct pci_device *intel_get_pci_device(void);
+
+uint32_t intel_get_drm_devid(int fd);
+
void intel_map_file(char *);
diff --git a/lib/intel_gpu_tools.c b/lib/intel_mmio.c
index a699ae82..faaeeef6 100644
--- a/lib/intel_gpu_tools.c
+++ b/lib/intel_mmio.c
@@ -36,58 +36,12 @@
#include <sys/fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
+
#include "intel_gpu_tools.h"
-#include "i915_drm.h"
-#include "intel_batchbuffer.h"
-#include "intel_chipset.h"
-struct pci_device *pci_dev;
-uint32_t devid;
void *mmio;
void
-intel_get_drm_devid(int fd)
-{
- int ret;
- struct drm_i915_getparam gp;
-
- gp.param = I915_PARAM_CHIPSET_ID;
- gp.value = (int *)&devid;
-
- ret = ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
- assert(ret == 0);
-}
-
-void
-intel_get_pci_device(void)
-{
- int err;
-
- err = pci_system_init();
- if (err != 0) {
- fprintf(stderr, "Couldn't initialize PCI system: %s\n",
- strerror(err));
- exit(1);
- }
-
- /* Grab the graphics card */
- pci_dev = pci_device_find_by_slot(0, 0, 2, 0);
- if (pci_dev == NULL)
- errx(1, "Couldn't find graphics card");
-
- err = pci_device_probe(pci_dev);
- if (err != 0) {
- fprintf(stderr, "Couldn't probe graphics card: %s\n",
- strerror(err));
- exit(1);
- }
-
- if (pci_dev->vendor_id != 0x8086)
- errx(1, "Graphics card is non-intel");
- devid = pci_dev->device_id;
-}
-
-void
intel_map_file(char *file)
{
int fd;
@@ -110,13 +64,13 @@ intel_map_file(char *file)
}
void
-intel_get_mmio(void)
+intel_get_mmio(struct pci_device *pci_dev)
{
+ uint32_t devid;
int mmio_bar;
int err;
- intel_get_pci_device();
-
+ devid = pci_dev->device_id;
if (IS_9XX(devid))
mmio_bar = 0;
else
@@ -135,47 +89,3 @@ intel_get_mmio(void)
}
}
-void
-intel_copy_bo(struct intel_batchbuffer *batch,
- drm_intel_bo *dst_bo, drm_intel_bo *src_bo,
- int width, int height)
-{
- uint32_t src_tiling, dst_tiling, swizzle;
- uint32_t src_pitch, dst_pitch;
- uint32_t cmd_bits = 0;
-
- drm_intel_bo_get_tiling(src_bo, &src_tiling, &swizzle);
- drm_intel_bo_get_tiling(dst_bo, &dst_tiling, &swizzle);
-
- src_pitch = width * 4;
- if (IS_965(devid) && src_tiling != I915_TILING_NONE) {
- src_pitch /= 4;
- cmd_bits |= XY_SRC_COPY_BLT_SRC_TILED;
- }
-
- dst_pitch = width * 4;
- if (IS_965(devid) && dst_tiling != I915_TILING_NONE) {
- dst_pitch /= 4;
- cmd_bits |= XY_SRC_COPY_BLT_DST_TILED;
- }
-
- BEGIN_BATCH(8);
- OUT_BATCH(XY_SRC_COPY_BLT_CMD |
- XY_SRC_COPY_BLT_WRITE_ALPHA |
- XY_SRC_COPY_BLT_WRITE_RGB |
- cmd_bits);
- OUT_BATCH((3 << 24) | /* 32 bits */
- (0xcc << 16) | /* copy ROP */
- dst_pitch);
- OUT_BATCH(0); /* dst x1,y1 */
- OUT_BATCH((height << 16) | width); /* dst x2,y2 */
- OUT_RELOC(dst_bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
- OUT_BATCH(0); /* src x1,y1 */
- OUT_BATCH(src_pitch);
- OUT_RELOC(src_bo, I915_GEM_DOMAIN_RENDER, 0, 0);
- ADVANCE_BATCH();
-
- intel_batchbuffer_flush(batch);
-}
-
-
diff --git a/lib/intel_pci.c b/lib/intel_pci.c
new file mode 100644
index 00000000..3bfacb53
--- /dev/null
+++ b/lib/intel_pci.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright © 2008 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <err.h>
+#include <assert.h>
+#include <sys/ioctl.h>
+#include <sys/fcntl.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+
+#include "intel_gpu_tools.h"
+
+struct pci_device *
+intel_get_pci_device(void)
+{
+ struct pci_device *pci_dev;
+ int err;
+
+ err = pci_system_init();
+ if (err != 0) {
+ fprintf(stderr, "Couldn't initialize PCI system: %s\n",
+ strerror(err));
+ exit(1);
+ }
+
+ /* Grab the graphics card */
+ pci_dev = pci_device_find_by_slot(0, 0, 2, 0);
+ if (pci_dev == NULL)
+ errx(1, "Couldn't find graphics card");
+
+ err = pci_device_probe(pci_dev);
+ if (err != 0) {
+ fprintf(stderr, "Couldn't probe graphics card: %s\n",
+ strerror(err));
+ exit(1);
+ }
+
+ if (pci_dev->vendor_id != 0x8086)
+ errx(1, "Graphics card is non-intel");
+
+ return pci_dev;
+}
diff --git a/tests/gem_bad_address.c b/tests/gem_bad_address.c
index 56a71aa2..188020d4 100644
--- a/tests/gem_bad_address.c
+++ b/tests/gem_bad_address.c
@@ -65,7 +65,6 @@ int main(int argc, char **argv)
int fd;
fd = drm_open_any();
- intel_get_drm_devid(fd);
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
diff --git a/tests/gem_bad_batch.c b/tests/gem_bad_batch.c
index ba8aa5d4..da2870bf 100644
--- a/tests/gem_bad_batch.c
+++ b/tests/gem_bad_batch.c
@@ -61,7 +61,6 @@ int main(int argc, char **argv)
int fd;
fd = drm_open_any();
- intel_get_drm_devid(fd);
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
diff --git a/tests/gem_bad_blit.c b/tests/gem_bad_blit.c
index 9a52529e..362b5aca 100644
--- a/tests/gem_bad_blit.c
+++ b/tests/gem_bad_blit.c
@@ -63,7 +63,7 @@ struct intel_batchbuffer *batch;
#define BAD_GTT_DEST ((256*1024*1024)) /* past end of aperture */
static void
-bad_blit(drm_intel_bo *src_bo)
+bad_blit(drm_intel_bo *src_bo, uint32_t devid)
{
uint32_t src_pitch = 512, dst_pitch = 512;
uint32_t cmd_bits = 0;
@@ -100,10 +100,11 @@ bad_blit(drm_intel_bo *src_bo)
int main(int argc, char **argv)
{
drm_intel_bo *src;
+ uint32_t devid;
int fd;
fd = drm_open_any();
- intel_get_drm_devid(fd);
+ devid = intel_get_drm_devid(fd);
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
@@ -111,7 +112,7 @@ int main(int argc, char **argv)
src = drm_intel_bo_alloc(bufmgr, "src", 128 * 128, 4096);
- bad_blit(src);
+ bad_blit(src, devid);
intel_batchbuffer_free(batch);
drm_intel_bufmgr_destroy(bufmgr);
diff --git a/tests/gem_pread_after_blit.c b/tests/gem_pread_after_blit.c
index 5abdb38a..4ba9a627 100644
--- a/tests/gem_pread_after_blit.c
+++ b/tests/gem_pread_after_blit.c
@@ -131,9 +131,10 @@ main(int argc, char **argv)
drm_intel_bo *src1, *src2, *bo;
uint32_t start1 = 0;
uint32_t start2 = 1024 * 1024 / 4;
+ uint32_t devid;
fd = drm_open_any();
- intel_get_drm_devid(fd);
+ devid = intel_get_drm_devid(fd);
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
@@ -146,21 +147,21 @@ main(int argc, char **argv)
/* First, do a full-buffer read after blitting */
printf("Large read after blit 1\n");
- intel_copy_bo(batch, bo, src1, width, height);
+ intel_copy_bo(batch, bo, src1, width, height, devid);
verify_large_read(bo, start1);
printf("Large read after blit 2\n");
- intel_copy_bo(batch, bo, src2, width, height);
+ intel_copy_bo(batch, bo, src2, width, height, devid);
verify_large_read(bo, start2);
printf("Small reads after blit 1\n");
- intel_copy_bo(batch, bo, src1, width, height);
+ intel_copy_bo(batch, bo, src1, width, height, devid);
verify_small_read(bo, start1);
printf("Small reads after blit 2\n");
- intel_copy_bo(batch, bo, src2, width, height);
+ intel_copy_bo(batch, bo, src2, width, height, devid);
verify_small_read(bo, start2);
printf("Large read after blit 3\n");
- intel_copy_bo(batch, bo, src1, width, height);
+ intel_copy_bo(batch, bo, src1, width, height, devid);
verify_large_read(bo, start1);
drm_intel_bo_unreference(src1);
diff --git a/tests/gem_ringfill.c b/tests/gem_ringfill.c
index d245f1fe..c9860aa6 100644
--- a/tests/gem_ringfill.c
+++ b/tests/gem_ringfill.c
@@ -55,11 +55,12 @@ static const int size = 1024 * 1024;
int main(int argc, char **argv)
{
int fd;
+ uint32_t devid;
int i;
drm_intel_bo *src_bo, *dst_bo;
fd = drm_open_any();
- intel_get_drm_devid(fd);
+ devid = intel_get_drm_devid(fd);
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
@@ -84,7 +85,7 @@ int main(int argc, char **argv)
* doing this, we aren't likely to with this test.
*/
for (i = 0; i < 128 * 1024 / (8 * 4) * 1.25; i++) {
- intel_copy_bo(batch, dst_bo, src_bo, width, height);
+ intel_copy_bo(batch, dst_bo, src_bo, width, height, devid);
intel_batchbuffer_flush(batch);
}
diff --git a/tests/gem_tiled_blits.c b/tests/gem_tiled_blits.c
index 54378b19..212b4b7b 100644
--- a/tests/gem_tiled_blits.c
+++ b/tests/gem_tiled_blits.c
@@ -60,47 +60,7 @@
static drm_intel_bufmgr *bufmgr;
struct intel_batchbuffer *batch;
static int width = 512, height = 512;
-
-static void
-copy_bo(drm_intel_bo *dst_bo, drm_intel_bo *src_bo)
-{
- uint32_t src_tiling, dst_tiling, swizzle;
- uint32_t src_pitch, dst_pitch;
- uint32_t cmd_bits = 0;
-
- drm_intel_bo_get_tiling(src_bo, &src_tiling, &swizzle);
- drm_intel_bo_get_tiling(dst_bo, &dst_tiling, &swizzle);
-
- src_pitch = width * 4;
- if (IS_965(devid) && src_tiling != I915_TILING_NONE) {
- src_pitch /= 4;
- cmd_bits |= XY_SRC_COPY_BLT_SRC_TILED;
- }
-
- dst_pitch = width * 4;
- if (IS_965(devid) && dst_tiling != I915_TILING_NONE) {
- dst_pitch /= 4;
- cmd_bits |= XY_SRC_COPY_BLT_DST_TILED;
- }
-
- BEGIN_BATCH(8);
- OUT_BATCH(XY_SRC_COPY_BLT_CMD |
- XY_SRC_COPY_BLT_WRITE_ALPHA |
- XY_SRC_COPY_BLT_WRITE_RGB |
- cmd_bits);
- OUT_BATCH((3 << 24) | /* 32 bits */
- (0xcc << 16) | /* copy ROP */
- dst_pitch);
- OUT_BATCH(0); /* dst x1,y1 */
- OUT_BATCH((height << 16) | width); /* dst x2,y2 */
- OUT_RELOC(dst_bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
- OUT_BATCH(0); /* src x1,y1 */
- OUT_BATCH(src_pitch);
- OUT_RELOC(src_bo, I915_GEM_DOMAIN_RENDER, 0, 0);
- ADVANCE_BATCH();
-
- intel_batchbuffer_flush(batch);
-}
+static uint32_t devid;
static drm_intel_bo *
create_bo(uint32_t start_val)
@@ -126,7 +86,7 @@ create_bo(uint32_t start_val)
}
drm_intel_bo_unmap(linear_bo);
- copy_bo(bo, linear_bo);
+ intel_copy_bo (batch, bo, linear_bo, width, height, devid);
drm_intel_bo_unreference(linear_bo);
@@ -142,7 +102,7 @@ check_bo(drm_intel_bo *bo, uint32_t start_val)
linear_bo = drm_intel_bo_alloc(bufmgr, "linear dst", 1024 * 1024, 4096);
- copy_bo(linear_bo, bo);
+ intel_copy_bo(batch, linear_bo, bo, width, height, devid);
drm_intel_bo_map(linear_bo, 0);
linear = linear_bo->virtual;
@@ -171,7 +131,7 @@ int main(int argc, char **argv)
int i;
fd = drm_open_any();
- intel_get_drm_devid(fd);
+ devid = intel_get_drm_devid(fd);
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
@@ -196,7 +156,7 @@ int main(int argc, char **argv)
if (src == dst)
continue;
- copy_bo(bo[dst], bo[src]);
+ intel_copy_bo(batch, bo[dst], bo[src], width, height, devid);
bo_start_val[dst] = bo_start_val[src];
/*
diff --git a/tests/gem_tiled_pread.c b/tests/gem_tiled_pread.c
index a6b99bde..e19453ed 100644
--- a/tests/gem_tiled_pread.c
+++ b/tests/gem_tiled_pread.c
@@ -58,49 +58,8 @@ static const int size = 1024 * 1024;
#define PAGE_SIZE 4096
-static void
-copy_bo(drm_intel_bo *dst_bo, drm_intel_bo *src_bo)
-{
- uint32_t src_tiling, dst_tiling, swizzle;
- uint32_t src_pitch, dst_pitch;
- uint32_t cmd_bits = 0;
-
- drm_intel_bo_get_tiling(src_bo, &src_tiling, &swizzle);
- drm_intel_bo_get_tiling(dst_bo, &dst_tiling, &swizzle);
-
- src_pitch = width * 4;
- if (IS_965(devid) && src_tiling != I915_TILING_NONE) {
- src_pitch /= 4;
- cmd_bits |= XY_SRC_COPY_BLT_SRC_TILED;
- }
-
- dst_pitch = width * 4;
- if (IS_965(devid) && dst_tiling != I915_TILING_NONE) {
- dst_pitch /= 4;
- cmd_bits |= XY_SRC_COPY_BLT_DST_TILED;
- }
-
- BEGIN_BATCH(8);
- OUT_BATCH(XY_SRC_COPY_BLT_CMD |
- XY_SRC_COPY_BLT_WRITE_ALPHA |
- XY_SRC_COPY_BLT_WRITE_RGB |
- cmd_bits);
- OUT_BATCH((3 << 24) | /* 32 bits */
- (0xcc << 16) | /* copy ROP */
- dst_pitch);
- OUT_BATCH(0); /* dst x1,y1 */
- OUT_BATCH((height << 16) | width); /* dst x2,y2 */
- OUT_RELOC(dst_bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
- OUT_BATCH(0); /* src x1,y1 */
- OUT_BATCH(src_pitch);
- OUT_RELOC(src_bo, I915_GEM_DOMAIN_RENDER, 0, 0);
- ADVANCE_BATCH();
-
- intel_batchbuffer_flush(batch);
-}
-
static drm_intel_bo *
-create_bo(void)
+create_bo(uint32_t devid)
{
drm_intel_bo *bo, *linear_bo;
uint32_t *linear;
@@ -122,7 +81,7 @@ create_bo(void)
linear[i] = val++;
drm_intel_bo_unmap(linear_bo);
- copy_bo(bo, linear_bo);
+ intel_copy_bo(batch, bo, linear_bo, width, height, devid);
drm_intel_bo_unreference(linear_bo);
@@ -163,19 +122,20 @@ int
main(int argc, char **argv)
{
int fd;
+ uint32_t devid;
drm_intel_bo *bo;
int i, iter = 100;
uint32_t buf[width * height];
uint32_t tiling, swizzle;
fd = drm_open_any();
- intel_get_drm_devid(fd);
+ devid = intel_get_drm_devid(fd);
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
batch = intel_batchbuffer_alloc(bufmgr);
- bo = create_bo();
+ bo = create_bo(devid);
drm_intel_bo_get_tiling(bo, &tiling, &swizzle);
diff --git a/tools/intel_audio_dump.c b/tools/intel_audio_dump.c
index 704ad235..f371b942 100644
--- a/tools/intel_audio_dump.c
+++ b/tools/intel_audio_dump.c
@@ -38,6 +38,7 @@
#include <fcntl.h>
#include <getopt.h>
#include <arpa/inet.h>
+
#include "intel_gpu_tools.h"
#define AUD_CONFIG 0x62000
@@ -187,7 +188,8 @@ int main(int argc, char **argv)
int i;
do_self_tests();
- intel_get_mmio();
+
+ intel_get_mmio(intel_get_pci_device());
/* printf("%-18s %8s %s\n\n", "register name", "raw value", "description"); */
diff --git a/tools/intel_error_decode.c b/tools/intel_error_decode.c
index d4bf8bcf..af205dc3 100644
--- a/tools/intel_error_decode.c
+++ b/tools/intel_error_decode.c
@@ -55,9 +55,15 @@
#include "instdone.h"
static void
-print_instdone (unsigned int instdone, unsigned int instdone1)
+print_instdone (uint32_t devid, unsigned int instdone, unsigned int instdone1)
{
int i;
+ static int once;
+
+ if (!once) {
+ init_instdone_definitions(devid);
+ once = 1;
+ }
for (i = 0; i < num_instdone_bits; i++) {
int busy = 0;
@@ -190,11 +196,11 @@ read_data_file (const char * filename)
matched = sscanf (line, " INSTDONE: 0x%08x\n", &reg);
if (matched)
- print_instdone (reg, -1);
+ print_instdone (devid, reg, -1);
matched = sscanf (line, " INSTDONE1: 0x%08x\n", &reg);
if (matched)
- print_instdone (-1, reg);
+ print_instdone (devid, -1, reg);
continue;
}
@@ -247,8 +253,6 @@ main (int argc, char *argv[])
return 1;
}
- init_instdone_definitions();
-
if (argc == 1) {
path = "/debug/dri/0";
err = stat (path, &st);
diff --git a/tools/intel_gpu_dump.c b/tools/intel_gpu_dump.c
index 9fd3f123..a6d2acb4 100644
--- a/tools/intel_gpu_dump.c
+++ b/tools/intel_gpu_dump.c
@@ -92,7 +92,7 @@ print_instdone (unsigned int instdone, unsigned int instdone1)
* exit()).
*/
static void
-read_data_file (const char * filename, int is_batch)
+read_data_file (uint32_t devid, const char * filename, int is_batch)
{
FILE *file;
uint32_t *data = NULL;
@@ -250,7 +250,9 @@ main (int argc, char *argv[])
const char *path;
struct stat st;
int err;
+ uint32_t devid;
uint32_t instdone, instdone1 = 0;
+ struct pci_device *pci_dev;
if (argc > 2) {
fprintf (stderr,
@@ -271,8 +273,10 @@ main (int argc, char *argv[])
return 1;
}
- intel_get_mmio();
- init_instdone_definitions();
+ pci_dev = intel_get_pci_device();
+ devid = pci_dev->device_id;
+ intel_get_mmio(pci_dev);
+ init_instdone_definitions(devid);
if (argc == 1) {
path = "/debug/dri/0";
@@ -352,7 +356,7 @@ main (int argc, char *argv[])
asprintf (&filename, "%s/i915_batchbuffers", path);
intel_decode_context_set_head_tail(acthd, 0xffffffff);
- read_data_file (filename, 1);
+ read_data_file (devid, filename, 1);
free (filename);
asprintf (&filename, "%s/i915_ringbuffer_data", path);
@@ -360,10 +364,10 @@ main (int argc, char *argv[])
printf("Ringbuffer: ");
printf("Reminder: head pointer is GPU read, tail pointer is CPU "
"write\n");
- read_data_file (filename, 0);
+ read_data_file (devid, filename, 0);
free (filename);
} else {
- read_data_file (path, 1);
+ read_data_file (devid, path, 1);
}
return 0;
diff --git a/tools/intel_gpu_time.c b/tools/intel_gpu_time.c
index b36bf389..c30b84d2 100644
--- a/tools/intel_gpu_time.c
+++ b/tools/intel_gpu_time.c
@@ -65,7 +65,7 @@ int main(int argc, char **argv)
static struct rusage rusage;
int status;
- intel_get_mmio();
+ intel_get_mmio(intel_get_pci_device());
if (argc == 1) {
fprintf(stderr, "usage: %s cmd [args...]\n", argv[0]);
diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
index 3ddbd387..b82a9bd8 100644
--- a/tools/intel_gpu_top.c
+++ b/tools/intel_gpu_top.c
@@ -137,8 +137,9 @@ print_clock(char *name, int clock) {
}
static int
-print_clock_info(void)
+print_clock_info(struct pci_device *pci_dev)
{
+ uint32_t devid = pci_dev->device_id;
uint16_t gcfgc;
if (IS_GM45(devid)) {
@@ -284,11 +285,16 @@ print_percentage_bar(float percent, int cur_line_len)
int main(int argc, char **argv)
{
- intel_get_mmio();
+ struct pci_device *pci_dev;
uint32_t ring_size;
+ uint32_t devid;
int i;
- init_instdone_definitions();
+ pci_dev = intel_get_pci_device();
+ devid = pci_dev->device_id;
+ intel_get_mmio(pci_dev);
+ init_instdone_definitions(devid);
+
for (i = 0; i < num_instdone_bits; i++) {
top_bits[i].bit = &instdone_bits[i];
top_bits[i].count = 0;
@@ -362,7 +368,7 @@ int main(int argc, char **argv)
printf("%s", clear_screen);
- print_clock_info();
+ print_clock_info(pci_dev);
percent = ring_idle / SAMPLES_TO_PERCENT_RATIO;
len = printf("%30s: %3d%%: ", "ring idle", percent);
diff --git a/tools/intel_gtt.c b/tools/intel_gtt.c
index 2e71104c..2c1639cd 100644
--- a/tools/intel_gtt.c
+++ b/tools/intel_gtt.c
@@ -42,10 +42,14 @@
int main(int argc, char **argv)
{
+ struct pci_device *pci_dev;
int start, aper_size;
unsigned char *gtt;
+ uint32_t devid;
- intel_get_mmio();
+ pci_dev = intel_get_pci_device();
+ devid = pci_dev->device_id;
+ intel_get_mmio(pci_dev);
if (!IS_9XX(devid)) {
printf("Unsupported chipset for gtt dumper\n");
diff --git a/tools/intel_lid.c b/tools/intel_lid.c
index 71eedb29..908224ee 100644
--- a/tools/intel_lid.c
+++ b/tools/intel_lid.c
@@ -117,7 +117,7 @@ int main(int argc, char **argv)
{
int swf14, acpi_lid;
- intel_get_mmio();
+ intel_get_mmio(intel_get_pci_device());
while (1) {
swf14 = INREG(SWF14);
diff --git a/tools/intel_reg_dumper.c b/tools/intel_reg_dumper.c
index 8a9cf7a0..b1a7e47a 100644
--- a/tools/intel_reg_dumper.c
+++ b/tools/intel_reg_dumper.c
@@ -33,6 +33,8 @@
#include <err.h>
#include "intel_gpu_tools.h"
+static uint32_t devid;
+
#define DEBUGSTRING(func) static void func(char **result, int reg, uint32_t val)
DEBUGSTRING(i830_16bit_func)
@@ -1658,10 +1660,15 @@ intel_dump_regs(void)
int main(int argc, char** argv)
{
+ struct pci_device *pci_dev;
+
+ pci_dev = intel_get_pci_device();
+ devid = pci_dev->device_id; /* XXX not true when mapping! */
+
if (argc == 2)
intel_map_file(argv[1]);
else
- intel_get_mmio();
+ intel_get_mmio(pci_dev);
if (HAS_PCH_SPLIT(devid) || getenv("HAS_PCH_SPLIT"))
ironlake_dump_regs();
diff --git a/tools/intel_reg_read.c b/tools/intel_reg_read.c
index 9a7712fc..02599245 100644
--- a/tools/intel_reg_read.c
+++ b/tools/intel_reg_read.c
@@ -53,7 +53,7 @@ int main(int argc, char** argv)
exit(1);
}
- intel_get_mmio();
+ intel_get_mmio(intel_get_pci_device());
if (!strcmp(argv[1], "-f")) {
dump_range(0x00000, 0x00fff); /* VGA registers */
diff --git a/tools/intel_reg_snapshot.c b/tools/intel_reg_snapshot.c
index f8219280..fcc8b812 100644
--- a/tools/intel_reg_snapshot.c
+++ b/tools/intel_reg_snapshot.c
@@ -29,9 +29,13 @@
int main(int argc, char** argv)
{
+ struct pci_device *pci_dev;
+ uint32_t devid;
int mmio_bar;
- intel_get_mmio();
+ pci_dev = intel_get_pci_device();
+ devid = pci_dev->device_id;
+ intel_get_mmio(pci_dev);
if (IS_9XX(devid))
mmio_bar = 0;
diff --git a/tools/intel_reg_write.c b/tools/intel_reg_write.c
index 7bed0623..c8af9bbf 100644
--- a/tools/intel_reg_write.c
+++ b/tools/intel_reg_write.c
@@ -43,7 +43,7 @@ int main(int argc, char** argv)
exit(1);
}
- intel_get_mmio();
+ intel_get_mmio(intel_get_pci_device());
sscanf(argv[1], "0x%x", &reg);
sscanf(argv[2], "0x%x", &value);
ptr = (volatile uint32_t *)((volatile char *)mmio + reg);