[PATCH i-g-t 5/7] lib/drmtest: Support nouveau

Thierry Reding thierry.reding at gmail.com
Thu Oct 12 13:29:41 UTC 2017


From: Thierry Reding <treding at nvidia.com>

Add a driver definition for nouveau and wire up all the necessary pieces
to identify its devices.

Signed-off-by: Thierry Reding <treding at nvidia.com>
---
 lib/drmtest.c | 14 ++++++++++++--
 lib/drmtest.h |  1 +
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 24a5ea0f6a0f..f46419ec36cf 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -80,7 +80,7 @@ static int __get_drm_device_name(int fd, char *name)
 	drm_version_t version;
 
 	memset(&version, 0, sizeof(version));
-	version.name_len = 4;
+	version.name_len = 8;
 	version.name = name;
 
 	if (!drmIoctl(fd, DRM_IOCTL_VERSION, &version)){
@@ -92,7 +92,7 @@ static int __get_drm_device_name(int fd, char *name)
 
 static bool __is_device(int fd, const char *expect)
 {
-	char name[5] = "";
+	char name[9] = "";
 
 	if (__get_drm_device_name(fd, name))
 		return false;
@@ -125,6 +125,11 @@ static bool is_amd_device(int fd)
 	return __is_device(fd, "amdg");
 }
 
+static bool is_nouveau_device(int fd)
+{
+	return __is_device(fd, "nouveau");
+}
+
 static bool has_known_intel_chipset(int fd)
 {
 	struct drm_i915_getparam gp;
@@ -277,6 +282,9 @@ int __drm_open_driver(int chipset)
 		if (chipset & DRIVER_AMDGPU && is_amd_device(fd))
 			return fd;
 
+		if (chipset & DRIVER_NOUVEAU && is_nouveau_device(fd))
+			return fd;
+
 		/* Only VGEM-specific tests should be run on VGEM */
 		if (chipset == DRIVER_ANY && !is_vgem_device(fd))
 			return fd;
@@ -352,6 +360,8 @@ static const char *chipset_to_str(int chipset)
 		return "virtio";
 	case DRIVER_AMDGPU:
 		return "amdgpu";
+	case DRIVER_NOUVEAU:
+		return "nouveau";
 	case DRIVER_ANY:
 		return "any";
 	default:
diff --git a/lib/drmtest.h b/lib/drmtest.h
index a86799d54834..e54e1b6756af 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -43,6 +43,7 @@
 #define DRIVER_VGEM	(1 << 2)
 #define DRIVER_VIRTIO	(1 << 3)
 #define DRIVER_AMDGPU	(1 << 4)
+#define DRIVER_NOUVEAU	(1 << 5)
 /*
  * Exclude DRVER_VGEM from DRIVER_ANY since if you run on a system
  * with vgem as well as a supported driver, you can end up with a
-- 
2.14.1



More information about the dri-devel mailing list