From owner-dev-commits-src-branches@freebsd.org Mon Mar 22 22:51:53 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F199F5BD416; Mon, 22 Mar 2021 22:51:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4F48rT6Rj8z4sL9; Mon, 22 Mar 2021 22:51:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C56C315E62; Mon, 22 Mar 2021 22:51:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 12MMprHE071490; Mon, 22 Mar 2021 22:51:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 12MMpr8l071489; Mon, 22 Mar 2021 22:51:53 GMT (envelope-from git) Date: Mon, 22 Mar 2021 22:51:53 GMT Message-Id: <202103222251.12MMpr8l071489@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 444aff36738a - stable/13 - cam: Permit non-pollable sims. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 444aff36738a98235306aa002d3dfe74cc475765 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Mar 2021 22:51:54 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=444aff36738a98235306aa002d3dfe74cc475765 commit 444aff36738a98235306aa002d3dfe74cc475765 Author: John Baldwin AuthorDate: 2021-02-11 21:49:43 +0000 Commit: John Baldwin CommitDate: 2021-03-22 20:36:09 +0000 cam: Permit non-pollable sims. Some CAM sim drivers do not support polling (notably iscsi(4)). Rather than using a no-op poll routine that always times out requests, permit a SIM to set a NULL poll callback. cam_periph_runccb() will fail polled requests non-pollable sims immediately as if they had timed out. Sponsored by: Chelsio (cherry picked from commit 447b3557a9cc5f00a301be8404339f21a9a0faa8) (cherry picked from commit e6405c8c37335a42a187a9d2470025b57347b1b5) --- sys/cam/cam_periph.c | 6 +++++- sys/cam/cam_sim.h | 6 ++++++ sys/cam/cam_xpt.c | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c index 92f7c33cbc75..98b9264f1069 100644 --- a/sys/cam/cam_periph.c +++ b/sys/cam/cam_periph.c @@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1247,7 +1248,10 @@ cam_periph_runccb(union ccb *ccb, * in the do loop below. */ if (must_poll) { - timeout = xpt_poll_setup(ccb); + if (cam_sim_pollable(ccb->ccb_h.path->bus->sim)) + timeout = xpt_poll_setup(ccb); + else + timeout = 0; } if (timeout == 0) { diff --git a/sys/cam/cam_sim.h b/sys/cam/cam_sim.h index 589d2bd1f16d..a1595a51fadb 100644 --- a/sys/cam/cam_sim.h +++ b/sys/cam/cam_sim.h @@ -142,5 +142,11 @@ cam_sim_bus(const struct cam_sim *sim) return (sim->bus_id); } +static __inline bool +cam_sim_pollable(const struct cam_sim *sim) +{ + return (sim->sim_poll != NULL); +} + #endif /* _KERNEL */ #endif /* _CAM_CAM_SIM_H */ diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index d71b8ef81240..9cfee80a6049 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -3181,6 +3181,7 @@ xpt_sim_poll(struct cam_sim *sim) { struct mtx *mtx; + KASSERT(cam_sim_pollable(sim), ("%s: non-pollable sim", __func__)); mtx = sim->mtx; if (mtx) mtx_lock(mtx); @@ -3203,6 +3204,8 @@ xpt_poll_setup(union ccb *start_ccb) devq = sim->devq; dev = start_ccb->ccb_h.path->device; + KASSERT(cam_sim_pollable(sim), ("%s: non-pollable sim", __func__)); + /* * Steal an opening so that no other queued requests * can get it before us while we simulate interrupts. @@ -3226,6 +3229,8 @@ void xpt_pollwait(union ccb *start_ccb, uint32_t timeout) { + KASSERT(cam_sim_pollable(start_ccb->ccb_h.path->bus->sim), + ("%s: non-pollable sim", __func__)); while (--timeout > 0) { xpt_sim_poll(start_ccb->ccb_h.path->bus->sim); if ((start_ccb->ccb_h.status & CAM_STATUS_MASK)