Skip to content

Commit 839a74b

Browse files
avri-altman-sndkmartinkpetersen
authored andcommitted
scsi: ufs: Fix toggling of clk_gating.state when clock gating is not allowed
This commit addresses an issue where clk_gating.state is being toggled in ufshcd_setup_clocks() even if clock gating is not allowed. The fix is to add a check for hba->clk_gating.is_initialized before toggling clk_gating.state in ufshcd_setup_clocks(). Since clk_gating.lock is now initialized unconditionally, it can no longer lead to the spinlock being used before it is properly initialized, but instead it is mostly for documentation purposes. Fixes: 1ab27c9 ("ufs: Add support for clock gating") Reported-by: Geert Uytterhoeven <[email protected]> Tested-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Avri Altman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 3d4114a commit 839a74b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/ufs/core/ufshcd.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -9140,7 +9140,7 @@ static int ufshcd_setup_clocks(struct ufs_hba *hba, bool on)
91409140
if (!IS_ERR_OR_NULL(clki->clk) && clki->enabled)
91419141
clk_disable_unprepare(clki->clk);
91429142
}
9143-
} else if (!ret && on) {
9143+
} else if (!ret && on && hba->clk_gating.is_initialized) {
91449144
scoped_guard(spinlock_irqsave, &hba->clk_gating.lock)
91459145
hba->clk_gating.state = CLKS_ON;
91469146
trace_ufshcd_clk_gating(dev_name(hba->dev),

0 commit comments

Comments
 (0)