Bug#411641: xorg-server: Xorg won't allow to have more than one isolateDevice
Package: xorg-server
Severity: normal
Using isolateDevice limits the video cards that X will touch when doing a pci
analysis. This allows to have different X servers in different video cards, that's
mostly used for multiseat. I wanted to have a Xinerama X (with two video cards)
and a secondary seat X. But isolateDevice would not allow to "isolate" two
video cards, so the Xinerama+multiseat was imposible.
The patch attached changes the xf86IsolateDevice to list of PCIids so it's
posible to have more than one isolated device per X server.
-- System Information:
Debian Release: 4.0
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-4-amd64
Locale: LANG=es_AR.UTF-8, LC_CTYPE=es_AR.UTF-8 (charmap=UTF-8)
diff -ruNa xorg-server-1.1.1/hw/xfree86/common/xf86Config.c xorg-server-1.1.1.new/hw/xfree86/common/xf86Config.c
--- xorg-server-1.1.1/hw/xfree86/common/xf86Config.c 2006-07-05 15:38:47.000000000 -0300
+++ xorg-server-1.1.1.new/hw/xfree86/common/xf86Config.c 2007-02-19 21:12:27.000000000 -0300
@@ -2740,15 +2740,48 @@
}
if (scanptr) {
int bus, device, func;
- if (strncmp(scanptr, "PCI:", 4) != 0) {
- xf86Msg(X_WARNING, "Bus types other than PCI not yet isolable.\n"
- "\tIgnoring IsolateDevice option.\n");
- } else if (sscanf(scanptr, "PCI:%d:%d:%d", &bus, &device, &func) == 3) {
- xf86IsolateDevice.bus = bus;
- xf86IsolateDevice.device = device;
- xf86IsolateDevice.func = func;
- xf86Msg(X_INFO,
+ int pos = 0, npci = 0, len;
+ /* num of allocked PCIids */
+ if (xf86IsolateDevice == NULL ) {
+ npci = 0;
+ } else {
+ while ( ! ( (xf86IsolateDevice[npci].bus == 0) &&
+ (xf86IsolateDevice[npci].device == 0) &&
+ (xf86IsolateDevice[npci].func == 0) ) ) {
+ npci++;
+ }
+ npci++;
+ }
+
+ len = strlen(scanptr);
+ while ( pos < len ) {
+ if (strncmp(scanptr+pos, "PCI:", 4)) {
+ xf86Msg(X_WARNING,
+ "Bus types other than PCI not yet isolable.\n"
+ "\tIgnoring IsolateDevice option.\n");
+ }
+ if ( sscanf(scanptr+pos,
+ "PCI:%d:%d:%d", &bus, &device, &func) == 3) {
+ if (npci == 0) {
+ npci = 2;
+ xf86IsolateDevice = malloc(npci * sizeof(PciBusId));
+ xf86IsolateDevice = memset((void *) xf86IsolateDevice,
+ 0, npci * sizeof(PciBusId));
+ } else {
+ npci++;
+ xf86IsolateDevice = realloc(xf86IsolateDevice,
+ npci * sizeof(PciBusId));
+ xf86IsolateDevice = memset((void *) xf86IsolateDevice +
+ ( (npci - 2) * sizeof(PciBusId)),
+ 0, 2 * sizeof(PciBusId));
+ }
+ xf86IsolateDevice[npci - 1].bus = bus;
+ xf86IsolateDevice[npci - 1].device = device;
+ xf86IsolateDevice[npci - 1].func = func;
+ } else {
+ xf86Msg(X_INFO,
"Isolating PCI bus \"%d:%d:%d\"\n", bus, device, func);
+ }
}
}
diff -ruNa xorg-server-1.1.1/hw/xfree86/common/xf86Globals.c xorg-server-1.1.1.new/hw/xfree86/common/xf86Globals.c
--- xorg-server-1.1.1/hw/xfree86/common/xf86Globals.c 2006-07-05 15:38:47.000000000 -0300
+++ xorg-server-1.1.1.new/hw/xfree86/common/xf86Globals.c 2007-02-19 21:06:45.000000000 -0300
@@ -246,7 +246,7 @@
RootWinPropPtr *xf86RegisteredPropertiesTable = NULL;
_X_EXPORT Bool xf86inSuspend = FALSE;
Bool xorgHWAccess = FALSE;
-PciBusId xf86IsolateDevice;
+PciBusId *xf86IsolateDevice = NULL;
#ifdef DLOPEN_HACK
/*
diff -ruNa xorg-server-1.1.1/hw/xfree86/common/xf86Init.c xorg-server-1.1.1.new/hw/xfree86/common/xf86Init.c
--- xorg-server-1.1.1/hw/xfree86/common/xf86Init.c 2006-07-05 21:42:03.000000000 -0300
+++ xorg-server-1.1.1.new/hw/xfree86/common/xf86Init.c 2007-02-19 21:15:22.000000000 -0300
@@ -1690,18 +1690,55 @@
if (!strcmp(argv[i], "-isolateDevice"))
{
int bus, device, func;
+ int pos = 0, npci = 0, len;
CHECK_FOR_REQUIRED_ARGUMENT();
- if (strncmp(argv[++i], "PCI:", 4)) {
- FatalError("Bus types other than PCI not yet isolable\n");
- }
- if (sscanf(argv[i], "PCI:%d:%d:%d", &bus, &device, &func) == 3) {
- xf86IsolateDevice.bus = bus;
- xf86IsolateDevice.device = device;
- xf86IsolateDevice.func = func;
- return 2;
+ /* num of allocked PCIids */
+ if (xf86IsolateDevice == NULL ) {
+ npci = 0;
} else {
- FatalError("Invalid isolated device specification\n");
+ while ( ! ( (xf86IsolateDevice[npci].bus == 0) &&
+ (xf86IsolateDevice[npci].device == 0) &&
+ (xf86IsolateDevice[npci].func == 0) ) ) {
+ npci++;
+ }
+ npci++;
+ }
+
+ len = strlen(argv[++i]);
+ while ( pos < len ) {
+ char *commaPos;
+ if (strncmp(argv[i]+pos, "PCI:", 4)) {
+ FatalError("Bus types other than PCI not yet isolable\n");
+ }
+ if (sscanf(argv[i]+pos, "PCI:%d:%d:%d", &bus, &device, &func) == 3) {
+ if (npci == 0) {
+ npci = 2;
+ xf86IsolateDevice = malloc(npci * sizeof(PciBusId));
+ xf86IsolateDevice = memset((void *) xf86IsolateDevice,
+ 0, npci * sizeof(PciBusId));
+ } else {
+ npci++;
+ xf86IsolateDevice = realloc(xf86IsolateDevice,
+ npci * sizeof(PciBusId));
+ xf86IsolateDevice = memset((void *) xf86IsolateDevice +
+ ( (npci - 2) * sizeof(PciBusId)),
+ 0, 2 * sizeof(PciBusId));
+ }
+ xf86IsolateDevice[npci - 1].bus = bus;
+ xf86IsolateDevice[npci - 1].device = device;
+ xf86IsolateDevice[npci - 1].func = func;
+
+ } else {
+ FatalError("Invalid isolated device specification\n");
+ }
+ commaPos = strchr(argv[i]+pos,',');
+ if ( commaPos == NULL ) {
+ pos = len;
+ } else {
+ pos = (long) commaPos - (long) argv[i] + 1;
+ }
}
+ if (npci > 0) return 2;
}
/* OS-specific processing */
return xf86ProcessArgument(argc, argv, i);
diff -ruNa xorg-server-1.1.1/hw/xfree86/common/xf86pciBus.c xorg-server-1.1.1.new/hw/xfree86/common/xf86pciBus.c
--- xorg-server-1.1.1/hw/xfree86/common/xf86pciBus.c 2006-07-05 15:31:40.000000000 -0300
+++ xorg-server-1.1.1.new/hw/xfree86/common/xf86pciBus.c 2007-02-19 21:21:25.000000000 -0300
@@ -184,6 +184,27 @@
&& (base1 == 0xffffffff)));
}
+static int
+CheckIsolateDevice(bus, device, func)
+{
+ int pos = 0;
+ if ( xf86IsolateDevice == NULL ) {
+ return 0;
+ }
+
+ while ( (xf86IsolateDevice[pos].bus) ||
+ (xf86IsolateDevice[pos].device) ||
+ (xf86IsolateDevice[pos].func) ) {
+ if ( (xf86IsolateDevice[pos].bus == bus) &&
+ (xf86IsolateDevice[pos].device == device) &&
+ (xf86IsolateDevice[pos].func == func) )
+ return 1;
+ pos++;
+ }
+
+ return 0;
+}
+
static void
FindPCIVideoInfo(void)
{
@@ -193,7 +214,10 @@
pciVideoPtr info;
int DoIsolateDeviceCheck = 0;
- if (xf86IsolateDevice.bus || xf86IsolateDevice.device || xf86IsolateDevice.func)
+ if ( (xf86IsolateDevice != NULL) &&
+ (xf86IsolateDevice[0].bus ||
+ xf86IsolateDevice[0].device ||
+ xf86IsolateDevice[0].func) )
DoIsolateDeviceCheck = 1;
pcrpp = xf86PciInfo = xf86scanpci(0);
@@ -210,9 +234,8 @@
if ( PCIINFOCLASSES(baseclass, subclass) &&
(!DoIsolateDeviceCheck ||
- (xf86IsolateDevice.bus == pcrp->busnum &&
- xf86IsolateDevice.device == pcrp->devnum &&
- xf86IsolateDevice.func == pcrp->funcnum)) ) {
+ CheckIsolateDevice(pcrp->busnum, pcrp->devnum, pcrp->funcnum) )) {
+
num++;
xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo,
sizeof(pciVideoPtr) * (num + 1));
diff -ruNa xorg-server-1.1.1/hw/xfree86/common/xf86Priv.h xorg-server-1.1.1.new/hw/xfree86/common/xf86Priv.h
--- xorg-server-1.1.1/hw/xfree86/common/xf86Priv.h 2006-07-05 15:31:40.000000000 -0300
+++ xorg-server-1.1.1.new/hw/xfree86/common/xf86Priv.h 2007-02-19 21:11:05.000000000 -0300
@@ -77,7 +77,7 @@
extern Gamma xf86Gamma;
extern char *xf86ServerName;
extern Bool xf86ShowUnresolved;
-extern PciBusId xf86IsolateDevice;
+extern PciBusId *xf86IsolateDevice;
/* Other parameters */
Reply to: