scsi: ufs: fix another race between clock scaling and gating

Commit 4f98a9564b745f3b0b1bea02d351c9f8f2f17d39 (scsi: ufs: fix race
between clock gating and scaling work) tried to fix the race condition
between clock gating and scaling work but it didn't fixed the race in
all possible states. This change fixes the race condition by making
sure that we hold the clock reference even if clocks are ON when we
entered into clock scaling work.

Change-Id: Ic3cf9224f5afb2900fe2553ce8c302cc8b20e623
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
This commit is contained in:
Subhash Jadavani 2015-04-21 17:19:03 -07:00 committed by David Keitel
parent 5d37480381
commit 30fd811fb7

View file

@ -8484,16 +8484,18 @@ static int ufshcd_devfreq_target(struct device *dev,
return 0; return 0;
} }
if (ufshcd_is_clkgating_allowed(hba) && if (ufshcd_is_clkgating_allowed(hba)) {
(hba->clk_gating.state != CLKS_ON)) { if (cancel_delayed_work(&hba->clk_gating.gate_work) ||
if (cancel_delayed_work(&hba->clk_gating.gate_work)) { (hba->clk_gating.state == CLKS_ON)) {
/* hold the vote until the scaling work is completed */ /* hold the vote until the scaling work is completed */
hba->clk_gating.active_reqs++; hba->clk_gating.active_reqs++;
release_clk_hold = true; release_clk_hold = true;
hba->clk_gating.state = CLKS_ON; if (hba->clk_gating.state != CLKS_ON) {
trace_ufshcd_clk_gating(dev_name(hba->dev), hba->clk_gating.state = CLKS_ON;
ufschd_clk_gating_state_to_string( trace_ufshcd_clk_gating(dev_name(hba->dev),
hba->clk_gating.state)); ufschd_clk_gating_state_to_string(
hba->clk_gating.state));
}
} else { } else {
/* /*
* Clock gating work seems to be running in parallel * Clock gating work seems to be running in parallel