/[gentoo-x86]/x11-base/xorg-server/files/1.0.2-fix-rom-read-dualhead.patch
Gentoo

Contents of /x11-base/xorg-server/files/1.0.2-fix-rom-read-dualhead.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Wed Jan 24 06:34:22 2007 UTC (7 years, 2 months ago) by dberkholz
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
Stop supporting Xorg 7.0.
(Portage version: 2.1.2)
 (Unsigned Manifest commit)

1 https://bugs.freedesktop.org/show_bug.cgi?id=6751
2
3 X.org breaks on newer Linux kernels as it re-writes BARs behind the kernels back
4 when attempting to read the ROMs, this causes crashes and hangs on dual-card
5 systems.
6
7 --- hw/xfree86/os-support/bus/Pci.c 2005-11-08 11:04:56.000000000 -0800
8 +++ hw/xfree86/os-support/bus/Pci.c 2006-06-29 15:48:37.000000000 -0700
9 @@ -233,6 +233,8 @@
10
11 static pciConfigPtr pci_devp[MAX_PCI_DEVICES + 1] = {NULL, };
12
13 +static int (*pciOSHandleBIOS)(PCITAG Tag, int basereg, unsigned char *buf, int len);
14 +
15 /*
16 * Platform specific PCI function pointers.
17 *
18 @@ -266,6 +268,11 @@
19 #endif
20 }
21
22 +void pciSetOSBIOSPtr(int (*bios_fn)(PCITAG Tag, int basereg, unsigned char * buf, int len))
23 +{
24 + pciOSHandleBIOS = bios_fn;
25 +}
26 +
27 PCITAG
28 pciFindFirst(CARD32 id, CARD32 mask)
29 {
30 @@ -1347,6 +1354,13 @@
31 PCITAG *pTag;
32 int i;
33
34 + /* fall back to the old code if the OS code fails */
35 + if (pciOSHandleBIOS) {
36 + n = pciOSHandleBIOS(Tag, basereg, func, ptr);
37 + if (n)
38 + return n;
39 + }
40 +
41 n = handlePciBIOS(Tag,basereg,func,ptr);
42 if (n)
43 return n;
44 --- hw/xfree86/os-support/bus/Pci.h 2005-11-08 11:04:56.000000000 -0800
45 +++ hw/xfree86/os-support/bus/Pci.h 2006-06-29 15:43:50.000000000 -0700
46 @@ -431,6 +431,7 @@
47 Bool pciMfDev(int, int);
48 ADDRESS pciAddrNOOP(PCITAG tag, PciAddrType type, ADDRESS);
49
50 +extern void pciSetOSBIOSPtr(int (*bios_fn)(PCITAG Tag, int basereg, unsigned char * buf, int len));
51 extern PCITAG (*pciFindFirstFP)(void);
52 extern PCITAG (*pciFindNextFP)(void);
53
54 --- hw/xfree86/os-support/bus/linuxPci.c 2005-11-08 11:04:56.000000000 -0800
55 +++ hw/xfree86/os-support/bus/linuxPci.c 2006-06-29 15:43:50.000000000 -0700
56 @@ -73,6 +73,7 @@
57 static void linuxPciCfgWriteByte(PCITAG tag, int off, CARD8 val);
58 static CARD16 linuxPciCfgReadWord(PCITAG tag, int off);
59 static void linuxPciCfgWriteWord(PCITAG tag, int off, CARD16 val);
60 +static int linuxPciHandleBIOS(PCITAG Tag, int basereg, unsigned char *buf, int len);
61
62 static pciBusFuncs_t linuxFuncs0 = {
63 /* pciReadLong */ linuxPciCfgRead,
64 @@ -125,6 +126,7 @@
65 pciBusInfo[0] = &linuxPci0;
66 pciFindFirstFP = pciGenFindFirst;
67 pciFindNextFP = pciGenFindNext;
68 + pciSetOSBIOSPtr(linuxPciHandleBIOS);
69 }
70
71 static int
72 @@ -892,3 +894,44 @@
73 }
74
75 #endif /* !INCLUDE_XF86_NO_DOMAIN */
76 +
77 +int linuxPciHandleBIOS(PCITAG Tag, int basereg, unsigned char *buf, int len)
78 +{
79 + unsigned int dom, bus, dev, func;
80 + unsigned int fd;
81 + char file[256];
82 + struct stat st;
83 + int ret;
84 + int sofar = 0;
85 +
86 + dom = PCI_DOM_FROM_TAG(Tag);
87 + bus = PCI_BUS_FROM_TAG(Tag);
88 + dev = PCI_DEV_FROM_TAG(Tag);
89 + func = PCI_FUNC_FROM_TAG(Tag);
90 + sprintf(file, "/sys/bus/pci/devices/%04x:%02x:%02x.%1x/rom",
91 + dom, bus, dev, func);
92 +
93 + if (stat(file, &st) == 0)
94 + {
95 + if ((fd = open(file, O_RDWR)))
96 + basereg = 0x0;
97 +
98 + /* enable the ROM first */
99 + write(fd, "1", 2);
100 + lseek(fd, 0, SEEK_SET);
101 + do {
102 + /* copy the ROM until we hit Len, EOF or read error */
103 + ret = read(fd, buf+sofar, len-sofar);
104 + if (ret <= 0)
105 + break;
106 + sofar += ret;
107 + } while (sofar < len);
108 +
109 + write(fd, "0", 2);
110 + close(fd);
111 + if (sofar < len)
112 + xf86MsgVerb(X_INFO, 3, "Attempted to read BIOS %dKB from %s: got %dKB\n", len/1024, file, sofar/1024);
113 + return sofar;
114 + }
115 + return 0;
116 +}

  ViewVC Help
Powered by ViewVC 1.1.20