Re: [PATCH] scsi: ufs: core: Fix double completion in ufshcd_clear_lu_cmds()
From: Bart Van Assche
Date: Fri Oct 16 2026 - 14:13:37 EST
On 10/16/26 1:54 AM, Stanley Jhu wrote:
+ spin_lock_irqsave(&hba->outstanding_lock, flags);The above code is identical to a code block in ufshcd_abort().
+ outstanding = __test_and_clear_bit(tag, &hba->outstanding_reqs);
+ spin_unlock_irqrestore(&hba->outstanding_lock, flags);
+
+ if (outstanding)
+ ufshcd_compl_one_cqe(hba, tag, NULL);
Additionally, a more generic version of this code is present in
ufshcd_poll(). Maybe this is a good time to move the code below into
a new helper function such that code duplication is avoided?
spin_lock_irqsave(&hba->outstanding_lock, flags);
tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);
completed_reqs = ~tr_doorbell & hba->outstanding_reqs;
WARN_ONCE(completed_reqs & ~hba->outstanding_reqs,
"completed: %#lx; outstanding: %#lx\n", completed_reqs,
hba->outstanding_reqs);
if (queue_num == UFSHCD_POLL_FROM_INTERRUPT_CONTEXT) {
/* Do not complete polled requests from interrupt context. */
ufshcd_clear_polled(hba, &completed_reqs);
}
hba->outstanding_reqs &= ~completed_reqs;
spin_unlock_irqrestore(&hba->outstanding_lock, flags);
Thanks,
Bart.