<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2900.3462" name=GENERATOR>
<STYLE>@font-face {
        font-family: ËÎÌå;
}
@font-face {
        font-family: Verdana;
}
@font-face {
        font-family: @ËÎÌå;
}
@page Section1 {size: 595.3pt 841.9pt; margin: 72.0pt 90.0pt 72.0pt 90.0pt; layout-grid: 15.6pt; }
P.MsoNormal {
        TEXT-JUSTIFY: inter-ideograph; FONT-SIZE: 10.5pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; TEXT-ALIGN: justify
}
LI.MsoNormal {
        TEXT-JUSTIFY: inter-ideograph; FONT-SIZE: 10.5pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; TEXT-ALIGN: justify
}
DIV.MsoNormal {
        TEXT-JUSTIFY: inter-ideograph; FONT-SIZE: 10.5pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; TEXT-ALIGN: justify
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.EmailStyle17 {
        FONT-WEIGHT: normal; COLOR: windowtext; FONT-STYLE: normal; FONT-FAMILY: Verdana; TEXT-DECORATION: none; mso-style-type: personal-compose
}
DIV.Section1 {
        page: Section1
}
UNKNOWN {
        FONT-SIZE: 10pt
}
BLOCKQUOTE {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; MARGIN-LEFT: 2em
}
OL {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
UL {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
</STYLE>
</HEAD>
<BODY style="FONT-SIZE: 10pt; FONT-FAMILY: verdana">
<DIV><FONT face=Verdana color=#c0c0c0 size=2></FONT></DIV>
<DIV><FONT face=Verdana color=#000080 size=2>
<H3 class=r>Thanks for all the suggestions and Comments!</H3>
<DIV class=r></FONT><FONT face=Verdana color=#000080 size=4>In&nbsp;the system, 
&nbsp;the total memory size is less&nbsp;than&nbsp;4GB.&nbsp;&nbsp; I want to 
know how to map the 3GB pci address to the kernel ,</FONT></DIV>
<DIV class=r><FONT color=#000080 size=4>and how can my driver access all the pci 
device. Usually we have only 1GB kernel address, minus the 896MB</FONT></DIV>
<DIV class=r><FONT color=#000080><FONT size=4>for memory map, we can only use 
the 128M for ioremap.</FONT> <FONT size=4>I can adjust the PAGE_OFFSET to a 
lower value, but it's not enough.</FONT></FONT></DIV>
<DIV class=r><FONT color=#000080 size=4></FONT>&nbsp;</DIV>
<DIV class=r>
<DIV>&gt;One&nbsp;can&nbsp;mmap()&nbsp;a&nbsp;PCI&nbsp;BAR&nbsp;from&nbsp;userspace,&nbsp;in&nbsp;which&nbsp;case&nbsp;the&nbsp;mapping&nbsp;comes</DIV>
<DIV>&gt;out&nbsp;of&nbsp;the&nbsp;"max&nbsp;userspace&nbsp;size"&nbsp;pool&nbsp;instead&nbsp;of&nbsp;the&nbsp;"all&nbsp;ioremap()s"&nbsp;pool.&nbsp;</DIV>
<DIV>&gt;The&nbsp;userspace&nbsp;pool&nbsp;is&nbsp;per&nbsp;processes.&nbsp;&nbsp;So&nbsp;while&nbsp;having&nbsp;four&nbsp;kernel&nbsp;drivers</DIV>
<DIV>&gt;each&nbsp;call&nbsp;ioremap(...,&nbsp;1GB)&nbsp;will&nbsp;never&nbsp;work,&nbsp;it&nbsp;is&nbsp;possible&nbsp;to&nbsp;have&nbsp;four</DIV>
<DIV>&gt;userspace&nbsp;processes&nbsp;each&nbsp;call&nbsp;mmap("/sys/bus/pci.../resource",&nbsp;1GB)&nbsp;and</DIV>
<DIV>&gt;have&nbsp;it&nbsp;work.</DIV></DIV>
<DIV class=r><FONT color=#000080 size=4></FONT><FONT face=Verdana color=#000080 
size=2></FONT>&nbsp;</DIV>
<DIV class=r><FONT face=Verdana><FONT color=#000080 size=4>There are many pci 
devices in the system and every pci device has only several tens of MB, so how 
can I call the 
mmap("/sys/bus/pci.../resource",&nbsp;1GB)&nbsp;</FONT></FONT></DIV>
<DIV class=r><FONT color=#000080 size=4>and how can I use it by my drivers 
?</FONT></DIV>
<DIV class=r><FONT color=#000080 size=4></FONT>&nbsp;</DIV>
<DIV class=r><FONT color=#000080 size=4>Thanks again for&nbsp;all your 
help!</FONT></DIV>
<DIV class=r><FONT face=Verdana color=#000080 size=2>&nbsp;</DIV></DIV>
<DIV>
<HR>
</DIV></FONT>
<DIV>
<DIV><FONT face=Verdana size=2></FONT></DIV><FONT face=Verdana size=2></FONT> 
</DIV>
<DIV><FONT face=Verdana size=2>
<DIV>On&nbsp;Fri,&nbsp;12&nbsp;Dec&nbsp;2008,&nbsp;Kumar&nbsp;Gala&nbsp;wrote:</DIV>
<DIV>&gt;&nbsp;On&nbsp;Dec&nbsp;12,&nbsp;2008,&nbsp;at&nbsp;3:04&nbsp;AM,&nbsp;Trent&nbsp;Piepho&nbsp;wrote:</DIV>
<DIV>&gt; 
&gt;&nbsp;On&nbsp;Thu,&nbsp;11&nbsp;Dec&nbsp;2008,&nbsp;Kumar&nbsp;Gala&nbsp;wrote:</DIV>
<DIV>&gt; &gt;&nbsp; 
&gt;&nbsp;On&nbsp;Dec&nbsp;11,&nbsp;2008,&nbsp;at&nbsp;10:07&nbsp;PM,&nbsp;Trent&nbsp;Piepho&nbsp;wrote:</DIV>
<DIV>&gt; &gt;&nbsp; &gt;&nbsp; 
&gt;&nbsp;On&nbsp;Thu,&nbsp;11&nbsp;Dec&nbsp;2008,&nbsp;Kumar&nbsp;Gala&nbsp;wrote:</DIV>
<DIV>&gt; &gt;&nbsp; &gt;&nbsp; &gt;&nbsp; 
&gt;&nbsp;The&nbsp;36-bit&nbsp;support&nbsp;is&nbsp;current&nbsp;(in&nbsp;tree)&nbsp;in&nbsp;complete.&nbsp;&nbsp;Work&nbsp;is&nbsp;in&nbsp;</DIV>
<DIV>&gt; &gt;&nbsp; &gt;&nbsp; &gt;&nbsp; 
&gt;&nbsp;add&nbsp;swiotlb&nbsp;support&nbsp;to&nbsp;PPC&nbsp;which&nbsp;will&nbsp;generically&nbsp;enable&nbsp;what&nbsp;you&nbsp;</DIV>
<DIV>&gt; &gt;&nbsp; &gt;&nbsp; &gt;&nbsp;</DIV>
<DIV>&gt; &gt;&nbsp; &gt;&nbsp; 
&gt;&nbsp;Don't&nbsp;the&nbsp;ATMU&nbsp;windows&nbsp;in&nbsp;the&nbsp;pcie&nbsp;controller&nbsp;serve&nbsp;as&nbsp;a&nbsp;IOMMU,&nbsp;making</DIV>
<DIV>&gt; &gt;&nbsp; &gt;&nbsp; &gt;&nbsp;swiotlb</DIV>
<DIV>&gt; &gt;&nbsp; &gt;&nbsp; 
&gt;&nbsp;unnecessary&nbsp;and&nbsp;wasteful?</DIV>
<DIV>&gt; &gt;&nbsp; &gt;&nbsp;</DIV>
<DIV>&gt; &gt;&nbsp; 
&gt;&nbsp;Nope.&nbsp;&nbsp;You&nbsp;have&nbsp;no&nbsp;way&nbsp;to&nbsp;tell&nbsp;when&nbsp;to&nbsp;switch&nbsp;a&nbsp;window&nbsp;as&nbsp;you&nbsp;have&nbsp;no&nbsp;</DIV>
<DIV>&gt; &gt;&nbsp; &gt;&nbsp;idea</DIV>
<DIV>&gt; &gt;&nbsp; 
&gt;&nbsp;when&nbsp;a&nbsp;device&nbsp;might&nbsp;DMA&nbsp;data.</DIV>
<DIV>&gt; &gt;&nbsp;</DIV>
<DIV>&gt; 
&gt;&nbsp;Isn't&nbsp;that&nbsp;what&nbsp;dma_alloc_coherent()&nbsp;and&nbsp;dma_map_single()&nbsp;are&nbsp;for?</DIV>
<DIV>&gt;</DIV>
<DIV>&gt;&nbsp;Nope.&nbsp;&nbsp;How&nbsp;would&nbsp;manipulate&nbsp;the&nbsp;PCI&nbsp;ATMU?</DIV>
<DIV>&nbsp;</DIV>
<DIV>Umm,&nbsp;out_be32()?&nbsp;&nbsp;Why&nbsp;would&nbsp;it&nbsp;be&nbsp;any&nbsp;different&nbsp;than&nbsp;other&nbsp;iommu</DIV>
<DIV>implementations,&nbsp;like&nbsp;the&nbsp;pseries&nbsp;one&nbsp;for&nbsp;example?</DIV>
<DIV>&nbsp;</DIV>
<DIV>Just&nbsp;define&nbsp;set&nbsp;a&nbsp;of&nbsp;fsl&nbsp;dma&nbsp;ops&nbsp;that&nbsp;use&nbsp;an&nbsp;inbound&nbsp;ATMU&nbsp;window&nbsp;if&nbsp;they</DIV>
<DIV>need&nbsp;to.&nbsp;&nbsp;The&nbsp;only&nbsp;issue&nbsp;would&nbsp;be&nbsp;if&nbsp;you&nbsp;have&nbsp;a&nbsp;32-bit&nbsp;device&nbsp;with&nbsp;multiple</DIV>
<DIV>concurrent&nbsp;DMA&nbsp;buffers&nbsp;scattered&nbsp;over&nbsp; 
&gt;&nbsp;32&nbsp;bits&nbsp;of&nbsp;address&nbsp;space&nbsp;and&nbsp;run</DIV>
<DIV>out&nbsp;of&nbsp;ATMU&nbsp;windows.&nbsp;&nbsp;But&nbsp;other&nbsp;iommu&nbsp;implementations&nbsp;have&nbsp;that&nbsp;same</DIV>
<DIV>limitation.&nbsp;&nbsp;You&nbsp;just&nbsp;have&nbsp;to&nbsp;try&nbsp;harder&nbsp;to&nbsp;allocate&nbsp;GFP_DMA&nbsp;memory&nbsp;that</DIV>
<DIV>doesn't&nbsp;need&nbsp;an&nbsp;ATMU&nbsp;window&nbsp;or&nbsp;create&nbsp;larger&nbsp;contiguous&nbsp;bounce&nbsp;buffer&nbsp;to</DIV>
<DIV>replace&nbsp;scattered&nbsp;smaller&nbsp;buffers.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&gt; 
&gt;&nbsp;It&nbsp;sounded&nbsp;like&nbsp;the&nbsp;original&nbsp;poster&nbsp;was&nbsp;talking&nbsp;about&nbsp;having&nbsp;3GB&nbsp;of&nbsp;PCI</DIV>
<DIV>&gt; 
&gt;&nbsp;BARs.&nbsp;&nbsp;How&nbsp;does&nbsp;swiotlb&nbsp;even&nbsp;enter&nbsp;the&nbsp;picture&nbsp;for&nbsp;that?</DIV>
<DIV>&gt;</DIV>
<DIV>&gt;&nbsp;It&nbsp;wasn't&nbsp;clear&nbsp;how&nbsp;much&nbsp;system&nbsp;memory&nbsp;they&nbsp;wanted.&nbsp;&nbsp;If&nbsp;they&nbsp;can&nbsp;fit&nbsp;their&nbsp;</DIV>
<DIV>&gt;&nbsp;entire&nbsp;memory&nbsp;map&nbsp;for&nbsp;PCI&nbsp;addresses&nbsp;in&nbsp;4G&nbsp;of&nbsp;address&nbsp;space&nbsp;(this&nbsp;includes&nbsp;all&nbsp;</DIV>
<DIV>&gt;&nbsp;of&nbsp;system&nbsp;DRAM)&nbsp;than&nbsp;they&nbsp;don't&nbsp;need&nbsp;anything&nbsp;special.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Why&nbsp;the&nbsp;need&nbsp;to&nbsp;fit&nbsp;the&nbsp;entire&nbsp;PCI&nbsp;memory&nbsp;map&nbsp;into&nbsp;the&nbsp;lower&nbsp;4G?&nbsp;&nbsp;What</DIV>
<DIV>issue&nbsp;is&nbsp;there&nbsp;with&nbsp;mapping&nbsp;a&nbsp;PCI&nbsp;BAR&nbsp;above&nbsp;4G&nbsp;if&nbsp;you&nbsp;have&nbsp;36-bit&nbsp;support?</DIV>
<DIV>&nbsp;</DIV>
<DIV>Putting&nbsp;system&nbsp;memory&nbsp;below&nbsp;4GB&nbsp;is&nbsp;only&nbsp;an&nbsp;issue&nbsp;if&nbsp;you're&nbsp;talking&nbsp;about</DIV>
<DIV>DMA.&nbsp;&nbsp;For&nbsp;mapping&nbsp;a&nbsp;PCI&nbsp;BAR,&nbsp;what&nbsp;does&nbsp;it&nbsp;doesn't&nbsp;matter?</DIV>
<DIV>&nbsp;</DIV>
<DIV>The&nbsp;problem&nbsp;I&nbsp;see&nbsp;with&nbsp;having&nbsp;large&nbsp;PCI&nbsp;BARs,&nbsp;is&nbsp;that&nbsp;the&nbsp;max&nbsp;userspace</DIV>
<DIV>process&nbsp;size&nbsp;plus&nbsp;low&nbsp;memory&nbsp;plus&nbsp;all&nbsp;ioremap()s&nbsp;must&nbsp;be&nbsp;less&nbsp;than&nbsp;4GB.&nbsp;&nbsp;If</DIV>
<DIV>one&nbsp;wants&nbsp;to&nbsp;call&nbsp;ioremap(...,&nbsp;3GB),&nbsp;then&nbsp;only&nbsp;1&nbsp;GB&nbsp;is&nbsp;left&nbsp;for&nbsp;userspace</DIV>
<DIV>plus&nbsp;low&nbsp;memory.&nbsp;&nbsp;That's&nbsp;not&nbsp;very&nbsp;much.</DIV>
<DIV>&nbsp;</DIV>
<DIV>One&nbsp;can&nbsp;mmap()&nbsp;a&nbsp;PCI&nbsp;BAR&nbsp;from&nbsp;userspace,&nbsp;in&nbsp;which&nbsp;case&nbsp;the&nbsp;mapping&nbsp;comes</DIV>
<DIV>out&nbsp;of&nbsp;the&nbsp;"max&nbsp;userspace&nbsp;size"&nbsp;pool&nbsp;instead&nbsp;of&nbsp;the&nbsp;"all&nbsp;ioremap()s"&nbsp;pool.&nbsp;</DIV>
<DIV>The&nbsp;userspace&nbsp;pool&nbsp;is&nbsp;per&nbsp;processes.&nbsp;&nbsp;So&nbsp;while&nbsp;having&nbsp;four&nbsp;kernel&nbsp;drivers</DIV>
<DIV>each&nbsp;call&nbsp;ioremap(...,&nbsp;1GB)&nbsp;will&nbsp;never&nbsp;work,&nbsp;it&nbsp;is&nbsp;possible&nbsp;to&nbsp;have&nbsp;four</DIV>
<DIV>userspace&nbsp;processes&nbsp;each&nbsp;call&nbsp;mmap("/sys/bus/pci.../resource",&nbsp;1GB)&nbsp;and</DIV>
<DIV>have&nbsp;it&nbsp;work.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&gt; &gt;&nbsp; 
&gt;From&nbsp;what&nbsp;I've&nbsp;read&nbsp;about&nbsp;swiotlb,&nbsp;it&nbsp;is&nbsp;a&nbsp;hack&nbsp;that&nbsp;allows&nbsp;one&nbsp;to&nbsp;do&nbsp;DMA</DIV>
<DIV>&gt; 
&gt;&nbsp;with&nbsp;32-bit&nbsp;PCI&nbsp;devices&nbsp;on&nbsp;64-bit&nbsp;systems&nbsp;that&nbsp;lack&nbsp;an&nbsp;IOMMU.&nbsp;&nbsp;It&nbsp;reserves</DIV>
<DIV>&gt; 
&gt;&nbsp;a&nbsp;large&nbsp;block&nbsp;of&nbsp;RAM&nbsp;under&nbsp;32-bits&nbsp;(technically&nbsp;it&nbsp;uses&nbsp;GFP_DMA)&nbsp;and&nbsp;doles</DIV>
<DIV>&gt; 
&gt;&nbsp;this&nbsp;out&nbsp;to&nbsp;drivers&nbsp;that&nbsp;allocate&nbsp;DMA&nbsp;memory.</DIV>
<DIV>&gt;</DIV>
<DIV>&gt;&nbsp;correct.&nbsp;&nbsp;It&nbsp;bounce&nbsp;buffers&nbsp;the&nbsp;DMAs&nbsp;to&nbsp;a&nbsp;32-bit&nbsp;dma'ble&nbsp;region&nbsp;and&nbsp;copies&nbsp;</DIV>
<DIV>&gt;&nbsp;to/from&nbsp;the&nbsp; 
&gt;32-bit&nbsp;address.</DIV></FONT></DIV></BODY></HTML>