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

Commit 8302b80f authored by jianzhou's avatar jianzhou
Browse files

Revert "scsi: ufs: fix race between clock gating and devfreq


scaling work"

This reverts commit 99a3bd3d.

Change-Id: Ie22b22435368989778e2a3391eff8085acbcb30c
Signed-off-by: default avatarjianzhou <jianzhou@codeaurora.org>
parent 6328e647
Loading
Loading
Loading
Loading
+0 −32
Original line number Diff line number Diff line
@@ -6716,47 +6716,15 @@ static int ufshcd_devfreq_target(struct device *dev,
{
	int err = 0;
	struct ufs_hba *hba = dev_get_drvdata(dev);
	bool release_clk_hold = false;
	unsigned long irq_flags;

	if (!ufshcd_is_clkscaling_enabled(hba))
		return -EINVAL;

	spin_lock_irqsave(hba->host->host_lock, irq_flags);
	if (ufshcd_eh_in_progress(hba)) {
		spin_unlock_irqrestore(hba->host->host_lock, irq_flags);
		return 0;
	}

	if (ufshcd_is_clkgating_allowed(hba) &&
	    (hba->clk_gating.state != CLKS_ON)) {
		if (cancel_delayed_work(&hba->clk_gating.gate_work)) {
			/* hold the vote until the scaling work is completed */
			hba->clk_gating.active_reqs++;
			release_clk_hold = true;
			hba->clk_gating.state = CLKS_ON;
		} else {
			/*
			 * Clock gating work seems to be running in parallel
			 * hence skip scaling work to avoid deadlock between
			 * current scaling work and gating work.
			 */
			spin_unlock_irqrestore(hba->host->host_lock, irq_flags);
			return 0;
		}
	}
	spin_unlock_irqrestore(hba->host->host_lock, irq_flags);

	if (*freq == UINT_MAX)
		err = ufshcd_scale_clks(hba, true);
	else if (*freq == 0)
		err = ufshcd_scale_clks(hba, false);

	spin_lock_irqsave(hba->host->host_lock, irq_flags);
	if (release_clk_hold)
		__ufshcd_release(hba);
	spin_unlock_irqrestore(hba->host->host_lock, irq_flags);

	return err;
}