Author: mav
Date: Sun Nov 29 00:49:14 2020
New Revision: 368134
URL: https://svnweb.freebsd.org/changeset/base/368134

Log:
  Remove alignment requirements for KVA buffer mapping.
  
  After r368124 vmapbuf() should happily map misaligned maxphys-sized buffers
  thanks to extra page added to pbuf_zone.

Modified:
  head/sys/cam/cam_periph.c

Modified: head/sys/cam/cam_periph.c
==============================================================================
--- head/sys/cam/cam_periph.c   Sun Nov 29 00:35:13 2020        (r368133)
+++ head/sys/cam/cam_periph.c   Sun Nov 29 00:49:14 2020        (r368134)
@@ -783,7 +783,6 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_ma
        u_int8_t **data_ptrs[CAM_PERIPH_MAXMAPS];
        u_int32_t lengths[CAM_PERIPH_MAXMAPS];
        u_int32_t dirs[CAM_PERIPH_MAXMAPS];
-       bool misaligned[CAM_PERIPH_MAXMAPS];
 
        bzero(mapinfo, sizeof(*mapinfo));
        if (maxmap == 0)
@@ -901,17 +900,6 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_ma
                               (long)(lengths[i]), (u_long)maxmap);
                        return (E2BIG);
                }
-
-               /*
-                * The userland data pointer passed in may not be page
-                * aligned.  vmapbuf() truncates the address to a page
-                * boundary, so if the address isn't page aligned, we'll
-                * need enough space for the given transfer length, plus
-                * whatever extra space is necessary to make it to the page
-                * boundary.
-                */
-               misaligned[i] = (lengths[i] +
-                   (((vm_offset_t)(*data_ptrs[i])) & PAGE_MASK) > maxphys);
        }
 
        /*
@@ -934,7 +922,7 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_ma
                 * small allocations malloc is backed by UMA, and so much
                 * cheaper on SMP systems.
                 */
-               if ((lengths[i] <= periph_mapmem_thresh || misaligned[i]) &&
+               if (lengths[i] <= periph_mapmem_thresh &&
                    ccb->ccb_h.func_code != XPT_MMC_IO) {
                        *data_ptrs[i] = malloc(lengths[i], M_CAMPERIPH,
                            M_WAITOK);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to