Bugzilla – Attachment 58769 Details for
Bug 132308
X server crashes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
IDP Log In
|
Forgot Password
[patch]
Alternative patch
diff.xorg_pcinew (text/plain), 9.72 KB, created by
Egbert Eich
on 2005-11-25 17:15:47 UTC
(
hide
)
Description:
Alternative patch
Filename:
MIME Type:
Creator:
Egbert Eich
Created:
2005-11-25 17:15:47 UTC
Size:
9.72 KB
patch
obsolete
>Index: Pci.c >=================================================================== >RCS file: /home/eich/cvs/xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c,v >retrieving revision 1.1.1.60 >diff -u -r1.1.1.60 Pci.c >--- Pci.c 25 Nov 2005 10:05:28 -0000 1.1.1.60 >+++ Pci.c 25 Nov 2005 17:11:30 -0000 >@@ -597,6 +597,16 @@ > return bits; > } > >+void >+pciInfoFromTag(PCITAG tag, int *domainnum, int *busnum, >+ int *devnum, int *funcnum) >+{ >+ *domainnum = PCI_DOM_FROM_TAG(tag); >+ *busnum = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(tag)); >+ *devnum = PCI_DEV_FROM_TAG(tag); >+ *funcnum = PCI_FUNC_FROM_TAG(tag); >+} >+ > PCITAG > pciTag(int busnum, int devnum, int funcnum) > { >Index: Pci.h >=================================================================== >RCS file: /home/eich/cvs/xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h,v >retrieving revision 1.1.1.37 >diff -u -r1.1.1.37 Pci.h >--- Pci.h 25 Nov 2005 10:05:28 -0000 1.1.1.37 >+++ Pci.h 25 Nov 2005 17:11:30 -0000 >@@ -120,7 +120,7 @@ > /* by xf86scanpci */ > #if defined(sun) && defined(SVR4) && defined(sparc) > # define MAX_PCI_BUSES 4096 /* Max number of PCI buses */ >-#elif defined(__alpha__) && defined (linux) >+#elif (defined(__alpha__) || defined(__ia64__)) && defined (linux) > # define MAX_PCI_DOMAINS 512 > # define PCI_DOM_MASK 0x01fful > # define MAX_PCI_BUSES (MAX_PCI_DOMAINS*256) /* 256 per domain */ >@@ -259,7 +259,7 @@ > # endif > #elif defined(__ia64__) > # if defined(linux) >-# define ARCH_PCI_INIT linuxPciInit >+# define ARCH_PCI_INIT ia64linuxPciInit > # define INCLUDE_XF86_MAP_PCI_MEM > # elif defined(FreeBSD) > # define ARCH_PCI_INIT freebsdPciInit >Index: altixPCI.c >=================================================================== >RCS file: /home/eich/cvs/xc/programs/Xserver/hw/xfree86/os-support/bus/altixPCI.c,v >retrieving revision 1.1.1.2 >diff -u -r1.1.1.2 altixPCI.c >--- altixPCI.c 13 Sep 2005 10:31:29 -0000 1.1.1.2 >+++ altixPCI.c 25 Nov 2005 17:11:30 -0000 >@@ -41,13 +41,14 @@ > static void get_bridge_info(pciBusInfo_t *bus_info, pciDevice *pdev) > { > unsigned int parent_segnum, segnum = PCI_DOM_FROM_TAG(pdev->tag); >- unsigned int parent_busnum, busnum = pdev->busnum; >+ unsigned int parent_busnum, parent_nodombus, busnum = pdev->busnum; >+ unsigned int nodombus = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(pdev->tag)); > char bridge_path[] = "/sys/class/pci_bus/0000:00/bridge"; > char bridge_target[] = "../../../devices/pci0000:00"; > > /* Path to this device's bridge */ > sprintf(bridge_path, "/sys/class/pci_bus/%04x:%02x/bridge", segnum, >- busnum); >+ nodombus); > > if (readlink(bridge_path, bridge_target, strlen(bridge_target)) < 0) { > perror("failed to dereference bridge link"); >@@ -56,7 +57,9 @@ > } > > sscanf(bridge_target, "../../../devices/pci%04x:%02x", &parent_segnum, >- &parent_busnum); >+ &parent_nodombus); >+ >+ parent_busnum = PCI_MAKE_BUS(parent_segnum, parent_nodombus); > > /* > * If there's no bridge or the bridge points to the device, use >Index: linuxPci.c >=================================================================== >RCS file: /home/eich/cvs/xc/programs/Xserver/hw/xfree86/os-support/bus/linuxPci.c,v >retrieving revision 1.1.1.12 >diff -u -r1.1.1.12 linuxPci.c >--- linuxPci.c 25 Nov 2005 10:05:28 -0000 1.1.1.12 >+++ linuxPci.c 25 Nov 2005 17:11:30 -0000 >@@ -55,6 +55,7 @@ > #include "xf86Priv.h" > #include "xf86_OSlib.h" > #include "Pci.h" >+#include <dirent.h> > > /* > * linux platform specific PCI access functions -- using /proc/bus/pci >@@ -130,34 +131,49 @@ > static int > linuxPciOpenFile(PCITAG tag, Bool write) > { >- static int lbus,ldev,lfunc,fd = -1,is_write = 0; >- int bus, dev, func; >+ static int ldomain, lbus,ldev,lfunc,fd = -1,is_write = 0; >+ static Bool domain_support = TRUE; >+ int domain, bus, dev, func; > char file[32]; > struct stat ignored; > >- bus = PCI_BUS_FROM_TAG(tag); >+ domain = PCI_DOM_FROM_TAG(tag); >+ bus = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(tag)); > dev = PCI_DEV_FROM_TAG(tag); > func = PCI_FUNC_FROM_TAG(tag); >- if (fd == -1 || (write && (!is_write)) >- || bus != lbus || dev != ldev || func != lfunc) { >- if (fd != -1) >+ >+ if (!domain_support && domain > 0) >+ return -1; >+ >+ if (fd == -1 || (write && (!is_write)) || bus != lbus >+ || dev != ldev || func != lfunc || domain != ldomain) { >+ >+ if (fd != -1) { > close(fd); >+ fd = -1; >+ } > if (bus < 256) { >- sprintf(file,"/proc/bus/pci/%02x",bus); >- if (stat(file, &ignored) < 0) >- sprintf(file, "/proc/bus/pci/0000:%02x/%02x.%1x", >- bus, dev, func); >- else >- sprintf(file, "/proc/bus/pci/%02x/%02x.%1x", >- bus, dev, func); >+ sprintf(file, "/proc/bus/pci/%04x:%02x", domain, bus); >+ if (stat(file, &ignored) < 0) { >+ domain_support = FALSE; >+ if (domain == 0) >+ sprintf(file, "/proc/bus/pci/%02x/%02x.%1x", >+ bus, dev, func); >+ else goto bail; >+ } else >+ sprintf(file, "/proc/bus/pci/%04x:%02x/%02x.%1x", >+ domain, bus, dev, func); > } else { >- sprintf(file,"/proc/bus/pci/%04x",bus); >- if (stat(file, &ignored) < 0) >- sprintf(file, "/proc/bus/pci/0000:%04x/%02x.%1x", >- bus, dev, func); >- else >- sprintf(file, "/proc/bus/pci/%04x/%02x.%1x", >- bus, dev, func); >+ sprintf(file, "/proc/bus/pci/%04x:%02x", domain, bus); >+ if (stat(file, &ignored) < 0) { >+ domain_support = FALSE; >+ if (domain == 0) >+ sprintf(file, "/proc/bus/pci/%04x/%02x.%1x", >+ bus, dev, func); >+ else goto bail; >+ } else >+ sprintf(file, "/proc/bus/pci/%04x:%02x/%02x.%1x", >+ domain, bus, dev, func); > } > if (write) { > fd = open(file,O_RDWR); >@@ -171,7 +187,8 @@ > fd = open(file,O_RDONLY); > is_write = FALSE; > } >- >+ bail: >+ ldomain = domain; > lbus = bus; > ldev = dev; > lfunc = func; >@@ -724,7 +741,7 @@ > struct stat st; > > dom = PCI_DOM_FROM_TAG(Tag); >- bus = PCI_BUS_FROM_TAG(Tag); >+ bus = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(Tag)); > dev = PCI_DEV_FROM_TAG(Tag); > func = PCI_FUNC_FROM_TAG(Tag); > sprintf(file, "/sys/devices/pci%04x:%02x/%04x:%02x:%02x.%1x/rom", >@@ -892,3 +909,112 @@ > } > > #endif /* !INCLUDE_XF86_NO_DOMAIN */ >+ >+#ifdef __ia64__ >+static PCITAG ia64linuxPciFindFirst(void); >+static PCITAG ia64linuxPciFindNext(void); >+ >+ >+void >+ia64linuxPciInit() >+{ >+ struct stat st; >+ /* Be a little paranoid here and only use this code for Altix systems. >+ * It is generic, so it should work on any system, but depends on >+ * /proc/bus/pci entries for each domain/bus combination. Altix is >+ * guaranteed a recent enough kernel to have them. >+ */ >+ if (stat("/proc/sgi_sn/licenseID", &st)) { >+ return linuxPciInit(); >+ } >+ if ((xf86Info.pciFlags == PCIForceNone) || >+ (-1 == stat("/proc/bus/pci", &st))) { >+ /* when using this as default for all linux architectures, >+ we'll need a fallback for 2.0 kernels here */ >+ return; >+ } >+ pciNumBuses = 1; >+ pciBusInfo[0] = &linuxPci0; >+ pciFindFirstFP = ia64linuxPciFindFirst; >+ pciFindNextFP = ia64linuxPciFindNext; >+} >+ >+static DIR *busdomdir; >+static DIR *devdir; >+ >+static PCITAG >+ia64linuxPciFindFirst(void) >+{ >+ busdomdir = opendir("/proc/bus/pci"); >+ devdir = NULL; >+ >+ return ia64linuxPciFindNext(); >+} >+ >+static struct dirent *getnextbus(int *domain, int *bus) >+{ >+ struct dirent *entry; >+ int dombus; >+ >+ for (;;) { >+ entry = readdir(busdomdir); >+ if (entry == NULL) { >+ *domain = 0; >+ *bus = 0; >+ closedir(busdomdir); >+ return NULL; >+ } >+ if (sscanf(entry->d_name, "%04x:%02x", domain, bus) != 2) >+ continue; >+ dombus = PCI_MAKE_BUS(*domain, *bus); >+ >+ if (pciNumBuses <= dombus) >+ pciNumBuses = dombus + 1; >+ if (!pciBusInfo[dombus]) { >+ pciBusInfo[dombus] = xnfalloc(sizeof(pciBusInfo_t)); >+ *pciBusInfo[dombus] = *pciBusInfo[0]; >+ } >+ >+ return entry; >+ } >+} >+ >+static PCITAG >+ia64linuxPciFindNext(void) >+{ >+ struct dirent *entry; >+ char file[40]; >+ static int bus, dev, func, domain; >+ PCITAG pciDeviceTag; >+ CARD32 devid; >+ >+ for (;;) { >+ if (devdir == NULL) { >+ entry = getnextbus(&domain, &bus); >+ if (!entry) >+ return PCI_NOT_FOUND; >+ snprintf(file, 40, "/proc/bus/pci/%s", entry->d_name); >+ devdir = opendir(file); >+ if (!devdir) >+ return PCI_NOT_FOUND; >+ >+ } >+ >+ entry = readdir(devdir); >+ >+ if (entry == NULL) { >+ closedir(devdir); >+ devdir = NULL; >+ continue; >+ } >+ >+ if (sscanf(entry->d_name, "%02x . %01x", &dev, &func) == 2) { >+ pciDeviceTag = PCI_MAKE_TAG(PCI_MAKE_BUS(domain, bus), dev, func); >+ devid = pciReadLong(pciDeviceTag, PCI_ID_REG); >+ if ((devid & pciDevidMask) == pciDevid) >+ /* Yes - Return it. Otherwise, next device */ >+ return pciDeviceTag; >+ } >+ } >+} >+#endif >Index: xf86Pci.h >=================================================================== >RCS file: /home/eich/cvs/xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h,v >retrieving revision 1.1.1.33 >diff -u -r1.1.1.33 xf86Pci.h >--- xf86Pci.h 27 Apr 2005 16:00:07 -0000 1.1.1.33 >+++ xf86Pci.h 25 Nov 2005 17:11:30 -0000 >@@ -768,6 +768,8 @@ > ADDRESS pciBusAddrToHostAddr(PCITAG tag, PciAddrType type, ADDRESS addr); > ADDRESS pciHostAddrToBusAddr(PCITAG tag, PciAddrType type, ADDRESS addr); > PCITAG pciTag(int busnum, int devnum, int funcnum); >+void pciInfoFromTag(PCITAG tag, int *domainnum, >+ int *busnum, int *devnum, int *funcnum); > int pciGetBaseSize(PCITAG tag, int indx, Bool destructive, Bool *min); > CARD32 pciCheckForBrokenBase(PCITAG tag,int basereg); > pointer xf86MapPciMem(int ScreenNum, int Flags, PCITAG Tag,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 132308
:
56480
|
56955
|
58767
|
58769
|
58776
|
58825
|
58912
|
63024