Revert "Revert "KMI: BACKPORT: FROMGIT: scsi: ufs: Optimize host lock on transfer requests send/compl paths""

This reverts commit 850f11aa85.

We need to go back upstream version with right fix.

Bug: 192095860
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: I26bf924125f06e97c1262578c99a2dbb58394235
This commit is contained in:
Jaegeuk Kim
2021-06-28 00:05:01 -07:00
parent 8d2e1c8a3e
commit 3b3bec8866
2 changed files with 11 additions and 6 deletions

View File

@@ -2665,7 +2665,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
(hba->clk_gating.state != CLKS_ON));
lrbp = &hba->lrb[tag];
if (unlikely(test_bit(tag, &hba->outstanding_reqs))) {
if (unlikely(lrbp->in_use)) {
if (hba->pm_op_in_progress)
set_host_byte(cmd, DID_BAD_TARGET);
else
@@ -2925,7 +2925,7 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba,
init_completion(&wait);
lrbp = &hba->lrb[tag];
if (unlikely(test_bit(tag, &hba->outstanding_reqs))) {
if (unlikely(lrbp->in_use)) {
err = -EBUSY;
goto out;
}
@@ -5134,9 +5134,8 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba,
bool update_scaling = false;
for_each_set_bit(index, &completed_reqs, hba->nutrs) {
if (!test_and_clear_bit(index, &hba->outstanding_reqs))
continue;
lrbp = &hba->lrb[index];
lrbp->in_use = false;
lrbp->compl_time_stamp = ktime_get();
cmd = lrbp->cmd;
if (cmd) {
@@ -5168,6 +5167,9 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba,
hba->clk_scaling.active_reqs--;
}
/* clear corresponding bits of completed commands */
hba->outstanding_reqs ^= completed_reqs;
ufshcd_clk_scaling_update_busy(hba);
}
@@ -6601,11 +6603,11 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba,
WARN_ON_ONCE(!ufshcd_valid_tag(hba, tag));
init_completion(&wait);
if (unlikely(test_bit(tag, &hba->outstanding_reqs))) {
lrbp = &hba->lrb[tag];
if (unlikely(lrbp->in_use)) {
err = -EBUSY;
goto out;
}
lrbp = &hba->lrb[tag];
WARN_ON(lrbp->cmd);
lrbp->cmd = NULL;
@@ -6974,6 +6976,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
if (lrbp->cmd) {
__ufshcd_transfer_req_compl(hba, (1UL << tag));
__set_bit(tag, &hba->outstanding_reqs);
lrbp->in_use = true;
hba->force_reset = true;
ufshcd_schedule_eh_work(hba);
}

View File

@@ -188,6 +188,7 @@ struct ufs_pm_lvl_states {
* @crypto_key_slot: the key slot to use for inline crypto (-1 if none)
* @data_unit_num: the data unit number for the first block for inline crypto
* @req_abort_skip: skip request abort task flag
* @in_use: indicates that this lrb is still in use
*/
struct ufshcd_lrb {
struct utp_transfer_req_desc *utr_descriptor_ptr;
@@ -217,6 +218,7 @@ struct ufshcd_lrb {
#endif
bool req_abort_skip;
bool in_use;
};
/**