[Intel-gfx] i915 render node discovery buggy?

Russell King - ARM Linux linux at arm.linux.org.uk
Tue Oct 27 03:24:36 PDT 2015


In passing, while reading the Intel DDX driver code, I've noticed
that the Intel driver contains code which assumes that the master and
render devices are related by minor device number, eg:

        /* Are we a render-node ourselves? */
        if (is_render_node(fd, &master))
                return NULL;

        sprintf(buf, "/dev/dri/renderD%d", (int)((master.st_rdev | 0x80) & 0xbf));
        if (stat(buf, &render) == 0 &&
            master.st_mode == render.st_mode &&
            render.st_rdev == ((master.st_rdev | 0x80) & 0xbf))
                return strdup(buf);

There's also code doing the reverse as well.

>From my observations, the assumption that this code is built upon is
false.  I have an ARM platform here (non-Intel graphics) which shows
the problem - we have a KMS-only DRM driver (card0) and a GPU-only
DRM driver (card1).  This populates the /dev/dri subdirectory as
follows:

crw-rw----+ 1 root video 226,   0 Oct 27 04:59 card0
crw-rw----+ 1 root video 226,   1 Oct 26 20:40 card1
crw-rw----  1 root video 226,  64 Oct 26 20:40 controlD64
crw-rw----  1 root video 226, 128 Oct 26 20:40 renderD128

and if I look at /sys/class/drm, you can then see who owns which devices:

lrwxrwxrwx 1 root root    0 Oct 26 20:40 card0 -> ../../devices/platform/armada-drm/drm/card0
lrwxrwxrwx 1 root root    0 Oct 26 20:40 card0-HDMI-A-1 -> ../../devices/platform/armada-drm/drm/card0/card0-HDMI-A-1
lrwxrwxrwx 1 root root    0 Oct 26 20:40 card1 -> ../../devices/platform/etnaviv/drm/card1
lrwxrwxrwx 1 root root    0 Oct 26 20:40 controlD64 -> ../../devices/platform/armada-drm/drm/controlD64
lrwxrwxrwx 1 root root    0 Oct 26 20:40 renderD128 -> ../../devices/platform/etnaviv/drm/renderD128

So, renderD128 is card1's render node, which does not conform to the
assumption which the Intel DDX driver makes - (1 | 0x80) & 0xbf is
not 128.  The same thing can happen if there's ever a case on Intel
hardware where a KMS DRM driver registers prior to the i915 driver.

I think the only way to properly determine which render nodes
correspond with which master node is to actually open the device and
check the device names, or parse sysfs - maybe reading the links of
/sys/class/drm, and checking which link dirname corresponds with the
master node.

Any comments?

-- 
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.


More information about the Intel-gfx mailing list