LinuxQuestions.org
Review your favorite Linux distribution.
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-08-2017, 03:05 AM   #1
woodyhuang1992
LQ Newbie
 
Registered: Aug 2017
Posts: 1

Rep: Reputation: Disabled
Question Conflict PCIE region size in /sys and /proc!


I and writing a PCIE driver for my custom FPGA base board, where bar0 and bar2 are adopted for io. However, after I insert this board to Openwrt router board, I find that the region size information given by /sys/devices/pci0000:00/0000:00:00.0/resource and /proc/iomem is conflict.

Content of /sys/devices/pci0000:00/0000:00:00.0/resource is (for bar0 and bar2):

0x0000000010008000 0x0000000010009000 0x0000000000040200
0x0000000010000000 0x0000000010008000 0x0000000000040200

While content of /proc/iomem is (for bar0 and bar2):

10000000-13ffffff : mem_base
10000000-13ffffff : PCI memory space
10000000-10007fff : 0000:00:00.0
10008000-10008fff : 0000:00:00.0

Obviously, the region size given by the former one is 4097, while the region size given by the latter one is 4096. According to the PCIE protocol, the region size should always be power of two, isn't it?

So what is the reason that cause this problem and how to fix it?
 
Old 11-11-2017, 12:44 PM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 8,717

Rep: Reputation: 887Reputation: 887Reputation: 887Reputation: 887Reputation: 887Reputation: 887Reputation: 887
Welcome to LQ.

As one of the few hardware heads about here, let me have a go at this.
Am I correct in assuming the relevant figures are highlighted?
Code:
0x0000000010008000 0x0000000010009000 0x0000000000040200
That, indeed gives some dubious multiple of 4096 on a calculator, but in fact 4097 in hardware- my calculator is very odd. This one
Code:
10008000-10008fff : 0000:00:00.0
The first of those gives 0x7fff of a difference, the second 0x0fff, or 4095; when you look at that from a hardware perspective, it's 4096, remembering the days of limited address lines, number ranges go from 0x00-0xFF for 256 addressable bits with 8 lines. 0x00 is a valid address, 255 is the top address, giving 256 bits

Applying this logic to your figures, the output of /sys/devices/pci0000:00/0000:00:00.0/resource is suspect. You notice the address 0x0000000010008000 is assigned to both blocks? I suspect it shouldn't be. That looks like a kernel bug or system bug to me.
For your purposes, treat it as 0x0000 - 7FFF & 8000 - 8fff, and report the bug. There's a time penalty in doing that, but pay it.

I must say in passing, that I expected to be fingering your code, and not the kernel.
 
Old 11-12-2017, 08:47 PM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,706
Blog Entries: 4

Rep: Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030
Also: the number of inclusive values in any range is hi - lo + 1 ... The number of values in the inclusive range [000...fff] is 4,096.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
I cannot see my PCIe device in /sys/devices rob18767 Linux - Hardware 4 08-26-2017 12:35 PM
[SOLVED] Clarification of Proc Filesystem for PCIe khhyle Linux - Newbie 3 12-05-2016 05:32 PM
whats the difference between /proc/sys and /sys sigint-ninja Linux - Newbie 1 01-15-2015 11:38 PM
[SOLVED] How serious is this conflict? ACPI: I/O resource... conflicts with region SMBI holister Linux - Hardware 9 11-10-2010 06:56 PM
[SOLVED] how to increase the size of '/proc/sys/vm/min_free_kbytes' from ... warnold Linux - Networking 2 11-06-2008 12:21 AM

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

All times are GMT -5. The time now is 10:25 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration