Question about ioremap and io_remap_page_range
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珉a娚b策靭wm呴b濓顬藳笔鈓閎烄�戧鐉_鉃豝n噐■�侂h櫒璀�&{鄗夸z罐楘+€�+zf"穐殘啳嗃i��飦�戧鐉_璁鎗:+v墾�)撸鴐歋鍄�澏�瓎踚��鹈砘璁鍜i
Quoted 7 lines · 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, andX_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
Quoted 11 lines · Ingo Molnar
Quoted 7 lines · 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, andX_ADDR=virt_to_phys(VIRT_ADDR);
Quoted 7 lines
i'd suggest to read
Documentation/DMA-mapping.txtin 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 indrivers/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
From: Armin Schindler <[email protected]>
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
[email protected]
Quoted 2 lines · Armin Schindler
virt_to_phys()is obsolete ? What should be used if I need the phys address of a memory page ? (e.g. formmap()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 ([email protected]) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html
Quoted 7 lines
Quoted 2 lines
VIRT_ADDR=ioremap(BUS_ADDR); to map a section of PCI memory, andX_ADDR=virt_to_phys(VIRT_ADDR);i'd suggest to read
Documentation/DMA-mapping.txtin 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
[email protected]
Quoted 11 lines · Jonathan Corbet
Quoted 7 lines
Quoted 2 lines
VIRT_ADDR=ioremap(BUS_ADDR); to map a section of PCI memory, andX_ADDR=virt_to_phys(VIRT_ADDR);i'd suggest to read
Documentation/DMA-mapping.txtin 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,
Quoted 1 line
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_rangedirectly, without implementing methods for virtual memory areas. In other words,remap_page_rangeis 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:
Quoted 1 line
if (offset >= _ _pa(high_memory) || (filp->f_flags & O_SYNC))
Looks like   got translated to &thinsp;
Signature · 1 line
/Jonathan Lundell.