From 83f6b501231d26c270130c8570aba9c792921667 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Sun, 29 Nov 2020 01:30:17 +0000 Subject: [PATCH] Remove alignment requirements for KVA buffer mapping. After r368124 pbuf_zone has extra page to handle this particular case. --- sys/kern/kern_physio.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c index 2b0f4d14b41e..3185e77aba46 100644 --- a/sys/kern/kern_physio.c +++ b/sys/kern/kern_physio.c @@ -30,11 +30,14 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include +#include #include +#include #include #include @@ -107,7 +110,7 @@ physio(struct cdev *dev, struct uio *uio, int ioflag) pbuf = uma_zalloc(pbuf_zone, M_WAITOK); MPASS((pbuf->b_flags & B_MAXPHYS) != 0); sa = pbuf->b_data; - maxpages = btoc(maxphys); + maxpages = PBUF_PAGES; pages = pbuf->b_pages; } prot = VM_PROT_READ; @@ -147,28 +150,6 @@ physio(struct cdev *dev, struct uio *uio, int ioflag) bp->bio_length = dev->si_iosize_max; if (bp->bio_length > maxphys) bp->bio_length = maxphys; - - /* - * Make sure the pbuf can map the request. - * The pbuf has kvasize = maxphys, so a request - * larger than maxphys - PAGE_SIZE must be - * page aligned or it will be fragmented. - */ - poff = (vm_offset_t)base & PAGE_MASK; - if (pbuf && bp->bio_length + poff > pbuf->b_kvasize) { - if (dev->si_flags & SI_NOSPLIT) { - uprintf("%s: request ptr %p is not " - "on a page boundary; cannot split " - "request\n", devtoname(dev), - base); - error = EFBIG; - goto doerror; - } - bp->bio_length = pbuf->b_kvasize; - if (poff != 0) - bp->bio_length -= PAGE_SIZE; - } - bp->bio_bcount = bp->bio_length; bp->bio_dev = dev; @@ -180,6 +161,7 @@ physio(struct cdev *dev, struct uio *uio, int ioflag) error = EFAULT; goto doerror; } + poff = (vm_offset_t)base & PAGE_MASK; if (pbuf && sa) { pmap_qenter((vm_offset_t)sa, pages, npages);