LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 11-09-2018, 03:48 PM   #1
smoky12
LQ Newbie
 
Registered: Nov 2018
Posts: 1

Rep: Reputation: Disabled
Mapping PCI BAR0 to two drivers


Hi Everyone,

I have an FPGA which exposes BAR0 to an x86 Host. The FPGA has a variety of peripherals on it, I2C, UART, SPI etc. All of these peripherals can be accessed by accessing different offsets from the BAR0 address.

I am running linux kernel 4.14 on the host and have written a pcie device driver which probes off the device id manufacturer ID of the FPGA.

The device driver calls pci_iomap( to obtain a cookie used to access the BAR. This works fine and via this mechanism I can read/write to the FPGA address space after calling ioremap on the cookie.

What I am trying to do now however is create a platform device and add as a resource the BAR0 address + the I2C offset, to get the i2c driver to probe off this new PCI device.

The problem I am having is that I am getting a EBUSY return code. when I try to register the resource to the platform device, after the pci_iomap has taken place.

The resource type is IORESOURCE_SYSTEM_RAM | IORESOURCE_MUXED and the start of the resource is the BAR0 address as returned by pci_iomap + I2C_OFFSET.

In the I2C device driver, I am expecting to do an ioremap on the resource and be able to access it by de-refencing


A couple of questions:

Is this the correct software flow for managing multiple devices exposed by a PCIe BAR0 address space?

If not, what is the correct flow?

If yes, any ideas on what may be going wrong?
 
Old 11-10-2018, 08:57 AM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
If the device zones are completely independent, I would rather go with *pci_iomap_range() to map every zone separately. You can probably modify the FPGA so that zones for each device are page-aligned so that only one driver will access one page - allows avoiding many errors with bad offsets between the drivers.

You would probably create one driver that will handle the PCI registration and than separate drivers for each device type? If this is possible, it might be a good idea so that you have simple code for each of the drivers and if you change one of the peripherals, you do not need to modify the others.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PCI BAR0/1 memory mapping in Tile Architecture venugatla Linux - Kernel 2 04-20-2018 06:18 AM
memory mapping in drivers utkarshrawat Programming 0 05-23-2012 09:54 AM
RH 8.0 Mapping Virtual Memory to get access to VMIC Reflective Memory PCI card. Merlin53 Linux - Hardware 0 05-05-2003 12:50 PM
network mapping hard drivers k3v0 Linux - General 3 12-30-2002 12:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 07:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration