Hi all,

I'm trying to optimize an embedded system based on
ARM9 CPU, which is running a cross-compiled version of
XFree86 4.3.0 on linux 2.4.18.

I noticed that XFree86, at start-up, makes a complete
scan of 256 possible PCI buses, looking for devices,
without checking (e.g. from /proc/bus/pci) how many
buses are actually present on the system.

I thought that in my system, where I have one bus
only, this could lead to a high startup time, so I
tried to make a patch (reported below) that detects
the actual number of buses by parsing
/proc/bus/pci/devices.

The results were not amazing, because the saved time
is really little.
Anyway I wanted to let you know about that. Maybe
someone can give me a feedback about the possible
drawbacks of this solution.

And, do you have other ideas of possible solutions to
speed up the XFree86 startup time on embedded systems
with limitations in filesystem speed and clock rate?

Thank you
--
Pier Paolo Glave


---- patch follows: ---- 
---
./xc/programs/Xserver/hw/xfree86/os-support/bus/linuxPci.c
2002-11-17 19:42:01.000000000 +0100
+++
./build/programs/Xserver/hw/xfree86/os-support/bus/linuxPci.c
2004-02-16 17:09:12.000000000 +0100
@@ -59,6 +59,7 @@
 static CARD32 linuxPciCfgRead(PCITAG tag, int off);
 static void linuxPciCfgWrite(PCITAG, int off, CARD32
val);
 static void linuxPciCfgSetBits(PCITAG tag, int off,
CARD32 mask, CARD32 bits);
+static unsigned int linuxPciGetMaxBus(void);
 
 static pciBusFuncs_t linuxFuncs0 = {
 /* pciReadLong      */ linuxPciCfgRead,
@@ -86,6 +87,7 @@
 linuxPciInit()
 {
        struct stat st;
+       unsigned int newMaxBus;
        if ((xf86Info.pciFlags == PCIForceNone) ||
            (-1 == stat("/proc/bus/pci", &st))) {
                /* when using this as default for all linux
architectures,
@@ -96,6 +98,11 @@
        pciBusInfo[0]  = &linuxPci0;
        pciFindFirstFP = pciGenFindFirst;
        pciFindNextFP  = pciGenFindNext;
+       /* Get the real max bus number */
+       newMaxBus = linuxPciGetMaxBus();
+       if (newMaxBus) {
+               pciMaxBusNum = newMaxBus;
+       }
 }
 
 static int
@@ -167,6 +174,43 @@
        }
 }
 
+/* 
+ * Returns the actual max number of buses present in
the system, taken
+ * from the info in /proc/bus/pci.
+ * Returns zero if something went wrong.
+ */ 
+static unsigned int linuxPciGetMaxBus(void)
+{
+       FILE *file;
+       char *res;
+       char c[0x200];
+       unsigned int num;
+       unsigned int bus, devfn;
+       unsigned int maxbus = 0;
+       
+       if (!(file = fopen("/proc/bus/pci/devices","r")))
+               return maxbus;
+       
+       do {
+               res = fgets(c,0x1ff,file);
+               if (res) {
+                       num = sscanf(res,"%02x%02x",&bus,&devfn);
+                       if (num != 2) { 
+                               fclose(file);
+                               return maxbus;
+                       }
+                       if (maxbus <= bus) {
+                               maxbus = bus+1;
+                       }
+               }
+                       
+       } while(res);
+       
+       fclose(file);
+       return maxbus;
+}
+
+
 #ifndef INCLUDE_XF86_NO_DOMAIN
 
 /*
---- end of patch ----



__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html
_______________________________________________
Devel mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/devel

Reply via email to