* xorg-server-1.5.2 doesn't work because of missing sysfs pci resource files @ 2008-12-05 15:43 Zhang Le 2008-12-05 17:59 ` Arnaud Patard 2008-12-06 10:20 ` Ralf Baechle 0 siblings, 2 replies; 11+ messages in thread From: Zhang Le @ 2008-12-05 15:43 UTC (permalink / raw) To: linux-mips 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: xorg-server-1.5.2 doesn't work because of missing sysfs pci resource files 2008-12-05 15:43 xorg-server-1.5.2 doesn't work because of missing sysfs pci resource files Zhang Le @ 2008-12-05 17:59 ` Arnaud Patard 2008-12-05 18:08 ` Ralf Baechle 2008-12-06 10:20 ` Ralf Baechle 1 sibling, 1 reply; 11+ messages in thread From: Arnaud Patard @ 2008-12-05 17:59 UTC (permalink / raw) To: linux-mips Zhang Le <r0bertz@gentoo.org> writes: > Hi, all, Hi, > 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? 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: xorg-server-1.5.2 doesn't work because of missing sysfs pci resource files 2008-12-05 17:59 ` Arnaud Patard @ 2008-12-05 18:08 ` Ralf Baechle 0 siblings, 0 replies; 11+ messages in thread From: Ralf Baechle @ 2008-12-05 18:08 UTC (permalink / raw) To: Arnaud Patard; +Cc: linux-mips On Fri, Dec 05, 2008 at 06:59:35PM +0100, Arnaud Patard wrote: Arnaud, > > 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? > > 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. 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: xorg-server-1.5.2 doesn't work because of missing sysfs pci resource files 2008-12-05 15:43 xorg-server-1.5.2 doesn't work because of missing sysfs pci resource files Zhang Le 2008-12-05 17:59 ` Arnaud Patard @ 2008-12-06 10:20 ` Ralf Baechle 2008-12-06 16:47 ` Zhang Le 2008-12-09 18:17 ` Arnaud Patard 1 sibling, 2 replies; 11+ messages in thread From: Ralf Baechle @ 2008-12-06 10:20 UTC (permalink / raw) To: linux-mips On Fri, Dec 05, 2008 at 11:43:42PM +0800, Zhang Le wrote: > 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? 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 <ralf@linux-mips.org> diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h index 5510c53..053e463 100644 --- a/arch/mips/include/asm/pci.h +++ b/arch/mips/include/asm/pci.h @@ -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. diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c index a377e9d..9233193 100644 --- a/arch/mips/pci/pci.c +++ b/arch/mips/pci/pci.c @@ -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) ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: xorg-server-1.5.2 doesn't work because of missing sysfs pci resource files 2008-12-06 10:20 ` Ralf Baechle @ 2008-12-06 16:47 ` Zhang Le 2008-12-09 17:22 ` Zhang Le 2008-12-09 18:17 ` Arnaud Patard 1 sibling, 1 reply; 11+ messages in thread From: Zhang Le @ 2008-12-06 16:47 UTC (permalink / raw) To: Ralf Baechle; +Cc: linux-mips On 10:20 Sat 06 Dec , Ralf Baechle wrote: > On Fri, Dec 05, 2008 at 11:43:42PM +0800, Zhang Le wrote: > > > 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? > > 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. > Signed-off-by: Ralf Baechle <ralf@linux-mips.org> > > diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h > index 5510c53..053e463 100644 > --- a/arch/mips/include/asm/pci.h > +++ b/arch/mips/include/asm/pci.h > @@ -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. > diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c > index a377e9d..9233193 100644 > --- a/arch/mips/pci/pci.c > +++ b/arch/mips/pci/pci.c > @@ -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) > Zhang, Le ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: xorg-server-1.5.2 doesn't work because of missing sysfs pci resource files 2008-12-06 16:47 ` Zhang Le @ 2008-12-09 17:22 ` Zhang Le 2008-12-09 17:39 ` Zhang Le 0 siblings, 1 reply; 11+ messages in thread From: Zhang Le @ 2008-12-09 17:22 UTC (permalink / raw) To: Ralf Baechle; +Cc: linux-mips On 00:47 Sun 07 Dec , Zhang Le wrote: > On 10:20 Sat 06 Dec , Ralf Baechle wrote: > > On Fri, Dec 05, 2008 at 11:43:42PM +0800, Zhang Le wrote: > > > 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? > > > > 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: xorg-server-1.5.2 doesn't work because of missing sysfs pci resource files 2008-12-09 17:22 ` Zhang Le @ 2008-12-09 17:39 ` Zhang Le 2008-12-09 17:57 ` Ralf Baechle 0 siblings, 1 reply; 11+ messages in thread From: Zhang Le @ 2008-12-09 17:39 UTC (permalink / raw) To: Ralf Baechle; +Cc: linux-mips On 01:22 Wed 10 Dec , Zhang Le wrote: > On 00:47 Sun 07 Dec , Zhang Le wrote: > > On 10:20 Sat 06 Dec , Ralf Baechle wrote: > > > On Fri, Dec 05, 2008 at 11:43:42PM +0800, Zhang Le wrote: > > > > 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? > > > > > > 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. It is working now! Just forget to load "vbe" module. Thanks! Zhang, Le ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: xorg-server-1.5.2 doesn't work because of missing sysfs pci resource files 2008-12-09 17:39 ` Zhang Le @ 2008-12-09 17:57 ` Ralf Baechle 0 siblings, 0 replies; 11+ messages in thread From: Ralf Baechle @ 2008-12-09 17:57 UTC (permalink / raw) To: linux-mips On Wed, Dec 10, 2008 at 01:39:08AM +0800, Zhang Le wrote: > > 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: xorg-server-1.5.2 doesn't work because of missing sysfs pci resource files 2008-12-06 10:20 ` Ralf Baechle 2008-12-06 16:47 ` Zhang Le @ 2008-12-09 18:17 ` Arnaud Patard 2008-12-09 18:36 ` Ralf Baechle 1 sibling, 1 reply; 11+ messages in thread From: Arnaud Patard @ 2008-12-09 18:17 UTC (permalink / raw) To: Ralf Baechle; +Cc: linux-mips Ralf Baechle <ralf@linux-mips.org> writes: Hi, > 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 <ralf@linux-mips.org> > > diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h > index 5510c53..053e463 100644 > --- a/arch/mips/include/asm/pci.h > +++ b/arch/mips/include/asm/pci.h > @@ -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. > diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c > index a377e9d..9233193 100644 > --- a/arch/mips/pci/pci.c > +++ b/arch/mips/pci/pci.c > @@ -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; What about things like _CACHE_UNCACHED_ACCELERATED ? Is there a way to use this flag ? Arnaud ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: xorg-server-1.5.2 doesn't work because of missing sysfs pci resource files 2008-12-09 18:17 ` Arnaud Patard @ 2008-12-09 18:36 ` Ralf Baechle 2008-12-09 19:01 ` Arnaud Patard 0 siblings, 1 reply; 11+ messages in thread From: Ralf Baechle @ 2008-12-09 18:36 UTC (permalink / raw) To: Arnaud Patard; +Cc: linux-mips On Tue, Dec 09, 2008 at 07:17:13PM +0100, Arnaud Patard wrote: > 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: xorg-server-1.5.2 doesn't work because of missing sysfs pci resource files 2008-12-09 18:36 ` Ralf Baechle @ 2008-12-09 19:01 ` Arnaud Patard 0 siblings, 0 replies; 11+ messages in thread From: Arnaud Patard @ 2008-12-09 19:01 UTC (permalink / raw) To: Ralf Baechle; +Cc: linux-mips Ralf Baechle <ralf@linux-mips.org> writes: Hi, > On Tue, Dec 09, 2008 at 07:17:13PM +0100, Arnaud Patard wrote: > >> 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. > > 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. 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-12-09 19:01 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-12-05 15:43 xorg-server-1.5.2 doesn't work because of missing sysfs pci resource files Zhang Le 2008-12-05 17:59 ` Arnaud Patard 2008-12-05 18:08 ` Ralf Baechle 2008-12-06 10:20 ` Ralf Baechle 2008-12-06 16:47 ` Zhang Le 2008-12-09 17:22 ` Zhang Le 2008-12-09 17:39 ` Zhang Le 2008-12-09 17:57 ` Ralf Baechle 2008-12-09 18:17 ` Arnaud Patard 2008-12-09 18:36 ` Ralf Baechle 2008-12-09 19:01 ` Arnaud Patard
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.