summaryrefslogtreecommitdiff
path: root/lib/intel_mmio.c
diff options
context:
space:
mode:
authorBen Widawsky <ben@bwidawsk.net>2013-02-21 22:05:33 -0800
committerJesse Barnes <jbarnes@virtuousgeek.org>2013-04-16 14:06:02 -0700
commit8904d29416e784f7ba0fb74455505fc251dd894f (patch)
treea9540b7ea484be6cc696b8555199161b78aeca1d /lib/intel_mmio.c
parentec107b019435ab49e8454664368bf1187f3d0273 (diff)
intel_mmio: Allow mmio without debugfs
With the introduction of the forcewake dance: commit cac8f8b52621f246a7cff412f340a7db28cb1b99 Author: Ben Widawsky <ben@bwidawsk.net> Date: Thu Jul 28 13:40:19 2011 -0700 forcewake: Add mmio code to do proper forcewake stuff for gen6 We lost the ability to do register access when either debugfs isn't mounted, or when the driver isn't loaded. The latter can be beneficial in debugging situations. This patch will allow the driver to still do mmio (leaving forcewake management up to the callers) provided that the i915 driver appears to not be loaded (according to sysfs) Requested by Jesse. Cc: Jesse Barnes <jbarnes@virtuousgeek.org> Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Diffstat (limited to 'lib/intel_mmio.c')
-rw-r--r--lib/intel_mmio.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/lib/intel_mmio.c b/lib/intel_mmio.c
index ff9cf3f9..806fc31c 100644
--- a/lib/intel_mmio.c
+++ b/lib/intel_mmio.c
@@ -43,6 +43,8 @@
#include "intel_gpu_tools.h"
+#define FAKEKEY 0x2468ace0
+
void *mmio;
static struct _mmio_data {
@@ -153,6 +155,22 @@ release_forcewake_lock(int fd)
close(fd);
}
+/* Dumb check to see if i915 was loaded */
+static bool
+i915_loaded(void)
+{
+ struct stat sb;
+ int ret;
+
+ ret = stat("/sys/module/i915/", &sb);
+ if (ret) {
+ return false;
+ }
+
+ assert(S_ISDIR(sb.st_mode));
+ return true;
+}
+
/*
* Initialize register access library.
*
@@ -190,10 +208,14 @@ intel_register_access_init(struct pci_device *pci_dev, int safe)
ret = find_debugfs_path("/debug/dri");
if (ret) {
fprintf(stderr, "Couldn't find path to dri/debugfs entry\n");
- return ret;
+ if (i915_loaded()) {
+ fprintf(stderr, "i915 loaded; not proceeding.\n");
+ return ret;
+ }
}
- }
- mmio_data.key = get_forcewake_lock();
+ mmio_data.key = FAKEKEY;
+ } else
+ mmio_data.key = get_forcewake_lock();
done:
mmio_data.inited++;
@@ -203,7 +225,7 @@ done:
void
intel_register_access_fini(void)
{
- if (mmio_data.key)
+ if (mmio_data.key && mmio_data.key != FAKEKEY)
release_forcewake_lock(mmio_data.key);
mmio_data.inited--;
}