* Question about ioremap and io_remap_page_range
@ 2001-09-27 6:04 舒国强
2001-09-27 6:52 ` Ingo Molnar
0 siblings, 1 reply; 7+ messages in thread
From: 舒国强 @ 2001-09-27 6:04 UTC (permalink / raw)
To: linux-kernel@vger.kernel.org
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="GB2312", Size: 952 bytes --]
Here is some rather basic questions I want ask ,any reply or comment please
CC to my emailbox,thank you very much.
When I work with kernel 2.4.2 in Intel X86 , I use
VIRT_ADDR = ioremap(BUS_ADDR); to map a section of PCI memory, and
X_ADDR = virt_to_phys(VIRT_ADDR);
I think in x86 platform X_ADDR should equel with BUS_ADDR, but it turns to be
NOT, can you explain ?
In X86 platform ,Can I use return value of ioremap() as a memory pointer?
I use io_remap_page_range(BUS_ADDR,,) in mmap() function,but the result is
that the memory I map is READ ONLY from user space,when I try to write to it,
a "do_sw_pg. bogus page(XXXXXXXX)" appears. Can you explain to me?
I know these questions are childish,but I need the answer urgently,thanks!
George Shu
ý:.˱Êâmçë¢kaÉb²ßìzwm
ébïî˱Êâmébìÿêçz_âØ^nr¡ö¦zË\x1aëh¨èÚ&£ûàz¿äz¹Þú+Ê+zf£¢·h§~Ûiÿÿïêÿêçz_è®\x0fæj:+v¨þ)ߣømSåy«\x1eæ¶\x17
\x01\x06ÛiÿÿðÃ\x0fí»\x1fè®\x0fåi\x7f
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Question about ioremap and io_remap_page_range
2001-09-27 6:04 Question about ioremap and io_remap_page_range 舒国强
@ 2001-09-27 6:52 ` Ingo Molnar
2001-09-27 8:03 ` Armin Schindler
2001-09-27 14:33 ` Jonathan Corbet
0 siblings, 2 replies; 7+ messages in thread
From: Ingo Molnar @ 2001-09-27 6:52 UTC (permalink / raw)
To: 舒国强; +Cc: linux-kernel@vger.kernel.org
On Thu, 27 Sep 2001, [GB2312] Êæ¹úÇ¿ wrote:
> Here is some rather basic questions I want ask ,any reply or comment
> please CC to my emailbox,thank you very much.
>
> When I work with kernel 2.4.2 in Intel X86 , I use
>
> VIRT_ADDR = ioremap(BUS_ADDR); to map a section of PCI memory, and
> X_ADDR = virt_to_phys(VIRT_ADDR);
i'd suggest to read Documentation/DMA-mapping.txt in any recent kernel
source, the bus_to_virt()/virt_to_phys() interface is obsolete and has
been replaced by the pci_alloc_*/pci_map_*/pci_free_*() dynamic
DMA-mapping API. You can find some nice examples of usage in
drivers/net/*.c.
Ingo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Question about ioremap and io_remap_page_range
2001-09-27 6:52 ` Ingo Molnar
@ 2001-09-27 8:03 ` Armin Schindler
2001-09-27 8:14 ` David S. Miller
2001-09-27 8:16 ` Russell King
2001-09-27 14:33 ` Jonathan Corbet
1 sibling, 2 replies; 7+ messages in thread
From: Armin Schindler @ 2001-09-27 8:03 UTC (permalink / raw)
To: Ingo Molnar
Cc: Êæ¹úÇ¿,
linux-kernel@vger.kernel.org
On Thu, 27 Sep 2001, Ingo Molnar wrote:
>
> On Thu, 27 Sep 2001, [GB2312] Êæ¹úÇ¿ wrote:
>
> > Here is some rather basic questions I want ask ,any reply or comment
> > please CC to my emailbox,thank you very much.
> >
> > When I work with kernel 2.4.2 in Intel X86 , I use
> >
> > VIRT_ADDR = ioremap(BUS_ADDR); to map a section of PCI memory, and
> > X_ADDR = virt_to_phys(VIRT_ADDR);
>
> i'd suggest to read Documentation/DMA-mapping.txt in any recent kernel
> source, the bus_to_virt()/virt_to_phys() interface is obsolete and has
> been replaced by the pci_alloc_*/pci_map_*/pci_free_*() dynamic
> DMA-mapping API. You can find some nice examples of usage in
> drivers/net/*.c.
>
> Ingo
virt_to_phys() is obsolete ? What should be used if I need the phys address
of a memory page ? (e.g. for mmap() remapping)
Armin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Question about ioremap and io_remap_page_range
2001-09-27 8:03 ` Armin Schindler
@ 2001-09-27 8:14 ` David S. Miller
2001-09-27 8:16 ` Russell King
1 sibling, 0 replies; 7+ messages in thread
From: David S. Miller @ 2001-09-27 8:14 UTC (permalink / raw)
To: mac; +Cc: mingo, guoqiang, linux-kernel
From: Armin Schindler <mac@melware.de>
Date: Thu, 27 Sep 2001 10:03:26 +0200 (MEST)
virt_to_phys() is obsolete ? What should be used if I need the phys address
of a memory page ? (e.g. for mmap() remapping)
Ingo really is talking about virt_to_bus/bus_to_virt.
Franks a lot,
David S. Miller
davem@redhat.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Question about ioremap and io_remap_page_range
2001-09-27 8:03 ` Armin Schindler
2001-09-27 8:14 ` David S. Miller
@ 2001-09-27 8:16 ` Russell King
1 sibling, 0 replies; 7+ messages in thread
From: Russell King @ 2001-09-27 8:16 UTC (permalink / raw)
To: Armin Schindler
Cc: Ingo Molnar, Êæ¹úÇ¿,
linux-kernel@vger.kernel.org
On Thu, Sep 27, 2001 at 10:03:26AM +0200, Armin Schindler wrote:
> virt_to_phys() is obsolete ? What should be used if I need the phys address
> of a memory page ? (e.g. for mmap() remapping)
virt_to_phys is only valid on the kernel direct mapped RAM area - memory
returned from kmalloc and non-highmem memory returned from get_free_page.
Since vmalloc and ioremap do not return a pointer into the direct mapped
RAM area, but its own mapping, it is not valid to use virt_to_phys on
these returned values, even through it might be a virtual address.
--
Russell King (rmk@arm.linux.org.uk) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Question about ioremap and io_remap_page_range
2001-09-27 6:52 ` Ingo Molnar
2001-09-27 8:03 ` Armin Schindler
@ 2001-09-27 14:33 ` Jonathan Corbet
2001-09-27 17:42 ` Jonathan Lundell
1 sibling, 1 reply; 7+ messages in thread
From: Jonathan Corbet @ 2001-09-27 14:33 UTC (permalink / raw)
To: linux-kernel
> > VIRT_ADDR = ioremap(BUS_ADDR); to map a section of PCI memory, and
> > X_ADDR = virt_to_phys(VIRT_ADDR);
>
> i'd suggest to read Documentation/DMA-mapping.txt in any recent kernel
> source, the bus_to_virt()/virt_to_phys() interface is obsolete and has
> been replaced by the pci_alloc_*/pci_map_*/pci_free_*() dynamic
> DMA-mapping API.
...or, of course, _Linux_Device_Drivers_, Second Edition, available online
at http://www.xml.com/ldd/chapter/book/index.html. The DMA chapter covers
this API as well.
</self-promotion>
jon
Jonathan Corbet
Executive editor, LWN.net
corbet@lwn.net
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Question about ioremap and io_remap_page_range
2001-09-27 14:33 ` Jonathan Corbet
@ 2001-09-27 17:42 ` Jonathan Lundell
0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Lundell @ 2001-09-27 17:42 UTC (permalink / raw)
To: Jonathan Corbet, linux-kernel
At 8:33 AM -0600 2001-09-27, Jonathan Corbet wrote:
> > > VIRT_ADDR = ioremap(BUS_ADDR); to map a section of PCI memory, and
>> > X_ADDR = virt_to_phys(VIRT_ADDR);
>>
>> i'd suggest to read Documentation/DMA-mapping.txt in any recent kernel
>> source, the bus_to_virt()/virt_to_phys() interface is obsolete and has
>> been replaced by the pci_alloc_*/pci_map_*/pci_free_*() dynamic
>> DMA-mapping API.
>
>...or, of course, _Linux_Device_Drivers_, Second Edition, available online
>at http://www.xml.com/ldd/chapter/book/index.html. The DMA chapter covers
>this API as well.
That chapter says, in small part,
>Based on this discussion, you might also want to map addresses
>returned by ioremap to user space. This mapping is easily
>accomplished because you can use remap_page_range directly, without
>implementing methods for virtual memory areas. In other words,
>remap_page_range is already usable for building new page tables that
>map I/O memory to user space
Are you suggesting that ioremap() objects can be passed to
remap_page_range()? How can that be valid?
Also, there's an html conversion error:
> if (offset >= _ _pa(high_memory) || (filp->f_flags & O_SYNC))
Looks like   got translated to &thinsp;
--
/Jonathan Lundell.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2001-09-27 17:42 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-09-27 6:04 Question about ioremap and io_remap_page_range 舒国强
2001-09-27 6:52 ` Ingo Molnar
2001-09-27 8:03 ` Armin Schindler
2001-09-27 8:14 ` David S. Miller
2001-09-27 8:16 ` Russell King
2001-09-27 14:33 ` Jonathan Corbet
2001-09-27 17:42 ` Jonathan Lundell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox