Date: Mon, 5 Oct 2015 08:46:48 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r288723 - stable/10/sys/cam/ctl Message-ID: <201510050846.t958km6R014240@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Mon Oct 5 08:46:48 2015 New Revision: 288723 URL: https://svnweb.freebsd.org/changeset/base/288723 Log: MFC r287293: Remove 600 bytes of port_priv from struct ctl_io_hdr. This field used only for camtgt frontend, and once it any way preallocates all requests, let it preallocate this memory too, not bothering core code. Modified: stable/10/sys/cam/ctl/ctl_io.h stable/10/sys/cam/ctl/scsi_ctl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/ctl_io.h ============================================================================== --- stable/10/sys/cam/ctl/ctl_io.h Mon Oct 5 08:45:56 2015 (r288722) +++ stable/10/sys/cam/ctl/ctl_io.h Mon Oct 5 08:46:48 2015 (r288723) @@ -173,35 +173,11 @@ union ctl_priv { #define CTL_PRIV_MODEPAGE 1 /* Modepage info for config write */ #define CTL_PRIV_BACKEND 2 /* Reserved for block, RAIDCore */ #define CTL_PRIV_BACKEND_LUN 3 /* Backend LUN pointer */ -#define CTL_PRIV_FRONTEND 4 /* LSI driver, ioctl front end */ -#define CTL_PRIV_USER 5 /* Userland use */ +#define CTL_PRIV_FRONTEND 4 /* Frontend storage */ +#define CTL_PRIV_FRONTEND2 5 /* Another frontend storage */ #define CTL_INVALID_PORTNAME 0xFF #define CTL_UNMAPPED_IID 0xFF -/* - * XXX KDM this size is for the port_priv variable in struct ctl_io_hdr - * below. This should be defined in terms of the size of struct - * ctlfe_lun_cmd_info at the moment: - * struct ctlfe_lun_cmd_info { - * int cur_transfer_index; - * ctlfe_cmd_flags flags; - * bus_dma_segment_t cam_sglist[32]; - * }; - * - * This isn't really the way I'd prefer to do it, but it does make some - * sense, AS LONG AS we can guarantee that there will always only be one - * outstanding DMA request per ctl_io. If that assumption isn't valid, - * then we've got problems. - * - * At some point it may be nice switch CTL over to using CCBs for - * everything. At that point we can probably use the ATIO/CTIO model, so - * that multiple simultaneous DMAs per command will just work. - * - * Also note that the current size, 600, is appropriate for 64-bit - * architectures, but is overkill for 32-bit architectures. Need a way to - * figure out the size at compile time, or just get rid of this altogether. - */ -#define CTL_PORT_PRIV_SIZE 600 struct ctl_sg_entry { void *addr; @@ -268,7 +244,6 @@ struct ctl_io_hdr { union ctl_io *serializing_sc; void *pool; /* I/O pool */ union ctl_priv ctl_private[CTL_NUM_PRIV];/* CTL private area */ - uint8_t port_priv[CTL_PORT_PRIV_SIZE];/* PORT private area*/ struct ctl_sg_entry remote_sglist[CTL_NUM_SG_ENTRIES]; struct ctl_sg_entry remote_dma_sglist[CTL_NUM_SG_ENTRIES]; struct ctl_sg_entry local_sglist[CTL_NUM_SG_ENTRIES]; Modified: stable/10/sys/cam/ctl/scsi_ctl.c ============================================================================== --- stable/10/sys/cam/ctl/scsi_ctl.c Mon Oct 5 08:45:56 2015 (r288722) +++ stable/10/sys/cam/ctl/scsi_ctl.c Mon Oct 5 08:46:48 2015 (r288723) @@ -119,11 +119,7 @@ typedef enum { CTLFE_CMD_PIECEWISE = 0x01 } ctlfe_cmd_flags; -/* - * The size limit of this structure is CTL_PORT_PRIV_SIZE, from ctl_io.h. - * Currently that is 600 bytes. - */ -struct ctlfe_lun_cmd_info { +struct ctlfe_cmd_info { int cur_transfer_index; size_t cur_transfer_off; ctlfe_cmd_flags flags; @@ -135,7 +131,6 @@ struct ctlfe_lun_cmd_info { #define CTLFE_MAX_SEGS 32 bus_dma_segment_t cam_sglist[CTLFE_MAX_SEGS]; }; -CTASSERT(sizeof(struct ctlfe_lun_cmd_info) <= CTL_PORT_PRIV_SIZE); /* * When we register the adapter/bus, request that this many ctl_ios be @@ -533,6 +528,7 @@ ctlferegister(struct cam_periph *periph, for (i = 0; i < CTLFE_ATIO_PER_LUN; i++) { union ccb *new_ccb; union ctl_io *new_io; + struct ctlfe_cmd_info *cmd_info; new_ccb = (union ccb *)malloc(sizeof(*new_ccb), M_CTLFE, M_ZERO|M_NOWAIT); @@ -546,6 +542,15 @@ ctlferegister(struct cam_periph *periph, status = CAM_RESRC_UNAVAIL; break; } + cmd_info = malloc(sizeof(*cmd_info), M_CTLFE, + M_ZERO | M_NOWAIT); + if (cmd_info == NULL) { + ctl_free_io(new_io); + free(new_ccb, M_CTLFE); + status = CAM_RESRC_UNAVAIL; + break; + } + new_io->io_hdr.ctl_private[CTL_PRIV_FRONTEND2].ptr = cmd_info; softc->atios_alloced++; new_ccb->ccb_h.io_ptr = new_io; @@ -556,6 +561,7 @@ ctlferegister(struct cam_periph *periph, xpt_action(new_ccb); status = new_ccb->ccb_h.status; if ((status & CAM_STATUS_MASK) != CAM_REQ_INPROG) { + free(cmd_info, M_CTLFE); ctl_free_io(new_io); free(new_ccb, M_CTLFE); break; @@ -686,13 +692,13 @@ ctlfedata(struct ctlfe_lun_softc *softc, u_int16_t *sglist_cnt) { struct ctlfe_softc *bus_softc; - struct ctlfe_lun_cmd_info *cmd_info; + struct ctlfe_cmd_info *cmd_info; struct ctl_sg_entry *ctl_sglist; bus_dma_segment_t *cam_sglist; size_t off; int i, idx; - cmd_info = (struct ctlfe_lun_cmd_info *)io->io_hdr.port_priv; + cmd_info = io->io_hdr.ctl_private[CTL_PRIV_FRONTEND2].ptr; bus_softc = softc->parent_softc; /* @@ -768,7 +774,7 @@ static void ctlfestart(struct cam_periph *periph, union ccb *start_ccb) { struct ctlfe_lun_softc *softc; - struct ctlfe_lun_cmd_info *cmd_info; + struct ctlfe_cmd_info *cmd_info; struct ccb_hdr *ccb_h; struct ccb_accept_tio *atio; struct ccb_scsiio *csio; @@ -796,7 +802,7 @@ ctlfestart(struct cam_periph *periph, un flags = atio->ccb_h.flags & (CAM_DIS_DISCONNECT|CAM_TAG_ACTION_VALID|CAM_DIR_MASK); - cmd_info = (struct ctlfe_lun_cmd_info *)io->io_hdr.port_priv; + cmd_info = io->io_hdr.ctl_private[CTL_PRIV_FRONTEND2].ptr; cmd_info->cur_transfer_index = 0; cmd_info->cur_transfer_off = 0; cmd_info->flags = 0; @@ -968,12 +974,17 @@ static void ctlfe_free_ccb(struct cam_periph *periph, union ccb *ccb) { struct ctlfe_lun_softc *softc; + union ctl_io *io; + struct ctlfe_cmd_info *cmd_info; softc = (struct ctlfe_lun_softc *)periph->softc; + io = ccb->ccb_h.io_ptr; switch (ccb->ccb_h.func_code) { case XPT_ACCEPT_TARGET_IO: softc->atios_freed++; + cmd_info = io->io_hdr.ctl_private[CTL_PRIV_FRONTEND2].ptr; + free(cmd_info, M_CTLFE); break; case XPT_IMMEDIATE_NOTIFY: case XPT_NOTIFY_ACKNOWLEDGE: @@ -983,7 +994,7 @@ ctlfe_free_ccb(struct cam_periph *periph break; } - ctl_free_io(ccb->ccb_h.io_ptr); + ctl_free_io(io); free(ccb, M_CTLFE); KASSERT(softc->atios_freed <= softc->atios_alloced, ("%s: " @@ -1078,6 +1089,7 @@ ctlfedone(struct cam_periph *periph, uni { struct ctlfe_lun_softc *softc; struct ctlfe_softc *bus_softc; + struct ctlfe_cmd_info *cmd_info; struct ccb_accept_tio *atio = NULL; union ctl_io *io = NULL; struct mtx *mtx; @@ -1139,10 +1151,12 @@ ctlfedone(struct cam_periph *periph, uni */ mtx_unlock(mtx); io = done_ccb->ccb_h.io_ptr; + cmd_info = io->io_hdr.ctl_private[CTL_PRIV_FRONTEND2].ptr; ctl_zero_io(io); /* Save pointers on both sides */ io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = done_ccb; + io->io_hdr.ctl_private[CTL_PRIV_FRONTEND2].ptr = cmd_info; done_ccb->ccb_h.io_ptr = io; /* @@ -1291,12 +1305,11 @@ ctlfedone(struct cam_periph *periph, uni return; } } else { - struct ctlfe_lun_cmd_info *cmd_info; + struct ctlfe_cmd_info *cmd_info; struct ccb_scsiio *csio; csio = &done_ccb->csio; - cmd_info = (struct ctlfe_lun_cmd_info *) - io->io_hdr.port_priv; + cmd_info = io->io_hdr.ctl_private[CTL_PRIV_FRONTEND2].ptr; io->io_hdr.flags &= ~CTL_FLAG_DMA_INPROG;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510050846.t958km6R014240>