From owner-svn-src-head@freebsd.org Sun Oct 25 10:49:07 2015 Return-Path: Delivered-To: svn-src-head@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 0B87A8BFE; Sun, 25 Oct 2015 10:49:07 +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 D99C41FF0; Sun, 25 Oct 2015 10:49:06 +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 t9PAn5Of011229; Sun, 25 Oct 2015 10:49:05 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9PAn5LI011225; Sun, 25 Oct 2015 10:49:05 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201510251049.t9PAn5LI011225@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 25 Oct 2015 10:49:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289930 - head/sys/dev/isp X-SVN-Group: head 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.20 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: Sun, 25 Oct 2015 10:49:07 -0000 Author: mav Date: Sun Oct 25 10:49:05 2015 New Revision: 289930 URL: https://svnweb.freebsd.org/changeset/base/289930 Log: Formalize/unify chip (re-)inits. Modified: head/sys/dev/isp/isp.c head/sys/dev/isp/isp_freebsd.c head/sys/dev/isp/isp_pci.c head/sys/dev/isp/isp_sbus.c Modified: head/sys/dev/isp/isp.c ============================================================================== --- head/sys/dev/isp/isp.c Sun Oct 25 09:16:20 2015 (r289929) +++ head/sys/dev/isp/isp.c Sun Oct 25 10:49:05 2015 (r289930) @@ -1368,6 +1368,8 @@ isp_scsi_init(ispsoftc_t *isp) sdparam *sdp_chan0, *sdp_chan1; mbreg_t mbs; + isp->isp_state = ISP_INITSTATE; + sdp_chan0 = SDPARAM(isp, 0); sdp_chan1 = sdp_chan0; if (IS_DUALBUS(isp)) { @@ -1543,7 +1545,7 @@ isp_scsi_init(ispsoftc_t *isp) } } - isp->isp_state = ISP_INITSTATE; + isp->isp_state = ISP_RUNSTATE; } static void @@ -1673,11 +1675,10 @@ isp_fibre_init(ispsoftc_t *isp) * We only support one channel on non-24XX cards */ fcp = FCPARAM(isp, 0); - if (fcp->role == ISP_ROLE_NONE) { - isp->isp_state = ISP_INITSTATE; + if (fcp->role == ISP_ROLE_NONE) return; - } + isp->isp_state = ISP_INITSTATE; ISP_MEMZERO(icbp, sizeof (*icbp)); icbp->icb_version = ICB_VERSION1; icbp->icb_fwoptions = fcp->isp_fwoptions; @@ -1978,7 +1979,7 @@ isp_fibre_init(ispsoftc_t *isp) /* * Whatever happens, we're now committed to being here. */ - isp->isp_state = ISP_INITSTATE; + isp->isp_state = ISP_RUNSTATE; } static void @@ -2001,10 +2002,11 @@ isp_fibre_init_2400(ispsoftc_t *isp) } if (chan == isp->isp_nchan) { isp_prt(isp, ISP_LOG_WARN1, "all %d channels with role 'none'", chan); - isp->isp_state = ISP_INITSTATE; return; } + isp->isp_state = ISP_INITSTATE; + /* * Start with channel 0. */ @@ -2285,7 +2287,7 @@ isp_fibre_init_2400(ispsoftc_t *isp) /* * Whatever happens, we're now committed to being here. */ - isp->isp_state = ISP_INITSTATE; + isp->isp_state = ISP_RUNSTATE; } static void @@ -4349,16 +4351,6 @@ isp_start(XS_T *xs) isp = XS_ISP(xs); /* - * Now make sure we're running. - */ - - if (isp->isp_state != ISP_RUNSTATE) { - isp_prt(isp, ISP_LOGERR, "Adapter not at RUNSTATE"); - XS_SETERR(xs, HBA_BOTCH); - return (CMD_COMPLETE); - } - - /* * Check command CDB length, etc.. We really are limited to 16 bytes * for Fibre Channel, but can do up to 44 bytes in parallel SCSI, * but probably only if we're running fairly new firmware (we'll @@ -4387,6 +4379,12 @@ isp_start(XS_T *xs) return (CMD_COMPLETE); } + if (isp->isp_state != ISP_RUNSTATE) { + isp_prt(isp, ISP_LOGERR, "Adapter not at RUNSTATE"); + XS_SETERR(xs, HBA_BOTCH); + return (CMD_COMPLETE); + } + /* * Try again later. */ @@ -4423,6 +4421,13 @@ isp_start(XS_T *xs) XS_SETERR(xs, HBA_SELTIMEOUT); return (CMD_COMPLETE); } + + if (isp->isp_state != ISP_RUNSTATE) { + isp_prt(isp, ISP_LOGERR, "Adapter not at RUNSTATE"); + XS_SETERR(xs, HBA_BOTCH); + return (CMD_COMPLETE); + } + if (sdp->update) { isp_spi_update(isp, XS_CHANNEL(xs)); } @@ -7915,7 +7920,8 @@ isp_reinit(ispsoftc_t *isp, int do_load_ { int i, res = 0; - isp_reset(isp, do_load_defaults); + if (isp->isp_state != ISP_RESETSTATE) + isp_reset(isp, do_load_defaults); if (isp->isp_state != ISP_RESETSTATE) { res = EIO; isp_prt(isp, ISP_LOGERR, "%s: cannot reset card", __func__); @@ -7924,15 +7930,10 @@ isp_reinit(ispsoftc_t *isp, int do_load_ } isp_init(isp); - if (isp->isp_state == ISP_INITSTATE) { - isp->isp_state = ISP_RUNSTATE; - } - - if (isp->isp_state != ISP_RUNSTATE) { + if (isp->isp_state > ISP_RESETSTATE && + isp->isp_state != ISP_RUNSTATE) { res = EIO; -#ifndef ISP_TARGET_MODE - isp_prt(isp, ISP_LOGWARN, "%s: not at runstate", __func__); -#endif + isp_prt(isp, ISP_LOGERR, "%s: cannot init card", __func__); ISP_DISABLE_INTS(isp); if (IS_FC(isp)) { /* Modified: head/sys/dev/isp/isp_freebsd.c ============================================================================== --- head/sys/dev/isp/isp_freebsd.c Sun Oct 25 09:16:20 2015 (r289929) +++ head/sys/dev/isp/isp_freebsd.c Sun Oct 25 10:49:05 2015 (r289930) @@ -4029,19 +4029,6 @@ isp_action(struct cam_sim *sim, union cc isp_prt(isp, ISP_LOGDEBUG2, "isp_action code %x", ccb->ccb_h.func_code); ISP_PCMD(ccb) = NULL; - if (isp->isp_state != ISP_RUNSTATE && ccb->ccb_h.func_code == XPT_SCSI_IO) { - isp_init(isp); - if (isp->isp_state != ISP_INITSTATE) { - /* - * Lie. Say it was a selection timeout. - */ - ccb->ccb_h.status = CAM_SEL_TIMEOUT; - isp_done((struct ccb_scsiio *) ccb); - return; - } - isp->isp_state = ISP_RUNSTATE; - } - switch (ccb->ccb_h.func_code) { case XPT_SCSI_IO: /* Execute the requested I/O operation */ bus = XS_CHANNEL(ccb); Modified: head/sys/dev/isp/isp_pci.c ============================================================================== --- head/sys/dev/isp/isp_pci.c Sun Oct 25 09:16:20 2015 (r289929) +++ head/sys/dev/isp/isp_pci.c Sun Oct 25 10:49:05 2015 (r289930) @@ -991,15 +991,10 @@ isp_pci_attach(device_t dev) * Make sure we're in reset state. */ ISP_LOCK(isp); - isp_reset(isp, 1); - if (isp->isp_state != ISP_RESETSTATE) { + if (isp_reinit(isp, 1) != 0) { ISP_UNLOCK(isp); goto bad; } - isp_init(isp); - if (isp->isp_state == ISP_INITSTATE) { - isp->isp_state = ISP_RUNSTATE; - } ISP_UNLOCK(isp); if (isp_attach(isp)) { ISP_LOCK(isp); Modified: head/sys/dev/isp/isp_sbus.c ============================================================================== --- head/sys/dev/isp/isp_sbus.c Sun Oct 25 09:16:20 2015 (r289929) +++ head/sys/dev/isp/isp_sbus.c Sun Oct 25 10:49:05 2015 (r289930) @@ -313,16 +313,11 @@ isp_sbus_attach(device_t dev) * Make sure we're in reset state. */ ISP_LOCK(isp); - isp_reset(isp, 1); - if (isp->isp_state != ISP_RESETSTATE) { + if (isp_reinit(isp, 1) != 0) { isp_uninit(isp); ISP_UNLOCK(isp); goto bad; } - isp_init(isp); - if (isp->isp_state == ISP_INITSTATE) { - isp->isp_state = ISP_RUNSTATE; - } ISP_UNLOCK(isp); if (isp_attach(isp)) { ISP_LOCK(isp);