All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nv: improve KMS detection
@ 2010-05-23 19:46 Marcin Slusarz
       [not found] ` <20100523194645.GA15846-OI9uyE9O0yo@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Marcin Slusarz @ 2010-05-23 19:46 UTC (permalink / raw)
  To: Aaron Plattner
  Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Christopher James Halse Rogers

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.

Signed-off-by: Marcin Slusarz <marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 src/Makefile.am |    2 +-
 src/nv_driver.c |   11 +++--------
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 5d57010..8b23e21 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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)
diff --git a/src/nv_driver.c b/src/nv_driver.c
index e10ae0c..6651cd4 100644
--- a/src/nv_driver.c
+++ b/src/nv_driver.c
@@ -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);
 }
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] nv: improve KMS detection
       [not found] ` <20100523194645.GA15846-OI9uyE9O0yo@public.gmane.org>
@ 2010-05-23 22:37   ` Ben Skeggs
  2010-05-28 18:45     ` Aaron Plattner
  0 siblings, 1 reply; 6+ messages in thread
From: Ben Skeggs @ 2010-05-23 22:37 UTC (permalink / raw)
  To: Marcin Slusarz
  Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	Christopher James Halse Rogers, Aaron Plattner

On Sun, 2010-05-23 at 21:46 +0200, Marcin Slusarz wrote:
> 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.

> 
> Signed-off-by: Marcin Slusarz <marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  src/Makefile.am |    2 +-
>  src/nv_driver.c |   11 +++--------
>  2 files changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 5d57010..8b23e21 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -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)
> diff --git a/src/nv_driver.c b/src/nv_driver.c
> index e10ae0c..6651cd4 100644
> --- a/src/nv_driver.c
> +++ b/src/nv_driver.c
> @@ -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);
>  }

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] nv: improve KMS detection
  2010-05-23 22:37   ` Ben Skeggs
@ 2010-05-28 18:45     ` Aaron Plattner
       [not found]       ` <20100528184517.GA12408-J3EY2hv0KmgMOYszX5p1ytBPR1lH4CV8@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Aaron Plattner @ 2010-05-28 18:45 UTC (permalink / raw)
  To: Ben Skeggs
  Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Christopher James Halse Rogers

On Sun, May 23, 2010 at 03:37:03PM -0700, Ben Skeggs wrote:
> On Sun, 2010-05-23 at 21:46 +0200, Marcin Slusarz wrote:
> > 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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] nv: improve KMS detection
       [not found]       ` <20100528184517.GA12408-J3EY2hv0KmgMOYszX5p1ytBPR1lH4CV8@public.gmane.org>
@ 2010-06-02 16:20         ` Marcin Slusarz
       [not found]           ` <20100602162047.GA2973-OI9uyE9O0yo@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Marcin Slusarz @ 2010-06-02 16:20 UTC (permalink / raw)
  To: Aaron Plattner
  Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Christopher James Halse Rogers

On Fri, May 28, 2010 at 11:45:17AM -0700, Aaron Plattner wrote:
> On Sun, May 23, 2010 at 03:37:03PM -0700, Ben Skeggs wrote:
> > On Sun, 2010-05-23 at 21:46 +0200, Marcin Slusarz wrote:
> > > 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.

Well, you are trading one dependency for other. It doesn't really matter...
Ben, are you going to send your patch to Aaron?

Marcin

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] nv: improve KMS detection
       [not found]           ` <20100602162047.GA2973-OI9uyE9O0yo@public.gmane.org>
@ 2010-06-02 19:07             ` Aaron Plattner
       [not found]               ` <20100602190752.GA17877-J3EY2hv0KmgMOYszX5p1ytBPR1lH4CV8@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Aaron Plattner @ 2010-06-02 19:07 UTC (permalink / raw)
  To: Marcin Slusarz
  Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Christopher James Halse Rogers

On Wed, Jun 02, 2010 at 09:20:47AM -0700, Marcin Slusarz wrote:
> On Fri, May 28, 2010 at 11:45:17AM -0700, Aaron Plattner wrote:
> > On Sun, May 23, 2010 at 03:37:03PM -0700, Ben Skeggs wrote:
> > > On Sun, 2010-05-23 at 21:46 +0200, Marcin Slusarz wrote:
> > > > 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.
> 
> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] nv: improve KMS detection
       [not found]               ` <20100602190752.GA17877-J3EY2hv0KmgMOYszX5p1ytBPR1lH4CV8@public.gmane.org>
@ 2010-06-02 22:19                 ` Ben Skeggs
  0 siblings, 0 replies; 6+ messages in thread
From: Ben Skeggs @ 2010-06-02 22:19 UTC (permalink / raw)
  To: Aaron Plattner
  Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Christopher James Halse Rogers

[-- Attachment #1: Type: text/plain, Size: 1512 bytes --]

On Wed, 2010-06-02 at 12:07 -0700, Aaron Plattner wrote:
> On Wed, Jun 02, 2010 at 09:20:47AM -0700, Marcin Slusarz wrote:
> > On Fri, May 28, 2010 at 11:45:17AM -0700, Aaron Plattner wrote:
> > > On Sun, May 23, 2010 at 03:37:03PM -0700, Ben Skeggs wrote:
> > > > On Sun, 2010-05-23 at 21:46 +0200, Marcin Slusarz wrote:
> > > > > 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.
> > 
> > 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.
> 
> -- Aaron


[-- Attachment #2: nv-refuse-kms.patch --]
[-- Type: text/x-patch, Size: 1107 bytes --]

From ee544c2b11ab327abab6e205425e6eafe961de2e Mon Sep 17 00:00:00 2001
From: Ben Skeggs <bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
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(-)

diff --git a/src/nv_driver.c b/src/nv_driver.c
index a7cf2dc..6f7fc0e 100644
--- a/src/nv_driver.c
+++ b/src/nv_driver.c
@@ -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 */
-- 
1.6.4


[-- Attachment #3: Type: text/plain, Size: 181 bytes --]

_______________________________________________
Nouveau mailing list
Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
http://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-06-02 22:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-23 19:46 [PATCH] nv: improve KMS detection Marcin Slusarz
     [not found] ` <20100523194645.GA15846-OI9uyE9O0yo@public.gmane.org>
2010-05-23 22:37   ` Ben Skeggs
2010-05-28 18:45     ` Aaron Plattner
     [not found]       ` <20100528184517.GA12408-J3EY2hv0KmgMOYszX5p1ytBPR1lH4CV8@public.gmane.org>
2010-06-02 16:20         ` Marcin Slusarz
     [not found]           ` <20100602162047.GA2973-OI9uyE9O0yo@public.gmane.org>
2010-06-02 19:07             ` Aaron Plattner
     [not found]               ` <20100602190752.GA17877-J3EY2hv0KmgMOYszX5p1ytBPR1lH4CV8@public.gmane.org>
2010-06-02 22:19                 ` Ben Skeggs

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.