]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
Make pass, sg and targ drivers respect HBA's maxio.
authormav <mav@FreeBSD.org>
Wed, 30 Sep 2015 13:31:37 +0000 (13:31 +0000)
committermav <mav@FreeBSD.org>
Wed, 30 Sep 2015 13:31:37 +0000 (13:31 +0000)
Previous limitation of 64K (DFLTPHYS) is quite annoying.

sys/cam/cam_compat.c
sys/cam/cam_periph.c
sys/cam/cam_periph.h
sys/cam/cam_xpt.c
sys/cam/scsi/scsi_pass.c
sys/cam/scsi/scsi_sg.c
sys/cam/scsi/scsi_target.c

index bcce814ffdf124e902ac8828c9841f10832d10a8..b8e57bb7e6b89101bb7612a6c81c49b0e58ec619 100644 (file)
@@ -300,7 +300,7 @@ cam_compat_translate_dev_match_0x18(union ccb *ccb)
 
        /* Remap the CCB into kernel address space */
        bzero(&mapinfo, sizeof(mapinfo));
-       cam_periph_mapmem(ccb, &mapinfo);
+       cam_periph_mapmem(ccb, &mapinfo, MAXPHYS);
 
        dm = ccb->cdm.matches;
        /* Translate in-place: old fields are smaller */
index 956e5d0a7a25170867321f9a8948b08f72c2b180..91cb45d371d7462b30e066f83d930464492e4f44 100644 (file)
@@ -716,16 +716,19 @@ camperiphfree(struct cam_periph *periph)
  * buffers to map stuff in and out, we're limited to the buffer size.
  */
 int
-cam_periph_mapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo)
+cam_periph_mapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo,
+    u_int maxmap)
 {
        int numbufs, i, j;
        int flags[CAM_PERIPH_MAXMAPS];
        u_int8_t **data_ptrs[CAM_PERIPH_MAXMAPS];
        u_int32_t lengths[CAM_PERIPH_MAXMAPS];
        u_int32_t dirs[CAM_PERIPH_MAXMAPS];
-       /* Some controllers may not be able to handle more data. */
-       size_t maxmap = DFLTPHYS;
 
+       if (maxmap == 0)
+               maxmap = DFLTPHYS;      /* traditional default */
+       else if (maxmap > MAXPHYS)
+               maxmap = MAXPHYS;       /* for safety */
        switch(ccb->ccb_h.func_code) {
        case XPT_DEV_MATCH:
                if (ccb->cdm.match_buf_len == 0) {
index ebcf1a42bdafa085ac291ed639dca1fdfef05f82..e28d5b11214d1fc52c86491c78ad6a2e3d5a5d8b 100644 (file)
@@ -160,7 +160,8 @@ int         cam_periph_hold(struct cam_periph *periph, int priority);
 void           cam_periph_unhold(struct cam_periph *periph);
 void           cam_periph_invalidate(struct cam_periph *periph);
 int            cam_periph_mapmem(union ccb *ccb,
-                                 struct cam_periph_map_info *mapinfo);
+                                 struct cam_periph_map_info *mapinfo,
+                                 u_int maxmap);
 void           cam_periph_unmapmem(union ccb *ccb,
                                    struct cam_periph_map_info *mapinfo);
 union ccb      *cam_periph_getccb(struct cam_periph *periph,
index ad55373c25a63fa60ca0b8a394bb976d8b421c5c..4ce48a386fe466713b589a2a0a997b3f112c23da 100644 (file)
@@ -536,7 +536,7 @@ xptdoioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *
                         * Map the pattern and match buffers into kernel
                         * virtual address space.
                         */
-                       error = cam_periph_mapmem(inccb, &mapinfo);
+                       error = cam_periph_mapmem(inccb, &mapinfo, MAXPHYS);
 
                        if (error) {
                                inccb->ccb_h.path = old_path;
index 584b6b35e78336b444d027d33e2361853f8adc0c..055291b1bd88cb5fd9b274791d0f403960b3705f 100644 (file)
@@ -77,6 +77,7 @@ struct pass_softc {
        u_int8_t         pd_type;
        union ccb        saved_ccb;
        int              open_count;
+       u_int            maxio;
        struct devstat  *device_stats;
        struct cdev     *dev;
        struct cdev     *alias_dev;
@@ -366,6 +367,13 @@ passregister(struct cam_periph *periph, void *arg)
        cpi.ccb_h.func_code = XPT_PATH_INQ;
        xpt_action((union ccb *)&cpi);
 
+       if (cpi.maxio == 0)
+               softc->maxio = DFLTPHYS;        /* traditional default */
+       else if (cpi.maxio > MAXPHYS)
+               softc->maxio = MAXPHYS;         /* for safety */
+       else
+               softc->maxio = cpi.maxio;       /* real value */
+
        /*
         * We pass in 0 for a blocksize, since we don't 
         * know what the blocksize of this device is, if 
@@ -657,7 +665,7 @@ passsendccb(struct cam_periph *periph, union ccb *ccb, union ccb *inccb)
                 * Dropping it here is reasonably safe.
                 */
                cam_periph_unlock(periph);
-               error = cam_periph_mapmem(ccb, &mapinfo); 
+               error = cam_periph_mapmem(ccb, &mapinfo, softc->maxio);
                cam_periph_lock(periph);
 
                /*
index 3e80ac3e763f6ca2023b6aae171712d660d4569a..3e130036ec02f1ae3ec40ed2477e94f7a7c2d06f 100644 (file)
@@ -99,6 +99,7 @@ struct sg_softc {
        sg_state                state;
        sg_flags                flags;
        int                     open_count;
+       u_int                   maxio;
        struct devstat          *device_stats;
        TAILQ_HEAD(, sg_rdwr)   rdwr_done;
        struct cdev             *dev;
@@ -325,6 +326,13 @@ sgregister(struct cam_periph *periph, void *arg)
        cpi.ccb_h.func_code = XPT_PATH_INQ;
        xpt_action((union ccb *)&cpi);
 
+       if (cpi.maxio == 0)
+               softc->maxio = DFLTPHYS;        /* traditional default */
+       else if (cpi.maxio > MAXPHYS)
+               softc->maxio = MAXPHYS;         /* for safety */
+       else
+               softc->maxio = cpi.maxio;       /* real value */
+
        /*
         * We pass in 0 for all blocksize, since we don't know what the
         * blocksize of the device is, if it even has a blocksize.
@@ -894,7 +902,7 @@ sgsendccb(struct cam_periph *periph, union ccb *ccb)
         * need for additional checks.
         */
        cam_periph_unlock(periph);
-       error = cam_periph_mapmem(ccb, &mapinfo);
+       error = cam_periph_mapmem(ccb, &mapinfo, softc->maxio);
        cam_periph_lock(periph);
        if (error)
                return (error);
index 42dc15275e83243b38d23ce663e5bb4f340a0a49..f2504abb8c5f655fbd7c7fda79c605bed0816e2b 100644 (file)
@@ -94,6 +94,7 @@ struct targ_softc {
        struct cam_periph       *periph;
        struct cam_path         *path;
        targ_state               state;
+       u_int                    maxio;
        struct selinfo           read_select;
        struct devstat           device_stats;
 };
@@ -403,6 +404,12 @@ targenable(struct targ_softc *softc, struct cam_path *path, int grp6_len,
                status = CAM_FUNC_NOTAVAIL;
                goto enable_fail;
        }
+       if (cpi.maxio == 0)
+               softc->maxio = DFLTPHYS;        /* traditional default */
+       else if (cpi.maxio > MAXPHYS)
+               softc->maxio = MAXPHYS;         /* for safety */
+       else
+               softc->maxio = cpi.maxio;       /* real value */
 
        /* Destroy any periph on our path if it is disabled */
        periph = cam_periph_find(path, "targ");
@@ -725,7 +732,7 @@ targsendccb(struct targ_softc *softc, union ccb *ccb,
        if ((ccb_h->func_code == XPT_CONT_TARGET_IO) ||
            (ccb_h->func_code == XPT_DEV_MATCH)) {
 
-               error = cam_periph_mapmem(ccb, mapinfo);
+               error = cam_periph_mapmem(ccb, mapinfo, softc->maxio);
 
                /*
                 * cam_periph_mapmem returned an error, we can't continue.