[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#246782: Failure to find video card with X



Package: xserver-xfree86
Version: 4.3.0-7

The code in xc/programs/Xserver/xfree86/hw/xfree86/os-support/bus/linuxPci.c
doesn't handle PCI Domains, so the X server fails to find the entry for the
video card under /proc.

This problem manifests itself with kernel 2.6.x.

Here's a simple patch to fix it, it first tries the old-style /proc/bus/pci
access, then tries to access it with the PCI Domain information as well.

I've only tested this on an Ultra 5 workstation with the testing distro.

---- begin patch ----
--- xc/programs/Xserver/hw/xfree86/os-support/bus/linuxPci.c.orig	2004-04-30 22:07:52.572277727 -0700
+++ xc/programs/Xserver/hw/xfree86/os-support/bus/linuxPci.c	2004-04-30 22:13:59.599136716 -0700
@@ -101,23 +101,34 @@
 static int
 linuxPciOpenFile(PCITAG tag)
 {
-	static int	lbus,ldev,lfunc,fd = -1;
-	int		bus, dev, func;
-	char		file[32];
+	static int	lbus,ldev,ldom,lfunc,fd = -1;
+	int		bus, dev, dom, func;
+	char		file[32], file2[32];
 
 	bus  = PCI_BUS_FROM_TAG(tag);
 	dev  = PCI_DEV_FROM_TAG(tag);
+	dev  = PCI_DOM_FROM_TAG(tag);
 	func = PCI_FUNC_FROM_TAG(tag);
-	if (fd == -1 || bus != lbus || dev != ldev || func != lfunc) {
+	if (fd == -1 || bus != lbus || dev != ldev || dom != ldom ||
+	    func != lfunc) {
 		if (fd != -1)
 			close(fd);
-		if (bus < 256)
+		if (bus < 256) {
 			sprintf(file, "/proc/bus/pci/%02x/%02x.%1x",
 				bus, dev, func);
-		else
+			sprintf(file2, "/proc/bus/pci/%04x:%02x/%02x.%1x",
+				dom, bus, dom, dev, func);
+		} else {
 			sprintf(file, "/proc/bus/pci/%04x/%02x.%1x",
 				bus, dev, func);
+			sprintf(file2, "/proc/bus/pci/%04x:%04x/%02x.%1x",
+				dom, bus, dev, func);
+		}
 		fd = open(file,O_RDWR);
+		if(fd == -1) {
+			fd = open(file2,O_RDWR);
+			ldom  = dom;
+		}
 		lbus  = bus;
 		ldev  = dev;
 		lfunc = func;
---- end patch ----

-- DN
Daniel



Reply to: