Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3018639pxj; Sun, 6 Jun 2021 23:20:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5a6u0LW1TqQhRHUIu3IKNLHF+ryRskWES0+OlAqyiHxarLEU6+oy7vme0YOKtEJvmLu2E X-Received: by 2002:a17:906:744:: with SMTP id z4mr16468218ejb.347.1623046833298; Sun, 06 Jun 2021 23:20:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623046833; cv=none; d=google.com; s=arc-20160816; b=kbbM4te6iPndQNDQ9mUST86HCwgYoquo5Z+kULKvVdxEY5I5b4uLmKoz5891JlIcE4 2aNCbKM1uqxEwDNtdxk8pDRtZt3gYnNLsWoQWq33z8CnWQRDDXLjNp+l48KvqONEayds 9AhckHx/JkBdxcJ4W9xWKfOzVrsXcQmdZww18Fhki621hkb7NppPRX48Wf44FyW2Y+BG Ot45BZmEF++HFdNq9CaZSXhJsmoOQvVzvb5ZYhqQQp4Li+4Zos1HmOsAfazfQcIu6ESi ZqA9Lsduc2QahrfU2cKykfiHszOriyOF2ewcsDY4vngNuziQil06lQ1HWRVm0ha+Xe6L MRfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :wdcironportexception:ironport-sdr:ironport-sdr:ironport-sdr :dkim-signature; bh=7Q8NFbVn12yqGNKNs71/xt7fZTWzJNYKOyM86vCwg+g=; b=a8hI39o6ESMhu9Yg8q9kpYBy0Dn5x2nmlsT2QASP/YbE5tpDQM0frwVdZFMNGZnehu fgnbnudPiPjCOSooW2flBjLY+VvySX8Ho/jzpBXhbL/vmg/2FF3XNlLGJG19Kt+G3lPR YKkBJWhaSFCnbimEcodXobGE7aF3aWVp6TgDh75v28T4mHtW04cwwsgpt96MOSKwKg5F Hu+wwHDle4fkwqdPAAlHX1LjTlq7kd2Ml5VPcyI/Nq6/9VtZJHOZ4pLaXLi2jsKSqvgn kSsF17327iOT4PspKTqxdrm043lxwbBqIbSAz72OG2j9HcSsVMiktk42dwcnNNdUzu7h MWsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=DeN0TUpV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 26si11809770ejk.419.2021.06.06.23.20.11; Sun, 06 Jun 2021 23:20:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=DeN0TUpV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230356AbhFGGRr (ORCPT + 99 others); Mon, 7 Jun 2021 02:17:47 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:4838 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230353AbhFGGRq (ORCPT ); Mon, 7 Jun 2021 02:17:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1623046555; x=1654582555; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Eg7FuxGEda1N/nS5nNBZ3iFh8zPGLfT1LdyYWIqHRXM=; b=DeN0TUpV57QjXGkdFv2mpimKMtAfZkqLZ87kBeFGVCHy6fUPH605JbrC RJx4xZzBS8HrRjfop/mPljXjr6laKqptajA5c5G6XWXVaG/EqW4wTbbFY 0uRPly27dA3CUp6BqxFSC5YcKF283blrbvb3u7yL4PsPNheU4QPsJO8yr 03Y90HY+vnaMw2J9Px/bgspvQF3BmlljN43rjLvmEoUT6D5dBdnpU0cMl wsiI1h4xl353iiVqArAqieVQLl7Zpjlfl7p0yxhIKHoql0/B2OtlSepDA vCCSqhBBUq/PeA1/KFu4KVR7n+1SW6SkjOwknuZqhQ9amCm3j7EpikRgd Q==; IronPort-SDR: 2kwnSo+e1h+enGEWPZHFGsYQ2SJnChc3jQQyiPFRP17Xx7WXrpj1gdn4A97QZASA3/X4C/Fr3E CYo+0qTQDYP2xc8Y4w0TOOjeARck2Z6obk6nlsNOC9V4elZW+PAAWwD+p6xc4s3b/97m6v7r5O iedWtjrwW+gBD9tHz7MHAt8Rv60yjyRRrDepagOgUrjDUO1yNSWzLw8Ho860D5L7I25Xp9N5K5 N6ihrQUyCGCqxoE7vgYG9TNbm46VMebuvtrnGvQmcVApYRx6QzGRFaFdGQYA49aZziNCIbXWZg wk0= X-IronPort-AV: E=Sophos;i="5.83,254,1616428800"; d="scan'208";a="170991635" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 07 Jun 2021 14:15:55 +0800 IronPort-SDR: t1CIkNPH6bbCvbqXlZbWBmbr38ukQm3Qc6d/Uaw9TfJMkbX52mp32p63oQtdmuSv6kTrhBG5ZC 8P09AzwIRz16pCbMBSEZJ3tiznhB78iWowGlh8sNrwL7ZI3tKIr5E28+Cq78iJj11SKdfcZ6wf 1LzHGunUeyqUkz78OiH3sYZqKqfyC0uR8yQKilumAFKdNc9f3HoBL2eICovyhsE/ZkqJGOhp/N MZ3B0vIhe7KK8buYEDTqCLLX49RWrVyUAWHnayd+aZABuu+AIg3qJz0BYpdzUKagUnJ3C1IAUZ 7TdXQ4cQ4KD51Fbdddzm7EwZ Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2021 22:55:04 -0700 IronPort-SDR: iXTA1paGG1tWlPlQhUrMONaZWE0WhnTOAS9gY6q6F3ni8J/lCb5D8AockGbyiw/nYmCKWss9bu 2XvgKGry4XdfS9q/egY03hLrjBmRNKOW+kUIWaNGbMGPmspjOrowUhyq5ewLsedSIFq+/VxN66 91+oWIxXJw3Lu9Dad36qsy934DU9eD/X8B/UKJPWWCokFlqG66IudX97kGrKsOYDBk2gp/RI7o lfgIP3O21lH7u910eplFzzFjQbu/owC4csJ5jPVmzJEKvqML+1deMPjbxh/7PISE0PmQjRwA3E rWI= WDCIronportException: Internal Received: from bxygm33.sdcorp.global.sandisk.com ([10.0.231.247]) by uls-op-cesaip02.wdc.com with ESMTP; 06 Jun 2021 23:15:52 -0700 From: Avri Altman To: "James E . J . Bottomley" , "Martin K . Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, Bart Van Assche , yongmyung lee , Daejun Park , alim.akhtar@samsung.com, asutoshd@codeaurora.org, Zang Leigang , Avi Shchislowski , Bean Huo , cang@codeaurora.org, stanley.chu@mediatek.com, Avri Altman Subject: [PATCH v10 09/12] scsi: ufshpb: Limit the number of inflight map requests Date: Mon, 7 Jun 2021 09:13:58 +0300 Message-Id: <20210607061401.58884-10-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210607061401.58884-1-avri.altman@wdc.com> References: <20210607061401.58884-1-avri.altman@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In host control mode the host is the originator of map requests. To not flood the device with map requests, use a simple throttling mechanism that limits the number of inflight map requests. Signed-off-by: Avri Altman Reviewed-by: Daejun Park --- drivers/scsi/ufs/ufshpb.c | 11 +++++++++++ drivers/scsi/ufs/ufshpb.h | 1 + 2 files changed, 12 insertions(+) diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index a31a9a6979de..bcfdf338244b 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -21,6 +21,7 @@ #define READ_TO_MS 1000 #define READ_TO_EXPIRIES 100 #define POLLING_INTERVAL_MS 200 +#define THROTTLE_MAP_REQ_DEFAULT 1 /* memory management */ static struct kmem_cache *ufshpb_mctx_cache; @@ -741,6 +742,14 @@ static struct ufshpb_req *ufshpb_get_map_req(struct ufshpb_lu *hpb, struct ufshpb_req *map_req; struct bio *bio; + if (hpb->is_hcm && + hpb->num_inflight_map_req >= THROTTLE_MAP_REQ_DEFAULT) { + dev_info(&hpb->sdev_ufs_lu->sdev_dev, + "map_req throttle. inflight %d throttle %d", + hpb->num_inflight_map_req, THROTTLE_MAP_REQ_DEFAULT); + return NULL; + } + map_req = ufshpb_get_req(hpb, srgn->rgn_idx, REQ_OP_SCSI_IN, false); if (!map_req) return NULL; @@ -755,6 +764,7 @@ static struct ufshpb_req *ufshpb_get_map_req(struct ufshpb_lu *hpb, map_req->rb.srgn_idx = srgn->srgn_idx; map_req->rb.mctx = srgn->mctx; + hpb->num_inflight_map_req++; return map_req; } @@ -764,6 +774,7 @@ static void ufshpb_put_map_req(struct ufshpb_lu *hpb, { bio_put(map_req->bio); ufshpb_put_req(hpb, map_req); + hpb->num_inflight_map_req--; } static int ufshpb_clear_dirty_bitmap(struct ufshpb_lu *hpb, diff --git a/drivers/scsi/ufs/ufshpb.h b/drivers/scsi/ufs/ufshpb.h index 448062a94760..cfa0abac21db 100644 --- a/drivers/scsi/ufs/ufshpb.h +++ b/drivers/scsi/ufs/ufshpb.h @@ -217,6 +217,7 @@ struct ufshpb_lu { struct ufshpb_req *pre_req; int num_inflight_pre_req; int throttle_pre_req; + int num_inflight_map_req; struct list_head lh_pre_req_free; int cur_read_id; int pre_req_min_tr_len; -- 2.25.1