[PATCH 2/2] xfree86: Support autoloading of non-PCI drivers

Thierry Reding thierry.reding at gmail.com
Thu Feb 13 01:11:50 PST 2014


On Wed, Feb 12, 2014 at 04:00:03PM -0800, Aaron Plattner wrote:
> On 02/12/2014 11:09 AM, Thierry Reding wrote:
> >* PGP Signed by an unknown key
> >
> >On Wed, Feb 12, 2014 at 05:28:56PM +0100, Hans de Goede wrote:
> >>Hi,
> >>
> >>On 02/12/2014 05:11 PM, Thierry Reding wrote:
> >>>Drivers for non-PCI devices cannot be autoloaded because there is no
> >>>mechanism in place to correlate the device to the driver name.
> >>>
> >>>This patch adds a simple table that maps the name of the Linux kernel
> >>>driver name to a list of DDX module names. Matching modules will be
> >>>added to the list of drivers that X tries to load for a given device.
> >>>
> >>>Signed-off-by: Thierry Reding <treding at nvidia.com>
> >>>---
> >>>  hw/xfree86/common/xf86platformBus.c | 41 +++++++++++++++++++++++++++++++++++++
> >>>  1 file changed, 41 insertions(+)
> >>>
> >>>diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
> >>>index 5875a91363cc..16c9bb6c1dbc 100644
> >>>--- a/hw/xfree86/common/xf86platformBus.c
> >>>+++ b/hw/xfree86/common/xf86platformBus.c
> >>>@@ -176,6 +176,41 @@ xf86_check_platform_slot(const struct xf86_platform_device *pd)
> >>>      return TRUE;
> >>>  }
> >>>
> >>>+#ifdef __linux__
> >>
> >>I'm not a big fan of this, why not put most of this in:
> >>
> >>hw/xfree86/os-support/linux/lnx_platform.c
> >>
> >>And make xf86platformBus.c simple call a helper for this
> >>from hw/xfree86/os-support/linux/lnx_platform.c ?
> >
> >I can easily move the table and the function below into lnx_platform.c
> >and only call it from here if that's preferred. This really should've
> >been marked RFC, since it's not clear to me if this is what we want. It
> >works and isn't all that ugly, so I thought I'd post it to get early
> >feedback if this is a good direction.
> >
> >Rob, Dave and I discussed this on IRC yesterday and Dave said that
> >having a lookup table like this was really the only sane thing to do.
> 
> When I suggested something similar a while ago for trying to autoload the
> nvidia_drv.so driver, it was suggested that it would be better to have a
> driver match section that could be placed into an xorg.conf.d snippet,
> rather than hard-coding this table in the server.  IIRC there's something
> similar for input devices already.
> 
> The idea would be that xf86-video-opentegra would install a
> /usr/share/X11/xorg.conf.d/opentegra.conf that would consist of something
> like this:
> 
> Section "OutputClass"
>   MatchPlatformDriver "tegra"
>   Driver "opentegra"
> EndSection
> 
> or something.  Does that sound reasonable?

It's an intriguing alternative. One of the things that's not clear to me
with that proposal is how you'd handle the case where multiple userspace
drivers can run on top of the same kernel driver. With my proposal there
is basically a policy encoded within the table in the X server that will
decide in which order the drivers are probed.

One could argue that the X server shouldn't be defining policy this way,
but the same thing is already done for PCI drivers. Similarily there is
policy to always fall back to xf86-video-modesetting, then
xf86-video-fbdev.

If each driver provided an xorg.conf.d snippet then, if I understand
correctly, each snippet will be applied in alphabetical order, so which
ever snippet is loaded first will cause the configured driver to be
probed before any others that match the OutputClass section.

As an example, if on Tegra we have two DDX modules that can run on top
of the Tegra DRM driver, we'd have these two files:

	/usr/share/X11/xorg.conf.d/opentegra.conf:

		Section "OutputClass"
			MatchPlatformDriver "tegra"
			Driver "opentegra"
		EndSection

	/usr/share/X11/xorg.conf.d/tegra.conf:

		Section "OutputClass"
			MatchPlatformDriver "tegra"
			Driver "tegra"
		EndSection

Since 'o' < 't', opentegra.conf will apply first and the order of
modules to be probed would be:

	1. /usr/lib/xorg/modules/drivers/opentegra_drv.so
	2. /usr/lib/xorg/modules/drivers/tegra_drv.so

Which I think would be as good a sensible default as any. Whoever wants
to override that default could still provide an explicit xorg.conf file
for their device.

Such a scheme would also easily allow distributions to provide their own
defaults by installing in this order:

	/usr/share/X11/xorg.conf.d/10-tegra.conf
	/usr/share/X11/xorg.conf.d/20-opentegra.conf

One big advantage of this approach is obviously that the server doesn't
need patching for every new driver. So it does indeed seem to be a
solution preferable to the static table within the X server. I'll have
a stab at it.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20140213/9967be71/attachment-0001.pgp>


More information about the xorg-devel mailing list