summaryrefslogtreecommitdiff
path: root/lib/igt_sysfs.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-06-05 11:55:57 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2017-06-21 15:12:54 +0100
commit310eaeb60579110c5a8e2f31d87ec659ab66b3b8 (patch)
tree2bdfce0dd80ff3280fa85daf0e80cf705ec00c56 /lib/igt_sysfs.c
parentd517ee729ddbe2bb8a5c6cc10e7ce35d73a8bd82 (diff)
lib: Force global reset + uevents for hang detector
The hang detector relies on a uevent for notification and aborting the test. As proposed, fine-grained resets may not produce a global uevent and so this hang detection becomes void. As we don't expect any hang, we can just reduce the reset to only a global + uevent and so maintain functionality, and switch back to fine-grained resets afterwards. Note that any test that requires testing fine-grained resets should ensure that they are enabled first as igt may leave the global parameters in an inconsistent state. v2: Restore fine-grained resets for explict igt_allow_hang() Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Michel Thierry <michel.thierry@intel.com> Reviewed-by: Michel Thierry <michel.thierry@intel.com>
Diffstat (limited to 'lib/igt_sysfs.c')
-rw-r--r--lib/igt_sysfs.c72
1 files changed, 54 insertions, 18 deletions
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 8ebc5b4f..15ed34be 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -139,6 +139,35 @@ int igt_sysfs_open(int device, int *idx)
}
/**
+ * igt_sysfs_set_parameters:
+ * @device: fd of the device (or -1 to default to Intel)
+ * @parameter: the name of the parameter to set
+ * @fmt: printf-esque format string
+ *
+ * Returns true on success
+ */
+bool igt_sysfs_set_parameter(int device,
+ const char *parameter,
+ const char *fmt, ...)
+{
+ va_list ap;
+ int dir;
+ int ret;
+
+ dir = igt_sysfs_open_parameters(device);
+ if (dir < 0)
+ return false;
+
+ va_start(ap, fmt);
+ ret = igt_sysfs_vprintf(dir, parameter, fmt, ap);
+ va_end(ap);
+
+ close(dir);
+
+ return ret > 0;
+}
+
+/**
* igt_sysfs_open_parameters:
* @device: fd of the device (or -1 to default to Intel)
*
@@ -336,19 +365,7 @@ int igt_sysfs_scanf(int dir, const char *attr, const char *fmt, ...)
return ret;
}
-/**
- * igt_sysfs_printf:
- * @dir: directory for the device from igt_sysfs_open()
- * @attr: name of the sysfs node to open
- * @fmt: printf format string
- * @...: Additional paramaters to store the scaned input values
- *
- * printf() wrapper for sysfs.
- *
- * Returns:
- * Number of characters written, negative value on error.
- */
-int igt_sysfs_printf(int dir, const char *attr, const char *fmt, ...)
+int igt_sysfs_vprintf(int dir, const char *attr, const char *fmt, va_list ap)
{
FILE *file;
int fd;
@@ -360,12 +377,7 @@ int igt_sysfs_printf(int dir, const char *attr, const char *fmt, ...)
file = fdopen(fd, "w");
if (file) {
- va_list ap;
-
- va_start(ap, fmt);
ret = vfprintf(file, fmt, ap);
- va_end(ap);
-
fclose(file);
}
close(fd);
@@ -374,6 +386,30 @@ int igt_sysfs_printf(int dir, const char *attr, const char *fmt, ...)
}
/**
+ * igt_sysfs_printf:
+ * @dir: directory for the device from igt_sysfs_open()
+ * @attr: name of the sysfs node to open
+ * @fmt: printf format string
+ * @...: Additional paramaters to store the scaned input values
+ *
+ * printf() wrapper for sysfs.
+ *
+ * Returns:
+ * Number of characters written, negative value on error.
+ */
+int igt_sysfs_printf(int dir, const char *attr, const char *fmt, ...)
+{
+ va_list ap;
+ int ret;
+
+ va_start(ap, fmt);
+ ret = igt_sysfs_vprintf(dir, attr, fmt, ap);
+ va_end(ap);
+
+ return ret;
+}
+
+/**
* igt_sysfs_get_u32:
* @dir: directory for the device from igt_sysfs_open()
* @attr: name of the sysfs node to open