From owner-svn-src-head@freebsd.org Mon Aug 13 19:59:33 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 97523107BB71; Mon, 13 Aug 2018 19:59:33 +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 4C2DB89DD6; Mon, 13 Aug 2018 19:59:33 +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 28AF011526; Mon, 13 Aug 2018 19:59:33 +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 w7DJxX8v047486; Mon, 13 Aug 2018 19:59:33 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w7DJxWUZ047484; Mon, 13 Aug 2018 19:59:32 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201808131959.w7DJxWUZ047484@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:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r337723 - head/sys/cam X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/cam X-SVN-Commit-Revision: 337723 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:33 -0000 Author: imp Date: Mon Aug 13 19:59:32 2018 New Revision: 337723 URL: https://svnweb.freebsd.org/changeset/base/337723 Log: Create xpt_sim_poll and refactor a bit using it. xpt_sim_poll takes the sim to poll as an argument. It will do the proper locking protocol, call the SIM polling routine, and then call camisr_runqueue to process completions on any CCBs the SIM's poll routine completed. It will be used during late shutdown when a SIM is waiting for CCBs it sent during shutdown to finish and the scheduler isn't running because we've panic'd. This sequence was used twice in cam_xpt, so refactor those to use this new function. Sponsored by: Netflix Differential Review: https://reviews.freebsd.org/D16663 Modified: head/sys/cam/cam_xpt.c head/sys/cam/cam_xpt.h Modified: head/sys/cam/cam_xpt.c ============================================================================== --- head/sys/cam/cam_xpt.c Mon Aug 13 19:21:28 2018 (r337722) +++ head/sys/cam/cam_xpt.c Mon Aug 13 19:59:32 2018 (r337723) @@ -3198,6 +3198,25 @@ call_sim: start_ccb->ccb_h.status)); } +/* + * Call the sim poll routine to allow the sim to complete + * any inflight requests, then call camisr_runqueue to + * complete any CCB that the polling completed. + */ +void +xpt_sim_poll(struct cam_sim *sim) +{ + struct mtx *mtx; + + mtx = sim->mtx; + if (mtx) + mtx_lock(mtx); + (*(sim->sim_poll))(sim); + if (mtx) + mtx_unlock(mtx); + camisr_runqueue(); +} + uint32_t xpt_poll_setup(union ccb *start_ccb) { @@ -3205,12 +3224,10 @@ xpt_poll_setup(union ccb *start_ccb) struct cam_sim *sim; struct cam_devq *devq; struct cam_ed *dev; - struct mtx *mtx; timeout = start_ccb->ccb_h.timeout * 10; sim = start_ccb->ccb_h.path->bus->sim; devq = sim->devq; - mtx = sim->mtx; dev = start_ccb->ccb_h.path->device; /* @@ -3223,12 +3240,7 @@ xpt_poll_setup(union ccb *start_ccb) (--timeout > 0)) { mtx_unlock(&devq->send_mtx); DELAY(100); - if (mtx) - mtx_lock(mtx); - (*(sim->sim_poll))(sim); - if (mtx) - mtx_unlock(mtx); - camisr_runqueue(); + xpt_sim_poll(sim); mtx_lock(&devq->send_mtx); } dev->ccbq.dev_openings++; @@ -3240,19 +3252,9 @@ xpt_poll_setup(union ccb *start_ccb) void xpt_pollwait(union ccb *start_ccb, uint32_t timeout) { - struct cam_sim *sim; - struct mtx *mtx; - sim = start_ccb->ccb_h.path->bus->sim; - mtx = sim->mtx; - while (--timeout > 0) { - if (mtx) - mtx_lock(mtx); - (*(sim->sim_poll))(sim); - if (mtx) - mtx_unlock(mtx); - camisr_runqueue(); + xpt_sim_poll(start_ccb->ccb_h.path->bus->sim); if ((start_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_INPROG) break; Modified: head/sys/cam/cam_xpt.h ============================================================================== --- head/sys/cam/cam_xpt.h Mon Aug 13 19:21:28 2018 (r337722) +++ head/sys/cam/cam_xpt.h Mon Aug 13 19:59:32 2018 (r337723) @@ -148,6 +148,7 @@ void xpt_release_path(struct cam_path *path); const char * xpt_action_name(uint32_t action); void xpt_pollwait(union ccb *start_ccb, uint32_t timeout); uint32_t xpt_poll_setup(union ccb *start_ccb); +void xpt_sim_poll(struct cam_sim *sim); /* * Perform a path inquiry at the request priority. The bzero may be