Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2867129pxv; Mon, 12 Jul 2021 03:59:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWDuj+zMZmnGo4ApiezsCVA6IpgXzMy5GxH61QH6Jj6gMavOgq7QThiNHCMvcJnOa6p5PO X-Received: by 2002:a05:6638:3181:: with SMTP id z1mr6192548jak.100.1626087569412; Mon, 12 Jul 2021 03:59:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626087569; cv=none; d=google.com; s=arc-20160816; b=d+01J8w/t3HJqD4AOTRKYDIqrYJ1kuAagBbNjrbab0BlkWK9Esy2XA43FLcbLY4nHM QRA9eZrQe6IFN8gnOwhmZGADmP0DdT1kbunFhNQG0v53jcy3LvPJEZ4hLFwzk9ODfsDG +OTcteMiPYEf9LH6EgLCvo4rc8YUeN5fs4zJ4kkk7vBBG61L9bvx3t6MXGlZk5EAC+y+ HONZN5rSyj5NR69OJl5mgqJckzgCfC17Y+krUtQrjwWYUB6OtfRKpEs3Za/0lSpD9vty clWxM5rVKOBrFZ9eckXuoWG6W1UD55QSpw9UyodpoYwXR19wNmzjFBBl7iiCge5o7DSm k6eQ== 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=GuSuSBg1ue9mb5+mRcLwZv3gPpXsDd4uKAS4HX01FZg=; b=q9zzogzx6ATrobOttlK2PxTMyyPbzy6CT52vpgtrI0Ni7eOaKHuVed+e7GfoTOJdZQ JiuX0cPtQv5BCNrLCEGKkwPRPiq3oM/DReSlEHvDW9YDakhTVxd5d5lgBxO0yrLj6afV NcAWrG5K8Agqa9jq8TBWzsyC9B52Td/9lGdXAbyZs2FA+jitRmSy7gC4qpusjfGE33uF Qm7+ZrCAM8kriyltS3ROy9L9neN/iSA3S/3fRtmsEViuNGc2MbEWYsWAynFoxzy2NKJA djxipEH/BlMauENaV1y3xSkF6WeVQhL2bv1aFwPFzA0NF0L9xTvgEpr7Dmn2EBLwJ5sG kF8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=Og0hydJA; 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 a4si19280711ilj.44.2021.07.12.03.59.17; Mon, 12 Jul 2021 03:59:29 -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=Og0hydJA; 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 S241704AbhGLJzT (ORCPT + 99 others); Mon, 12 Jul 2021 05:55:19 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:33186 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237071AbhGLJzM (ORCPT ); Mon, 12 Jul 2021 05:55:12 -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=1626083545; x=1657619545; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jObncAsp+JMdQEIeZYaXSS1wRDtUP2PUPeJ34o4VIXc=; b=Og0hydJA+GYbrkIzn84agZ6wjWsemlZydLq7aO19TGy0C87wpNPN6Ivq zC1RLtt/y3QOMg3EPr5TVZGuQ31LQBwCoHRLs493YjlcbGmcZms1ngXS/ H109u98xclD5ToPUIz6QN/r/yuxqzSWkQ8mOGbpBZKbwDC/pM8rk18CNg Qc3ASXT9q5pwN7yRIZp8k9jJ3RuN+j3bKg648gEspMFsD+TTi+OcovKBM apNXIpdBfTfssDoeMgjuuAJUQ4MXsGFX5IOrt4Zrmd+KYargOfANPYR9q 9jkpoXbvnSaBiFAP747CLTkayj3MlvJTmt/qpJes3kVbgOnQBR3RxG6I8 Q==; IronPort-SDR: p7zr5Zd1XTwGvqH0hUKgYKtDidPC/fK2MazwRLDLSKemMGqe/VJIRwnLGemasRgQSiUWVUuT0O KvrNrt7wBvP/6Q29cT2Zw2rW6yTPHIGeJLkC74qjRoNqdM3rAtGgBI4ZMg21PrSLFkemaH6Jer o+cQQYpTr4Cdld1u1XR0FRv0PHvQMa+w7E1/oy9IJ1SnUK+ixlKL+q2dlViZ82eaIunlycRMCe gZcI8NBAz9gpyT9+ksf0hSDcA9GC90mQQnMSmzExnRdHjXo+Ixh1SZRGBXwRcy7bC7RI6Xv5qu 50A= X-IronPort-AV: E=Sophos;i="5.84,232,1620662400"; d="scan'208";a="278155980" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 12 Jul 2021 17:52:23 +0800 IronPort-SDR: PvGWsHkSrNFCzslH2B9CFpxQOFQvjLa2QbKsF5GP8GOu7Yx2nof5MCtUOVCitQDBbIh842k2b5 CM2QADRgJVBvTO6Qwm3oMtNVwt7yoTu97MmNExKhZ55HYUO1AZRCf8MCJIbxGpivjtX1x+/iPH mjCO5CyBgy21N0k6DHqlnXmJJ6EM4112tAhv5qtlTOdtUPb8WJFcMW8vn1VY6pcFNPglvGvrMl yiVd1kc6AZW0gh0o/MPxiYKGEXG0a9LxY3YncmPT8tztttdhmiXKOsrzJUTwDCQ6vzo1buKXjv sZTMLFcgMb4kNW4xZDFqrUJK Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2021 02:29:07 -0700 IronPort-SDR: HS/Szc3ouw9r3j2JN40ob0pHNQid2sPOnbLcf35TmP/vOrBMoVmkMy/FMsFelS6q6NbOmA71BP 4E75Xv6W83xfV1yg8dwM2lAceQt6rKDW7xlNRN2zKH/f5SXaM4cvunrsRBDkW7YsZ7LtVy+NYE caygD7LbvmfmHoNt1P9d8EDAsnO/9XFMkphB+z31DNm4UhkuS3kDx+B/sdJujBSYhf2Vw7OS5a KVkzR1o4HiLmm2ksLTm7iz/rAN9JLzNYfE5uA5mrHC/ZJP5ncIrfeYTM4dDgWC1tdKtcZgzWqS cBY= WDCIronportException: Internal Received: from bxygm33.sdcorp.global.sandisk.com ([10.0.231.247]) by uls-op-cesaip02.wdc.com with ESMTP; 12 Jul 2021 02:52:18 -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 v12 09/12] scsi: ufshpb: Limit the number of inflight map requests Date: Mon, 12 Jul 2021 12:50:36 +0300 Message-Id: <20210712095039.8093-10-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210712095039.8093-1-avri.altman@wdc.com> References: <20210712095039.8093-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 4138f081d1dc..472633052af1 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; @@ -742,6 +743,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; @@ -756,6 +765,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; } @@ -765,6 +775,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 8309b59c7819..edf565e9036f 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