Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following output from running lspci -vv -s 00:00 on my single board computer running Linux.

07:05.0 RAID bus controller: Adaptec AAC-RAID (Rocket) (rev 03)
        Subsystem: Adaptec ASR-2230S + ASR-2230SLP PCI-X (Lancer)
        Control: I/O- Mem+ BusMaster+ SpecCycle+ MemWINV+ VGASnoop-
        ParErr- Stepping- SERR+ FastB2B-
        Status: Cap+ 66MHz+ UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- SERR-
        Latency: 64 (250ns min, 250ns max), Cache Line Size: 64 bytes
        Interrupt: pin A routed to IRQ 74
        Region 0: Memory at f7a00000 (64-bit, non-prefetchable) [size=2M]
        Region 2: Memory at f79ff000 (64-bit, non-prefetchable)
[Remaining output truncated]

The above is only example output and not exactly what I am getting but it contains the items of interest.

I understand most of the output from the lspci command, but I would like someone to explain to me the lines that begin with Region ... What type of memory am I looking at here specified by the Region line? How might I access it? With that asked, I am trying to accomplish communication between two single board computers connected over the PCI bus. I should be able to talk directly. All there is a PCI arbiter running the bus. This is what I've accomplished so far...

I created a Linux kernel module for outbound PCI traffic. Basically it maps all the way down from userspace (with a user space application) using the driver mmap implementation. I write to the location returned by mmap and I actually see the traffic with a bus analyzer! Now on the other single board computer I try read its sysfs resource for the PCI device but only see all FFs and no changes.

Any advice or explanation on how all of this memory mapping occurs, involving PCI, would be greatly appreciated. Thanks!

share|improve this question

migrated from Apr 6 '13 at 5:53

This question came from our site for professional and enthusiast programmers.

See linux/Documentation/io-mapping.txt for calls to allocate I/O memory to communicate with PCI devices. This is a good explanation of how to access I/O memory: – Peter L. Apr 5 '13 at 23:39
up vote 1 down vote accepted

In the PCI/PCI-X/PCI-E devices, there are BARs registers in the PCI configuration space. And during Linux Kernel booting up, it will scan the PCI bus, find all PCI devices including PCI-to-PCI bridge and PCI devices. And kernel will check how many BARs are there in the PCI devices' configuration space. And check how much memory space each BAR needs and the memory space type by writing 0xFFFFFFFF to BAR register. Then kernel will allocate the memory space resources to the PCI devices.

In your case, Region lion is show the BAR registers.

In each device driver corresponding, one can get the base physical address that Linux Kernel allocate for each BAR by calling pci_resource_start(), and call pci_iomap() to map the base physical address to kernel virtual address, or using remap_pfn_range() to implement one mmap method for user space process to map the physical address to user space process virtual address.

share|improve this answer

Registers on the devices are either IOmapped or memorymapped.(true for x86) Region shows in which kernel virtual address these registers are mapped. In this case they are memory mapped at iven kernel virtual address space.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .