* [RFC] implement syscall pciconfig_iobase
@ 2009-02-20 13:01 Zhang Le
2009-02-20 14:51 ` Ralf Baechle
0 siblings, 1 reply; 4+ messages in thread
From: Zhang Le @ 2009-02-20 13:01 UTC (permalink / raw)
To: linux-mips
This is for xorg-server support.
Currently, xorg-server on loongson need a patch:
http://www.gentoo-cn.org/gitweb/?p=loongson;a=blob;f=x11-base/xorg-server/files/xorg-server-1.5.3-loongson.patch;h=9c48b3752b7f14b6603524f46ae832f312e7c6fe;hb=HEAD#l37
Please note that line 37, the last parameter to mmap, which is the ioBase_phys,
is hardcoded.
This patch no long applies to xorg-server git master.
So I took at look at the code trying to find out why. And then I found powerpc
has implemented this syscall: pciconfig_iobase
Please take a look at the following code:
http://cgit.freedesktop.org/xorg/xserver/tree/hw/xfree86/os-support/linux/lnx_video.c#n517
At the first glance, it is absolutely a good idea to implement this for mips,
too. However when I read pciconfig_iobase's manpage, I found this sentence:
Most of the interaction with PCI devices is already handled by the
kernel PCI layer, and thus these calls should not normally need to be
accessed from userspace.
So I decided to bring this issue here, so that you guys could give me some
advice.
Thanks in advance!
Zhang, Le
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] implement syscall pciconfig_iobase
2009-02-20 13:01 [RFC] implement syscall pciconfig_iobase Zhang Le
@ 2009-02-20 14:51 ` Ralf Baechle
2009-02-20 16:50 ` Zhang Le
2009-02-21 7:03 ` Zhang Le
0 siblings, 2 replies; 4+ messages in thread
From: Ralf Baechle @ 2009-02-20 14:51 UTC (permalink / raw)
To: linux-mips
On Fri, Feb 20, 2009 at 09:01:57PM +0800, Zhang Le wrote:
> Currently, xorg-server on loongson need a patch:
> http://www.gentoo-cn.org/gitweb/?p=loongson;a=blob;f=x11-base/xorg-server/files/xorg-server-1.5.3-loongson.patch;h=9c48b3752b7f14b6603524f46ae832f312e7c6fe;hb=HEAD#l37
> Please note that line 37, the last parameter to mmap, which is the ioBase_phys,
> is hardcoded.
>
> This patch no long applies to xorg-server git master.
It should have been rejected by the maintainer before. This was obviously
fragile and had no fighting chance to ever work on anything but a Fulong.
> So I took at look at the code trying to find out why. And then I found powerpc
> has implemented this syscall: pciconfig_iobase
>
> Please take a look at the following code:
> http://cgit.freedesktop.org/xorg/xserver/tree/hw/xfree86/os-support/linux/lnx_video.c#n517
>
> At the first glance, it is absolutely a good idea to implement this for mips,
> too. However when I read pciconfig_iobase's manpage, I found this sentence:
>
> Most of the interaction with PCI devices is already handled by the
> kernel PCI layer, and thus these calls should not normally need to be
> accessed from userspace.
>
> So I decided to bring this issue here, so that you guys could give me some
> advice.
You can find the resources either by something like:
# lspci -vvv -s 1d.1
00:1d.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #2 (rev 02) (prog-if 00 [UHCI])
Subsystem: Dell Device 01fe
Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Interrupt: pin B routed to IRQ 21
Region 4: I/O ports at 6f60 [size=32]
Kernel driver in use: uhci_hcd
Now let's see how to find this in sysfs:
# ls -l /sys/bus/pci/devices/0000:00:1d.1/resource*
-r--r--r-- 1 root root 4096 2009-02-20 14:13 /sys/bus/pci/devices/0000:00:1d.1/resource
-rw------- 1 root root 32 2009-02-20 14:20 /sys/bus/pci/devices/0000:00:1d.1/resource4
# cat /sys/bus/pci/devices/0000:00:1d.1/resource
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000006f60 0x0000000000006f7f 0x0000000000020101
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
So if you want to mmap the 4th resource, just mmap the file
/sys/bus/pci/devices/0000:00:1d.1/resource4. This leaves how to obtain
the "0000:00:1d.1" - you have to find it by looking at the vendor and device
files in every file in /proc/bus/pci/devices/ which contain the PCI vendor
and device ID as hex numbers. For my example device here:
[root@h5 0000:09:00.0]# cat device
0x1673
[root@h5 0000:09:00.0]# cat vendor
0x14e4
[root@h5 0000:09:00.0]#
Hopefully X finally has some nice infrastructure for this sort of stuff.
And for completeness sake, directly looking at the BARs in the PCI config
space is another method but this one is deprecated these days as it may
not work on some complex systems.
# od -A x -t x4 -j 0x10 -N 0x20 /proc/bus/pci/00/1d.1
000010 00000000 00000000 00000000 00000000
000020 00006f61 00000000 00000000 01fe1028
000030
#
Ralf
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] implement syscall pciconfig_iobase
2009-02-20 14:51 ` Ralf Baechle
@ 2009-02-20 16:50 ` Zhang Le
2009-02-21 7:03 ` Zhang Le
1 sibling, 0 replies; 4+ messages in thread
From: Zhang Le @ 2009-02-20 16:50 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips
On 14:51 Fri 20 Feb , Ralf Baechle wrote:
> On Fri, Feb 20, 2009 at 09:01:57PM +0800, Zhang Le wrote:
>
> > Currently, xorg-server on loongson need a patch:
> > http://www.gentoo-cn.org/gitweb/?p=loongson;a=blob;f=x11-base/xorg-server/files/xorg-server-1.5.3-loongson.patch;h=9c48b3752b7f14b6603524f46ae832f312e7c6fe;hb=HEAD#l37
> > Please note that line 37, the last parameter to mmap, which is the ioBase_phys,
> > is hardcoded.
> >
> > This patch no long applies to xorg-server git master.
>
> It should have been rejected by the maintainer before. This was obviously
> fragile and had no fighting chance to ever work on anything but a Fulong.
Exactly.
[snip]
> # lspci -vvv -s 1d.1
> 00:1d.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #2 (rev 02) (prog-if 00 [UHCI])
> Subsystem: Dell Device 01fe
> Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
> Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
> Latency: 0
> Interrupt: pin B routed to IRQ 21
> Region 4: I/O ports at 6f60 [size=32]
> Kernel driver in use: uhci_hcd
>
> Now let's see how to find this in sysfs:
>
> # ls -l /sys/bus/pci/devices/0000:00:1d.1/resource*
> -r--r--r-- 1 root root 4096 2009-02-20 14:13 /sys/bus/pci/devices/0000:00:1d.1/resource
> -rw------- 1 root root 32 2009-02-20 14:20 /sys/bus/pci/devices/0000:00:1d.1/resource4
> # cat /sys/bus/pci/devices/0000:00:1d.1/resource
> 0x0000000000000000 0x0000000000000000 0x0000000000000000
> 0x0000000000000000 0x0000000000000000 0x0000000000000000
> 0x0000000000000000 0x0000000000000000 0x0000000000000000
> 0x0000000000000000 0x0000000000000000 0x0000000000000000
> 0x0000000000006f60 0x0000000000006f7f 0x0000000000020101
> 0x0000000000000000 0x0000000000000000 0x0000000000000000
> 0x0000000000000000 0x0000000000000000 0x0000000000000000
>
> So if you want to mmap the 4th resource, just mmap the file
> /sys/bus/pci/devices/0000:00:1d.1/resource4. This leaves how to obtain
> the "0000:00:1d.1" - you have to find it by looking at the vendor and device
> files in every file in /proc/bus/pci/devices/ which contain the PCI vendor
> and device ID as hex numbers. For my example device here:
>
> [root@h5 0000:09:00.0]# cat device
> 0x1673
> [root@h5 0000:09:00.0]# cat vendor
> 0x14e4
> [root@h5 0000:09:00.0]#
>
> Hopefully X finally has some nice infrastructure for this sort of stuff.
>
> And for completeness sake, directly looking at the BARs in the PCI config
> space is another method but this one is deprecated these days as it may
> not work on some complex systems.
>
> # od -A x -t x4 -j 0x10 -N 0x20 /proc/bus/pci/00/1d.1
> 000010 00000000 00000000 00000000 00000000
> 000020 00006f61 00000000 00000000 01fe1028
> 000030
> #
Thank you for the above comment! It is very informative!
I will try to make a new patch.
Zhang, Le
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] implement syscall pciconfig_iobase
2009-02-20 14:51 ` Ralf Baechle
2009-02-20 16:50 ` Zhang Le
@ 2009-02-21 7:03 ` Zhang Le
1 sibling, 0 replies; 4+ messages in thread
From: Zhang Le @ 2009-02-21 7:03 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips
On 14:51 Fri 20 Feb , Ralf Baechle wrote:
> You can find the resources either by something like:
>
> # lspci -vvv -s 1d.1
> 00:1d.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #2 (rev 02) (prog-if 00 [UHCI])
> Subsystem: Dell Device 01fe
> Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
> Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
> Latency: 0
> Interrupt: pin B routed to IRQ 21
> Region 4: I/O ports at 6f60 [size=32]
> Kernel driver in use: uhci_hcd
>
> Now let's see how to find this in sysfs:
[snip]
Hi, Ralf,
After careful thought, I think this may be not what I need.
Actually libpciaccess, which is a integral component of X now, need this
mmap-able resourceN (N=1,2,3..) file. And previously mips don't have these file.
This patch just solved this problem.
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=98873f53becea9a8a46972ff252e96fe575b120d
What I need is access to this address in userspace:
#define LOONGSON2E_IO_PORT_BASE 0x1fd00000UL
which is defined in arch/mips/include/asm/mach-lemote/pci.h
Or maybe a better idea is to implement ioperm/iopl for mips, as discussed 7
years ago:
http://www.linux-mips.org/archives/linux-mips/2002-04/msg00085.html
Zhang, Le
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-02-21 7:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-20 13:01 [RFC] implement syscall pciconfig_iobase Zhang Le
2009-02-20 14:51 ` Ralf Baechle
2009-02-20 16:50 ` Zhang Le
2009-02-21 7:03 ` Zhang Le
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.