Skip to content

Commit

Permalink
scsi: ufs: ufshpb: Limit the number of in-flight map requests
Browse files Browse the repository at this point in the history
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 in-flight map requests.

Link: https://lore.kernel.org/r/20210712095039.8093-10-avri.altman@wdc.com
Reviewed-by: Daejun Park <daejun7.park@samsung.com>
Signed-off-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Avri Altman authored and Martin K. Petersen committed Aug 1, 2021
1 parent 13c044e commit 33845a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/scsi/ufs/ufshpb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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_DRV_IN, false);
if (!map_req)
return NULL;
Expand All @@ -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;
}
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions drivers/scsi/ufs/ufshpb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 33845a2

Please sign in to comment.