Reserved tags are numerically lower than non-reserved tags. Compensate the change caused by reserving tags by subtracting the number of reserved tags from the tag number assigned by the block layer. Cc: Yaniv Gardi <ygardi@xxxxxxxxxxxxxx> Cc: Subhash Jadavani <subhashj@xxxxxxxxxxxxxx> Cc: Stanley Chu <stanley.chu@xxxxxxxxxxxx> Cc: Avri Altman <avri.altman@xxxxxxx> Cc: Tomas Winkler <tomas.winkler@xxxxxxxxx> Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx> --- drivers/scsi/ufs/ufshcd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 9fc05a535624..3e3c6257a343 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2402,7 +2402,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) hba = shost_priv(host); - tag = cmd->request->tag; + tag = cmd->request->tag - hba->nutmrs; if (!ufshcd_valid_tag(hba, tag)) { dev_err(hba->dev, "%s: invalid command tag %d: cmd=0x%p, cmd->request=0x%p", @@ -5965,7 +5965,8 @@ static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd) host = cmd->device->host; hba = shost_priv(host); - tag = cmd->request->tag; + tag = cmd->request->tag - hba->nutmrs; + WARN_ON_ONCE(!ufshcd_valid_tag(hba, tag)); lrbp = &hba->lrb[tag]; err = ufshcd_issue_tm_cmd(hba, lrbp->lun, 0, UFS_LOGICAL_RESET, &resp); @@ -6036,7 +6037,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) host = cmd->device->host; hba = shost_priv(host); - tag = cmd->request->tag; + tag = cmd->request->tag - hba->nutmrs; lrbp = &hba->lrb[tag]; if (!ufshcd_valid_tag(hba, tag)) { dev_err(hba->dev, @@ -8320,7 +8321,8 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) /* Configure LRB */ ufshcd_host_memory_configure(hba); - host->can_queue = hba->nutrs; + host->can_queue = hba->nutrs + hba->nutmrs; + host->reserved_tags = hba->nutmrs; host->cmd_per_lun = hba->nutrs; host->max_id = UFSHCD_MAX_ID; host->max_lun = UFS_MAX_LUNS; -- 2.24.0.rc1.363.gb1bccd3e3d-goog