Quoting Chris Wilson (2017-11-14 13:18:44) > 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@xxxxxxxxxxxxxxxxxx> > --- > 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)) { Eek, m->bit is already a bit and not a shift. Still puzzled where the device went between tests though, no sign of it being unloaded. -Chris _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx