From owner-svn-src-all@freebsd.org Mon Nov 30 21:45:26 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 15074A3D80D; Mon, 30 Nov 2015 21:45:26 +0000 (UTC) (envelope-from mav@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 mx1.freebsd.org (Postfix) with ESMTPS id BD76E147E; Mon, 30 Nov 2015 21:45:25 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tAULjOnY073945; Mon, 30 Nov 2015 21:45:24 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tAULjO7F073944; Mon, 30 Nov 2015 21:45:24 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201511302145.tAULjO7F073944@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 30 Nov 2015 21:45:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r291521 - stable/10/sys/dev/isp X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Nov 2015 21:45:26 -0000 Author: mav Date: Mon Nov 30 21:45:24 2015 New Revision: 291521 URL: https://svnweb.freebsd.org/changeset/base/291521 Log: MFC r291161: Gracefully stop firmware before resetting chip when changing role. Modified: stable/10/sys/dev/isp/isp.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/isp/isp.c ============================================================================== --- stable/10/sys/dev/isp/isp.c Mon Nov 30 21:44:38 2015 (r291520) +++ stable/10/sys/dev/isp/isp.c Mon Nov 30 21:45:24 2015 (r291521) @@ -1338,11 +1338,32 @@ isp_reset(ispsoftc_t *isp, int do_load_d } /* + * Clean firmware shutdown. + */ +static int +isp_deinit(ispsoftc_t *isp) +{ + mbreg_t mbs; + + isp->isp_state = ISP_NILSTATE; + MBSINIT(&mbs, MBOX_STOP_FIRMWARE, MBLOGALL, 500000); + mbs.param[1] = 0; + mbs.param[2] = 0; + mbs.param[3] = 0; + mbs.param[4] = 0; + mbs.param[5] = 0; + mbs.param[6] = 0; + mbs.param[7] = 0; + mbs.param[8] = 0; + isp_mboxcmd(isp, &mbs); + return (mbs.param[0] == MBOX_COMMAND_COMPLETE ? 0 : mbs.param[0]); +} + +/* * Initialize Parameters of Hardware to a known state. * * Locks are held before coming here. */ - void isp_init(ispsoftc_t *isp) { @@ -6799,7 +6820,7 @@ static const uint32_t mbpfc[] = { ISP_FC_OPMAP(0x2f, 0x21), /* 0x11: MBOX_INIT_RES_QUEUE */ ISP_FC_OPMAP(0x0f, 0x01), /* 0x12: MBOX_EXECUTE_IOCB */ ISP_FC_OPMAP(0x03, 0x03), /* 0x13: MBOX_WAKE_UP */ - ISP_FC_OPMAP(0x01, 0xff), /* 0x14: MBOX_STOP_FIRMWARE */ + ISP_FC_OPMAP_HALF(0x1, 0xff, 0x0, 0x03), /* 0x14: MBOX_STOP_FIRMWARE */ ISP_FC_OPMAP(0x4f, 0x01), /* 0x15: MBOX_ABORT */ ISP_FC_OPMAP(0x07, 0x01), /* 0x16: MBOX_ABORT_DEVICE */ ISP_FC_OPMAP(0x07, 0x01), /* 0x17: MBOX_ABORT_TARGET */ @@ -7621,6 +7642,8 @@ isp_reinit(ispsoftc_t *isp, int do_load_ { int i, res = 0; + if (isp->isp_state == ISP_RUNSTATE) + isp_deinit(isp); if (isp->isp_state != ISP_RESETSTATE) isp_reset(isp, do_load_defaults); if (isp->isp_state != ISP_RESETSTATE) {