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:58:33 PDT 2015
Hi,
On 03-07-15 20:56, Hans de Goede wrote:
> 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).
Just realized I forgot one important detail, if I completely
kill the Xserver at this point, then the reference does
get cleared and I can unload the udl kmod, so this seems to
be a userspace problem.
Regards,
Hans
More information about the xorg-devel
mailing list