2006-03-29 12:19:31

by yogeshwar sonawane

[permalink] [raw]
Subject: whether to use nopage() implementation or remap_page/pfn_range() api

Hi all,

I am allocating a buffer with __get_free_pages, then trying to map it.
As remap_pfn/page_range() cannot be used, I tried nopage()
implementation (check nopage_module.c). But while looking through some
drivers (oss), i found that remap_pfn/page_range() can be used for
such physical memory after setting PG_reserved bit of all pages of the
buffer. So i tried setting PG_reserved bit & then using
remap_page_range() (check remap_module.c). its also working fine.

1) Now what will be the correct way to do such type of mapping?

then i wrote the above things for memory obtained by pci_alloc_consistent().
pci_remap_module.c contains implementation using remap_page_range().
pci_nopage_module.c contains implementation using nopage().

but while running nopage implementation, i am getting some kernel messeges like:

<0>Bad page state at __free_pages_ok (in process 'a.out', page c1632720)
flags:0x20001070 mapping:c19e23a4 mapcount:0 count:2
Backtrace:
[<c01426d9>] bad_page+0x58/0x89
[<c01429e3>] __free_pages_ok+0x77/0xcc
[<f89130d3>] my_close+0x6d/0x74 [pci_nopage_module]
[<c015a816>] __fput+0x55/0x100
[<c014df24>] remove_vm_struct+0x62/0x79
[<c014fc9c>] exit_mmap+0x13e/0x148
[<c012016a>] mmput+0x4e/0x72
[<c01240c7>] do_exit+0x1f1/0x3de
[<c012439f>] sys_exit_group+0x0/0xd
[<c02d0fb7>] syscall_call+0x7/0xb
Trying to fix it up, but a reboot is needed


Can somebody help me regarding this?

If i am missing something, let me know.

i have tried this on Fedora core 3 as well as RHEL4-U2 & getting
messeges on both.

thanks in advance.
Yogeshwar


Attachments:
(No filename) (1.53 kB)
remap_module.c (2.03 kB)
nopage_module.c (2.63 kB)
pci_remap_module.c (2.77 kB)
pci_nopage_module.c (3.25 kB)
user.c (850.00 B)
Makefile (192.00 B)
Download all attachments