Message ID | 20230331074650.75-1-avri.altman@wdc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp389267vqo; Fri, 31 Mar 2023 00:51:38 -0700 (PDT) X-Google-Smtp-Source: AK7set+osBU4Jr/hE5aalpCEjAxg945axdhr2A6ZQy65jBfkoQOviJhIyxSvLzxWMxkCTai1XtxN X-Received: by 2002:a05:6a20:4890:b0:da:90e5:fc17 with SMTP id fo16-20020a056a20489000b000da90e5fc17mr23440657pzb.13.1680249097646; Fri, 31 Mar 2023 00:51:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680249097; cv=none; d=google.com; s=arc-20160816; b=vblIgx8530BiAcP5gn0atMB9gqssiJIW0rqJp+RZDGydNfNYD3HJ5wdrpWiygFV3Nl zwuJ+YBzb/ORMyyLUdCiYKa7GSBfUN/UPr7nGRBJAgfHVZMgtAPVTZAgv4Dhs09Sbajq EZRva+j8ZWLRyReiVuIOWR62e7FIqTHYO1GOljbDzkCloagUEJrxKiPwl08a24na2Wlu 0V4PdOmw+mYSDZM2tthLx10ZyAVOMbpgqlCrVgrB5H5qaoXI+DmsyuXgMBjJz1KFhzhy ibP7lBdGKFdi35S+BCknIPgxEt627jWhis5C6I6+GODeSQ2yAshzrstdIU3n39EJOCw+ nP8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :wdcironportexception:ironport-sdr:ironport-sdr:dkim-signature; bh=wt8ipyhq5IQA41dMUJZ+IJRlRokIhgj2fxbDmDfAgdU=; b=GYGUBc5VwN4qdVuvBAwb1d+WRQHb45Q6oYAJWeHOJWx90FNk3BqECxrdUgLqlr6tDI EwXmSRuIQ/sQY+ofrlsXxzAhkbnZZ01TKVqsyADEuJ3UG/EB3blqtrz0VoX5zQtD2ZfN gta2GQiU5sN9by9btblt+XhsNHvS9hctioUdkgrsGPYMlTB7HwELJzA4kZuRkhVoqsV2 Y2pG7CZpgSdbR2bvCZHWTeNwLxB7jkBoULoHSu8qHqr2a7y2E3nynFKar3HIV96EaDXd +oimvvqPu2PV7l5NwX5wEJnIdbqUUEcNoDE/x5pYQ9a8uRaVN4w6lRl2zM3I9YjPEeyl pQYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=CrV2T2fD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a188-20020a624dc5000000b00624eb57b45dsi1807817pfb.74.2023.03.31.00.51.24; Fri, 31 Mar 2023 00:51:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=CrV2T2fD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231180AbjCaHui (ORCPT <rfc822;jimliu8233@gmail.com> + 99 others); Fri, 31 Mar 2023 03:50:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231213AbjCaHuT (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 31 Mar 2023 03:50:19 -0400 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7997110AA8; Fri, 31 Mar 2023 00:49:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1680248961; x=1711784961; h=from:to:cc:subject:date:message-id; bh=wvFXHtpZ7xPN75TSbGJGueSihEi7iWOy4Ow7TTI4BhQ=; b=CrV2T2fDOBoAZrLP16Hn/uI0uu1L1tfci67n3YaameI9mUeglvsEG/ay uPai+m7VPp5Iy5JnufED7FWb7NcZkkvn06RCYkOeBk3OEjl29VlsVknyl aqoytvEsqT2de1uyhZOosLVhJNL+4ViphnaYWN24mx/efxquPUNPvRdNE doSPkJT/xCT3DUOGv0R8j4WNV3DhKuBjdDfQcDvFTy5SJ3yTWUazipEIM LN5hdv38P5zHGxBQU+uob+h0b2B23ZN6zdYpfOdxuQ7fk3UP0KmX7M9SV syX85wMlePQaw3Co1eI++9pibYxjKf5ewT6eJwYET3o8ZyQs6SIJ/pOOh Q==; X-IronPort-AV: E=Sophos;i="5.98,307,1673884800"; d="scan'208";a="331406323" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 31 Mar 2023 15:47:04 +0800 IronPort-SDR: UiICxUixaSpM0FBiqKJyNulx0j6qIkigx4HrZOjt/8xxmUZDTbFgovVZ4VWSD3y6x8z1gci8Cq kuqwMGNr0jUvQ34iK9Ko3/xRiC0AKNeuJXS2n6law6/96u2IOI3ciU+Fd7Vldi69s71lB2/hdr 38HkbPvut1uLpJBuldyvSDBK/xCHnra9qTAWnRT3G4JtRz2PmBO1Wd19/91BHCX+EF77o/h/1F RDJFrvFU9rwvUxJ2Kl9CRTdmyyErj9Rg3kgvJKG3x2ucSibzBtz2TXPqnohVmDJulqzTYsd8/I LLA= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 31 Mar 2023 00:03:12 -0700 IronPort-SDR: b31kBmBQnRDARAFbLux9YmCnsRW8UbbrsifQPGXsyNtpbsPFvacY+QDWVnEFCJijV5x6zXQEOU 8Btw01YRScDFzc03kMKbEW8MnT+H3sOKdn6EjTxHOg/p1xRrwIq7nkg3cAeiGGZob275R+JPIT Wbb1P2Exu75Nllr713JLJ0eOFmFgAntqvJ7d62S5V283nHMQOD61g6EdJ5QRpAji0Mz+HUFSek KODGfEmGHBOzxE+CyetJELXDwDETVo9ETQgjRMfOtRQrdNSQJHHIFPoSdp8KYLcQh5nrysDDeR H84= WDCIronportException: Internal Received: from bxygm33.ad.shared ([10.225.33.176]) by uls-op-cesaip02.wdc.com with ESMTP; 31 Mar 2023 00:46:59 -0700 From: Avri Altman <avri.altman@wdc.com> To: "James E . J . Bottomley" <jejb@linux.vnet.ibm.com>, "Martin K . Petersen" <martin.petersen@oracle.com> Cc: Asutosh Das <quic_asutoshd@quicinc.com>, quic_cang@quicinc.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Johannes Thumshirn <Johannes.Thumshirn@wdc.com>, Bart Van Assche <bvanassche@acm.org>, Avri Altman <avri.altman@wdc.com> Subject: [PATCH v2] scsi: ufs: mcq: Limit the amount of inflight requests Date: Fri, 31 Mar 2023 10:46:50 +0300 Message-Id: <20230331074650.75-1-avri.altman@wdc.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761868877475571140?= X-GMAIL-MSGID: =?utf-8?q?1761868877475571140?= |
Series |
[v2] scsi: ufs: mcq: Limit the amount of inflight requests
|
|
Commit Message
Avri Altman
March 31, 2023, 7:46 a.m. UTC
in UFS, each request is designated via the triplet <iid, lun, task tag>.
In UFS4.0 the Initiator ID field is 8 bits wide, comprised of the
EXT_IID and IID fields. Together with the task tag (single byte), they
limit the driver's hw queues capacity.
---
v1 -> v2:
Attend Johannes's and Bart's comments
Signed-off-by: Avri Altman <avri.altman@wdc.com>
---
drivers/ufs/core/ufshcd.c | 5 +++++
1 file changed, 5 insertions(+)
Comments
Looks good code wise, though I have 0 clue of UFS.
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Hi Avri, https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Avri-Altman/scsi-ufs-mcq-Limit-the-amount-of-inflight-requests/20230331-155149 base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next patch link: https://lore.kernel.org/r/20230331074650.75-1-avri.altman%40wdc.com patch subject: [PATCH v2] scsi: ufs: mcq: Limit the amount of inflight requests config: parisc-randconfig-m031-20230329 (https://download.01.org/0day-ci/archive/20230401/202304011340.ltlHYazS-lkp@intel.com/config) compiler: hppa-linux-gcc (GCC) 12.1.0 If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Reported-by: Dan Carpenter <error27@gmail.com> | Link: https://lore.kernel.org/r/202304011340.ltlHYazS-lkp@intel.com/ New smatch warnings: drivers/ufs/core/ufshcd.c:8473 ufshcd_alloc_mcq() warn: missing error code 'ret' Old smatch warnings: drivers/ufs/core/ufshcd.c:5412 ufshcd_uic_cmd_compl() error: we previously assumed 'hba->active_uic_cmd' could be null (see line 5400) drivers/ufs/core/ufshcd.c:2350 ufshcd_hba_capabilities() warn: missing error code? 'err' vim +/ret +8473 drivers/ufs/core/ufshcd.c 57b1c0ef89ac9d drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8457 static int ufshcd_alloc_mcq(struct ufs_hba *hba) 57b1c0ef89ac9d drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8458 { 7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8459 int ret; 7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8460 int old_nutrs = hba->nutrs; 7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8461 7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8462 ret = ufshcd_mcq_decide_queue_depth(hba); 7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8463 if (ret < 0) 7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8464 return ret; 7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8465 7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8466 hba->nutrs = ret; 7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8467 ret = ufshcd_mcq_init(hba); 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8468 if (ret) 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8469 goto err; 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8470 2580a95e61d461 drivers/ufs/core/ufshcd.c Avri Altman 2023-03-31 8471 if (hba->nutrs * hba->nr_hw_queues > SZ_64K - 1) { 2580a95e61d461 drivers/ufs/core/ufshcd.c Avri Altman 2023-03-31 8472 dev_info(hba->dev, "there can be at most 64K inflight requests\n"); 2580a95e61d461 drivers/ufs/core/ufshcd.c Avri Altman 2023-03-31 @8473 goto err; ret = -EINVAL; 2580a95e61d461 drivers/ufs/core/ufshcd.c Avri Altman 2023-03-31 8474 } 2580a95e61d461 drivers/ufs/core/ufshcd.c Avri Altman 2023-03-31 8475 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8476 /* 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8477 * Previously allocated memory for nutrs may not be enough in MCQ mode. 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8478 * Number of supported tags in MCQ mode may be larger than SDB mode. 6ccf44fe4cd7c4 drivers/scsi/ufs/ufshcd.c Seungwon Jeon 2013-06-26 8479 */ 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8480 if (hba->nutrs != old_nutrs) { 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8481 ufshcd_release_sdb_queue(hba, old_nutrs); 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8482 ret = ufshcd_memory_alloc(hba); 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8483 if (ret) 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8484 goto err; 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8485 ufshcd_host_memory_configure(hba); 7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8486 } 7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8487 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8488 ret = ufshcd_mcq_memory_alloc(hba); 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8489 if (ret) 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8490 goto err; 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8491 7224c806876e46 drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8492 return 0; 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8493 err: 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8494 hba->nutrs = old_nutrs; 4682abfae2eb3a drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8495 return ret; 57b1c0ef89ac9d drivers/ufs/core/ufshcd.c Asutosh Das 2023-01-13 8496 }
On 31/03/2023 08:46, Avri Altman wrote: > in UFS, each request is designated via the triplet <iid, lun, task tag>. > > In UFS4.0 the Initiator ID field is 8 bits wide, comprised of the > EXT_IID and IID fields. Together with the task tag (single byte), they > limit the driver's hw queues capacity. > > --- > v1 -> v2: > Attend Johannes's and Bart's comments > > Signed-off-by: Avri Altman <avri.altman@wdc.com> > --- > drivers/ufs/core/ufshcd.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c > index 35a3bd95c5e4..cac7c9918c5b 100644 > --- a/drivers/ufs/core/ufshcd.c > +++ b/drivers/ufs/core/ufshcd.c > @@ -8468,6 +8468,11 @@ static int ufshcd_alloc_mcq(struct ufs_hba *hba) > if (ret) > goto err; > > + if (hba->nutrs * hba->nr_hw_queues > SZ_64K - 1) { If shost->host_tagset is set - which it seems to be for this driver - then the number of HW queues would not influence how many IOs the host may be sent. Rather this is just limited by just the HW queue depth. Thanks, John > + dev_info(hba->dev, "there can be at most 64K inflight requests\n"); > + goto err; > + } > + > /* > * Previously allocated memory for nutrs may not be enough in MCQ mode. > * Number of supported tags in MCQ mode may be larger than SDB mode.
> On 31/03/2023 08:46, Avri Altman wrote: > > in UFS, each request is designated via the triplet <iid, lun, task tag>. > > > > In UFS4.0 the Initiator ID field is 8 bits wide, comprised of the > > EXT_IID and IID fields. Together with the task tag (single byte), they > > limit the driver's hw queues capacity. > > > > --- > > v1 -> v2: > > Attend Johannes's and Bart's comments > > > > Signed-off-by: Avri Altman <avri.altman@wdc.com> > > --- > > drivers/ufs/core/ufshcd.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c > > index 35a3bd95c5e4..cac7c9918c5b 100644 > > --- a/drivers/ufs/core/ufshcd.c > > +++ b/drivers/ufs/core/ufshcd.c > > @@ -8468,6 +8468,11 @@ static int ufshcd_alloc_mcq(struct ufs_hba *hba) > > if (ret) > > goto err; > > > > + if (hba->nutrs * hba->nr_hw_queues > SZ_64K - 1) { > > If shost->host_tagset is set - which it seems to be for this driver - then the > number of HW queues would not influence how many IOs the host may be > sent. Rather this is just limited by just the HW queue depth. Thanks. The purpose of this patch is merely to document the ufs spec restrictions. practically, it impose no functional change. I will elaborate the commit log accordingly. Thanks, Avri > > Thanks, > John > > > + dev_info(hba->dev, "there can be at most 64K inflight requests\n"); > > + goto err; > > + } > > + > > /* > > * Previously allocated memory for nutrs may not be enough in MCQ > mode. > > * Number of supported tags in MCQ mode may be larger than SDB > mode.
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 35a3bd95c5e4..cac7c9918c5b 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8468,6 +8468,11 @@ static int ufshcd_alloc_mcq(struct ufs_hba *hba) if (ret) goto err; + if (hba->nutrs * hba->nr_hw_queues > SZ_64K - 1) { + dev_info(hba->dev, "there can be at most 64K inflight requests\n"); + goto err; + } + /* * Previously allocated memory for nutrs may not be enough in MCQ mode. * Number of supported tags in MCQ mode may be larger than SDB mode.