From owner-svn-src-stable@freebsd.org Sat Mar 31 19:18:08 2018 Return-Path: Delivered-To: svn-src-stable@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 10C3AF79518; Sat, 31 Mar 2018 19:18:08 +0000 (UTC) (envelope-from smh@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 B2E4E7227D; Sat, 31 Mar 2018 19:18:07 +0000 (UTC) (envelope-from smh@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 ADEB81BF4D; Sat, 31 Mar 2018 19:18:07 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2VJI74X058818; Sat, 31 Mar 2018 19:18:07 GMT (envelope-from smh@FreeBSD.org) Received: (from smh@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2VJI7DA058816; Sat, 31 Mar 2018 19:18:07 GMT (envelope-from smh@FreeBSD.org) Message-Id: <201803311918.w2VJI7DA058816@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: smh set sender to smh@FreeBSD.org using -f From: Steven Hartland Date: Sat, 31 Mar 2018 19:18:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r331849 - stable/11/sys/dev/mps X-SVN-Group: stable-11 X-SVN-Commit-Author: smh X-SVN-Commit-Paths: stable/11/sys/dev/mps X-SVN-Commit-Revision: 331849 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Mar 2018 19:18:08 -0000 Author: smh Date: Sat Mar 31 19:18:07 2018 New Revision: 331849 URL: https://svnweb.freebsd.org/changeset/base/331849 Log: MFC r330951: Fix mps deadlock when handling panic Sponsored by: Multiplay Modified: stable/11/sys/dev/mps/mps_sas_lsi.c stable/11/sys/dev/mps/mpsvar.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mps/mps_sas_lsi.c ============================================================================== --- stable/11/sys/dev/mps/mps_sas_lsi.c Sat Mar 31 19:16:25 2018 (r331848) +++ stable/11/sys/dev/mps/mps_sas_lsi.c Sat Mar 31 19:18:07 2018 (r331849) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -124,7 +125,7 @@ int mpssas_get_sas_address_for_sata_disk(struct mps_so u64 *sas_address, u16 handle, u32 device_info, u8 *is_SATA_SSD); static int mpssas_volume_add(struct mps_softc *sc, u16 handle); -static void mpssas_SSU_to_SATA_devices(struct mps_softc *sc); +static void mpssas_SSU_to_SATA_devices(struct mps_softc *sc, int howto); static void mpssas_stop_unit_done(struct cam_periph *periph, union ccb *done_ccb); @@ -1112,7 +1113,7 @@ out: * Return nothing. */ static void -mpssas_SSU_to_SATA_devices(struct mps_softc *sc) +mpssas_SSU_to_SATA_devices(struct mps_softc *sc, int howto) { struct mpssas_softc *sassc = sc->sassc; union ccb *ccb; @@ -1120,7 +1121,7 @@ mpssas_SSU_to_SATA_devices(struct mps_softc *sc) target_id_t targetid; struct mpssas_target *target; char path_str[64]; - struct timeval cur_time, start_time; + int timeout; /* * For each target, issue a StartStopUnit command to stop the device. @@ -1183,17 +1184,23 @@ mpssas_SSU_to_SATA_devices(struct mps_softc *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 timeout 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("mpswait", hz/10); - getmicrotime(&cur_time); - if ((cur_time.tv_sec - start_time.tv_sec) > 60) { + if (--timeout == 0) { mps_dprint(sc, MPS_FAULT, "Time has expired waiting " "for SSU commands to complete.\n"); break; @@ -1235,7 +1242,7 @@ mpssas_stop_unit_done(struct cam_periph *periph, union * Return nothing. */ void -mpssas_ir_shutdown(struct mps_softc *sc) +mpssas_ir_shutdown(struct mps_softc *sc, int howto) { u16 volume_mapping_flags; u16 ioc_pg8_flags = le16toh(sc->ioc_pg8.Flags); @@ -1340,5 +1347,5 @@ out: } } } - mpssas_SSU_to_SATA_devices(sc); + mpssas_SSU_to_SATA_devices(sc, howto); } Modified: stable/11/sys/dev/mps/mpsvar.h ============================================================================== --- stable/11/sys/dev/mps/mpsvar.h Sat Mar 31 19:16:25 2018 (r331848) +++ stable/11/sys/dev/mps/mpsvar.h Sat Mar 31 19:18:07 2018 (r331849) @@ -722,7 +722,7 @@ int mps_config_get_volume_wwid(struct mps_softc *sc, u int mps_config_get_raid_pd_pg0(struct mps_softc *sc, Mpi2ConfigReply_t *mpi_reply, Mpi2RaidPhysDiskPage0_t *config_page, u32 page_address); -void mpssas_ir_shutdown(struct mps_softc *sc); +void mpssas_ir_shutdown(struct mps_softc *sc, int howto); int mps_reinit(struct mps_softc *sc); void mpssas_handle_reinit(struct mps_softc *sc);