Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2555332rdb; Tue, 12 Sep 2023 05:49:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHfiYEgF2d8SBjGnfJ01YWnF51DK+DGqdZW1TT9jiGrDmNFBdNhnXEqUyKYpVoWIs1weXSo X-Received: by 2002:a9d:4815:0:b0:6b8:9a3a:ea12 with SMTP id c21-20020a9d4815000000b006b89a3aea12mr14066882otf.12.1694522968018; Tue, 12 Sep 2023 05:49:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694522967; cv=none; d=google.com; s=arc-20160816; b=oqtj/N3ttvsaKPu8npQQ47xPkbYTWtmnzdn3oLYan6EPdG/9SHJzXrjteJiWvDGBVT Q5ikxZowQXUeHNBjEiWrtuwfNwNT8wxWuoE1UiXvhnsTJupsotb1Uke/A1m3suQwKCPo m6t/iPcyqh6579Rmpzn8ctWhzZXoaDhxVax7/2tmQ6eN7j1pS1bPgeFgnHewc/mNI5N+ hFFqHykDQbYpYtdfBpM1QqYPuw9wOzPwCiAr7ip8Dkox5vOKi2/plE/eX9cmMu2O2AOl SL1Gt1LKWfrd5hq/vVTp0oHh+vvn3971IQnAOw6gf3UwR+fVs+x8XVF9eZ/aydmFnlOw b8Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0pMQ5nEz3PDPyWX6xH/nQcRfwUknEDWO/EEsxvwrKEE=; fh=fP4Ih3qxYOTw5sPjM7X3O+v6dYgGRKV/24z8tZ1fYQ4=; b=xXmOrWQ8Q8Frak8qe7x9OfwDudVWk+QB/2enhWZasF2uqTPIDqH8ABbzP4XWiXDN3C TTM4TzJggj7/X8qCtTXxbUTbSqpTY7FFtlS+j06o6QQJakrMXAaFhiRkW37y1pBFZ46x uA8jTvDxJDavhikNoRDXgMoKNmeuzGWjlnUNkSCfzNWjXerA3hBiYkdBAli5QvL/GM1/ ENwOqItzJCEzci2AmsKOhbxSI1M7n2zaVE2Fg9nRWBL4Daht8Mc3eYl8upQaEnA/KnBr K2jmBCO67WeEmM22BfsVhUGCc6smgEaFSUqEcdL5BKW+ObZ/mAx5JE1925ATHNCABUgh OTgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kSdaMriA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id v3-20020a655c43000000b005634b43d2e6si7982364pgr.627.2023.09.12.05.49.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 05:49:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kSdaMriA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 3A4C38450869; Mon, 11 Sep 2023 21:43:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237481AbjILCXv (ORCPT + 99 others); Mon, 11 Sep 2023 22:23:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236287AbjILCXc (ORCPT ); Mon, 11 Sep 2023 22:23:32 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B402213B51E for ; Mon, 11 Sep 2023 18:47:25 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6860C116AF; Mon, 11 Sep 2023 23:16:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694474171; bh=Oleg9TJC+AKMIQSbLWxgrU0AxqMUMBEa9ZbYFKCkri0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kSdaMriAlU8GQInb0AOV1OrCTNMMt2tUj6Cx9/LGyQUdzT8afM7Ti40wvIH9oaIGY cNydm7/eRwDhhL4viT0P+BazWi/jWTtwGBivEI0xbPvCG17l9J5DM+tIT3fU/NE1e3 tlHVzOgLTRg0fVPlhOVudi7e6cjNoiUbqFjoXJGaQFr+WFyX1a6+Jvut+OIEh49Ld3 ffyf6OjObXsHY1Mg0qm79IEf8cvVn72HwlLxiVKLFM9ovckbFiLnCbHQ3L+fLtT/4l IuxIyBbJBTLwyboUGIS7o5z8xc3c/LMp4HxPnvI6fRBC0Lr2DtcleWHaUaZNau9Srz xRAleNAf8q0Hg== Date: Mon, 11 Sep 2023 16:16:09 -0700 From: Keith Busch To: Felix Yan Cc: highenthalpyh@gmail.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, xuwd1@hotmail.com Subject: Re: [PATCH] nvme-pci: ignore bogus CRTO according to NVME 2.0 spec Message-ID: References: <20230908155442.31423-1-felixonmars@archlinux.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 11 Sep 2023 21:43:43 -0700 (PDT) On Mon, Sep 11, 2023 at 04:00:42PM -0700, Keith Busch wrote: > @@ -2257,12 +2258,15 @@ int nvme_enable_ctrl(struct nvme_ctrl *ctrl) > > if (ctrl->cap & NVME_CAP_CRMS_CRIMS) { > ctrl->ctrl_config |= NVME_CC_CRIME; > - timeout = NVME_CRTO_CRIMT(crto); > + /* > + * CRIMT should always be greater or equal to CAP.TO, > + * but some devices are known to get this wrong. Use > + * the larger of the two values. > + */ > + timeout = max(timeout, NVME_CRTO_CRIMT(crto)); > } else { > timeout = NVME_CRTO_CRWMT(crto); > } Er... please pretend I added the "max()" handling in the 'else' case instead of the CRIMS case. -- >8 -- @@ -2259,10 +2260,13 @@ int nvme_enable_ctrl(struct nvme_ctrl *ctrl) ctrl->ctrl_config |= NVME_CC_CRIME; timeout = NVME_CRTO_CRIMT(crto); } else { - timeout = NVME_CRTO_CRWMT(crto); + /* + * CRWMT should always be greater or equal to CAP.TO, + * but some devices are known to get this wrong. Use + * the larger of the two values. + */ + timeout = max(timeout, NVME_CRTO_CRWMT(crto)); }