xorg-server-1.5.2 doesn't work because of missing sysfs pci resource files
Hi, all,
I have tried xorg-server-1.5.2 on loongson 2f recently. But I found it doesn't work.
It's mainly because of this change:
http://www.x.org/wiki/PciReworkProposal
In short:
"Rather than duplicating the efforts of kernel developers, X.org needs to use the interfaces provided by the kernel as much as possible."
I have read some code of libpciaccess, the new library utilizing kernel function to access pci bus. It will try to mmap this file:
/sys/bus/pci/devices/0000:0x:xx.x/resource0
(replace x with any digit appropriate)
Note there is a 0 at the end of the file name. This file's permission is 600.
However, I found on my loongson system, there is only /sys/bus/pci/devices/0000:0x:xx.x/resource Note there is no 0 at the end.
Then I tried to read kernel code. I found it seems that for mips linux to have this file, HAVE_PCI_MMAP must be defined. However, it is currently not defined.
Since I am not familiar with PCI, yet.
So could someone please shed some light on this?
Why HAVE_PCI_MMAP is not defined?
Thanks in advance!
Zhang, Le
Quoted 1 line · Zhang Le
Hi, all,
Hi,
Quoted 6 lines
Then I tried to read kernel code. I found it seems that for mips linux to have this file,
HAVE_PCI_MMAPmust be defined. However, it is currently not defined.Since I am not familiar with PCI, yet.
So could someone please shed some light on this?
WhyHAVE_PCI_MMAPis not defined?
HAVE_PCI_MMAP must be defined when you have a pci_mmap_page_range() function (see Documentation/filesystems/sysfs-pci.txt) and we don't have a pci_mmap_page_range() on mips.
Hope that helps you.
Arnaud
On Fri, Dec 05, 2008 at 06:59:35PM +0100, Arnaud Patard wrote:
Arnaud,
Quoted 10 lines
Quoted 6 lines
Then I tried to read kernel code. I found it seems that for mips linux to have this file,
HAVE_PCI_MMAPmust be defined. However, it is currently not defined.Since I am not familiar with PCI, yet.
So could someone please shed some light on this?
WhyHAVE_PCI_MMAPis not defined?
HAVE_PCI_MMAPmust be defined when you have apci_mmap_page_range()function (seeDocumentation/filesystems/sysfs-pci.txt) and we don't have apci_mmap_page_range()on mips.
Correct - but if the code is not present the kernel does not use an alternative implementation. I just looked into implementing that and it seems nothing that I could do quickly to still get it into 2.6.28, sorry ...
Ralf
Quoted 19 lines · Zhang Le
I have tried xorg-server-1.5.2 on loongson 2f recently. But I found it doesn't work.
It's mainly because of this change:
http://www.x.org/wiki/PciReworkProposalIn short:
"Rather than duplicating the efforts of kernel developers, X.org needs to use the interfaces provided by the kernel as much as possible."I have read some code of libpciaccess, the new library utilizing kernel function to access pci bus. It will try to mmap this file:
/sys/bus/pci/devices/0000:0x:xx.x/resource0
(replace x with any digit appropriate)
Note there is a 0 at the end of the file name. This file's permission is 600.However, I found on my loongson system, there is only /sys/bus/pci/devices/0000:0x:xx.x/resource Note there is no 0 at the end.
Quoted 6 lines
Then I tried to read kernel code. I found it seems that for mips linux to have this file,
HAVE_PCI_MMAPmust be defined. However, it is currently not defined.Since I am not familiar with PCI, yet.
So could someone please shed some light on this?
WhyHAVE_PCI_MMAPis not defined?
Here is a quick'n'dirty solution which I've not tested beyond just compiling. It should work but performance will be bad. Either way, I'm interested in a test report with X.
Ralf
arch/mips/include/asm/pci.h +5 -0
@@ -79,6 +79,11 @@ static inline void pcibios_penalize_isa_irq(int irq, int active)/* We don't do dynamic PCI IRQ allocation */ } +#define HAVE_PCI_MMAP + +extern int pci_mmap_page_range (struct pci_dev *dev,struct vm_area_struct *vma, +enum pci_mmap_state mmap_state,int write_combine); +/* * Dynamic DMA mapping stuff. * MIPS has everything mapped statically.
arch/mips/pci/pci.c +16 -0
@@ -354,6 +354,22 @@ EXPORT_SYMBOL(PCIBIOS_MIN_IO);EXPORT_SYMBOL (PCIBIOS_MIN_MEM );#endif +int pci_mmap_page_range (struct pci_dev *dev,struct vm_area_struct *vma, +enum pci_mmap_state mmap_state,int write_combine) +{ +unsigned long prot; + +/* +* Ignore write-combine; for now only return uncached mappings. +*/ + prot =pgprot_val (vma->vm_page_prot); + prot = (prot & ~_CACHE_MASK) | _CACHE_UNCACHED; + vma->vm_page_prot =__pgprot (prot); + +return remap_pfn_range (vma, vma->vm_start, vma->vm_pgoff, + vma->vm_end - vma->vm_start, vma->vm_page_prot); +} +char * (*pcibios_plat_setup)(char *str)__devinitdata ;char *__devinit pcibios_setup (char *str)
Quoted 24 lines · Ralf Baechle
Quoted 22 lines · Zhang Le
I have tried xorg-server-1.5.2 on loongson 2f recently. But I found it doesn't work.
It's mainly because of this change:
http://www.x.org/wiki/PciReworkProposalIn short:
"Rather than duplicating the efforts of kernel developers, X.org needs to use the interfaces provided by the kernel as much as possible."I have read some code of libpciaccess, the new library utilizing kernel function to access pci bus. It will try to mmap this file:
/sys/bus/pci/devices/0000:0x:xx.x/resource0
(replace x with any digit appropriate)
Note there is a 0 at the end of the file name. This file's permission is 600.However, I found on my loongson system, there is only /sys/bus/pci/devices/0000:0x:xx.x/resource Note there is no 0 at the end.
Then I tried to read kernel code. I found it seems that for mips linux to have this file,
HAVE_PCI_MMAPmust be defined. However, it is currently not defined.
Quoted 7 lines
Quoted 3 lines
Since I am not familiar with PCI, yet.
So could someone please shed some light on this?
WhyHAVE_PCI_MMAPis not defined?Here is a quick'n'dirty solution which I've not tested beyond just compiling. It should work but performance will be bad. Either way, I'm interested in a test report with X.
Thanks, Ralf.
I will test it.
Quoted 36 lines
Signed-off-by Ralf Baechle <[email protected]>arch/mips/include/asm/pci.h +5
-0@@ -79,6 +79,11 @@ static inline void pcibios_penalize_isa_irq(int irq, int active)/* We don't do dynamic PCI IRQ allocation */ } +#define HAVE_PCI_MMAP + +extern int pci_mmap_page_range (struct pci_dev *dev,struct vm_area_struct *vma, +enum pci_mmap_state mmap_state,int write_combine); +/* * Dynamic DMA mapping stuff. * MIPS has everything mapped statically. arch/mips/pci/pci.c +9
-0@@ -354,6 +354,22 @@ EXPORT_SYMBOL(PCIBIOS_MIN_IO);EXPORT_SYMBOL (PCIBIOS_MIN_MEM );#endif +int pci_mmap_page_range (struct pci_dev *dev,struct vm_area_struct *vma, +enum pci_mmap_state mmap_state,int write_combine) +{ +unsigned long prot; + +/* +* Ignore write-combine; for now only return uncached mappings. +*/ + prot =pgprot_val (vma->vm_page_prot);
arch/mips/pci/pci.c EXPORT_SYMBOL(PCIBIOS_MIN_IO); · line 375
Quoted 10 lines
arch/mips/pci/pci.c +7
-0+ prot = (prot & ~_CACHE_MASK) | _CACHE_UNCACHED; + vma->vm_page_prot =__pgprot (prot); + +return remap_pfn_range (vma, vma->vm_start, vma->vm_pgoff, + vma->vm_end - vma->vm_start, vma->vm_page_prot); +} +char * (*pcibios_plat_setup)(char *str)__devinitdata ;char *__devinit pcibios_setup (char *str)
Zhang, Le
Quoted 5 lines · Zhang Le
Quoted 4 lines · Ralf Baechle
Quoted 3 lines · Zhang Le
Then I tried to read kernel code. I found it seems that for mips linux to have this file,
HAVE_PCI_MMAPmust be defined. However, it is currently not defined.
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Since I am not familiar with PCI, yet.
So could someone please shed some light on this?
WhyHAVE_PCI_MMAPis not defined?Here is a quick'n'dirty solution which I've not tested beyond just compiling. It should work but performance will be bad. Either way, I'm interested in a test report with X.
Hi, Ralf,
I have build a new kernel with this patch.
Now I have the resource{0,1} file with permission 600.
However, X is not working yet, since there is an undefined reference in sis's X driver.
I will try to fix it and report back.
Zhang, Le
Quoted 14 lines · Zhang Le
Quoted 5 lines · Zhang Le
Quoted 4 lines · Ralf Baechle
Quoted 3 lines · Zhang Le
Then I tried to read kernel code. I found it seems that for mips linux to have this file,
HAVE_PCI_MMAPmust be defined. However, it is currently not defined.Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Since I am not familiar with PCI, yet.
So could someone please shed some light on this?
WhyHAVE_PCI_MMAPis not defined?Here is a quick'n'dirty solution which I've not tested beyond just compiling. It should work but performance will be bad. Either way, I'm interested in a test report with X.
Quoted 6 lines
Hi, Ralf,
I have build a new kernel with this patch.
Now I have the resource{0,1} file with permission 600.
However, X is not working yet, since there is an undefined reference in sis's X driver.
It is working now! Just forget to load "vbe" module. Thanks!
Zhang, Le
Quoted 7 lines · Zhang Le
Quoted 4 lines
I have build a new kernel with this patch.
Now I have the resource{0,1} file with permission 600.
However, X is not working yet, since there is an undefined reference in sis's X driver.It is working now! Just forget to load "vbe" module. Thanks!
Wonderful, thanks for testing!
Now, my patch doesn't try to handle all the caching modes. Any mapping will be uncached which is guaranteed to deliver the lowest possible performance. Registers should be mapped uncached but a framebuffer will usually work best if mapped in uncached accelerated mode. On most MIPS implementations the effect of mapping something multiple times in different caching modes is undefined so that needs to be avoided which will require some bookkeeping etc. Too much for 2.6.28 but this simple solution seems harmless enough to be pushed for 2.6.28 and -stable.
Ralf
Ralf Baechle <[email protected]> writes:
Hi,
Quoted 32 lines
Here is a quick'n'dirty solution which I've not tested beyond just compiling. It should work but performance will be bad. Either way, I'm interested in a test report with X.
Ralf
Signed-off-by Ralf Baechle <[email protected]>arch/mips/include/asm/pci.h +5
-0@@ -79,6 +79,11 @@ static inline void pcibios_penalize_isa_irq(int irq, int active)/* We don't do dynamic PCI IRQ allocation */ } +#define HAVE_PCI_MMAP + +extern int pci_mmap_page_range (struct pci_dev *dev,struct vm_area_struct *vma, +enum pci_mmap_state mmap_state,int write_combine); +/* * Dynamic DMA mapping stuff. * MIPS has everything mapped statically. arch/mips/pci/pci.c +0
-0@@ -354,6 +354,22 @@ EXPORT_SYMBOL(PCIBIOS_MIN_IO);EXPORT_SYMBOL (PCIBIOS_MIN_MEM );#endif
arch/mips/pci/pci.c EXPORT_SYMBOL(PCIBIOS_MIN_IO); · line 366
Quoted 10 lines
arch/mips/pci/pci.c +10
-0+int pci_mmap_page_range (struct pci_dev *dev,struct vm_area_struct *vma, +enum pci_mmap_state mmap_state,int write_combine) +{ +unsigned long prot; + +/* +* Ignore write-combine; for now only return uncached mappings. +*/ + prot =pgprot_val (vma->vm_page_prot); + prot = (prot & ~_CACHE_MASK) | _CACHE_UNCACHED;
What about things like _CACHE_UNCACHED_ACCELERATED ? Is there a way to use this flag ?
Arnaud
Quoted 2 lines · Arnaud Patard
What about things like
_CACHE_UNCACHED_ACCELERATED? Is there a way to use this flag ?
That's possible but will require some additional care in the code. Multiple mappings using different cache modes need to be avoided and also not all processors support _CACHE_UNCACHED_ACCELERATED.
If you know your software is playing nice and your CPU supports _CACHE_UNCACHED_ACCELERATED, you can hack the mmap function to use _CACHE_UNCACHED_ACCELERATED if write_combine is set. Just for now and for something which I'm planning to push for 2.6.28 I don't want anything that's more than trivial.
Ralf
Ralf Baechle <[email protected]> writes:
Hi,
Quoted 8 lines · Arnaud Patard
Quoted 3 lines
What about things like
_CACHE_UNCACHED_ACCELERATED? Is there a way to use this flag ?That's possible but will require some additional care in the code. Multiple mappings using different cache modes need to be avoided and also not all processors support
_CACHE_UNCACHED_ACCELERATED.
well, for that, one can always define a Kconfig entry for that. It would be usefull for using _CACHE_UNCACHED_ACCELERATED in fb_pgprotect in asm/fb.h too.
Quoted 6 lines
If you know your software is playing nice and your CPU supports
_CACHE_UNCACHED_ACCELERATED, you can hack the mmap function to use_CACHE_UNCACHED_ACCELERATEDifwrite_combineis set. Just for now and for something which I'm planning to push for 2.6.28 I don't want anything that's more than trivial.
Ok, no problem. I'm only asking if it will be possible to use it. For now, I don't have the pci_mmap_page_range requirement on my systems.
Thanks,
Arnaud