From nobody Thu May 8 15:44:59 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 4Ztc095G6Kz5vF7F for ; Thu, 08 May 2025 15:45:13 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) (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 4Ztc0868CPz47f4 for ; Thu, 08 May 2025 15:45:12 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20230601.gappssmtp.com header.s=20230601 header.b=dgCVSMMO; spf=none (mx1.freebsd.org: domain of wlosh@bsdimp.com has no SPF policy when checking 2607:f8b0:4864:20::42a) smtp.mailfrom=wlosh@bsdimp.com; dmarc=none Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-7398d65476eso1043835b3a.1 for ; Thu, 08 May 2025 08:45:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1746719110; x=1747323910; 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=/wsLL/mXCVyXysM2BK/5IsqlNJlty3piTZGhe66EkV4=; b=dgCVSMMOWyl+/jOjZXjngK8lvUbNWTL5I36aXwY+DVwI03+xx/8rpx/oTC5+61GaEx jLAIAn4Plp/Qh+NvUaPpO7ASk7fVPC3cOghxgQ0MN/uvITYV/LNmw4S4H3EX3BMJab/f OTd3Bmd4pjZz8h1M3loo7iJiTWEd3sGzsGqoFbiDF0WNaW1qix1/xZuOS1dkCsABC8lD FiCevYcaLIFscrpzCUjECyvPxM0MRV4xiPZEPWwHWpGNAUblf4zXsjBrW8dD6Pq3MAfQ /ry98Er3Ht2cVMthEMJ5vyjr8IHbEsGW47C/sPB9tfuqGNDqt/FOkWLWi0gW1/q9rGfP TEqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746719110; x=1747323910; 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=/wsLL/mXCVyXysM2BK/5IsqlNJlty3piTZGhe66EkV4=; b=p26E7Vlmu8MWsJpSgN3LIXaWvFIoePPzhLar+97WxjIlrCztbDh72Fb959zGJ7Keos zXxMj1/rnJzvDhS231R5QCBPsD3ceZWNzoIaF7HevkBMQElpLNk/x+NQ0UX1xCpHnBt8 X15YC5HzmaVKOeU8D9UlCc++M7bbT+jhwFoIf5/i+Vg4fruJYtXV0HFPKH3bgVLhjOUD v4rMcgLZ3ywLC4IHyab5HGpcryWgkA5ZbzOPlZR0VRSC/zOuqVfIiwtqbyuu3Ybx38/7 NZRlO2sQnaqMCHbZrNHnCT4We3RrW+ArNFGRW6xe1ghfIPW9KYynUg8egiO00O/dgEtF dEYQ== X-Forwarded-Encrypted: i=1; AJvYcCWsl1kGFyEaxIvwJDbXv85SMqrU4tPaCLS5dob5vVIZuInlYETyGUQsmvu+U2YXceF+lYiyLgqbk9Ao+9Q358CyjJL2@freebsd.org X-Gm-Message-State: AOJu0YyvLWvAPOnvZt9YSBvCYf+FOeUY+WQeEzualn1T9JapagcAfxff fDEjCuvBFPa5ZSRYNHMoZmsYeI8BkHZhs/fT9VogUQp1zHagYJ9e7YzQO7ILJWqgugDtIftkTz1 YFwoPxpcE54DakLOYiFOp+fRt8u3Tpo7b854HdKRFpq3LQrSp X-Gm-Gg: ASbGnctbht5tmQRguLtLa7rLapICuU2raox95lgrs7QLoRuF/RJuOd9Lu0/L1r+/SFs LyyYmLydV+ZiIXI2n/beG6Jw7Pm5cA/rQjhVBK04cMeWm2LFqbv6738iglOn85CTcYmcaRIKq14 H36yXW76fYcIN9loLHNv7YYg== X-Google-Smtp-Source: AGHT+IFmk9vrN5Khhk23qXfFPrBCJa/bDa2B9JhhBwx1fB4tOsRL52+z+ESuqMCcFJLrZxtFpr1OB30KtkyeoPnsPhU= X-Received: by 2002:a05:6a00:6383:b0:737:cd8:2484 with SMTP id d2e1a72fcca58-740a9318f65mr4957554b3a.6.1746719110492; Thu, 08 May 2025 08:45:10 -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> In-Reply-To: <878qn8r3t6.wl-herbert@gojira.at> From: Warner Losh Date: Thu, 8 May 2025 09:44:59 -0600 X-Gm-Features: ATxdqUHLbjc1DY600n_4qds0iHOY07LrG6JmIjFMnqvosqJ9SOa_H-KFtTqhdT4 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: 4Ztc0868CPz47f4 X-Spamd-Bar: -- X-Spamd-Result: default: False [-2.42 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.99)[-0.985]; NEURAL_HAM_MEDIUM(-0.44)[-0.438]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20230601.gappssmtp.com:s=20230601]; MIME_GOOD(-0.10)[text/plain]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_COUNT_ONE(0.00)[1]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MISSING_XM_UA(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::42a:from]; DMARC_NA(0.00)[bsdimp.com]; MLMMJ_DEST(0.00)[dev-commits-src-all@freebsd.org]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; R_SPF_NA(0.00)[no SPF record]; PREVIOUSLY_DELIVERED(0.00)[dev-commits-src-all@freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_TLS_LAST(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20230601.gappssmtp.com:+] 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 wrote: > > > > The branch stable/14 has been updated by imp: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=3D80b069913d496bd73b0ea8e5= 15b6bf3706530ea1 > > > > 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 ndob bi= ts are set > > > > Firmware advertises the transfer lenght for writesame commands to d= river during init. > > So for any writesame IOs with ndob and unmap bit set and transfer l= engh is greater > > than the max write same length specified by the firmware, then dire= ct 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 3f3a15543a6721100dda0e4219eb48ecbe35731a= ) > > --- > > 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_sof= tc *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_WRITESAMEDIVERT_S= UPPORTED; > > + > > 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_softc *s= c, > > 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(struct m= pi3mr_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/wat= chdog 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_cam.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 f= lags, 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) | scsiio_c= db_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] & 0x08; > > + ndob =3D scsiio_cdb_ptr(csio)[unmap_ndob_index] & 0x01; > > + num_blocks =3D get_unaligned_be32(scsiio_cdb_ptr(csio) + > > + ((opcode =3D=3D WRITE_SAM= E_16) ? 10 : 28)); > > + > > + /* Check conditions for diversion to firmware */ > > + if (unmap && ndob && num_blocks > ws_len) { > > + req->MsgFlags |=3D MPI3_SCSIIO_MSGFLAGS_DIVERT_TO= _FIRMWARE; > > + req->Flags =3D htole32(le32toh(req->Flags) | > > + MPI3_SCSIIO_FLAGS_DIVERT_REA= SON_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_cam.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/Makefile > > 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_app.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_DECL} > > https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D249068#c2 > > -- > Herbert