All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH igt 1/2] lib: Attempt to load the module for a missing device
@ 2017-11-14 13:18 Chris Wilson
  2017-11-14 13:18 ` [PATCH igt 2/2] lib/kmod: Stop reloading i915 after every kselftest Chris Wilson
                   ` (12 more replies)
  0 siblings, 13 replies; 19+ messages in thread
From: Chris Wilson @ 2017-11-14 13:18 UTC (permalink / raw)
  To: intel-gfx

If we asked to open a particular chipset and we find no matching device,
try again after attempting to load its module. Previously we only did
this for vgem, which is not automatically probed during boot, but if we
want to leave the module unloaded we have to try harder when we need the
device.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 lib/drmtest.c | 68 +++++++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 50 insertions(+), 18 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index e6bdbc35..3a2a6343 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -235,20 +235,14 @@ static int modprobe(const char *driver)
 	return igt_kmod_load(driver, "");
 }
 
-/**
- * __drm_open_driver:
- * @chipset: OR'd flags for each chipset to search, eg. #DRIVER_INTEL
- *
- * Open the first DRM device we can find, searching up to 16 device nodes
- *
- * Returns:
- * An open DRM fd or -1 on error
- */
-int __drm_open_driver(int chipset)
+static void modprobe_i915(const char *name)
 {
-	if (chipset & DRIVER_VGEM)
-		modprobe("vgem");
+	/* When loading i915, we also want to load snd-hda et al */
+	igt_i915_driver_load(NULL);
+}
 
+static int __open_device(unsigned int chipset)
+{
 	for (int i = 0; i < 16; i++) {
 		char name[80];
 		int fd;
@@ -262,16 +256,13 @@ int __drm_open_driver(int chipset)
 		    has_known_intel_chipset(fd))
 			return fd;
 
-		if (chipset & DRIVER_VC4 &&
-		    is_vc4_device(fd))
+		if (chipset & DRIVER_VC4 && is_vc4_device(fd))
 			return fd;
 
-		if (chipset & DRIVER_VGEM &&
-		    is_vgem_device(fd))
+		if (chipset & DRIVER_VGEM && is_vgem_device(fd))
 			return fd;
 
-		if (chipset & DRIVER_VIRTIO &&
-		    is_virtio_device(fd))
+		if (chipset & DRIVER_VIRTIO && is_virtio_device(fd))
 			return fd;
 
 		if (chipset & DRIVER_AMDGPU && is_amd_device(fd))
@@ -287,6 +278,47 @@ int __drm_open_driver(int chipset)
 	return -1;
 }
 
+/**
+ * __drm_open_driver:
+ * @chipset: OR'd flags for each chipset to search, eg. #DRIVER_INTEL
+ *
+ * Open the first DRM device we can find, searching up to 16 device nodes
+ *
+ * Returns:
+ * An open DRM fd or -1 on error
+ */
+int __drm_open_driver(int chipset)
+{
+	static const struct {
+		unsigned int bit;
+		const char *module;
+		void (*modprobe)(const char *name);
+	} modules[] = {
+		{ DRIVER_AMDGPU, "amdgpu" },
+		{ DRIVER_INTEL, "i915", modprobe_i915 },
+		{ DRIVER_VC4, "vc4" },
+		{ DRIVER_VGEM, "vgem" },
+		{ DRIVER_VIRTIO, "virtio-gpu" },
+		{}
+	}, *m;
+	int fd;
+
+	fd = __open_device(chipset);
+	if (fd != -1)
+		return fd;
+
+	for (m = modules; m->module; m++) {
+		if (chipset & (1ul << m->bit)) {
+			if (m->modprobe)
+				m->modprobe(m->module);
+			else
+				modprobe(m->module);
+		}
+	}
+
+	return __open_device(chipset);
+}
+
 static int __drm_open_driver_render(int chipset)
 {
 	char *name;
-- 
2.15.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 19+ messages in thread
* [PATCH igt 1/2] lib: Attempt to load the module for a missing device
@ 2017-11-13 10:56 Chris Wilson
  0 siblings, 0 replies; 19+ messages in thread
From: Chris Wilson @ 2017-11-13 10:56 UTC (permalink / raw)
  To: intel-gfx

If we asked to open a particular chipset and we find no matching device,
try again after attempting to load its module. Previously we only did
this for vgem, which is not automatically probed during boot, but if we
want to leave the module unloaded we have to try harder when we need the
device.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 lib/drmtest.c | 68 +++++++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 50 insertions(+), 18 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index e6bdbc35..3a2a6343 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -235,20 +235,14 @@ static int modprobe(const char *driver)
 	return igt_kmod_load(driver, "");
 }
 
-/**
- * __drm_open_driver:
- * @chipset: OR'd flags for each chipset to search, eg. #DRIVER_INTEL
- *
- * Open the first DRM device we can find, searching up to 16 device nodes
- *
- * Returns:
- * An open DRM fd or -1 on error
- */
-int __drm_open_driver(int chipset)
+static void modprobe_i915(const char *name)
 {
-	if (chipset & DRIVER_VGEM)
-		modprobe("vgem");
+	/* When loading i915, we also want to load snd-hda et al */
+	igt_i915_driver_load(NULL);
+}
 
+static int __open_device(unsigned int chipset)
+{
 	for (int i = 0; i < 16; i++) {
 		char name[80];
 		int fd;
@@ -262,16 +256,13 @@ int __drm_open_driver(int chipset)
 		    has_known_intel_chipset(fd))
 			return fd;
 
-		if (chipset & DRIVER_VC4 &&
-		    is_vc4_device(fd))
+		if (chipset & DRIVER_VC4 && is_vc4_device(fd))
 			return fd;
 
-		if (chipset & DRIVER_VGEM &&
-		    is_vgem_device(fd))
+		if (chipset & DRIVER_VGEM && is_vgem_device(fd))
 			return fd;
 
-		if (chipset & DRIVER_VIRTIO &&
-		    is_virtio_device(fd))
+		if (chipset & DRIVER_VIRTIO && is_virtio_device(fd))
 			return fd;
 
 		if (chipset & DRIVER_AMDGPU && is_amd_device(fd))
@@ -287,6 +278,47 @@ int __drm_open_driver(int chipset)
 	return -1;
 }
 
+/**
+ * __drm_open_driver:
+ * @chipset: OR'd flags for each chipset to search, eg. #DRIVER_INTEL
+ *
+ * Open the first DRM device we can find, searching up to 16 device nodes
+ *
+ * Returns:
+ * An open DRM fd or -1 on error
+ */
+int __drm_open_driver(int chipset)
+{
+	static const struct {
+		unsigned int bit;
+		const char *module;
+		void (*modprobe)(const char *name);
+	} modules[] = {
+		{ DRIVER_AMDGPU, "amdgpu" },
+		{ DRIVER_INTEL, "i915", modprobe_i915 },
+		{ DRIVER_VC4, "vc4" },
+		{ DRIVER_VGEM, "vgem" },
+		{ DRIVER_VIRTIO, "virtio-gpu" },
+		{}
+	}, *m;
+	int fd;
+
+	fd = __open_device(chipset);
+	if (fd != -1)
+		return fd;
+
+	for (m = modules; m->module; m++) {
+		if (chipset & (1ul << m->bit)) {
+			if (m->modprobe)
+				m->modprobe(m->module);
+			else
+				modprobe(m->module);
+		}
+	}
+
+	return __open_device(chipset);
+}
+
 static int __drm_open_driver_render(int chipset)
 {
 	char *name;
-- 
2.15.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2017-11-15 12:55 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-14 13:18 [PATCH igt 1/2] lib: Attempt to load the module for a missing device Chris Wilson
2017-11-14 13:18 ` [PATCH igt 2/2] lib/kmod: Stop reloading i915 after every kselftest Chris Wilson
2017-11-14 13:51 ` ✗ Fi.CI.BAT: warning for series starting with [1/2] lib: Attempt to load the module for a missing device Patchwork
2017-11-14 13:56 ` [PATCH igt 1/2] " Chris Wilson
2017-11-14 14:10   ` Petri Latvala
2017-11-14 14:28     ` Chris Wilson
2017-11-14 14:07 ` [PATCH igt v2] " Chris Wilson
2017-11-14 18:17 ` ✗ Fi.CI.BAT: failure for series starting with [v2] lib: Attempt to load the module for a missing device (rev2) Patchwork
2017-11-14 18:45 ` [PATCH igt v3] lib: Attempt to load the module for a missing device Chris Wilson
2017-11-14 21:22 ` ✗ Fi.CI.BAT: failure for series starting with [v3] lib: Attempt to load the module for a missing device (rev3) Patchwork
2017-11-14 21:33 ` [PATCH igt v4] lib: Attempt to load the module for a missing device Chris Wilson
2017-11-15 11:06   ` Petri Latvala
2017-11-15 11:22     ` Chris Wilson
2017-11-14 22:35 ` ✓ Fi.CI.BAT: success for series starting with [v4] lib: Attempt to load the module for a missing device (rev4) Patchwork
2017-11-15  1:54 ` ✗ Fi.CI.IGT: warning " Patchwork
2017-11-15 11:30 ` [PATCH igt v5] lib: Attempt to load the module for a missing device Chris Wilson
2017-11-15 11:53 ` ✓ Fi.CI.BAT: success for series starting with [v5] lib: Attempt to load the module for a missing device (rev5) Patchwork
2017-11-15 12:55 ` ✓ Fi.CI.IGT: " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2017-11-13 10:56 [PATCH igt 1/2] lib: Attempt to load the module for a missing device Chris Wilson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.