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

Commit b76f4279 authored by Vijay Viswanath's avatar Vijay Viswanath Committed by Ram Prakash Gupta
Browse files

mmc: host: Add device_prepare pm for mmc_host



mmc_host is a virtual device and it doesn't have any pm ops and so during
pm registration of device, no_pm_callback gets set as true. The
mmc_host device is not runtime enabled as it is a virtual device and
mmc_host is the parent device of mmc_card. As the mmc_host is runtime
disabled, mmc_card can runtime suspend/resume without depending on
state of mmc_host during normal operations. During system suspend, the
direct_complete flag of mmc_host device gets set as it has no pm_ops.
When mmc_card successfully suspends, it clears the direct_complete flag
of its parent (mmc_host).

But in certain cases during dpm_suspend, an async error can occur after
suspend work for mmc_card is scheduled and before it gets executed. In
that case, mmc_card suspend work will not clear the direct_complete flag
of mmc_host. When mmc_host suspend comes after that of mmc_card,
it too will skip all actions.

But by this time, the mmc_host device has been added to device_suspended
list. So during resume, mmc_host resume will do dpm resume of mmc_host.
In dpm_resume, all devices which has direct_complete flag set will be
runtime_enabled. This is because, in dpm_suspend, any device with
direct_complete flag will be runtime_disabled. Thus, mmc_host which has
direct_complete flag set, will get runtime enabled during dpm_resume.
This is a problem in pm framework with direct_complete flag
(runtime enabling a device in resume when it was not runtime disabled
in suspend path).

Now that mmc_host device is runtime enabled, to runtime resume the
mmc_card, the pm framework will try to runtime resume the mmc_host
device as well and will fail. This prevents mmc_card from runtime
resuming after a runtime_suspend.

Fix this by adding a dummy suspend_prepare() fn for mmc_host. This
prevents the direct_complete flag of mmc_host device from getting set.

Change-Id: Ib739399027958d17e418e0240684b0b517a02941
Signed-off-by: default avatarVijay Viswanath <vviswana@codeaurora.org>
Signed-off-by: default avatarRam Prakash Gupta <rampraka@codeaurora.org>
parent aae6a63f
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -47,9 +47,28 @@ static void mmc_host_classdev_release(struct device *dev)
	kfree(host);
}

static int mmc_host_prepare(struct device *dev)
{
	/*
	 * Since mmc_host is a virtual device, we don't have to do anything.
	 * If we return a positive value, the pm framework will consider that
	 * the runtime suspend and system suspend of this device is same and
	 * will set direct_complete flag as true. We don't want this as the
	 * mmc_host always has positive disable_depth and setting the flag
	 * will not speed up the suspend process.
	 * So return 0.
	 */
	return 0;
}

static const struct dev_pm_ops mmc_pm_ops = {
	.prepare = mmc_host_prepare,
};

static struct class mmc_host_class = {
	.name		= "mmc_host",
	.dev_release	= mmc_host_classdev_release,
	.pm		= &mmc_pm_ops,
};

int mmc_register_host_class(void)