Using prime with udl leaks a ref, making it impossible to unload the udl kmod

Hans de Goede hdegoede at redhat.com
Fri Jul 3 11:56:59 PDT 2015


Hi Dave,

I've been working on a kms driver for a mini projector
which uses usb for its video transport. During the
development of this I've hit this problem where once
used from within Xorg to extend my regular gnome-desktop,
the module keeps a refcount of 1 after unplugging the
projector, so I cannot unload it which makes development
somewhat awkward.

I've reproduced the problem with an udl device and the
udl kms driver to make sure this is not a problem with
my driver.

So I've spend a day debugging this, I quickly found a
leaked fd for /dev/dri/card1 in /proc/<xorg-pid>/fd/
and after looking for an extra open() it turns out this
comes from a dup(). I've managed to pinpoint the source
of this, and just send a patch to fix the fd leak:

"glamor_egl: Properly free resources on init-error and exit"

After this I see no more fd leak, but sadly the problem is
still there. It is different now though, if I plug in an
udl device wait for X to see it load the modesetting driver,
etc., and then plug it out, everything is good. This is
different then before and shows my fd-leak patch helps.

But if I then go into the gnome control-panel, and change
the state of the udl attached monitor from "off" to
"secondary", and then unplug the udl, somehow somewhere
X still keeps a reference (like through a dma-buf object
or some such).

This is all on a fully up2date Fedora-22 system, with
everything standard, except that I've rebuild the
xserver with the patch mentioned above.

If you've any suggestions on how to debug this further
that would be much appreciated.

Regards,

Hans


More information about the xorg-devel mailing list