Bug 197572 - X.Org PCI patches stilll left
Summary: X.Org PCI patches stilll left
Status: RESOLVED FIXED
Alias: None
Product: openSUSE 10.2
Classification: openSUSE
Component: X.Org (show other bugs)
Version: Alpha 2plus
Hardware: Other Other
: P5 - None : Blocker (vote)
Target Milestone: ---
Assignee: Stefan Dirsch
QA Contact: Stefan Dirsch
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 197190
  Show dependency treegraph
 
Reported: 2006-08-07 15:17 UTC by Stefan Dirsch
Modified: 2006-10-09 19:55 UTC (History)
2 users (show)

See Also:
Found By: Other
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
p_pci-domain.diff (18.36 KB, patch)
2006-08-07 15:20 UTC, Stefan Dirsch
Details | Diff
p_pci-ia64.diff (584 bytes, patch)
2006-08-07 15:20 UTC, Stefan Dirsch
Details | Diff
p_pci-ce-x.diff (9.84 KB, patch)
2006-08-07 15:21 UTC, Stefan Dirsch
Details | Diff
p_mappciBIOS_complete.diff (12.84 KB, patch)
2006-08-07 15:21 UTC, Stefan Dirsch
Details | Diff
p_pci-legacy-mmap.diff (1.96 KB, patch)
2006-08-07 15:22 UTC, Stefan Dirsch
Details | Diff
Fixed p_pci-domain.diff (20.36 KB, patch)
2006-08-22 15:53 UTC, Matthias Hopf
Details | Diff
The hunks in bus/Pci.h were reverted. (20.36 KB, patch)
2006-08-23 10:09 UTC, Stefan Dirsch
Details | Diff
fixed compilation (20.37 KB, patch)
2006-08-23 10:23 UTC, Stefan Dirsch
Details | Diff
Hopefully fixed patch (20.75 KB, patch)
2006-08-23 14:43 UTC, Matthias Hopf
Details | Diff
Xorg.0.log with PCI domain patch applied. (17.91 KB, text/plain)
2006-08-23 21:34 UTC, Stefan Dirsch
Details
Xorg.0.log without PCI domain patch (26.63 KB, text/plain)
2006-08-23 21:36 UTC, Stefan Dirsch
Details
Updated patch, using different kernel interface (20.35 KB, patch)
2006-08-24 11:40 UTC, Matthias Hopf
Details | Diff
Updated p_pci-ce-x.diff patch (7.78 KB, patch)
2006-08-24 14:18 UTC, Matthias Hopf
Details | Diff
Final p_pci-domain patch (20.49 KB, patch)
2006-08-25 07:46 UTC, Matthias Hopf
Details | Diff
New final p_pci-domain patch (18.69 KB, patch)
2006-10-09 12:52 UTC, Matthias Hopf
Details | Diff
Additional patch p_enable-altrix.diff (1.14 KB, patch)
2006-10-09 13:16 UTC, Matthias Hopf
Details | Diff
Again - p_enable-altrix.diff (1.63 KB, patch)
2006-10-09 14:36 UTC, Matthias Hopf
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Dirsch 2006-08-07 15:17:58 UTC
I checked all the about 80 patches of our X.Org package for 10.1. I could drop most patches, since these were already upstream or don't make sense any longer, and integrated about 34 patches patches to our new X.Org 7 packages.

5 PCI patches (some of them are somewhat IA64 specific) are still left. I didn't try to integrate them, since they didn't went in easily and I don't have any clue of the Xserver PCI code at all and therefore don't want to break
it completely.

The patches were applied in the following order, which might be important to know!

Patch334:       p_pci-domain.diff
Patch350:       p_pci-ia64.diff
Patch357:       p_pci-ce-x.diff
Patch359:       p_mappciBIOS_complete.diff
%ifarch ia64
Patch364:       p_pci-legacy-mmap.diff
%endif

I'll attach them all.

Some informations I still could find about them in our 'FILES' file:

p_pci-domain.diff [KEEP?]
- fixes Xserver crash on SGI Altix machines (#132308)
p_pci-ia64.diff [KEEP?]
- Mach64 driver bails out on ia64 because it cannot map device
  memory. It turns out that some bogus and unneeded code attempts
  to find the root bridge of the device and fails to do so proberly
  as there this host-to-pci bridge is not existant. This code has
  been around for years although it completely unclear what it had
  been intended for. Fixing this by eliminating the bogus code. 
  (eich, Bug #145953)
p_pci-ce-x.diff [KEEP?]
- fixes PCI bus scanning on CE systems (pci-pci bridges, Bug #147261)
p_mappciBIOS_complete.diff [KEEP?]
- fixes system hang (IERR on PCI bus) on Dell machines (Bug #151644)
p_pci-legacy-mmap.diff [KEEP?]
- fixes legacy area mapping on IA64 (Bug #166112)
Comment 1 Stefan Dirsch 2006-08-07 15:20:05 UTC
Created attachment 95362 [details]
p_pci-domain.diff
Comment 2 Stefan Dirsch 2006-08-07 15:20:41 UTC
Created attachment 95365 [details]
p_pci-ia64.diff
Comment 3 Stefan Dirsch 2006-08-07 15:21:13 UTC
Created attachment 95366 [details]
p_pci-ce-x.diff
Comment 4 Stefan Dirsch 2006-08-07 15:21:49 UTC
Created attachment 95367 [details]
p_mappciBIOS_complete.diff
Comment 5 Stefan Dirsch 2006-08-07 15:22:17 UTC
Created attachment 95368 [details]
p_pci-legacy-mmap.diff
Comment 6 Stefan Dirsch 2006-08-07 15:23:48 UTC
All these patches need to applied to package xorg-x11-server.
Comment 7 Stefan Dirsch 2006-08-07 21:38:17 UTC
Looks like that "p_mappciBIOS_complete.diff" is already upstream. Only the last hunk in hw/xfree86/os-support/linux/lnx_pci.c is handled slighly different.
Comment 8 Stefan Dirsch 2006-08-20 09:51:46 UTC
I've added the patches now to our xorg-x11-server package, but *disabled* them.
Comment 9 Matthias Hopf 2006-08-22 15:53:00 UTC
Created attachment 96794 [details]
Fixed p_pci-domain.diff

I have (sort-of) guessed the additions to /sys related device file (link) changes (is26), but it seems to correlate.
I also assume that linuxPciHandleBIOS() (new) needs PCI_BUS_NO_DOMAIN() handling.
Fixed several potential buffer overflows due to domain handling.

xf86GetPciHostConfigFromTag() has no PCI_BUS_NO_DOMAIN() handling, but never had so far. Don't know the potential impact here.

Fixed some potential index overflow handling (academic).
Completely rewrote lnx_pci.c device scanning. This needs testing badly!
Comment 10 Stefan Dirsch 2006-08-23 10:09:22 UTC
Created attachment 96866 [details]
The hunks in bus/Pci.h were reverted.
Comment 11 Stefan Dirsch 2006-08-23 10:12:11 UTC
But the new p_pci-domain.diff still needs some improvement. :-)

lnx_pci.c: In function 'xf86OSLinuxGetPciDevs':
lnx_pci.c:46: error: expected '{' before '*' token
lnx_pci.c:54: error: 'dirent1' undeclared (first use in this function)
lnx_pci.c:54: error: (Each undeclared identifier is reported only once
lnx_pci.c:54: error: for each function it appears in.)
lnx_pci.c:59: error: 'dirent2' undeclared (first use in this function)
lnx_pci.c:75: warning: format '%08x' expects type 'unsigned int', but argument 7 has type 'long unsigned int'
lnx_pci.c:75: warning: format '%08x' expects type 'unsigned int', but argument 8 has type 'long unsigned int'
lnx_pci.c: In function 'xf86GetPciSizeFromOS':
lnx_pci.c:160: warning: unused variable 'fn'
lnx_pci.c:160: warning: unused variable 'dev'
lnx_pci.c: In function 'xf86GetPciOffsetFromOS':
lnx_pci.c:196: warning: unused variable 'fn'
lnx_pci.c:196: warning: unused variable 'dev'
lnx_pci.c: In function 'xf86GetOSOffsetFromPCI':
lnx_pci.c:224: warning: unused variable 'fn'
lnx_pci.c:224: warning: unused variable 'dev'
make[5]: *** [lnx_pci.lo] Error 1
Comment 12 Stefan Dirsch 2006-08-23 10:23:05 UTC
Created attachment 96867 [details]
fixed compilation
Comment 13 Stefan Dirsch 2006-08-23 10:34:31 UTC
Still remaining:

lnx_pci.c: In function 'xf86OSLinuxGetPciDevs':
lnx_pci.c:48: warning: 'i' may be used uninitialized in this function

+    unsigned int i, num, devfn;
[...]
+                           if ( (file = fopen (c, "r")) ) {
+                               i = 0;
+                               while (i < 7 && fgets (c, 0x200, file)) {
+                                   if (sscanf (c, PCIADDR_FMT " " PCIADDR_FMT " " PCIADDR_IGNORE_FMT, &begin, &end) == 2) {
+                                       tmp->offset[i] = begin;
+                                       tmp->size[i]   = end - begin;
+                                       i++;
+                                   }
+                               }
+                               fclose (file);
+                           }
+                           if (i > 0) {
+                               tmp->next = ret;
+                               ret       = tmp;
+                           } else
+                               xfree (tmp);

Should we better initialize it with "i=0" in the decleration?
Comment 14 Matthias Hopf 2006-08-23 14:43:27 UTC
Created attachment 96898 [details]
Hopefully fixed patch
Comment 15 Stefan Dirsch 2006-08-23 21:07:42 UTC
p_pci-ia64.diff:
- applies smoothly and looks ok to me.

p_mappciBIOS_complete.diff:
> Looks like that "p_mappciBIOS_complete.diff" is already upstream. Only the
> last hunk in hw/xfree86/os-support/linux/lnx_pci.c is handled slighly
> different.
Indeed. This patch is already upstream including the last hunk for lnx_pci.c!

Remaining patches for investigation:
- p_pci-ce-x.diff (adjust/review)
- p_pci-legacy-mmap.diff (review, apply also for non-IA64 platforms?)
Comment 16 Stefan Dirsch 2006-08-23 21:34:58 UTC
Created attachment 97000 [details]
Xorg.0.log with PCI domain patch applied.

Looks like there's still some room for improvement. :-)
Comment 17 Stefan Dirsch 2006-08-23 21:36:53 UTC
Created attachment 97003 [details]
Xorg.0.log without PCI domain patch

For comparison the logfile of an Xserver with working PCI scan code. :-)
Comment 18 Matthias Hopf 2006-08-24 11:40:08 UTC
Created attachment 97027 [details]
Updated patch, using different kernel interface

This patch uses a slightly different kernel interface (/sys/bus/pci/devices instead of /sys/devices), as the later one seems to have a *big* kernel bug involved.

I'm not marking the old patch as obsolete, because it is the way it should be done, but we cannot use it ATM. I already asked for the support level of /sys/bus/pci (whether it's already depricated or what), but ATM this seems to work correctly.

BTW - on ia64 /sys/devices seems to work correctly.
Comment 19 Matthias Hopf 2006-08-24 14:18:42 UTC
Created attachment 97046 [details]
Updated p_pci-ce-x.diff patch

Nuked unnecessary changes.
Updated to match 7.1.
Comment 20 Matthias Hopf 2006-08-24 14:19:56 UTC
p_pci-legacy-mmap.diff should currently only be applied for ia64. Implications for other platforms are still unclear, and the patch is trivial to maintain.
Comment 21 Matthias Hopf 2006-08-24 14:22:53 UTC
The patch from comment #18 still has some debugging output enabled (one ErrorF).
This should of course be removed in the final version.
Comment 22 Matthias Hopf 2006-08-25 07:46:53 UTC
Created attachment 97112 [details]
Final p_pci-domain patch

This patch finally fixes all issues remaining, verfied with the nv driver. The number of available cards wasn't counted, and the pci resource size was off by one.

The new system still differs in the data in its internal data structure, as in /sys the pci addresses are the real addresses, while the /proc addresses contain flags (io/mem, 32/64bit, prfetchable) in the lowest 2 or 4 bits for io and memory, repsectively. 

These flags are saved internally and removed by checking the flags of some external magic address in xf86GetOSOffsetFromPCI. The new system doesn't save these bits, but due to the masking the final results are the same to the caller of xf86GetOSOffsetFromPCI.
Comment 23 Stefan Dirsch 2006-08-25 08:36:03 UTC
Comment on attachment 95367 [details]
p_mappciBIOS_complete.diff

already included upstream
Comment 24 Stefan Dirsch 2006-08-25 08:52:18 UTC
Thanks a lot, Matthias!
Comment 25 Stefan Dirsch 2006-08-25 09:29:35 UTC
I've tested the new PCI domain patch (+ PCI-PCI bridge patch) on shannon (works fine!) and submitted a new xorg-x11-server package for STABLE. These patches also fixes the PCI scanning on IA64. On this platform we now see different problems (see Bug #197190), but we no longer handle these in this bugreport, since they seem to be unrelated. Finally closing as FIXED. :-)
Comment 26 Matthias Hopf 2006-10-09 12:49:42 UTC
Reopening - some patches are broken.

Attaching new ones.
Comment 27 Matthias Hopf 2006-10-09 12:52:08 UTC
Created attachment 100972 [details]
New final p_pci-domain patch

Fixes:

- internal domain number of by one (was supposed to be a
  cleanup, but other code dependet on this semantics)
- fixed another long-standing of-by-1 error
Comment 28 Matthias Hopf 2006-10-09 13:16:37 UTC
Created attachment 100983 [details]
Additional patch p_enable-altrix.diff

This additional patch enables the build of the altrix detection routines, which have apparently not been included in Xorg 7.1 yet.

This patch needs a autoreconf -fi after application.
Comment 29 Matthias Hopf 2006-10-09 13:17:25 UTC
Please commit :)
Comment 30 Stefan Dirsch 2006-10-09 13:21:01 UTC
Thanks! Will do so.
Comment 31 Matthias Hopf 2006-10-09 14:36:30 UTC
Created attachment 101011 [details]
Again - p_enable-altrix.diff

Sorry, missing include directory...
Comment 32 Stefan Dirsch 2006-10-09 19:55:32 UTC
New patches applied now.