* Alpha and PCI Driver (w/ mmap) problems ...
@ 2000-05-10 4:00 John Ward
2000-05-11 4:00 ` Georg Acher
2000-05-11 4:00 ` John Ward
0 siblings, 2 replies; 4+ messages in thread
From: John Ward @ 2000-05-10 4:00 UTC (permalink / raw)
I have a "simple" PCI card that has a memory region which is mmap'able
... so I wrote a driver which identifies the card with the
pci_find_device() call, and then mmap's the information out of the
appropriate base address using the following call:
remap_page_range(vma->vm_start, (vma->vm_offset + g_offset),
(vma->vm_end
- vma->vm_start), vma->vm_page_prot);
Anyhow, I have a corresponding application program that simply opens the
device and then prints out the contents of a mmap'd region:
fd = open("/dev/truetime", O_RDWR));
ptr = mmap(0, MAX_DEV_MEM_SIZE, (PROT_READ | PROT_WRITE), MAP_SHARED,
fd, 0);
etc ...
Problem is that on my alpha system I get all 0's ... nada ... zilch.
BUT when I run it on our Intel/Linux systems it works just fine. I can
see the data changing, set some registers, etc ... The only thing I did
differently on the alpha system was add a flag to my compile code:
"-ffixed-8" ... otherwise I got some weird error, actually this error:
------------------------------------------------------
In file included from /usr/include/asm/semaphore.h:11,
from /usr/include/linux/fs.h:164,
from truetime.c:9:
/usr/include/asm/current.h:4: global register variable follows a
function definition
/usr/include/asm/current.h:4: warning: call-clobbered register used for
global register variable
------------------------
So the -ffixed-8 seemed to fix this ... don't know if it's causing
another problem or not ... I've tried various compile flags, I can read
all of the PCI configuration registers using either setpci or my driver
itself, but I just can't seem to get at the data, I print out the
address returned from my mmap call and it matches the same virtual
memory address that I get inside my driver, so technically I should be
pointed to the correct address space ...
SO, anybody with experience writing Alpha/Linux device drivers ... could
you offer any suggestions? <I can provide more complete code snippets if
necessary>
Here's some basic system specs:
RH Linux, kernel 2.2.15 w/ SMP support, on Compaq ES40 system.
In addition here's a little more of the PCI information:
% lspci -vv
...
...
...
01:03.0 Bridge: PLX Technology, Inc. PCI <-> IOBus Bridge (rev 01)
Subsystem: True Time Inc.: Unknown device 5900
Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr-
Stepping-
SERR- FastB2B-
Status: Cap- 66Mhz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort-
<TAbort- <MAbort- >SERR- <PERR-
Interrupt: pin A routed to IRQ 32
Region 0: Memory at 0000000001211400 (32-bit, non-prefetchable)
Region 1: I/O ports at 11200
Region 2: Memory at 0000000001211000 (32-bit, non-prefetchable)
...
...
...
(Region 2 or BASE_ADDRESS_2 is where my data is located)
Thanks in advance,
John Ward
wardj@cctcorp.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Alpha and PCI Driver (w/ mmap) problems ...
2000-05-10 4:00 Alpha and PCI Driver (w/ mmap) problems John Ward
2000-05-11 4:00 ` Georg Acher
@ 2000-05-11 4:00 ` John Ward
1 sibling, 0 replies; 4+ messages in thread
From: John Ward @ 2000-05-11 4:00 UTC (permalink / raw)
Not sure if I was ever going to get a response on this one ... does
anybody know where else I might find some answers?
Thanks in advance,
John
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Alpha and PCI Driver (w/ mmap) problems ...
2000-05-10 4:00 Alpha and PCI Driver (w/ mmap) problems John Ward
@ 2000-05-11 4:00 ` Georg Acher
2000-05-12 4:00 ` John Ward
2000-05-11 4:00 ` John Ward
1 sibling, 1 reply; 4+ messages in thread
From: Georg Acher @ 2000-05-11 4:00 UTC (permalink / raw)
In article <391958A4.4D5D66C7@cfl.rr.com>,
John Ward <wardj@cfl.rr.com> writes:
|> I have a "simple" PCI card that has a memory region which is mmap'able
|> ... so I wrote a driver which identifies the card with the
|> pci_find_device() call, and then mmap's the information out of the
|> appropriate base address using the following call:
|>
|> remap_page_range(vma->vm_start, (vma->vm_offset + g_offset),
|> (vma->vm_end
|> - vma->vm_start), vma->vm_page_prot);
|>
|> Anyhow, I have a corresponding application program that simply opens the
|> device and then prints out the contents of a mmap'd region:
|>
|> fd = open("/dev/truetime", O_RDWR));
|>
|> ptr = mmap(0, MAX_DEV_MEM_SIZE, (PROT_READ | PROT_WRITE), MAP_SHARED,
|> fd, 0);
|>
|> etc ...
|>
|> Problem is that on my alpha system I get all 0's ... nada ... zilch.
Are you sure, that you really map the actual PCI address space? On Alpha, the
tiny 32bit-PCI space is not starting at CPU address 0. To convert the PCI
address into the addresses as needed by the CPU, you should use bus_to_virt.
Accessing PCI memory in userspace via /dev/mem has similar problems, but there
exists a library (included somewhere in XFree) that calculates the necessary
offset.
--
Georg Acher, acher@in.tum.de
http://www.in.tum.de/~acher/
"Oh no, not again !" The bowl of petunias
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Alpha and PCI Driver (w/ mmap) problems ...
2000-05-11 4:00 ` Georg Acher
@ 2000-05-12 4:00 ` John Ward
0 siblings, 0 replies; 4+ messages in thread
From: John Ward @ 2000-05-12 4:00 UTC (permalink / raw)
Georg Acher wrote:
> Are you sure, that you really map the actual PCI address space? On Alpha, the
> tiny 32bit-PCI space is not starting at CPU address 0. To convert the PCI
> address into the addresses as needed by the CPU, you should use bus_to_virt.
No I wasn't sure ... I tried the bus_to_virt() and related functions ...
didn't get me anywhere. Finally I installed kernel 2.3.99-pre6 and I
still wasn't able to mmap the data but I was (FINALLY!) able to
readb/writeb the card after doing an ioremap() on the address. So I can
now "see the card" and the data (albiet in a fashion other than I
originally expected) ... after some reading in IO-mappings.txt kernel
document - I'm not even sure it's possible to do the mmap on the alpha,
it would appear that I got lucky on the Intel/x86 arch (in a
non-portable way) with my mmap'ings.
I tried the same code again on the original kernel 2.2.15 (minus kernel
version porting diffs) and it wouldn't work (all ff's in my "registers")
... so I'm not sure what the deal is.
I would still love to mmap the data, but for now I guess my only option
is to deal with the data in readb/writeb() fashion. Unless anybody has
any more suggestions or more specific examples to identify what I might
try instead.
Thanks for the info ...
John
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2000-05-12 4:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-05-10 4:00 Alpha and PCI Driver (w/ mmap) problems John Ward
2000-05-11 4:00 ` Georg Acher
2000-05-12 4:00 ` John Ward
2000-05-11 4:00 ` John Ward
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox