Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f0e7e5ba authored by Ziqi Chen's avatar Ziqi Chen
Browse files

scsi: ufs: Avoid potential lrb race caused by early release of lrb_in_use



There are still operations of lrbp after clearing lrb_in_use in
__ufshcd_transfer_req_compl. It may mess up the next task which takes
this lrbp in some corner cases. Hold lrb_in_use till all operations of
lrbp finished to avoid this potential race issue.

Change-Id: I4470d3596b7fedda0e791f35b22b1ca9864bbbfc
Signed-off-by: default avatarZiqi Chen <ziqichen@codeaurora.org>
parent 82e0a0f5
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -6499,7 +6499,6 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba,
			result = ufshcd_transfer_rsp_status(hba, lrbp);
			scsi_dma_unmap(cmd);
			cmd->result = result;
			clear_bit_unlock(index, &hba->lrb_in_use);
			lrbp->compl_time_stamp = ktime_get();
			update_req_stats(hba, lrbp);
			/* Mark completed command as NULL in LRB */
@@ -6519,6 +6518,8 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba,
					lrbp, cmd->request);
			}

			clear_bit_unlock(index, &hba->lrb_in_use);

			/* Do not touch lrbp after scsi done */
			cmd->scsi_done(cmd);
		} else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE ||
@@ -6569,7 +6570,6 @@ void ufshcd_abort_outstanding_transfer_requests(struct ufs_hba *hba, int result)
			/* Clear pending transfer requests */
			ufshcd_clear_cmd(hba, index);
			ufshcd_outstanding_req_clear(hba, index);
			clear_bit_unlock(index, &hba->lrb_in_use);
			lrbp->compl_time_stamp = ktime_get();
			update_req_stats(hba, lrbp);
			/* Mark completed command as NULL in LRB */
@@ -6586,6 +6586,7 @@ void ufshcd_abort_outstanding_transfer_requests(struct ufs_hba *hba, int result)
				ufshcd_vops_crypto_engine_cfg_end(hba,
						lrbp, cmd->request);
			}
			clear_bit_unlock(index, &hba->lrb_in_use);
			/* Do not touch lrbp after scsi done */
			cmd->scsi_done(cmd);
		} else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE) {