[Intel-gfx] [PATCH igt 1/2] lib: Attempt to load the module for a missing device
Chris Wilson
chris at chris-wilson.co.uk
Tue Nov 14 14:28:33 UTC 2017
Quoting Petri Latvala (2017-11-14 14:10:27)
> On Tue, Nov 14, 2017 at 01:56:22PM +0000, Chris Wilson wrote:
> > 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 at 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)) {
> >
> > 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.
>
>
> I don't see any signs of it being loaded in the first
> place. Assuming I'm reading right and this is the correct line to look
> for (from the base run):
>
>
> <6>[ 265.406984] [drm] Initialized vgem 1.0.0 20120112 for virtual device on minor 1
Ah, right; looking for the wrong thing and didn't click that it was
erroring out on vgem. In which case, fixing m->bit should explain it.
-chris
More information about the Intel-gfx
mailing list