Date: Thu, 1 Jul 2021 19:37:08 GMT From: Alexander Motin <mav@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: fa3d57c25610 - main - mrsas(4): Report more correct maximum I/O size. Message-ID: <202107011937.161Jb85H089023@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=fa3d57c256104649217b5022947de9c1c59a326e commit fa3d57c256104649217b5022947de9c1c59a326e Author: Alexander Motin <mav@FreeBSD.org> AuthorDate: 2021-07-01 19:28:55 +0000 Commit: Alexander Motin <mav@FreeBSD.org> CommitDate: 2021-07-01 19:37:01 +0000 mrsas(4): Report more correct maximum I/O size. Subtract one SGE for the case of misaligned address. Also take into account maximum number of sectors reported by firmware, that gives nicer 256KB limit instead of 276KB calculated from the SGE limit. While there, remove number of I/O size checks, duplicating what is already checked by CAM and busdma(9). MFC after: 1 month Sponsored by: iXsystems, Inc. --- sys/dev/mrsas/mrsas.c | 11 ++++++----- sys/dev/mrsas/mrsas_cam.c | 36 +----------------------------------- 2 files changed, 7 insertions(+), 40 deletions(-) diff --git a/sys/dev/mrsas/mrsas.c b/sys/dev/mrsas/mrsas.c index 01173387c8d4..8814642fccd0 100644 --- a/sys/dev/mrsas/mrsas.c +++ b/sys/dev/mrsas/mrsas.c @@ -1914,15 +1914,16 @@ mrsas_alloc_mem(struct mrsas_softc *sc) /* * Allocate parent DMA tag */ - if (bus_dma_tag_create(NULL, /* parent */ + if (bus_dma_tag_create( + bus_get_dma_tag(sc->mrsas_dev), /* parent */ 1, /* alignment */ 0, /* boundary */ BUS_SPACE_MAXADDR, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ - maxphys, /* maxsize */ - sc->max_num_sge, /* nsegments */ - maxphys, /* maxsegsize */ + BUS_SPACE_MAXSIZE, /* maxsize */ + BUS_SPACE_UNRESTRICTED, /* nsegments */ + BUS_SPACE_MAXSIZE, /* maxsegsize */ 0, /* flags */ NULL, NULL, /* lockfunc, lockarg */ &sc->mrsas_parent_tag /* tag */ @@ -2533,7 +2534,7 @@ mrsas_init_fw(struct mrsas_softc *sc) sc->ctrl_info->max_strips_per_io; max_sectors_2 = sc->ctrl_info->max_request_size; tmp_sectors = min(max_sectors_1, max_sectors_2); - sc->max_sectors_per_req = sc->max_num_sge * MRSAS_PAGE_SIZE / 512; + sc->max_sectors_per_req = (sc->max_num_sge - 1) * MRSAS_PAGE_SIZE / 512; if (tmp_sectors && (sc->max_sectors_per_req > tmp_sectors)) sc->max_sectors_per_req = tmp_sectors; diff --git a/sys/dev/mrsas/mrsas_cam.c b/sys/dev/mrsas/mrsas_cam.c index 3557782dae49..85dacdb9f306 100644 --- a/sys/dev/mrsas/mrsas_cam.c +++ b/sys/dev/mrsas/mrsas_cam.c @@ -369,7 +369,7 @@ mrsas_action(struct cam_sim *sim, union ccb *ccb) else ccb->cpi.max_target = MRSAS_MAX_LD_IDS - 1; #if (__FreeBSD_version > 704000) - ccb->cpi.maxio = sc->max_num_sge * MRSAS_PAGE_SIZE; + ccb->cpi.maxio = sc->max_sectors_per_req * 512; #endif ccb->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); @@ -513,21 +513,11 @@ mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim, ccb_h->status = CAM_REQ_INVALID; goto done; case CAM_DATA_VADDR: - if (csio->dxfer_len > (sc->max_num_sge * MRSAS_PAGE_SIZE)) { - mrsas_release_mpt_cmd(cmd); - ccb_h->status = CAM_REQ_TOO_BIG; - goto done; - } cmd->length = csio->dxfer_len; if (cmd->length) cmd->data = csio->data_ptr; break; case CAM_DATA_BIO: - if (csio->dxfer_len > (sc->max_num_sge * MRSAS_PAGE_SIZE)) { - mrsas_release_mpt_cmd(cmd); - ccb_h->status = CAM_REQ_TOO_BIG; - goto done; - } cmd->length = csio->dxfer_len; if (cmd->length) cmd->data = csio->data_ptr; @@ -539,11 +529,6 @@ mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim, #else if (!(ccb_h->flags & CAM_DATA_PHYS)) { /* Virtual data address */ if (!(ccb_h->flags & CAM_SCATTER_VALID)) { - if (csio->dxfer_len > (sc->max_num_sge * MRSAS_PAGE_SIZE)) { - mrsas_release_mpt_cmd(cmd); - ccb_h->status = CAM_REQ_TOO_BIG; - goto done; - } cmd->length = csio->dxfer_len; if (cmd->length) cmd->data = csio->data_ptr; @@ -867,11 +852,6 @@ mrsas_build_ldio_rw(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd, io_request->DataLength = htole32(cmd->length); if (mrsas_map_request(sc, cmd, ccb) == SUCCESS) { - if (cmd->sge_count > sc->max_num_sge) { - device_printf(sc->mrsas_dev, "Error: sge_count (0x%x) exceeds" - "max (0x%x) allowed\n", cmd->sge_count, sc->max_num_sge); - return (FAIL); - } if (sc->is_ventura || sc->is_aero) io_request->RaidContext.raid_context_g35.numSGE = cmd->sge_count; else { @@ -1234,11 +1214,6 @@ mrsas_build_ldio_nonrw(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd, io_request->DataLength = cmd->length; if (mrsas_map_request(sc, cmd, ccb) == SUCCESS) { - if (cmd->sge_count > sc->max_num_sge) { - device_printf(sc->mrsas_dev, "Error: sge_count (0x%x) exceeds" - "max (0x%x) allowed\n", cmd->sge_count, sc->max_num_sge); - return (1); - } if (sc->is_ventura || sc->is_aero) io_request->RaidContext.raid_context_g35.numSGE = cmd->sge_count; else { @@ -1364,11 +1339,6 @@ mrsas_build_syspdio(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd, io_request->DataLength = htole32(cmd->length); if (mrsas_map_request(sc, cmd, ccb) == SUCCESS) { - if (cmd->sge_count > sc->max_num_sge) { - device_printf(sc->mrsas_dev, "Error: sge_count (0x%x) exceeds" - "max (0x%x) allowed\n", cmd->sge_count, sc->max_num_sge); - return (1); - } if (sc->is_ventura || sc->is_aero) io_request->RaidContext.raid_context_g35.numSGE = cmd->sge_count; else { @@ -1714,10 +1684,6 @@ mrsas_data_load_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error) if (cmd->flags & MRSAS_DIR_OUT) bus_dmamap_sync(cmd->sc->data_tag, cmd->data_dmamap, BUS_DMASYNC_PREWRITE); - if (nseg > sc->max_num_sge) { - device_printf(sc->mrsas_dev, "SGE count is too large or 0.\n"); - return; - } /* Check for whether PRPs should be built or IEEE SGLs*/ if ((cmd->io_request->IoFlags & MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH) &&
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107011937.161Jb85H089023>