From nobody Thu Jun 19 15:53:11 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4bNQB01020z5yqmK; Thu, 19 Jun 2025 15:53:12 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bNQ9z6tj4z4M9G; Thu, 19 Jun 2025 15:53:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750348392; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ydqonzRduhJ4P+nlVxXab02FZWdP8ui+lnyYH/pAd/4=; b=d4l9NaSMqZTQvuLnf8N/FiUp4Wt0kaptfSQMtCMSM/zN9BbKY3/x7+1IGsI3MvGio7bIHB G4yG5Yu1Y0ZHRu+gs7e96+qEGYnmkL3H3FcR95PEwcyGvS5uuuAkHsi53T2s0ZbTkXjUq0 k47ERauoo3nezD/erm7SRk3G/ZImeEfgMFpclAA8Q/UFgnaAdWsE8h/8EVdMzm9oNXKOb4 dfeQ0zeRBfSG9i4jNfNhduM4yxS02hoXixAwTctK/zmXvkQfP/2ZwubRBAu+sSm4HKUhaL UzGEgFF5KI35FHRVYs+FZctKORTWfaHwqFb7XC1TXQtNGkaMiGsHAAf5d+hmPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750348392; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ydqonzRduhJ4P+nlVxXab02FZWdP8ui+lnyYH/pAd/4=; b=V4iQ99a73QlYc/MZXx0onEyGKSvwwtS2foOcblMPYaix3DuLs493l3eX8kpuh7RD2vL84J SdhK+dooX2mxmbD4lBbP0z9ZNXDieKvwifxUNLzROsKah9L3mKZT8TAKhbJLe60CeeBKWv vEfVftdaeVn2cySrtDjL2l/Wn1zPp5vQiVfEVYiBZoo+r5MSLb0xc93eq7Tyc3GmrRAYwy ApMqgPlwd17jpHyscXjV+rO0W3hgTPdJpkw4bvA71YTFyPMeucTVPoHY6fn7xbLKChDyLj hWe04imiho1LjaAKDKD022kmGwoUISYUN05EckgrjF5tLvh1vWNym6m6dEJK6A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1750348392; a=rsa-sha256; cv=none; b=pewdr6TchMaEboMd1vfYkwjPbg+fZjkPgFOJdjSX/1D4KIroyTOk4Pa6aD4gXeCj+A5e4u cnxBv9NhemjkVxKHqvNTGoO5ot+mzPjOAGf4xTIw7nWr7NxVLUnltB39sFyONhsym3p6gw G1NLlolZF2LKFDiDbvbRAPd6t1ouR4IjmHW1Vm7KQUm66PBgUOWrk0F+rOieE2Xfru6/ir zH2b9A4iZWk0ywVsJT7cyu5Jmxo1lFaW0lkm90fdQIscMU0RLzypvNE6+OxU4KBFXizWHt PydWZVwY218EFG0e6EbYEjdwW7yD2LcUmm4DRmF++w0ishImYOO+ErP3ErqcNw== 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 4bNQ9z6T7Qz1Kjx; Thu, 19 Jun 2025 15:53:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 55JFrB6s071035; Thu, 19 Jun 2025 15:53:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 55JFrB8G071032; Thu, 19 Jun 2025 15:53:11 GMT (envelope-from git) Date: Thu, 19 Jun 2025 15:53:11 GMT Message-Id: <202506191553.55JFrB8G071032@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 5ecf95544907 - main - pass: Use pointer to ccb header rather than longer construct List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5ecf95544907c2ed318486ac24af3e105ec2701b Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=5ecf95544907c2ed318486ac24af3e105ec2701b commit 5ecf95544907c2ed318486ac24af3e105ec2701b Author: Warner Losh AuthorDate: 2025-06-19 14:01:12 +0000 Commit: Warner Losh CommitDate: 2025-06-19 15:52:25 +0000 pass: Use pointer to ccb header rather than longer construct Take a pointer to the ccb header in a few places where it's not ambiguous (eg we have multiple ccbs in the routine). The code is a little shorter this way. In places we had mulitple ccbs, I refrained from doing this since that's more complex to manage. This also means that we're making a stronger guarantee to the compiler we're only accessing this part of the ccb, which reduces a few warnings from gcc with picky settings we normally disable for CAM). This makes the driver slightly less SCSI specific where csio was used to do this needlessly. There's no functional change. Sponsored by: Netflix --- sys/cam/scsi/scsi_pass.c | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/sys/cam/scsi/scsi_pass.c b/sys/cam/scsi/scsi_pass.c index a6787be8737f..7bf9fa72b245 100644 --- a/sys/cam/scsi/scsi_pass.c +++ b/sys/cam/scsi/scsi_pass.c @@ -896,23 +896,23 @@ static void passdone(struct cam_periph *periph, union ccb *done_ccb) { struct pass_softc *softc; - struct ccb_scsiio *csio; + struct ccb_hdr *hdr; softc = (struct pass_softc *)periph->softc; cam_periph_assert(periph, MA_OWNED); - csio = &done_ccb->csio; - switch (csio->ccb_h.ccb_type) { + hdr = &done_ccb->ccb_h; + switch (hdr->ccb_type) { case PASS_CCB_QUEUED_IO: { struct pass_io_req *io_req; - io_req = done_ccb->ccb_h.ccb_ioreq; + io_req = hdr->ccb_ioreq; #if 0 xpt_print(periph->path, "%s: called for user CCB %p\n", __func__, io_req->user_ccb_ptr); #endif - if (((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) && + if (((hdr->status & CAM_STATUS_MASK) != CAM_REQ_CMP) && ((io_req->flags & PASS_IO_ABANDONED) == 0)) { int error; uint32_t cam_flags, sense_flags; @@ -936,14 +936,14 @@ passdone(struct cam_periph *periph, union ccb *done_ccb) /* * Log data/transaction completion with devstat(9). */ - switch (done_ccb->ccb_h.func_code) { + switch (hdr->func_code) { case XPT_SCSI_IO: devstat_end_transaction(softc->device_stats, done_ccb->csio.dxfer_len - done_ccb->csio.resid, done_ccb->csio.tag_action & 0x3, - ((done_ccb->ccb_h.flags & CAM_DIR_MASK) == + ((hdr->flags & CAM_DIR_MASK) == CAM_DIR_NONE) ? DEVSTAT_NO_DATA : - (done_ccb->ccb_h.flags & CAM_DIR_OUT) ? + (hdr->flags & CAM_DIR_OUT) ? DEVSTAT_WRITE : DEVSTAT_READ, NULL, &io_req->start_time); break; @@ -951,9 +951,9 @@ passdone(struct cam_periph *periph, union ccb *done_ccb) devstat_end_transaction(softc->device_stats, done_ccb->ataio.dxfer_len - done_ccb->ataio.resid, 0, /* Not used in ATA */ - ((done_ccb->ccb_h.flags & CAM_DIR_MASK) == + ((hdr->flags & CAM_DIR_MASK) == CAM_DIR_NONE) ? DEVSTAT_NO_DATA : - (done_ccb->ccb_h.flags & CAM_DIR_OUT) ? + (hdr->flags & CAM_DIR_OUT) ? DEVSTAT_WRITE : DEVSTAT_READ, NULL, &io_req->start_time); break; @@ -1118,12 +1118,14 @@ static void passiocleanup(struct pass_softc *softc, struct pass_io_req *io_req) { union ccb *ccb; + struct ccb_hdr *hdr; uint8_t **data_ptrs[CAM_PERIPH_MAXMAPS]; int i, numbufs; ccb = &io_req->ccb; + hdr = &ccb->ccb_h; - switch (ccb->ccb_h.func_code) { + switch (hdr->func_code) { case XPT_DEV_MATCH: numbufs = min(io_req->num_bufs, 2); @@ -1279,6 +1281,7 @@ static int passmemsetup(struct cam_periph *periph, struct pass_io_req *io_req) { union ccb *ccb; + struct ccb_hdr *hdr; struct pass_softc *softc; int numbufs, i; uint8_t **data_ptrs[CAM_PERIPH_MAXMAPS]; @@ -1295,11 +1298,12 @@ passmemsetup(struct cam_periph *periph, struct pass_io_req *io_req) error = 0; ccb = &io_req->ccb; + hdr = &ccb->ccb_h; maxmap = 0; num_segs = 0; seg_cnt_ptr = NULL; - switch(ccb->ccb_h.func_code) { + switch(hdr->func_code) { case XPT_DEV_MATCH: if (ccb->cdm.match_buf_len == 0) { printf("%s: invalid match buffer length 0\n", __func__); @@ -1323,40 +1327,40 @@ passmemsetup(struct cam_periph *periph, struct pass_io_req *io_req) break; case XPT_SCSI_IO: case XPT_CONT_TARGET_IO: - if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE) + if ((hdr->flags & CAM_DIR_MASK) == CAM_DIR_NONE) return(0); /* * The user shouldn't be able to supply a bio. */ - if ((ccb->ccb_h.flags & CAM_DATA_MASK) == CAM_DATA_BIO) + if ((hdr->flags & CAM_DATA_MASK) == CAM_DATA_BIO) return (EINVAL); - io_req->data_flags = ccb->ccb_h.flags & CAM_DATA_MASK; + io_req->data_flags = hdr->flags & CAM_DATA_MASK; data_ptrs[0] = &ccb->csio.data_ptr; lengths[0] = ccb->csio.dxfer_len; - dirs[0] = ccb->ccb_h.flags & CAM_DIR_MASK; + dirs[0] = hdr->flags & CAM_DIR_MASK; num_segs = ccb->csio.sglist_cnt; seg_cnt_ptr = &ccb->csio.sglist_cnt; numbufs = 1; maxmap = softc->maxio; break; case XPT_ATA_IO: - if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE) + if ((hdr->flags & CAM_DIR_MASK) == CAM_DIR_NONE) return(0); /* * We only support a single virtual address for ATA I/O. */ - if ((ccb->ccb_h.flags & CAM_DATA_MASK) != CAM_DATA_VADDR) + if ((hdr->flags & CAM_DATA_MASK) != CAM_DATA_VADDR) return (EINVAL); io_req->data_flags = CAM_DATA_VADDR; data_ptrs[0] = &ccb->ataio.data_ptr; lengths[0] = ccb->ataio.dxfer_len; - dirs[0] = ccb->ccb_h.flags & CAM_DIR_MASK; + dirs[0] = hdr->flags & CAM_DIR_MASK; numbufs = 1; maxmap = softc->maxio; break; @@ -1385,14 +1389,14 @@ passmemsetup(struct cam_periph *periph, struct pass_io_req *io_req) break; case XPT_NVME_ADMIN: case XPT_NVME_IO: - if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE) + if ((hdr->flags & CAM_DIR_MASK) == CAM_DIR_NONE) return (0); - io_req->data_flags = ccb->ccb_h.flags & CAM_DATA_MASK; + io_req->data_flags = hdr->flags & CAM_DATA_MASK; data_ptrs[0] = &ccb->nvmeio.data_ptr; lengths[0] = ccb->nvmeio.dxfer_len; - dirs[0] = ccb->ccb_h.flags & CAM_DIR_MASK; + dirs[0] = hdr->flags & CAM_DIR_MASK; num_segs = ccb->nvmeio.sglist_cnt; seg_cnt_ptr = &ccb->nvmeio.sglist_cnt; numbufs = 1;