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

Commit 2f8e6bcf authored by Sudheer Papothi's avatar Sudheer Papothi
Browse files

soundwire: Avoid runtime suspend after device path bringup



There is a possible race condition that runtime suspend is being
called after device path bringup. To avoid this race condition,
add a mutex lock during device path bringup to serialize runtime
suspend and resume.

CRs-Fixed: 967442
Change-Id: I268a25b05799c66fc019e19e46939286e54fb514
Signed-off-by: default avatarSudheer Papothi <spapothi@codeaurora.org>
parent ac263d37
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -1277,6 +1277,7 @@ static int swrm_remove(struct platform_device *pdev)
	pm_runtime_set_suspended(&pdev->dev);
	swr_unregister_master(&swrm->master);
	mutex_destroy(&swrm->mlock);
	mutex_destroy(&swrm->reslock);
	kfree(swrm);
	return 0;
}
@@ -1447,12 +1448,16 @@ int swrm_wcd_notify(struct platform_device *pdev, u32 id, void *data)
	case SWR_DEVICE_UP:
		dev_dbg(swrm->dev, "%s: swr master up called\n", __func__);
		mutex_lock(&swrm->mlock);
		mutex_lock(&swrm->reslock);
		if ((swrm->state == SWR_MSTR_RESUME) ||
		    (swrm->state == SWR_MSTR_UP)) {
			dev_dbg(swrm->dev, "%s: SWR master is already UP: %d\n",
				__func__, swrm->state);
		} else {
			pm_runtime_mark_last_busy(&pdev->dev);
			mutex_unlock(&swrm->reslock);
			pm_runtime_get_sync(&pdev->dev);
			mutex_lock(&swrm->reslock);
			list_for_each_entry(swr_dev, &mstr->devices, dev_list) {
				ret = swr_reset_device(swr_dev);
				if (ret) {
@@ -1465,6 +1470,7 @@ int swrm_wcd_notify(struct platform_device *pdev, u32 id, void *data)
			pm_runtime_mark_last_busy(&pdev->dev);
			pm_runtime_put_autosuspend(&pdev->dev);
		}
		mutex_unlock(&swrm->reslock);
		mutex_unlock(&swrm->mlock);
		break;
	case SWR_SET_NUM_RX_CH: