Date: Sat, 11 Jan 2003 16:18:50 -0500 From: Jake Burkholder <jake@locore.ca> To: Matthew Dillon <dillon@apollo.backplane.com> Cc: hackers@FreeBSD.ORG, "Alan L. Cox" <alc@imimic.com>, Tor.Egge@cvsup.no.freebsd.org Subject: Re: vmapbuf/vunmapbuf consolidation -- need alpha/ia64 review. Message-ID: <20030111161850.C212@locore.ca> In-Reply-To: <200301112051.h0BKpiWr047795@apollo.backplane.com>; from dillon@apollo.backplane.com on Sat, Jan 11, 2003 at 12:51:44PM -0800 References: <20021102171534X.tegge@cvsup.no.freebsd.org> <3DCD7F3A.DE013857@imimic.com> <200301092137.h09Lbo0E005483@apollo.backplane.com> <3E1DF369.81ADB566@imimic.com> <200301100058.h0A0wiqo000380@apollo.backplane.com> <3E1FF17B.455C2A71@imimic.com> <200301112051.h0BKpiWr047795@apollo.backplane.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Apparently, On Sat, Jan 11, 2003 at 12:51:44PM -0800, Matthew Dillon said words to the effect of; > This patch consolidates all the vmapbuf()/vunmapbuf() implementations > into kern/vfs_bio.c, removing them from */*/vm_machdep.c. Cool. I was planning to do this myself just for general cleanup. > Index: kern/vfs_bio.c > =================================================================== > RCS file: /home/ncvs/src/sys/kern/vfs_bio.c,v > retrieving revision 1.352 > diff -u -r1.352 vfs_bio.c > --- kern/vfs_bio.c 7 Jan 2003 19:55:08 -0000 1.352 > +++ kern/vfs_bio.c 11 Jan 2003 20:42:03 -0000 > @@ -3540,6 +3540,77 @@ > bp->b_npages = newnpages; > } > > +/* > + * Map an IO request into kernel virtual address space. > + * > + * All requests are (re)mapped into kernel VA space. > + * Notice that we use b_bufsize for the size of the buffer > + * to be mapped. b_bcount might be modified by the driver. > + */ > +void > +vmapbuf(struct buf *bp) > +{ > + caddr_t addr, kva; > + vm_offset_t pa; > + int pidx; > + struct vm_page *m; > + > + GIANT_REQUIRED; > + > + if ((bp->b_flags & B_PHYS) == 0) > + panic("vmapbuf"); > + > + for (addr = (caddr_t)trunc_page((vm_offset_t)bp->b_data), pidx = 0; > + addr < bp->b_data + bp->b_bufsize; > + addr += PAGE_SIZE, pidx++) { > + /* > + * Do the vm_fault if needed; do the copy-on-write thing > + * when reading stuff off device into memory. > + */ > + vm_fault_quick((addr >= bp->b_data) ? addr : bp->b_data, > + (bp->b_iocmd == BIO_READ)?(VM_PROT_READ|VM_PROT_WRITE):VM_PROT_READ); > + pa = trunc_page(pmap_kextract((vm_offset_t) addr)); The sparc64 version is subtely different here. You need use pmap_extract with the pmap of the current process, pmap_kextract won't work even for the current address space because kva is not mapped into each process's pmap. ... pmap = &curproc->p_vmspace->vm_pmap; ... pa = trunc_page(pmap_extract(pmap, (vm_offset_t)addr)); ... This should work for all platforms. The rest looks fine apart from style bugs. Jake To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030111161850.C212>