Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: ufs: core: Rework ufshcd_mcq_compl_pending_transfer()

Replace a tag loop with blk_mq_tagset_busy_iter(). This patch prepares
for removing the hba->lrb[] array.

Reviewed-by: Avri Altman <avri.altman@sandisk.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20251031204029.2883185-16-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
63a5b959 f59568f4

+46 -34
+46 -34
drivers/ufs/core/ufshcd.c
··· 5725 5725 return completed_reqs != 0; 5726 5726 } 5727 5727 5728 + static bool ufshcd_mcq_force_compl_one(struct request *rq, void *priv) 5729 + { 5730 + struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq); 5731 + struct scsi_device *sdev = rq->q->queuedata; 5732 + struct Scsi_Host *shost = sdev->host; 5733 + struct ufs_hba *hba = shost_priv(shost); 5734 + struct ufshcd_lrb *lrbp = &hba->lrb[rq->tag]; 5735 + struct ufs_hw_queue *hwq = ufshcd_mcq_req_to_hwq(hba, rq); 5736 + 5737 + if (!hwq) 5738 + return true; 5739 + 5740 + ufshcd_mcq_compl_all_cqes_lock(hba, hwq); 5741 + 5742 + /* 5743 + * For those cmds of which the cqes are not present in the cq, complete 5744 + * them explicitly. 5745 + */ 5746 + scoped_guard(spinlock_irqsave, &hwq->cq_lock) { 5747 + if (!test_bit(SCMD_STATE_COMPLETE, &cmd->state)) { 5748 + set_host_byte(cmd, DID_REQUEUE); 5749 + ufshcd_release_scsi_cmd(hba, lrbp); 5750 + scsi_done(cmd); 5751 + } 5752 + } 5753 + 5754 + return true; 5755 + } 5756 + 5757 + static bool ufshcd_mcq_compl_one(struct request *rq, void *priv) 5758 + { 5759 + struct scsi_device *sdev = rq->q->queuedata; 5760 + struct Scsi_Host *shost = sdev->host; 5761 + struct ufs_hba *hba = shost_priv(shost); 5762 + struct ufs_hw_queue *hwq = ufshcd_mcq_req_to_hwq(hba, rq); 5763 + 5764 + if (hwq) 5765 + ufshcd_mcq_poll_cqe_lock(hba, hwq); 5766 + 5767 + return true; 5768 + } 5769 + 5728 5770 /** 5729 5771 * ufshcd_mcq_compl_pending_transfer - MCQ mode function. It is 5730 5772 * invoked from the error handler context or ufshcd_host_reset_and_restore() ··· 5781 5739 static void ufshcd_mcq_compl_pending_transfer(struct ufs_hba *hba, 5782 5740 bool force_compl) 5783 5741 { 5784 - struct ufs_hw_queue *hwq; 5785 - struct ufshcd_lrb *lrbp; 5786 - struct scsi_cmnd *cmd; 5787 - unsigned long flags; 5788 - int tag; 5789 - 5790 - for (tag = 0; tag < hba->nutrs; tag++) { 5791 - lrbp = &hba->lrb[tag]; 5792 - cmd = lrbp->cmd; 5793 - if (!ufshcd_cmd_inflight(cmd) || 5794 - test_bit(SCMD_STATE_COMPLETE, &cmd->state)) 5795 - continue; 5796 - 5797 - hwq = ufshcd_mcq_req_to_hwq(hba, scsi_cmd_to_rq(cmd)); 5798 - if (!hwq) 5799 - continue; 5800 - 5801 - if (force_compl) { 5802 - ufshcd_mcq_compl_all_cqes_lock(hba, hwq); 5803 - /* 5804 - * For those cmds of which the cqes are not present 5805 - * in the cq, complete them explicitly. 5806 - */ 5807 - spin_lock_irqsave(&hwq->cq_lock, flags); 5808 - if (cmd && !test_bit(SCMD_STATE_COMPLETE, &cmd->state)) { 5809 - set_host_byte(cmd, DID_REQUEUE); 5810 - ufshcd_release_scsi_cmd(hba, lrbp); 5811 - scsi_done(cmd); 5812 - } 5813 - spin_unlock_irqrestore(&hwq->cq_lock, flags); 5814 - } else { 5815 - ufshcd_mcq_poll_cqe_lock(hba, hwq); 5816 - } 5817 - } 5742 + blk_mq_tagset_busy_iter(&hba->host->tag_set, 5743 + force_compl ? ufshcd_mcq_force_compl_one : 5744 + ufshcd_mcq_compl_one, 5745 + NULL); 5818 5746 } 5819 5747 5820 5748 /**