nv: improve KMS detection
PATCH 1/1 nv: improve KMS detection
1) DRICreatePCIBusID belongs to xserver dri module, so when it's unavailable we can't format string for drmCheckModesettingSupported. (This situation happened to me with KMS enabled and dri module moved somewhere else by Gentoo's "eselect opengl set nvidia" switcher) Open code DRICreatePCIBusID to drop dri dependency.
2) Once we dropped dependency on dri module (which linked to libdrm), we have to link directly to libdrm.
--- src/Makefile.am | 2 +- src/nv_driver.c | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-)
src/Makefile.am +1 -1
@@ -25,7 +25,7 @@ # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. AM_CFLAGS = @XMODES_CFLAGS@ @XORG_CFLAGS@ $(LIBDRM_CFLAGS) nv_drv_la_LTLIBRARIES = nv_drv.la -nv_drv_la_LDFLAGS = -module -avoid-version +nv_drv_la_LDFLAGS = -module -avoid-version $(LIBDRM_LIBS) nv_drv_ladir = @moduledir@/drivers nv_drv_la_SOURCES = $(nv_sources) $(riva_sources) $(g80_sources)
src/nv_driver.c +3 -8
@@ -836,18 +836,13 @@ NVIsSupported(CARD32 id) }#ifdef HAVE_KMS -static Bool NVKernelModesettingEnabled (struct pci_device *device) +static Bool NVKernelModesettingEnabled (struct pci_device *dev) { -char *busIdString; +char busIdString[20 ];int ret; -if (!xf86LoaderCheckSymbol ("DRICreatePCIBusID" )) -return FALSE; - - busIdString =DRICreatePCIBusID (device); - +snprintf (busIdString,20 ,"pci:%04x:%02x:%02x.%d" , dev->domain, dev->bus, dev->dev, dev->func); ret =drmCheckModesettingSupported (busIdString); -xfree (busIdString);return (ret ==0 ); }
Signature · 1 line
1.7.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 7 lines · Marcin Slusarz
1) DRICreatePCIBusID belongs to xserver dri module, so when it's unavailable we can't format string for drmCheckModesettingSupported. (This situation happened to me with KMS enabled and dri module moved somewhere else by Gentoo's "eselect opengl set nvidia" switcher) Open code DRICreatePCIBusID to drop dri dependency.
2) Once we dropped dependency on dri module (which linked to libdrm), we have to link directly to libdrm.
An alternative, which we use in Fedora for nv/vesa is to use pci_device_has_kernel_driver() from libpciaccess.
Ben.
Quoted 46 lines
Signed-off-by Marcin Slusarz <[email protected]>--- src/Makefile.am | 2 +- src/nv_driver.c | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-)src/Makefile.am +1
-1@@ -25,7 +25,7 @@ # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. AM_CFLAGS = @XMODES_CFLAGS@ @XORG_CFLAGS@ $(LIBDRM_CFLAGS) nv_drv_la_LTLIBRARIES = nv_drv.la -nv_drv_la_LDFLAGS = -module -avoid-version +nv_drv_la_LDFLAGS = -module -avoid-version $(LIBDRM_LIBS) nv_drv_ladir = @moduledir@/drivers nv_drv_la_SOURCES = $(nv_sources) $(riva_sources) $(g80_sources)src/nv_driver.c +3
-8@@ -836,18 +836,13 @@ NVIsSupported(CARD32 id) }#ifdef HAVE_KMS -static Bool NVKernelModesettingEnabled (struct pci_device *device) +static Bool NVKernelModesettingEnabled (struct pci_device *dev) { -char *busIdString; +char busIdString[20 ];int ret; -if (!xf86LoaderCheckSymbol ("DRICreatePCIBusID" )) -return FALSE; - - busIdString =DRICreatePCIBusID (device); - +snprintf (busIdString,20 ,"pci:%04x:%02x:%02x.%d" , dev->domain, dev->bus, dev->dev, dev->func); ret =drmCheckModesettingSupported (busIdString); -xfree (busIdString);return (ret ==0 ); }
Quoted 10 lines · Ben Skeggs
Quoted 7 lines · Marcin Slusarz
1) DRICreatePCIBusID belongs to xserver dri module, so when it's unavailable we can't format string for drmCheckModesettingSupported. (This situation happened to me with KMS enabled and dri module moved somewhere else by Gentoo's "eselect opengl set nvidia" switcher) Open code DRICreatePCIBusID to drop dri dependency.
2) Once we dropped dependency on dri module (which linked to libdrm), we have to link directly to libdrm.An alternative, which we use in Fedora for nv/vesa is to use
pci_device_has_kernel_driver()from libpciaccess.
That seems better than open-coding it, and avoids a dependency on libdrm which is nice.
A message that is not in the archive (sent off-list or not yet received): 20100528184517.GA12408-J3EY2hv0KmgMOYszX5p1ytBPR1lH4CV8@public.gmane.org
Quoted 9 lines · Aaron Plattner
Quoted 8 lines · Ben Skeggs
Quoted 7 lines · Marcin Slusarz
1) DRICreatePCIBusID belongs to xserver dri module, so when it's unavailable we can't format string for drmCheckModesettingSupported. (This situation happened to me with KMS enabled and dri module moved somewhere else by Gentoo's "eselect opengl set nvidia" switcher) Open code DRICreatePCIBusID to drop dri dependency.
2) Once we dropped dependency on dri module (which linked to libdrm), we have to link directly to libdrm.
Quoted 5 lines
Quoted 2 lines
An alternative, which we use in Fedora for nv/vesa is to use
pci_device_has_kernel_driver()from libpciaccess.That seems better than open-coding it, and avoids a dependency on libdrm which is nice.
Well, you are trading one dependency for other. It doesn't really matter... Ben, are you going to send your patch to Aaron?
Marcin
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 10 lines · Marcin Slusarz
Quoted 9 lines · Aaron Plattner
Quoted 8 lines · Ben Skeggs
Quoted 7 lines · Marcin Slusarz
1) DRICreatePCIBusID belongs to xserver dri module, so when it's unavailable we can't format string for drmCheckModesettingSupported. (This situation happened to me with KMS enabled and dri module moved somewhere else by Gentoo's "eselect opengl set nvidia" switcher) Open code DRICreatePCIBusID to drop dri dependency.
2) Once we dropped dependency on dri module (which linked to libdrm), we have to link directly to libdrm.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
An alternative, which we use in Fedora for nv/vesa is to use
pci_device_has_kernel_driver()from libpciaccess.That seems better than open-coding it, and avoids a dependency on libdrm which is nice.
Well, you are trading one dependency for other. It doesn't really matter... Ben, are you going to send your patch to Aaron?
Yeah, but the server already has a dependency on libpciaccess, while the libdrm dependency is just for a module, and I think might be optional (I haven't kept up with the dri2 patches on the list).
-- Aaron
A message that is not in the archive (sent off-list or not yet received): 20100602190752.GA17877-J3EY2hv0KmgMOYszX5p1ytBPR1lH4CV8@public.gmane.org
Quoted 17 lines · Aaron Plattner
Quoted 16 lines · Marcin Slusarz
Quoted 14 lines · Aaron Plattner
Quoted 10 lines · Ben Skeggs
Quoted 7 lines · Marcin Slusarz
1) DRICreatePCIBusID belongs to xserver dri module, so when it's unavailable we can't format string for drmCheckModesettingSupported. (This situation happened to me with KMS enabled and dri module moved somewhere else by Gentoo's "eselect opengl set nvidia" switcher) Open code DRICreatePCIBusID to drop dri dependency.
2) Once we dropped dependency on dri module (which linked to libdrm), we have to link directly to libdrm.An alternative, which we use in Fedora for nv/vesa is to use
pci_device_has_kernel_driver()from libpciaccess.That seems better than open-coding it, and avoids a dependency on libdrm which is nice.
Quoted 6 lines
Quoted 2 lines
Well, you are trading one dependency for other. It doesn't really matter... Ben, are you going to send your patch to Aaron?
Yeah, but the server already has a dependency on libpciaccess, while the libdrm dependency is just for a module, and I think might be optional (I haven't kept up with the dri2 patches on the list).
Exactly. Patch is attached, but it was readily available in Fedora CVS anyway.
Ben.
Quoted 2 lines
-- Aaron
From ee544c2b11ab327abab6e205425e6eafe961de2e Mon Sep 17 00:00:00 2001
From: Ben Skeggs <[email protected]>
Date: Fri, 28 Aug 2009 09:43:16 +1000
Subject: [PATCH] nv: refuse to load if there's a kernel driver bound to the device already
--- src/nv_driver.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
src/nv_driver.c +6 -0
@@ -780,6 +780,12 @@ NVPciProbe(DriverPtr drv, int entity, struct pci_device *dev, intptr_t data) NVGetPCIXpressChip(dev) : dev->vendor_id << 16 | dev->device_id;const char *name =xf86TokenToString (NVKnownChipsets, id); +if (pci_device_has_kernel_driver (dev)) { +ErrorF ("The PCI device has a kernel module claiming it.\n" ); +ErrorF ("This driver cannot operate until it has been unloaded\n" ); +return FALSE; + } +if (dev->vendor_id ==PCI_VENDOR_NVIDIA && !name && !NVIsSupported (id) && !NVIsG80 (id)) {/* See if pci.ids knows what the heck this thing is */
Signature · 1 line
1.6.4
_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau