Skip to contentSkip to conversation

Make drivers/char/mem.c use remap_pfn_range()

DISCUSSION William Lee Irwin III 2 participants 5 messages Oct 22, 2004 1 message not in the archive Char and misc drivers

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 8 lines · Linux Kernel Mailing List

ChangeSet 1.2036.1.25, 2004/10/21 15:25:17-07:00, [email protected]
Make drivers/char/mem.c use remap_pfn_range()
Rather than the deprecated remap_page_range() function that can't handle all of the PFN range anyway.
Also, since that will now mark the vma as being special, there's no need to do it in mmap_mem() any more.

 mem.c |   19 +++++++------------
 1 files changed, 7 insertions(+), 12 deletions(-)

Odd. I doublechecked the patches I submitted and they actually covered this.

-- wli

#2 lore raw
Quoted 3 lines · William Lee Irwin III

Odd. I doublechecked the patches I submitted and they actually covered this.

Andrew had a broken patch that shifted the wrong argument by PAGE_SHIFT, do you want to take the blame for that one (it shifted the size, not the pfn)?

Linus

#3 lore raw
Quoted 2 lines · William Lee Irwin III
Quoted 2 lines

Odd. I doublechecked the patches I submitted and they actually covered this.

Quoted 3 lines · Linus Torvalds

Andrew had a broken patch that shifted the wrong argument by PAGE_SHIFT, do you want to take the blame for that one (it shifted the size, not the pfn)?

What I posted shifted the correct argument, though vma->vm_pgoff would have been been better, as it shifted offset right by PAGE_SHIFT, where offset could have overflowed. I have no idea what you're referring to about shifting the wrong argument.

This hunk appeared verbatim in my posted patch,

	Message-ID: <[email protected]>:
drivers/char/mem.c +1 -1
Index: mm3-2.6.9-rc2/drivers/char/mem.c
===================================================================
@@ -227,7 +227,7 @@
 	 */
 	vma->vm_flags |= VM_RESERVED|VM_IO;
 
-	if (remap_page_range(vma, vma->vm_start, offset,
+	if (remap_pfn_range(vma, vma->vm_start, offset >> PAGE_SHIFT,
 			vma->vm_end-vma->vm_start, vma->vm_page_prot))
 		return -EAGAIN;
 	return 0;
#4 lore raw
Quoted 5 lines · William Lee Irwin III

What I posted shifted the correct argument, though vma->vm_pgoff would have been been better, as it shifted offset right by PAGE_SHIFT, where offset could have overflowed. I have no idea what you're referring to about shifting the wrong argument.

Ok, that patch just got lost.

Quite as well, actually. The whole point of changing remap_page_range() to remap_pfn_range() is to give the full range of page frame numbers, and just shifting "offset" back down thus seems to be a bug to me. Otherwise we migth as well just have continued with the old code.

Linus

#5 lore raw
Quoted 4 lines · William Lee Irwin III
Quoted 4 lines

What I posted shifted the correct argument, though vma->vm_pgoff would have been been better, as it shifted offset right by PAGE_SHIFT, where offset could have overflowed. I have no idea what you're referring to about shifting the wrong argument.

Quoted 5 lines · Linus Torvalds

Ok, that patch just got lost.
Quite as well, actually. The whole point of changing remap_page_range() to remap_pfn_range() is to give the full range of page frame numbers, and just shifting "offset" back down thus seems to be a bug to me. Otherwise we migth as well just have continued with the old code.

What I had intended to be the functional improvements were in the arch code for pci_mmap_page_range(), but I would say the mem.c change beyond my own changes is an improvement. All is well.

-- wli