Skip to content

Commit

Permalink
scsi: ufs: core: Initialize hba->reserved_slot earlier
Browse files Browse the repository at this point in the history
Move the hba->reserved_slot and the host->can_queue assignments from
ufshcd_config_mcq() into ufshcd_alloc_mcq(). The advantages of this change
are as follows:

 - It becomes easier to verify that these two parameters are updated if
   hba->nutrs is updated.

 - It prevents unnecessary assignments to these two parameters. While
   ufshcd_config_mcq() is called during host reset, ufshcd_alloc_mcq() is
   not.

Cc: Can Guo <[email protected]>
Reviewed-by: Peter Wang <[email protected]>
Reviewed-by: Manivannan Sadhasivam <[email protected]>
Signed-off-by: Bart Van Assche <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Martin K. Petersen <[email protected]>
  • Loading branch information
bvanassche authored and martinkpetersen committed Jul 11, 2024
1 parent b53eb9a commit f4750af
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/ufs/core/ufshcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -8678,6 +8678,9 @@ static int ufshcd_alloc_mcq(struct ufs_hba *hba)
if (ret)
goto err;

hba->host->can_queue = hba->nutrs - UFSHCD_NUM_RESERVED;
hba->reserved_slot = hba->nutrs - UFSHCD_NUM_RESERVED;

return 0;
err:
hba->nutrs = old_nutrs;
Expand All @@ -8699,9 +8702,6 @@ static void ufshcd_config_mcq(struct ufs_hba *hba)
ufshcd_mcq_make_queues_operational(hba);
ufshcd_mcq_config_mac(hba, hba->nutrs);

hba->host->can_queue = hba->nutrs - UFSHCD_NUM_RESERVED;
hba->reserved_slot = hba->nutrs - UFSHCD_NUM_RESERVED;

ufshcd_mcq_enable(hba);
hba->mcq_enabled = true;

Expand Down

0 comments on commit f4750af

Please sign in to comment.