From owner-svn-src-head@freebsd.org Mon Dec 24 05:05:41 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 492AF1356F68; Mon, 24 Dec 2018 05:05:41 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8BEE16F97F; Mon, 24 Dec 2018 05:05:40 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 805C51FC01; Mon, 24 Dec 2018 05:05:40 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wBO55ewl015437; Mon, 24 Dec 2018 05:05:40 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wBO55dPL015431; Mon, 24 Dec 2018 05:05:39 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <201812240505.wBO55dPL015431@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Mon, 24 Dec 2018 05:05:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r342386 - in head/sys/dev: mpr mps X-SVN-Group: head X-SVN-Commit-Author: scottl X-SVN-Commit-Paths: in head/sys/dev: mpr mps X-SVN-Commit-Revision: 342386 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8BEE16F97F X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.955,0]; NEURAL_HAM_LONG(-1.00)[-0.998,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Dec 2018 05:05:41 -0000 Author: scottl Date: Mon Dec 24 05:05:38 2018 New Revision: 342386 URL: https://svnweb.freebsd.org/changeset/base/342386 Log: First step in refactoring and fixing the error recovery and task management code in the mpr and mps drivers. Eliminate duplicated code and fix some comments. Modified: head/sys/dev/mpr/mpr_sas.c head/sys/dev/mpr/mpr_user.c head/sys/dev/mpr/mprvar.h head/sys/dev/mps/mps_sas.c head/sys/dev/mps/mps_user.c head/sys/dev/mps/mpsvar.h Modified: head/sys/dev/mpr/mpr_sas.c ============================================================================== --- head/sys/dev/mpr/mpr_sas.c Mon Dec 24 01:12:43 2018 (r342385) +++ head/sys/dev/mpr/mpr_sas.c Mon Dec 24 05:05:38 2018 (r342386) @@ -229,9 +229,12 @@ mprsas_startup_decrement(struct mprsas_softc *sassc) } } -/* The firmware requires us to stop sending commands when we're doing task - * management, so refcount the TMs and keep the simq frozen when any are in +/* + * The firmware requires us to stop sending commands when we're doing task + * management. * use. + * XXX The logic for serializing the device has been made lazy and moved to + * mprsas_prepare_for_tm(). */ struct mpr_command * mprsas_alloc_tm(struct mpr_softc *sc) @@ -467,8 +470,6 @@ mprsas_prepare_volume_remove(struct mprsas_softc *sass cm->cm_targ = targ; cm->cm_data = NULL; - cm->cm_desc.HighPriority.RequestFlags = - MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY; cm->cm_complete = mprsas_remove_volume; cm->cm_complete_data = (void *)(uintptr_t)handle; @@ -531,8 +532,6 @@ mprsas_prepare_remove(struct mprsas_softc *sassc, uint cm->cm_targ = targ; cm->cm_data = NULL; - cm->cm_desc.HighPriority.RequestFlags = - MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY; cm->cm_complete = mprsas_remove_device; cm->cm_complete_data = (void *)(uintptr_t)handle; @@ -1494,8 +1493,6 @@ mprsas_send_reset(struct mpr_softc *sc, struct mpr_com } tm->cm_data = NULL; - tm->cm_desc.HighPriority.RequestFlags = - MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY; tm->cm_complete_data = (void *)tm; callout_reset(&tm->cm_callout, MPR_RESET_TIMEOUT * hz, @@ -1623,8 +1620,6 @@ mprsas_send_abort(struct mpr_softc *sc, struct mpr_com req->TaskMID = htole16(cm->cm_desc.Default.SMID); tm->cm_data = NULL; - tm->cm_desc.HighPriority.RequestFlags = - MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY; tm->cm_complete = mprsas_abort_complete; tm->cm_complete_data = (void *)tm; tm->cm_targ = cm->cm_targ; @@ -3336,8 +3331,6 @@ mprsas_action_resetdev(struct mprsas_softc *sassc, uni req->MsgFlags = MPI2_SCSITASKMGMT_MSGFLAGS_LINK_RESET; tm->cm_data = NULL; - tm->cm_desc.HighPriority.RequestFlags = - MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY; tm->cm_complete = mprsas_resetdev_complete; tm->cm_complete_data = ccb; @@ -3750,6 +3743,13 @@ mprsas_read_cap_done(struct cam_periph *periph, union #endif /* (__FreeBSD_version < 901503) || \ ((__FreeBSD_version >= 1000000) && (__FreeBSD_version < 1000006)) */ +/* + * Set the INRESET flag for this target so that no I/O will be sent to + * the target until the reset has completed. If an I/O request does + * happen, the devq will be frozen. The CCB holds the path which is + * used to release the devq. The devq is released and the CCB is freed + * when the TM completes. + */ void mprsas_prepare_for_tm(struct mpr_softc *sc, struct mpr_command *tm, struct mprsas_target *target, lun_id_t lun_id) @@ -3757,13 +3757,6 @@ mprsas_prepare_for_tm(struct mpr_softc *sc, struct mpr union ccb *ccb; path_id_t path_id; - /* - * Set the INRESET flag for this target so that no I/O will be sent to - * the target until the reset has completed. If an I/O request does - * happen, the devq will be frozen. The CCB holds the path which is - * used to release the devq. The devq is released and the CCB is freed - * when the TM completes. - */ ccb = xpt_alloc_ccb_nowait(); if (ccb) { path_id = cam_sim_path(sc->sassc->sim); Modified: head/sys/dev/mpr/mpr_user.c ============================================================================== --- head/sys/dev/mpr/mpr_user.c Mon Dec 24 01:12:43 2018 (r342385) +++ head/sys/dev/mpr/mpr_user.c Mon Dec 24 05:05:38 2018 (r342386) @@ -835,8 +835,6 @@ mpr_user_pass_thru(struct mpr_softc *sc, mpr_pass_thru task->TaskMID = cm->cm_desc.Default.SMID; cm->cm_data = NULL; - cm->cm_desc.HighPriority.RequestFlags = - MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY; cm->cm_complete = NULL; cm->cm_complete_data = NULL; Modified: head/sys/dev/mpr/mprvar.h ============================================================================== --- head/sys/dev/mpr/mprvar.h Mon Dec 24 01:12:43 2018 (r342385) +++ head/sys/dev/mpr/mprvar.h Mon Dec 24 05:05:38 2018 (r342386) @@ -657,6 +657,8 @@ mpr_alloc_high_priority_command(struct mpr_softc *sc) TAILQ_REMOVE(&sc->high_priority_req_list, cm, cm_link); cm->cm_state = MPR_CM_STATE_BUSY; cm->cm_timeout_handler = NULL; + cm->cm_desc.HighPriority.RequestFlags = + MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY; return (cm); } Modified: head/sys/dev/mps/mps_sas.c ============================================================================== --- head/sys/dev/mps/mps_sas.c Mon Dec 24 01:12:43 2018 (r342385) +++ head/sys/dev/mps/mps_sas.c Mon Dec 24 05:05:38 2018 (r342386) @@ -227,9 +227,11 @@ mpssas_startup_decrement(struct mpssas_softc *sassc) } } -/* The firmware requires us to stop sending commands when we're doing task - * management, so refcount the TMs and keep the simq frozen when any are in - * use. +/* + * The firmware requires us to stop sending commands when we're doing task + * management. + * XXX The logic for serializing the device has been made lazy and moved to + * mpssas_prepare_for_tm(). */ struct mps_command * mpssas_alloc_tm(struct mps_softc *sc) @@ -472,8 +474,6 @@ mpssas_prepare_volume_remove(struct mpssas_softc *sass cm->cm_targ = targ; cm->cm_data = NULL; - cm->cm_desc.HighPriority.RequestFlags = - MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY; cm->cm_complete = mpssas_remove_volume; cm->cm_complete_data = (void *)(uintptr_t)handle; @@ -536,7 +536,6 @@ mpssas_prepare_remove(struct mpssas_softc *sassc, uint cm->cm_targ = targ; cm->cm_data = NULL; - cm->cm_desc.HighPriority.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY; cm->cm_complete = mpssas_remove_device; cm->cm_complete_data = (void *)(uintptr_t)handle; @@ -1428,7 +1427,6 @@ mpssas_send_reset(struct mps_softc *sc, struct mps_com } tm->cm_data = NULL; - tm->cm_desc.HighPriority.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY; tm->cm_complete_data = (void *)tm; callout_reset(&tm->cm_callout, MPS_RESET_TIMEOUT * hz, @@ -1557,7 +1555,6 @@ mpssas_send_abort(struct mps_softc *sc, struct mps_com req->TaskMID = htole16(cm->cm_desc.Default.SMID); tm->cm_data = NULL; - tm->cm_desc.HighPriority.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY; tm->cm_complete = mpssas_abort_complete; tm->cm_complete_data = (void *)tm; tm->cm_targ = cm->cm_targ; @@ -3079,7 +3076,6 @@ mpssas_action_resetdev(struct mpssas_softc *sassc, uni req->MsgFlags = MPI2_SCSITASKMGMT_MSGFLAGS_LINK_RESET; tm->cm_data = NULL; - tm->cm_desc.HighPriority.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY; tm->cm_complete = mpssas_resetdev_complete; tm->cm_complete_data = ccb; tm->cm_targ = targ; @@ -3475,6 +3471,13 @@ mpssas_read_cap_done(struct cam_periph *periph, union #endif /* (__FreeBSD_version < 901503) || \ ((__FreeBSD_version >= 1000000) && (__FreeBSD_version < 1000006)) */ +/* + * Set the INRESET flag for this target so that no I/O will be sent to + * the target until the reset has completed. If an I/O request does + * happen, the devq will be frozen. The CCB holds the path which is + * used to release the devq. The devq is released and the CCB is freed + * when the TM completes. + */ void mpssas_prepare_for_tm(struct mps_softc *sc, struct mps_command *tm, struct mpssas_target *target, lun_id_t lun_id) @@ -3482,13 +3485,6 @@ mpssas_prepare_for_tm(struct mps_softc *sc, struct mps union ccb *ccb; path_id_t path_id; - /* - * Set the INRESET flag for this target so that no I/O will be sent to - * the target until the reset has completed. If an I/O request does - * happen, the devq will be frozen. The CCB holds the path which is - * used to release the devq. The devq is released and the CCB is freed - * when the TM completes. - */ ccb = xpt_alloc_ccb_nowait(); if (ccb) { path_id = cam_sim_path(sc->sassc->sim); Modified: head/sys/dev/mps/mps_user.c ============================================================================== --- head/sys/dev/mps/mps_user.c Mon Dec 24 01:12:43 2018 (r342385) +++ head/sys/dev/mps/mps_user.c Mon Dec 24 05:05:38 2018 (r342386) @@ -847,8 +847,6 @@ mps_user_pass_thru(struct mps_softc *sc, mps_pass_thru task->TaskMID = cm->cm_desc.Default.SMID; cm->cm_data = NULL; - cm->cm_desc.HighPriority.RequestFlags = - MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY; cm->cm_complete = NULL; cm->cm_complete_data = NULL; Modified: head/sys/dev/mps/mpsvar.h ============================================================================== --- head/sys/dev/mps/mpsvar.h Mon Dec 24 01:12:43 2018 (r342385) +++ head/sys/dev/mps/mpsvar.h Mon Dec 24 05:05:38 2018 (r342386) @@ -625,6 +625,8 @@ mps_alloc_high_priority_command(struct mps_softc *sc) TAILQ_REMOVE(&sc->high_priority_req_list, cm, cm_link); cm->cm_state = MPS_CM_STATE_BUSY; cm->cm_timeout_handler = NULL; + cm->cm_desc.HighPriority.RequestFlags = + MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY; return (cm); }