From owner-svn-src-head@freebsd.org Mon Aug 13 19:59:47 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 ECC4D107BBB6; Mon, 13 Aug 2018 19:59:46 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1C48389EF0; Mon, 13 Aug 2018 19:59:43 +0000 (UTC) (envelope-from imp@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 E367211528; Mon, 13 Aug 2018 19:59:42 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w7DJxg8B047593; Mon, 13 Aug 2018 19:59:42 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w7DJxgKM047590; Mon, 13 Aug 2018 19:59:42 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201808131959.w7DJxgKM047590@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Mon, 13 Aug 2018 19:59:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r337725 - in head/sys/dev: mpr mps X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: in head/sys/dev: mpr mps X-SVN-Commit-Revision: 337725 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 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, 13 Aug 2018 19:59:47 -0000 Author: imp Date: Mon Aug 13 19:59:42 2018 New Revision: 337725 URL: https://svnweb.freebsd.org/changeset/base/337725 Log: Port the mps panic-safe shutdown_final handling to mpr r330951 by smh fixed the mps driver to avoid deadlocks when panicing. The same code is needed for mpr, so port it here, along with the fix which allows the CCBs scheduled to complete avoiding at least a scary message and likely other unintended consequences. Sponsored by: Netflix Differential Review: https://reviews.freebsd.org/D16663 Modified: head/sys/dev/mpr/mpr_sas_lsi.c head/sys/dev/mpr/mprvar.h head/sys/dev/mps/mps_sas_lsi.c Modified: head/sys/dev/mpr/mpr_sas_lsi.c ============================================================================== --- head/sys/dev/mpr/mpr_sas_lsi.c Mon Aug 13 19:59:37 2018 (r337724) +++ head/sys/dev/mpr/mpr_sas_lsi.c Mon Aug 13 19:59:42 2018 (r337725) @@ -46,10 +46,12 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include #include +#include #include #include @@ -127,7 +129,7 @@ int mprsas_get_sas_address_for_sata_disk(struct mpr_so u64 *sas_address, u16 handle, u32 device_info, u8 *is_SATA_SSD); static int mprsas_volume_add(struct mpr_softc *sc, u16 handle); -static void mprsas_SSU_to_SATA_devices(struct mpr_softc *sc); +static void mprsas_SSU_to_SATA_devices(struct mpr_softc *sc, int howto); static void mprsas_stop_unit_done(struct cam_periph *periph, union ccb *done_ccb); @@ -1469,7 +1471,7 @@ out: * Return nothing. */ static void -mprsas_SSU_to_SATA_devices(struct mpr_softc *sc) +mprsas_SSU_to_SATA_devices(struct mpr_softc *sc, int howto) { struct mprsas_softc *sassc = sc->sassc; union ccb *ccb; @@ -1477,7 +1479,7 @@ mprsas_SSU_to_SATA_devices(struct mpr_softc *sc) target_id_t targetid; struct mprsas_target *target; char path_str[64]; - struct timeval cur_time, start_time; + int timeout; mpr_lock(sc); @@ -1544,17 +1546,25 @@ mprsas_SSU_to_SATA_devices(struct mpr_softc *sc) mpr_unlock(sc); /* - * Wait until all of the SSU commands have completed or time has - * expired (60 seconds). Pause for 100ms each time through. If any - * command times out, the target will be reset in the SCSI command - * timeout routine. + * Timeout after 60 seconds by default or 10 seconds if howto has + * RB_NOSYNC set which indicates we're likely handling a panic. */ - getmicrotime(&start_time); - while (sc->SSU_refcount) { + timeout = 600; + if (howto & RB_NOSYNC) + timeout = 100; + + /* + * Wait until all of the SSU commands have completed or time + * has expired. Pause for 100ms each time through. If any + * command times out, the target will be reset in the SCSI + * command timeout routine. + */ + while (sc->SSU_refcount > 0) { pause("mprwait", hz/10); + if (SCHEDULER_STOPPED()) + xpt_sim_poll(sassc->sim); - getmicrotime(&cur_time); - if ((cur_time.tv_sec - start_time.tv_sec) > 60) { + if (--timeout == 0) { mpr_dprint(sc, MPR_ERROR, "Time has expired waiting " "for SSU commands to complete.\n"); break; @@ -1596,7 +1606,7 @@ mprsas_stop_unit_done(struct cam_periph *periph, union * Return nothing. */ void -mprsas_ir_shutdown(struct mpr_softc *sc) +mprsas_ir_shutdown(struct mpr_softc *sc, int howto) { u16 volume_mapping_flags; u16 ioc_pg8_flags = le16toh(sc->ioc_pg8.Flags); @@ -1701,5 +1711,5 @@ out: } } } - mprsas_SSU_to_SATA_devices(sc); + mprsas_SSU_to_SATA_devices(sc, howto); } Modified: head/sys/dev/mpr/mprvar.h ============================================================================== --- head/sys/dev/mpr/mprvar.h Mon Aug 13 19:59:37 2018 (r337724) +++ head/sys/dev/mpr/mprvar.h Mon Aug 13 19:59:42 2018 (r337725) @@ -807,7 +807,7 @@ int mpr_config_get_volume_wwid(struct mpr_softc *sc, u int mpr_config_get_raid_pd_pg0(struct mpr_softc *sc, Mpi2ConfigReply_t *mpi_reply, Mpi2RaidPhysDiskPage0_t *config_page, u32 page_address); -void mprsas_ir_shutdown(struct mpr_softc *sc); +void mprsas_ir_shutdown(struct mpr_softc *sc, int howto); int mpr_reinit(struct mpr_softc *sc); void mprsas_handle_reinit(struct mpr_softc *sc); Modified: head/sys/dev/mps/mps_sas_lsi.c ============================================================================== --- head/sys/dev/mps/mps_sas_lsi.c Mon Aug 13 19:59:37 2018 (r337724) +++ head/sys/dev/mps/mps_sas_lsi.c Mon Aug 13 19:59:42 2018 (r337725) @@ -1115,6 +1115,7 @@ out: /** * mpssas_SSU_to_SATA_devices * @sc: per adapter object + * @howto: mast of RB_* bits for how we're rebooting * * Looks through the target list and issues a StartStopUnit SCSI command to each * SATA direct-access device. This helps to ensure that data corruption is @@ -1248,6 +1249,7 @@ mpssas_stop_unit_done(struct cam_periph *periph, union /** * mpssas_ir_shutdown - IR shutdown notification * @sc: per adapter object + * @howto: mast of RB_* bits for how we're rebooting * * Sending RAID Action to alert the Integrated RAID subsystem of the IOC that * the host system is shutting down.