Index: sys/dev/mps/mps.c =================================================================== --- sys/dev/mps/mps.c +++ sys/dev/mps/mps.c @@ -1350,6 +1350,7 @@ sc->disable_msix = 0; sc->disable_msi = 0; sc->max_chains = MPS_CHAIN_FRAMES; + sc->max_io_pages = MPS_MAXIO_PAGES; sc->enable_ssu = MPS_SSU_ENABLE_SSD_DISABLE_HDD; sc->spinup_wait_time = DEFAULT_SPINUP_WAIT; @@ -1360,6 +1361,7 @@ TUNABLE_INT_FETCH("hw.mps.disable_msix", &sc->disable_msix); TUNABLE_INT_FETCH("hw.mps.disable_msi", &sc->disable_msi); TUNABLE_INT_FETCH("hw.mps.max_chains", &sc->max_chains); + TUNABLE_INT_FETCH("hw.mps.max_io_pages", &sc->max_io_pages); TUNABLE_INT_FETCH("hw.mps.enable_ssu", &sc->enable_ssu); TUNABLE_INT_FETCH("hw.mps.spinup_wait_time", &sc->spinup_wait_time); @@ -1380,6 +1382,10 @@ device_get_unit(sc->mps_dev)); TUNABLE_INT_FETCH(tmpstr, &sc->max_chains); + snprintf(tmpstr, sizeof(tmpstr), "dev.mps.%d.max_io_pages", + device_get_unit(sc->mps_dev)); + TUNABLE_INT_FETCH(tmpstr, &sc->max_io_pages); + bzero(sc->exclude_ids, sizeof(sc->exclude_ids)); snprintf(tmpstr, sizeof(tmpstr), "dev.mps.%d.exclude_ids", device_get_unit(sc->mps_dev)); @@ -1465,6 +1471,11 @@ &sc->max_chains, 0,"maximum chain frames that will be allocated"); SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), + OID_AUTO, "max_io_pages", CTLFLAG_RD, + &sc->max_io_pages, 0,"maximum pages to allow per I/O (if <1 use " + "IOCFacts)"); + + SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "enable_ssu", CTLFLAG_RW, &sc->enable_ssu, 0, "enable SSU to SATA SSD/HDD at shutdown"); Index: sys/dev/mps/mps_sas.c =================================================================== --- sys/dev/mps/mps_sas.c +++ sys/dev/mps/mps_sas.c @@ -928,6 +928,8 @@ case XPT_PATH_INQ: { struct ccb_pathinq *cpi = &ccb->cpi; + struct mps_softc *sc = sassc->sc; + uint8_t sges_per_frame; cpi->version_num = 1; cpi->hba_inquiry = PI_SDTR_ABLE|PI_TAG_ABLE|PI_WIDE_16; @@ -951,12 +953,23 @@ cpi->transport_version = 0; cpi->protocol = PROTO_SCSI; cpi->protocol_version = SCSI_REV_SPC; -#if __FreeBSD_version >= 800001 + /* - * XXX KDM where does this number come from? - */ - cpi->maxio = 256 * 1024; -#endif + * Max IO Size is Page Size * the following: + * ((SGEs per frame - 1 for chain element) * + * Max Chain Depth) + 1 for no chain needed in last frame + * + * If user suggests a Max IO size to use, use the smaller of the + * user's value and the calculated value as long as the user's + * value is larger than 0. The user's value is in pages. + */ + sges_per_frame = ((sc->facts->IOCRequestFrameSize * 4) / + sizeof(MPI2_SGE_SIMPLE64)) - 1; + cpi->maxio = (sges_per_frame * sc->facts->MaxChainDepth) + 1; + cpi->maxio *= PAGE_SIZE; + if ((sc->max_io_pages > 0) && (sc->max_io_pages * PAGE_SIZE < + cpi->maxio)) + cpi->maxio = sc->max_io_pages * PAGE_SIZE; mpssas_set_ccbstatus(ccb, CAM_REQ_CMP); break; } Index: sys/dev/mps/mpsvar.h =================================================================== --- sys/dev/mps/mpsvar.h +++ sys/dev/mps/mpsvar.h @@ -41,6 +41,7 @@ #define MPS_EVT_REPLY_FRAMES 32 #define MPS_REPLY_FRAMES MPS_REQ_FRAMES #define MPS_CHAIN_FRAMES 2048 +#define MPS_MAXIO_PAGES (-1) #define MPS_SENSE_LEN SSD_FULL_SIZE #define MPS_MSI_COUNT 1 #define MPS_SGE64_SIZE 12 @@ -280,6 +281,7 @@ int io_cmds_highwater; int chain_free; int max_chains; + int max_io_pages; int chain_free_lowwater; u_int enable_ssu; int spinup_wait_time;