public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* i915 render node discovery buggy?
@ 2015-10-27 10:24 Russell King - ARM Linux
  2015-10-27 11:28 ` Martin Peres
  0 siblings, 1 reply; 2+ messages in thread
From: Russell King - ARM Linux @ 2015-10-27 10:24 UTC (permalink / raw)
  To: Daniel Vetter, intel-gfx

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.
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: i915 render node discovery buggy?
  2015-10-27 10:24 i915 render node discovery buggy? Russell King - ARM Linux
@ 2015-10-27 11:28 ` Martin Peres
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Peres @ 2015-10-27 11:28 UTC (permalink / raw)
  To: intel-gfx

On 27/10/15 12:24, Russell King - ARM Linux wrote:
> 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?

libdrm already has the right function for that:|char 
*drmGetRenderDeviceNameFromFd(int fd);


|

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

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

end of thread, other threads:[~2015-10-27 11:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-27 10:24 i915 render node discovery buggy? Russell King - ARM Linux
2015-10-27 11:28 ` Martin Peres

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox