Bug 8698

Summary: fstat May Be Inappropriate For Reading The ROM
Product: xorg Reporter: Alex Williamson <alex.williamson>
Component: Lib/pciaccessAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED DUPLICATE QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: high CC: alexdeucher, myron.stowe
Version: 7.1 (2006.05)   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
Read the ROM in big chunks none

Description Alex Williamson 2006-10-18 07:56:40 UTC
xf86ReadDomainMemory() currently reads the ROM from sysfs 1 byte at a time. 
I've measured this taking over 20 seconds to complete.  Is there any reason to
read the ROM in such small chunks?  I'll upload a patch that reads in larger
chunks, reducing the ROM read time to about a tenth of a second.
Comment 1 Alex Williamson 2006-10-18 08:00:29 UTC
Created attachment 7458 [details] [review]
Read the ROM in big chunks

This patch significantly reduces the number of reads to load the VGA ROM.  At
least one distribution (SLES10) already includes this patch.
Comment 2 Daniel Stone 2007-02-27 01:34:07 UTC
Sorry about the phenomenal bug spam, guys.  Adding xorg-team@ to the QA contact so bugs don't get lost in future.
Comment 3 Adam Jackson 2008-02-24 21:49:24 UTC
Think this is resolved in pciaccess, but let's put it on the tracker to be sure it gets looked at.
Comment 4 David Nusinow 2008-02-27 19:27:00 UTC
This looks good in libpciaccess from what I can tell.

pci_device_linux_sysfs_read_rom reads the whole file in. It gets the size from fstat'ing the file. If it can't open the file via sysfs pci_device_linux_devmem_read_rom gets called to read the ROM, and it just reads the whole ROM in as well via slightly different means.

I'm going to mark this closed. Please reopen if you think I've missed something and this bug isn't really fixed.
Comment 5 Julien Cristau 2008-02-28 00:52:23 UTC
(In reply to comment #4)
> pci_device_linux_sysfs_read_rom reads the whole file in. It gets the size from
> fstat'ing the file. 

i'm not sure that's such a good plan.  at least on my machine, fstat() says the size is 0, while reading from the file works fine.
Comment 6 Alex Deucher 2008-02-28 09:56:42 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > pci_device_linux_sysfs_read_rom reads the whole file in. It gets the size from
> > fstat'ing the file. 
> 
> i'm not sure that's such a good plan.  at least on my machine, fstat() says the
> size is 0, while reading from the file works fine.
> 

I've seen the same behavior.  Seems to vary from card to card.
Comment 7 David Nusinow 2008-02-28 17:07:38 UTC
Ok, I'm reopening this and reassigning it to libpciaccess.
Comment 8 Adam Jackson 2008-02-29 13:49:29 UTC
The 'fstat returns 0 size' thing is a different bug.

*** This bug has been marked as a duplicate of bug 13988 ***

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.