From owner-svn-src-stable-10@freebsd.org Mon Nov 30 21:32:13 2015 Return-Path: Delivered-To: svn-src-stable-10@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 9540AA3D013; Mon, 30 Nov 2015 21:32:13 +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 70D4F1059; Mon, 30 Nov 2015 21:32:13 +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 tAULWCjf069056; Mon, 30 Nov 2015 21:32:12 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tAULWCJD069054; Mon, 30 Nov 2015 21:32:12 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201511302132.tAULWCJD069054@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:32:12 +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: r291503 - 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-stable-10@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Nov 2015 21:32:13 -0000 Author: mav Date: Mon Nov 30 21:32:12 2015 New Revision: 291503 URL: https://svnweb.freebsd.org/changeset/base/291503 Log: MFC r290504: Make ISP_SLEEP() really sleep instead of spinning. While there, simplify the wait logic. Modified: stable/10/sys/dev/isp/isp.c stable/10/sys/dev/isp/isp_freebsd.h 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:31:34 2015 (r291502) +++ stable/10/sys/dev/isp/isp.c Mon Nov 30 21:32:12 2015 (r291503) @@ -2756,12 +2756,13 @@ static int isp_fclink_test(ispsoftc_t *isp, int chan, int usdelay) { mbreg_t mbs; - int count, check_for_fabric, r; + int check_for_fabric, r; uint8_t lwfs; int loopid; fcparam *fcp; fcportdb_t *lp; isp_pdb_t pdb; + NANOTIME_T hra, hrb; fcp = FCPARAM(isp, chan); @@ -2772,13 +2773,8 @@ isp_fclink_test(ispsoftc_t *isp, int cha * Wait up to N microseconds for F/W to go to a ready state. */ lwfs = FW_CONFIG_WAIT; - count = 0; - while (count < usdelay) { - uint64_t enano; - uint32_t wrk; - NANOTIME_T hra, hrb; - - GET_NANOTIME(&hra); + GET_NANOTIME(&hra); + do { isp_fw_state(isp, chan); if (lwfs != fcp->isp_fwstate) { isp_prt(isp, ISP_LOGCONFIG|ISP_LOG_SANCFG, "Chan %d Firmware State <%s->%s>", chan, isp_fc_fw_statename((int)lwfs), isp_fc_fw_statename((int)fcp->isp_fwstate)); @@ -2787,46 +2783,9 @@ isp_fclink_test(ispsoftc_t *isp, int cha if (fcp->isp_fwstate == FW_READY) { break; } + ISP_SLEEP(isp, 1000); GET_NANOTIME(&hrb); - - /* - * Get the elapsed time in nanoseconds. - * Always guaranteed to be non-zero. - */ - enano = NANOTIME_SUB(&hrb, &hra); - - isp_prt(isp, ISP_LOGDEBUG1, "usec%d: 0x%lx->0x%lx enano 0x%x%08x", count, (long) GET_NANOSEC(&hra), (long) GET_NANOSEC(&hrb), (uint32_t)(enano >> 32), (uint32_t)(enano)); - - /* - * If the elapsed time is less than 1 millisecond, - * delay a period of time up to that millisecond of - * waiting. - * - * This peculiar code is an attempt to try and avoid - * invoking uint64_t math support functions for some - * platforms where linkage is a problem. - */ - if (enano < (1000 * 1000)) { - count += 1000; - enano = (1000 * 1000) - enano; - while (enano > (uint64_t) 4000000000U) { - ISP_SLEEP(isp, 4000000); - enano -= (uint64_t) 4000000000U; - } - wrk = enano; - wrk /= 1000; - ISP_SLEEP(isp, wrk); - } else { - while (enano > (uint64_t) 4000000000U) { - count += 4000000; - enano -= (uint64_t) 4000000000U; - } - wrk = enano; - count += (wrk / 1000); - } - } - - + } while (NANOTIME_SUB(&hrb, &hra) / 1000 < usdelay); /* * If we haven't gone to 'ready' state, return. Modified: stable/10/sys/dev/isp/isp_freebsd.h ============================================================================== --- stable/10/sys/dev/isp/isp_freebsd.h Mon Nov 30 21:31:34 2015 (r291502) +++ stable/10/sys/dev/isp/isp_freebsd.h Mon Nov 30 21:32:12 2015 (r291503) @@ -399,8 +399,14 @@ struct isposinfo { #define ISP_MEMZERO(a, b) memset(a, 0, b) #define ISP_MEMCPY memcpy #define ISP_SNPRINTF snprintf -#define ISP_DELAY DELAY -#define ISP_SLEEP(isp, x) DELAY(x) +#define ISP_DELAY(x) DELAY(x) +#if __FreeBSD_version < 1000029 +#define ISP_SLEEP(isp, x) msleep(&(isp)->isp_osinfo.lock, \ + &(isp)->isp_osinfo.lock, 0, "isp_sleep", ((x) + tick - 1) / tick) +#else +#define ISP_SLEEP(isp, x) msleep_sbt(&(isp)->isp_osinfo.lock, \ + &(isp)->isp_osinfo.lock, 0, "isp_sleep", (x) * SBT_1US, 0, 0) +#endif #define ISP_MIN imin