[PATCH 2/5] intel_mmio: Allow mmio without debugfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



With the introduction of the forcewake dance:

commit cac8f8b52621f246a7cff412f340a7db28cb1b99
Author: Ben Widawsky <ben at 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 at virtuousgeek.org>
Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
 lib/intel_mmio.c | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/lib/intel_mmio.c b/lib/intel_mmio.c
index 2281037..3933080 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.
  *
@@ -188,10 +206,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++;
@@ -201,7 +223,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--;
 }
-- 
1.8.1.4



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux