Modifications to linuxPci.c to optimize PCI scan

2004-02-16 Thread Pier Paolo Glave
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.0 +0100
+++
./build/programs/Xserver/hw/xfree86/os-support/bus/linuxPci.c
2004-02-16 17:09:12.0 +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


[XFree86] How to speed up XFree86 startup on ARM-Linux

2004-02-12 Thread Pier Paolo Glave
Hi all,

I'm trying to use XFree86 4.3.0 on an embedded system
based on ARM9 core running at 200 MHz, with a
graphical card connected on the PCI bus (for the first
trials I'm using a Matrox Millennium II, and then I'm
going to switch to a custom hardware). I'm running
Linux 2.4.18.
I crosscompiled the full XFree86 version, and not the
tiny one, because I need to use the modular drivers
(such as mga_drv.o) for graphical accelerations.

I succeeded in running the X server on my system, but
the server startup time is quite high: if launched
soon after the system boot, X -probeonly  takes
about 16 seconds to terminate.

I suspect that most of this time could be spent by CPU
for file accesses: e.g. loading modules, or writing
the logfile.

The following points drive me to this suspicion:
1. I have a JFFS2 filesystem on a flash memory. This
filesystem is compressed, and moreover it uses some
algorithms to avoid insisting on the same flash sector
and to make garbage collection: therefore, it can be
heavy for the CPU if a lot of files are accessed, as
in the case of XFree86.
2. If I launch X -probeonly several times
consecutively, the execution times vary a lot, ranging
from 10 to 20 seconds. I think this huge variation can
be the effect of file caching and/or JFFS2 processing.

I made some attempts to reduce the file access time,
in this way:
1. Using a RAM filesystem (tmpfs) to store all the
/usr/X11R6 stuff (modules) and changing the
configuration file to load modules from there. Result:
no meaningful change.
2. Changing the logfile position with the -logfile
option. I tried using /dev/null, and using a path
located in a tmpfs filesystem, but in both cases the
X server aborts with signal 4.

I wanted to ask you what problem can I have with
-logfile to cause the server abort, and if you have
some better ideas that could speed up the server
startup.

Sorry for the long post and thanks in advance.
--
Pier Paolo Glave



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