From 94ca15ec921852eef91af21830de74a31ce8ec5e Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 5 Nov 2021 13:30:52 -0700 Subject: [PATCH] BACKPORT: FROMLIST: scsi: ufs: Limit the queue depth to host->can_queue Before reducing 'can_queue' from 32 to 31, make ufshcd_change_queue_depth() restrict the queue depth to 'can_queue' instead of hba->nutrs (32). This is a backport of a subset of the following patch: "[PATCH 2/2] scsi: ufs: Fix a deadlock in the error handler". Bug: 205080886 Link: https://lore.kernel.org/linux-scsi/20211103000529.1549411-3-bvanassche@acm.org/ Change-Id: I6e694a9698f91293fc2987217e3f939726c397dd Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index cede7163b8d8..7f48823dd38a 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4904,11 +4904,7 @@ static int ufshcd_slave_alloc(struct scsi_device *sdev) */ static int ufshcd_change_queue_depth(struct scsi_device *sdev, int depth) { - struct ufs_hba *hba = shost_priv(sdev->host); - - if (depth > hba->nutrs) - depth = hba->nutrs; - return scsi_change_queue_depth(sdev, depth); + return scsi_change_queue_depth(sdev, min(depth, sdev->host->can_queue)); } static void ufshcd_hpb_destroy(struct ufs_hba *hba, struct scsi_device *sdev)