aboutsummaryrefslogtreecommitdiff
path: root/sys/cam
diff options
context:
space:
mode:
Diffstat (limited to 'sys/cam')
-rw-r--r--sys/cam/ata/ata_da.c4
-rw-r--r--sys/cam/cam_compat.c2
-rw-r--r--sys/cam/cam_periph.c16
-rw-r--r--sys/cam/cam_xpt.c2
-rw-r--r--sys/cam/ctl/ctl_backend_block.c58
-rw-r--r--sys/cam/mmc/mmc_da.c2
-rw-r--r--sys/cam/nvme/nvme_da.c4
-rw-r--r--sys/cam/scsi/scsi_cd.c4
-rw-r--r--sys/cam/scsi/scsi_da.c6
-rw-r--r--sys/cam/scsi/scsi_pass.c8
-rw-r--r--sys/cam/scsi/scsi_sa.c6
-rw-r--r--sys/cam/scsi/scsi_sg.c4
-rw-r--r--sys/cam/scsi/scsi_target.c4
13 files changed, 60 insertions, 60 deletions
diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c
index 99335e94bfca..cd49776e4f8b 100644
--- a/sys/cam/ata/ata_da.c
+++ b/sys/cam/ata/ata_da.c
@@ -3447,8 +3447,8 @@ adasetgeom(struct ada_softc *softc, struct ccb_getdev *cgd)
maxio = softc->cpi.maxio; /* Honor max I/O size of SIM */
if (maxio == 0)
maxio = DFLTPHYS; /* traditional default */
- else if (maxio > MAXPHYS)
- maxio = MAXPHYS; /* for safety */
+ else if (maxio > maxphys)
+ maxio = maxphys; /* for safety */
if (softc->flags & ADA_FLAG_CAN_48BIT)
maxio = min(maxio, 65536 * softc->params.secsize);
else /* 28bit ATA command limit */
diff --git a/sys/cam/cam_compat.c b/sys/cam/cam_compat.c
index 07aba7d357db..4c89072fa389 100644
--- a/sys/cam/cam_compat.c
+++ b/sys/cam/cam_compat.c
@@ -368,7 +368,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, MAXPHYS);
+ cam_periph_mapmem(ccb, &mapinfo, maxphys);
dm = ccb->cdm.matches;
/* Translate in-place: old fields are smaller */
diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c
index cc4a6d41ae76..aaa9bc3eada7 100644
--- a/sys/cam/cam_periph.c
+++ b/sys/cam/cam_periph.c
@@ -772,7 +772,7 @@ camperiphfree(struct cam_periph *periph)
* Map user virtual pointers into kernel virtual address space, so we can
* access the memory. This is now a generic function that centralizes most
* of the sanity checks on the data flags, if any.
- * This also only works for up to MAXPHYS memory. Since we use
+ * This also only works for up to maxphys memory. Since we use
* buffers to map stuff in and out, we're limited to the buffer size.
*/
int
@@ -788,8 +788,8 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo,
bzero(mapinfo, sizeof(*mapinfo));
if (maxmap == 0)
maxmap = DFLTPHYS; /* traditional default */
- else if (maxmap > MAXPHYS)
- maxmap = MAXPHYS; /* for safety */
+ 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) {
@@ -813,9 +813,9 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo,
}
/*
* This request will not go to the hardware, no reason
- * to be so strict. vmapbuf() is able to map up to MAXPHYS.
+ * to be so strict. vmapbuf() is able to map up to maxphys.
*/
- maxmap = MAXPHYS;
+ maxmap = maxphys;
break;
case XPT_SCSI_IO:
case XPT_CONT_TARGET_IO:
@@ -881,9 +881,9 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo,
/*
* This request will not go to the hardware, no reason
- * to be so strict. vmapbuf() is able to map up to MAXPHYS.
+ * to be so strict. vmapbuf() is able to map up to maxphys.
*/
- maxmap = MAXPHYS;
+ maxmap = maxphys;
break;
default:
return(EINVAL);
@@ -911,7 +911,7 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo,
* boundary.
*/
misaligned[i] = (lengths[i] +
- (((vm_offset_t)(*data_ptrs[i])) & PAGE_MASK) > MAXPHYS);
+ (((vm_offset_t)(*data_ptrs[i])) & PAGE_MASK) > maxphys);
}
/*
diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c
index 12d001ef729c..d71b8ef81240 100644
--- a/sys/cam/cam_xpt.c
+++ b/sys/cam/cam_xpt.c
@@ -553,7 +553,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, MAXPHYS);
+ error = cam_periph_mapmem(inccb, &mapinfo, maxphys);
if (error) {
inccb->ccb_h.path = old_path;
diff --git a/sys/cam/ctl/ctl_backend_block.c b/sys/cam/ctl/ctl_backend_block.c
index 2e79b166339b..cd4fab766844 100644
--- a/sys/cam/ctl/ctl_backend_block.c
+++ b/sys/cam/ctl/ctl_backend_block.c
@@ -102,9 +102,11 @@ __FBSDID("$FreeBSD$");
*/
#define CTLBLK_HALF_IO_SIZE (512 * 1024)
#define CTLBLK_MAX_IO_SIZE (CTLBLK_HALF_IO_SIZE * 2)
-#define CTLBLK_MAX_SEG MIN(CTLBLK_HALF_IO_SIZE, MAXPHYS)
-#define CTLBLK_HALF_SEGS MAX(CTLBLK_HALF_IO_SIZE / CTLBLK_MAX_SEG, 1)
+#define CTLBLK_MIN_SEG (128 * 1024)
+#define CTLBLK_MAX_SEG MIN(CTLBLK_HALF_IO_SIZE, maxphys)
+#define CTLBLK_HALF_SEGS MAX(CTLBLK_HALF_IO_SIZE / CTLBLK_MIN_SEG, 1)
#define CTLBLK_MAX_SEGS (CTLBLK_HALF_SEGS * 2)
+#define CTLBLK_NUM_SEGS (CTLBLK_MAX_IO_SIZE / CTLBLK_MAX_SEG)
#ifdef CTLBLK_DEBUG
#define DPRINTF(fmt, args...) \
@@ -189,10 +191,8 @@ struct ctl_be_block_softc {
int num_luns;
SLIST_HEAD(, ctl_be_block_lun) lun_list;
uma_zone_t beio_zone;
- uma_zone_t buf_zone;
-#if (CTLBLK_MAX_SEG > 131072)
- uma_zone_t buf128_zone;
-#endif
+ uma_zone_t bufmin_zone;
+ uma_zone_t bufmax_zone;
};
static struct ctl_be_block_softc backend_block_softc;
@@ -307,12 +307,13 @@ ctl_alloc_seg(struct ctl_be_block_softc *softc, struct ctl_sg_entry *sg,
size_t len)
{
-#if (CTLBLK_MAX_SEG > 131072)
- if (len <= 131072)
- sg->addr = uma_zalloc(softc->buf128_zone, M_WAITOK);
- else
-#endif
- sg->addr = uma_zalloc(softc->buf_zone, M_WAITOK);
+ if (len <= CTLBLK_MIN_SEG) {
+ sg->addr = uma_zalloc(softc->bufmin_zone, M_WAITOK);
+ } else {
+ KASSERT(len <= CTLBLK_MAX_SEG,
+ ("Too large alloc %zu > %lu", len, CTLBLK_MAX_SEG));
+ sg->addr = uma_zalloc(softc->bufmax_zone, M_WAITOK);
+ }
sg->len = len;
}
@@ -320,12 +321,13 @@ static void
ctl_free_seg(struct ctl_be_block_softc *softc, struct ctl_sg_entry *sg)
{
-#if (CTLBLK_MAX_SEG > 131072)
- if (sg->len <= 131072)
- uma_zfree(softc->buf128_zone, sg->addr);
- else
-#endif
- uma_zfree(softc->buf_zone, sg->addr);
+ if (sg->len <= CTLBLK_MIN_SEG) {
+ uma_zfree(softc->bufmin_zone, sg->addr);
+ } else {
+ KASSERT(sg->len <= CTLBLK_MAX_SEG,
+ ("Too large free %zu > %lu", sg->len, CTLBLK_MAX_SEG));
+ uma_zfree(softc->bufmax_zone, sg->addr);
+ }
}
static struct ctl_be_block_io *
@@ -1344,7 +1346,7 @@ ctl_be_block_cw_dispatch_ws(struct ctl_be_block_lun *be_lun,
else
pbo = 0;
len_left = (uint64_t)lbalen->len * cbe_lun->blocksize;
- for (i = 0, lba = 0; i < CTLBLK_MAX_SEGS && len_left > 0; i++) {
+ for (i = 0, lba = 0; i < CTLBLK_NUM_SEGS && len_left > 0; i++) {
/*
* Setup the S/G entry for this chunk.
*/
@@ -1631,7 +1633,7 @@ ctl_be_block_dispatch(struct ctl_be_block_lun *be_lun,
* Setup the S/G entry for this chunk.
*/
ctl_alloc_seg(softc, &beio->sg_segs[i],
- min(CTLBLK_MAX_SEG, len_left));
+ MIN(CTLBLK_MAX_SEG, len_left));
DPRINTF("segment %d addr %p len %zd\n", i,
beio->sg_segs[i].addr, beio->sg_segs[i].len);
@@ -2802,12 +2804,11 @@ ctl_be_block_init(void)
mtx_init(&softc->lock, "ctlblock", NULL, MTX_DEF);
softc->beio_zone = uma_zcreate("beio", sizeof(struct ctl_be_block_io),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
- softc->buf_zone = uma_zcreate("ctlblock", CTLBLK_MAX_SEG,
+ softc->bufmin_zone = uma_zcreate("ctlblockmin", CTLBLK_MIN_SEG,
NULL, NULL, NULL, NULL, /*align*/ 0, /*flags*/0);
-#if (CTLBLK_MAX_SEG > 131072)
- softc->buf128_zone = uma_zcreate("ctlblock128", 131072,
- NULL, NULL, NULL, NULL, /*align*/ 0, /*flags*/0);
-#endif
+ if (CTLBLK_MIN_SEG < CTLBLK_MAX_SEG)
+ softc->bufmax_zone = uma_zcreate("ctlblockmax", CTLBLK_MAX_SEG,
+ NULL, NULL, NULL, NULL, /*align*/ 0, /*flags*/0);
SLIST_INIT(&softc->lun_list);
return (0);
}
@@ -2832,10 +2833,9 @@ ctl_be_block_shutdown(void)
mtx_lock(&softc->lock);
}
mtx_unlock(&softc->lock);
- uma_zdestroy(softc->buf_zone);
-#if (CTLBLK_MAX_SEG > 131072)
- uma_zdestroy(softc->buf128_zone);
-#endif
+ uma_zdestroy(softc->bufmin_zone);
+ if (CTLBLK_MIN_SEG < CTLBLK_MAX_SEG)
+ uma_zdestroy(softc->bufmax_zone);
uma_zdestroy(softc->beio_zone);
mtx_destroy(&softc->lock);
sx_destroy(&softc->modify_lock);
diff --git a/sys/cam/mmc/mmc_da.c b/sys/cam/mmc/mmc_da.c
index 1f6d116510f6..127d1cb48602 100644
--- a/sys/cam/mmc/mmc_da.c
+++ b/sys/cam/mmc/mmc_da.c
@@ -1592,7 +1592,7 @@ sdda_add_part(struct cam_periph *periph, u_int type, const char *name,
part->disk->d_name = part->name;
part->disk->d_drv1 = part;
part->disk->d_maxsize =
- MIN(MAXPHYS, sdda_get_max_data(periph,
+ MIN(maxphys, sdda_get_max_data(periph,
(union ccb *)&cpi) * mmc_get_sector_size(periph));
part->disk->d_unit = cnt;
part->disk->d_flags = 0;
diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c
index 73079f90d781..8e7f7318ce3b 100644
--- a/sys/cam/nvme/nvme_da.c
+++ b/sys/cam/nvme/nvme_da.c
@@ -906,8 +906,8 @@ ndaregister(struct cam_periph *periph, void *arg)
maxio = cpi.maxio; /* Honor max I/O size of SIM */
if (maxio == 0)
maxio = DFLTPHYS; /* traditional default */
- else if (maxio > MAXPHYS)
- maxio = MAXPHYS; /* for safety */
+ else if (maxio > maxphys)
+ maxio = maxphys; /* for safety */
disk->d_maxsize = maxio;
flbas_fmt = (nsd->flbas >> NVME_NS_DATA_FLBAS_FORMAT_SHIFT) &
NVME_NS_DATA_FLBAS_FORMAT_MASK;
diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c
index 2b4bdc6020fd..e009b0a586c3 100644
--- a/sys/cam/scsi/scsi_cd.c
+++ b/sys/cam/scsi/scsi_cd.c
@@ -696,8 +696,8 @@ cdregister(struct cam_periph *periph, void *arg)
softc->disk->d_drv1 = periph;
if (cpi.maxio == 0)
softc->disk->d_maxsize = DFLTPHYS; /* traditional default */
- else if (cpi.maxio > MAXPHYS)
- softc->disk->d_maxsize = MAXPHYS; /* for safety */
+ else if (cpi.maxio > maxphys)
+ softc->disk->d_maxsize = maxphys; /* for safety */
else
softc->disk->d_maxsize = cpi.maxio;
softc->disk->d_flags = 0;
diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c
index ac1d9456a5d1..490f75336efd 100644
--- a/sys/cam/scsi/scsi_da.c
+++ b/sys/cam/scsi/scsi_da.c
@@ -2921,8 +2921,8 @@ daregister(struct cam_periph *periph, void *arg)
softc->disk->d_drv1 = periph;
if (cpi.maxio == 0)
softc->maxio = DFLTPHYS; /* traditional default */
- else if (cpi.maxio > MAXPHYS)
- softc->maxio = MAXPHYS; /* for safety */
+ else if (cpi.maxio > maxphys)
+ softc->maxio = maxphys; /* for safety */
else
softc->maxio = cpi.maxio;
if (softc->quirks & DA_Q_128KB)
@@ -4819,7 +4819,7 @@ dadone_proberc(struct cam_periph *periph, union ccb *done_ccb)
if (maxsector == 0)
maxsector = -1;
}
- if (block_size >= MAXPHYS) {
+ if (block_size >= maxphys) {
xpt_print(periph->path,
"unsupportable block size %ju\n",
(uintmax_t) block_size);
diff --git a/sys/cam/scsi/scsi_pass.c b/sys/cam/scsi/scsi_pass.c
index 79e86ccaf267..146ff8f26700 100644
--- a/sys/cam/scsi/scsi_pass.c
+++ b/sys/cam/scsi/scsi_pass.c
@@ -583,15 +583,15 @@ passregister(struct cam_periph *periph, void *arg)
periph->periph_name, periph->unit_number);
snprintf(softc->io_zone_name, sizeof(softc->io_zone_name), "%s%dIO",
periph->periph_name, periph->unit_number);
- softc->io_zone_size = MAXPHYS;
+ softc->io_zone_size = maxphys;
knlist_init_mtx(&softc->read_select.si_note, cam_periph_mtx(periph));
xpt_path_inq(&cpi, periph->path);
if (cpi.maxio == 0)
softc->maxio = DFLTPHYS; /* traditional default */
- else if (cpi.maxio > MAXPHYS)
- softc->maxio = MAXPHYS; /* for safety */
+ else if (cpi.maxio > maxphys)
+ softc->maxio = maxphys; /* for safety */
else
softc->maxio = cpi.maxio; /* real value */
@@ -1507,7 +1507,7 @@ passmemsetup(struct cam_periph *periph, struct pass_io_req *io_req)
/*
* We allocate buffers in io_zone_size increments for an
- * S/G list. This will generally be MAXPHYS.
+ * S/G list. This will generally be maxphys.
*/
if (lengths[0] <= softc->io_zone_size)
num_segs_needed = 1;
diff --git a/sys/cam/scsi/scsi_sa.c b/sys/cam/scsi/scsi_sa.c
index fe2912c8b52c..9441e0d4673b 100644
--- a/sys/cam/scsi/scsi_sa.c
+++ b/sys/cam/scsi/scsi_sa.c
@@ -2447,12 +2447,12 @@ saregister(struct cam_periph *periph, void *arg)
/*
* If maxio isn't set, we fall back to DFLTPHYS. Otherwise we take
- * the smaller of cpi.maxio or MAXPHYS.
+ * the smaller of cpi.maxio or maxphys.
*/
if (cpi.maxio == 0)
softc->maxio = DFLTPHYS;
- else if (cpi.maxio > MAXPHYS)
- softc->maxio = MAXPHYS;
+ else if (cpi.maxio > maxphys)
+ softc->maxio = maxphys;
else
softc->maxio = cpi.maxio;
diff --git a/sys/cam/scsi/scsi_sg.c b/sys/cam/scsi/scsi_sg.c
index 81b964a6828e..8e3f0a27ab58 100644
--- a/sys/cam/scsi/scsi_sg.c
+++ b/sys/cam/scsi/scsi_sg.c
@@ -327,8 +327,8 @@ sgregister(struct cam_periph *periph, void *arg)
if (cpi.maxio == 0)
softc->maxio = DFLTPHYS; /* traditional default */
- else if (cpi.maxio > MAXPHYS)
- softc->maxio = MAXPHYS; /* for safety */
+ else if (cpi.maxio > maxphys)
+ softc->maxio = maxphys; /* for safety */
else
softc->maxio = cpi.maxio; /* real value */
diff --git a/sys/cam/scsi/scsi_target.c b/sys/cam/scsi/scsi_target.c
index b8713bded1cb..b2874f49f13f 100644
--- a/sys/cam/scsi/scsi_target.c
+++ b/sys/cam/scsi/scsi_target.c
@@ -404,8 +404,8 @@ targenable(struct targ_softc *softc, struct cam_path *path, int grp6_len,
}
if (cpi.maxio == 0)
softc->maxio = DFLTPHYS; /* traditional default */
- else if (cpi.maxio > MAXPHYS)
- softc->maxio = MAXPHYS; /* for safety */
+ else if (cpi.maxio > maxphys)
+ softc->maxio = maxphys; /* for safety */
else
softc->maxio = cpi.maxio; /* real value */