[PATCH 15/31] xf86: load modesetting driver on Linux hotplug

Michal Srb msrb at suse.com
Tue Jun 26 10:03:19 PDT 2012

On Wednesday 20 of June 2012 15:00:30 Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
> This driver is currently really the only choice for a hotplug
> at the moment, we can refine this in the future to try and
> pick the driver names.
> We have to reload this as it can get unloaded it not used
> in the original probe.

This unfortunatelly fails on my machine. If the device is not plugged during 
start of X, the hotplugging doesn't work correctly. The module is loaded but 
prints this to log:
  (II) Failed to load module "modesetting" (already loaded, 0)
And the modesetting driver is not added to X server.

It is because the Setup function of xf86-video-modesetting module keeps static 
variable (setupDone) which ensures that any repeated loading of the module 
fails. In case the modesetting driver is not needed during start, it is 
removed from X server and subsequently also the module is unloaded. When the 
modesetting module is loaded again because of hotplug, the driver has to be 
added again from Setup. Unfortunatelly the setupDone variable is not reset to 
zero between UnloadModule and LoadModule.

I am no expert on dynamic libraries, but I found this is probably the cause:
Static variables are reset to original values when library gets unloaded and 
loaded again. In our case the library won't get unloaded after dlclose because 
dlsym was called earlier on symbol from that library (modesettingModuleData) 
and that keeps reference counter above zero.

Patch with possible solution follows...

Michal Srb

More information about the xorg-devel mailing list