From nobody Mon May 12 22:14:51 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 4ZxDS84sD4z5vvC0 for ; Mon, 12 May 2025 22:15:04 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZxDS80LfLz45LR for ; Mon, 12 May 2025 22:15:04 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-30c35ac35dfso3855667a91.1 for ; Mon, 12 May 2025 15:15:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1747088103; x=1747692903; darn=freebsd.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=WUYxasLzKDAWIej65egP2T8M1v/9m8L1CysFfFLKOO8=; b=lOSY9s8bIbf0yitECg5Gx6rNSggc4dqAl1xxpko36rjc9uAE+bA/TqLt42hBTxHu7C FSC7yeZIzOE6lw2M3AnuTcHPb7uDDkwh7vt9iY2hjj/DPfYUdILtNqjH/m4swnSG0/jG 9K88RghT8t0uMHacfGQwKwwdfsv/G0BEtaXMtEBEaM0g6n3Rd2wmQQdYn549NNP6gia0 mVvAN0jbp0cQYpDQt6AoGKMKlECNtCkA4hS37yT4Ae9b/4G3A08wgKT3nM4siWdQkLKo GpVNCTLAU00ZC5YiIa75bcDUubJutSRE0hkjjvHhGh2HL2EAvYq4kUd5RsUecOGqRKj8 JLpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747088103; x=1747692903; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WUYxasLzKDAWIej65egP2T8M1v/9m8L1CysFfFLKOO8=; b=IKhdewPXUWfabOOb0quiXSvjnBiBo9ymFSOy+yWorZRrAEfu2jRujDSQ/sGJtvmL5T YS1bLqm6I2umNDCjOGg2Ol3J5UUvjFLsJ9JU7DjOJdod+EQSpcX+CB0lTqBgLjkeNu44 dEfGLGD+ZzlI0s+4KeGK2vv/959ljble49gBRSCs5O/bN3A8BA4h2Sw9gfySS91Us2WA Dh1TenRAcy5x60HF1TtbUl/7pIlUY3b0iOP/LPa3BSkpVMk6cZwJAbV7DjWHjH2p5+dP 8ahFxYSwxBnMKbh8qfWgBKIy/OopSDco3zRmciIdDxqLoR7rqoOYjwtLb8qDVAeaUtkv RINw== X-Forwarded-Encrypted: i=1; AJvYcCVcZbU0w6m+W15ED81w4MPh0WUVd1kmtpQnVCtv8QPysmmtmNMME6ETTQFTCKzFiUsnXCJgHaoF8wnbGlFiCDQhci7N@freebsd.org X-Gm-Message-State: AOJu0Yw4eUunkp4wFtgKWvqWmi4vo8WXFpBxvn4Gt+4Bwydu1OaTA36h FlNvxjE8rzAyRATMd4aTkfH5QQbQgIDry5B6/B3QRsoy9jAdYl1mxWjcyoegdoHvcRWuo6Dhaen 3hLd5snChsX03RZgeXy/mfbQ80XLC2tpJGUu2Dg== X-Gm-Gg: ASbGncvH/S9jtTpMcVC+/sPFq5ffjvlBE7QCGmSoC91U76XVByCD2BH6xS1nXTVGiZ7 2/NA8lyz3pfP+Y5MujWWE+9TA9LcJc8h7R4DxIHmWJWTY+SDg2Q0fKY2A8ZVMBW/G7OEGS8K6NJ 6/wukPaAlseXOWwCZIfjc/2XVQn0E37pSaAx90D9TRKiU+WbBdREA2Gf74ryqcv+nlehsu4pFcF w== X-Google-Smtp-Source: AGHT+IGEtShE4hXV+tBbKyoT+LMmP1XyK4hNNIYgvXh5/rRhpqnnpPpHsh3askSL4ErSrUECQCNWhgWXzHSCm/MqoNI= X-Received: by 2002:a17:90b:3908:b0:2fe:99cf:f566 with SMTP id 98e67ed59e1d1-30c3cefe5cfmr23037107a91.13.1747088102496; Mon, 12 May 2025 15:15:02 -0700 (PDT) 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 References: <202504301721.53UHLjlw095104@gitrepo.freebsd.org> <878qn8r3t6.wl-herbert@gojira.at> <87msbipbve.wl-herbert@gojira.at> In-Reply-To: <87msbipbve.wl-herbert@gojira.at> From: Warner Losh Date: Mon, 12 May 2025 16:14:51 -0600 X-Gm-Features: AX0GCFsAjrzk1BGs0JHOh9oJDBVa-FcnXGGORIRPoZ6SLPWMNbppQme4O2hXUoM Message-ID: Subject: Re: git: 80b069913d49 - stable/14 - mpi3mr: Divert large WriteSame IOs to firmware if unmap and ndob bits are set To: "Herbert J. Skuhra" Cc: Warner Losh , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-branches@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4ZxDS80LfLz45LR X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] X-Spamd-Bar: ---- I'll try. Warner On Mon, May 12, 2025 at 12:43=E2=80=AFAM Herbert J. Skuhra wrote: > > Yes, thanks. Merge to releng/14.3? > > On Thu, 08 May 2025 17:44:59 +0200, Warner Losh wrote: > > > > I think that I've fixed this. > > > > Warner > > > > On Wed, May 7, 2025 at 6:41=E2=80=AFAM Herbert J. Skuhra wrote: > > > > > > On Wed, 30 Apr 2025 19:21:45 +0200, Warner Losh wro= te: > > > > > > > > The branch stable/14 has been updated by imp: > > > > > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=3D80b069913d496bd73b0e= a8e515b6bf3706530ea1 > > > > > > > > commit 80b069913d496bd73b0ea8e515b6bf3706530ea1 > > > > Author: Chandrakanth patil > > > > AuthorDate: 2024-06-06 08:38:52 +0000 > > > > Commit: Warner Losh > > > > CommitDate: 2025-04-30 17:05:52 +0000 > > > > > > > > mpi3mr: Divert large WriteSame IOs to firmware if unmap and ndo= b bits are set > > > > > > > > Firmware advertises the transfer lenght for writesame commands = to driver during init. > > > > So for any writesame IOs with ndob and unmap bit set and transf= er lengh is greater > > > > than the max write same length specified by the firmware, then = direct those commands > > > > to firmware instead of hardware otherwise hardware will break. > > > > > > > > Reviewed by: imp > > > > Approved by: imp > > > > Differential revision: https://reviews.freebsd.org/D44452 > > > > > > > > (cherry picked from commit 3f3a15543a6721100dda0e4219eb48ecbe35= 731a) > > > > --- > > > > sys/dev/mpi3mr/mpi3mr.c | 16 ++++++++++++++++ > > > > sys/dev/mpi3mr/mpi3mr.h | 2 ++ > > > > sys/dev/mpi3mr/mpi3mr_cam.c | 35 +++++++++++++++++++++++++++++++++= ++ > > > > sys/dev/mpi3mr/mpi3mr_cam.h | 1 + > > > > sys/modules/mpi3mr/Makefile | 3 +++ > > > > 5 files changed, 57 insertions(+) > > > > > > > > diff --git a/sys/dev/mpi3mr/mpi3mr.c b/sys/dev/mpi3mr/mpi3mr.c > > > > index 03fea4bdfcc7..a7bc459c1db8 100644 > > > > --- a/sys/dev/mpi3mr/mpi3mr.c > > > > +++ b/sys/dev/mpi3mr/mpi3mr.c > > > > @@ -2177,6 +2177,8 @@ static int mpi3mr_issue_iocinit(struct mpi3mr= _softc *sc) > > > > time_in_msec =3D (now.tv_sec * 1000 + now.tv_usec/1000); > > > > iocinit_req.TimeStamp =3D htole64(time_in_msec); > > > > > > > > + iocinit_req.MsgFlags |=3D MPI3_IOCINIT_MSGFLAGS_WRITESAMEDIVE= RT_SUPPORTED; > > > > + > > > > init_completion(&sc->init_cmds.completion); > > > > retval =3D mpi3mr_submit_admin_cmd(sc, &iocinit_req, > > > > sizeof(iocinit_req)); > > > > @@ -3340,6 +3342,19 @@ void mpi3mr_update_device(struct mpi3mr_soft= c *sc, > > > > break; > > > > } > > > > > > > > + switch (flags & MPI3_DEVICE0_FLAGS_MAX_WRITE_SAME_MASK) { > > > > + case MPI3_DEVICE0_FLAGS_MAX_WRITE_SAME_256_LB: > > > > + tgtdev->ws_len =3D 256; > > > > + break; > > > > + case MPI3_DEVICE0_FLAGS_MAX_WRITE_SAME_2048_LB: > > > > + tgtdev->ws_len =3D 2048; > > > > + break; > > > > + case MPI3_DEVICE0_FLAGS_MAX_WRITE_SAME_NO_LIMIT: > > > > + default: > > > > + tgtdev->ws_len =3D 0; > > > > + break; > > > > + } > > > > + > > > > switch (tgtdev->dev_type) { > > > > case MPI3_DEVICE_DEVFORM_SAS_SATA: > > > > { > > > > @@ -5649,6 +5664,7 @@ static void mpi3mr_invalidate_devhandles(stru= ct mpi3mr_softc *sc) > > > > target->io_throttle_enabled =3D 0; > > > > target->io_divert =3D 0; > > > > target->throttle_group =3D NULL; > > > > + target->ws_len =3D 0; > > > > } > > > > } > > > > mtx_unlock_spin(&sc->target_lock); > > > > diff --git a/sys/dev/mpi3mr/mpi3mr.h b/sys/dev/mpi3mr/mpi3mr.h > > > > index 2f91b0b702dd..fa50ed035fc2 100644 > > > > --- a/sys/dev/mpi3mr/mpi3mr.h > > > > +++ b/sys/dev/mpi3mr/mpi3mr.h > > > > @@ -232,6 +232,8 @@ extern char fmt_os_ver[16]; > > > > > > > > #define MPI3MR_PERIODIC_DELAY 1 /* 1 second heartbeat= /watchdog check */ > > > > > > > > +#define WRITE_SAME_32 0x0d > > > > + > > > > struct completion { > > > > unsigned int done; > > > > struct mtx lock; > > > > diff --git a/sys/dev/mpi3mr/mpi3mr_cam.c b/sys/dev/mpi3mr/mpi3mr_ca= m.c > > > > index d4cb7e9265dd..dca194a5c8cd 100644 > > > > --- a/sys/dev/mpi3mr/mpi3mr_cam.c > > > > +++ b/sys/dev/mpi3mr/mpi3mr_cam.c > > > > @@ -83,6 +83,7 @@ > > > > #include "mpi3mr.h" > > > > #include /* XXX for pcpu.h */ > > > > #include /* XXX for PCPU_GET *= / > > > > +#include > > > > > > > > #define smp_processor_id() PCPU_GET(cpuid) > > > > > > > > @@ -102,6 +103,37 @@ extern void mpi3mr_add_sg_single(void *paddr, = U8 flags, U32 length, > > > > > > > > static U32 event_count; > > > > > > > > +static > > > > +inline void mpi3mr_divert_ws(Mpi3SCSIIORequest_t *req, > > > > + struct ccb_scsiio *csio, > > > > + U16 ws_len) > > > > +{ > > > > + U8 unmap =3D 0, ndob =3D 0; > > > > + U32 num_blocks =3D 0; > > > > + U8 opcode =3D scsiio_cdb_ptr(csio)[0]; > > > > + U16 service_action =3D ((scsiio_cdb_ptr(csio)[8] << 8) | scsi= io_cdb_ptr(csio)[9]); > > > > + > > > > + > > > > + if (opcode =3D=3D WRITE_SAME_16 || > > > > + (opcode =3D=3D VARIABLE_LEN_CDB && > > > > + service_action =3D=3D WRITE_SAME_32)) { > > > > + > > > > + int unmap_ndob_index =3D (opcode =3D=3D WRITE_SAME_16= ) ? 1 : 10; > > > > + > > > > + unmap =3D scsiio_cdb_ptr(csio)[unmap_ndob_index] & 0x= 08; > > > > + ndob =3D scsiio_cdb_ptr(csio)[unmap_ndob_index] & 0x0= 1; > > > > + num_blocks =3D get_unaligned_be32(scsiio_cdb_ptr(csio= ) + > > > > + ((opcode =3D=3D WRITE= _SAME_16) ? 10 : 28)); > > > > + > > > > + /* Check conditions for diversion to firmware */ > > > > + if (unmap && ndob && num_blocks > ws_len) { > > > > + req->MsgFlags |=3D MPI3_SCSIIO_MSGFLAGS_DIVER= T_TO_FIRMWARE; > > > > + req->Flags =3D htole32(le32toh(req->Flags) | > > > > + MPI3_SCSIIO_FLAGS_DIVERT= _REASON_WRITE_SAME_TOO_LARGE); > > > > + } > > > > + } > > > > +} > > > > + > > > > static void mpi3mr_prepare_sgls(void *arg, > > > > bus_dma_segment_t *segs, int nsegs, int error) > > > > { > > > > @@ -1080,6 +1112,9 @@ mpi3mr_action_scsiio(struct mpi3mr_cam_softc = *cam_sc, union ccb *ccb) > > > > break; > > > > } > > > > > > > > + if (targ->ws_len) > > > > + mpi3mr_divert_ws(req, csio, targ->ws_len); > > > > + > > > > req->Flags =3D htole32(mpi_control); > > > > > > > > if (csio->ccb_h.flags & CAM_CDB_POINTER) > > > > diff --git a/sys/dev/mpi3mr/mpi3mr_cam.h b/sys/dev/mpi3mr/mpi3mr_ca= m.h > > > > index 3a0526217f86..115ce0c4b8d7 100644 > > > > --- a/sys/dev/mpi3mr/mpi3mr_cam.h > > > > +++ b/sys/dev/mpi3mr/mpi3mr_cam.h > > > > @@ -121,6 +121,7 @@ struct mpi3mr_target { > > > > struct mpi3mr_throttle_group_info *throttle_group; > > > > uint64_t q_depth; > > > > enum mpi3mr_target_state state; > > > > + uint16_t ws_len; > > > > }; > > > > > > > > struct mpi3mr_cam_softc { > > > > diff --git a/sys/modules/mpi3mr/Makefile b/sys/modules/mpi3mr/Makef= ile > > > > index 3f1f63a94ac3..39aa2e3f0ddd 100644 > > > > --- a/sys/modules/mpi3mr/Makefile > > > > +++ b/sys/modules/mpi3mr/Makefile > > > > @@ -6,6 +6,9 @@ SRCS=3D mpi3mr_pci.c mpi3mr.c mpi3mr_cam.c mpi3mr_a= pp.c > > > > SRCS+=3D opt_cam.h > > > > SRCS+=3D device_if.h bus_if.h pci_if.h > > > > > > > > +CFLAGS+=3D -I${SRCTOP}/sys/compat/linuxkpi/common/include > > > > +DEBUG_FLAGS=3D -g > > > ^^^^^^^^^^^^^^^^ > > > > + > > > > .include > > > > > > > > CWARNFLAGS.mpi3mr_sas.c=3D ${NO_WUNNEEDED_INTERNAL_DEC= L} > > > > > > https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D249068#c2 > > > > > > -- > > > Herbert