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

Commit 5e982dac authored by Praveen Kurapati's avatar Praveen Kurapati
Browse files

msm: ipa4: Fix race condition in adpl pipe open



Observing race condition during odl pipe open
simultaneously. Add changes to protect the scenario
with mutex lock.

Change-Id: Ib79df57fe871ed8ce8ce480589a93235d030cba0
Signed-off-by: default avatarPraveen Kurapati <pkurapat@codeaurora.org>
parent e30ed885
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
 */

#include "ipa_i.h"
@@ -418,6 +418,7 @@ static int ipa_adpl_open(struct inode *inode, struct file *filp)
	int ret = 0;

	IPADBG("Called the function :\n");
	mutex_lock(&ipa3_odl_ctx->pipe_lock);
	if (ipa3_odl_ctx->odl_state.odl_init &&
				!ipa3_odl_ctx->odl_state.adpl_open) {
		/* Activate ipa_pm*/
@@ -431,6 +432,7 @@ static int ipa_adpl_open(struct inode *inode, struct file *filp)
		print_ipa_odl_state_bit_mask();
		ret = -ENODEV;
	}
	mutex_unlock(&ipa3_odl_ctx->pipe_lock);

	return ret;
}
@@ -439,6 +441,7 @@ static int ipa_adpl_release(struct inode *inode, struct file *filp)
{
	int ret = 0;
	/* Deactivate ipa_pm */
	mutex_lock(&ipa3_odl_ctx->pipe_lock);
	ret = ipa_pm_deactivate_sync(ipa3_odl_ctx->odl_pm_hdl);
	if (ret)
		IPAERR("failed to activate pm\n");
@@ -451,6 +454,7 @@ static int ipa_adpl_release(struct inode *inode, struct file *filp)
			IPAERR("mpm failed to disable ADPL over ODL\n");

	}
	mutex_unlock(&ipa3_odl_ctx->pipe_lock);

	return ret;
}
@@ -667,6 +671,7 @@ int ipa_odl_init(void)
	odl_cdev = ipa3_odl_ctx->odl_cdev;
	INIT_LIST_HEAD(&ipa3_odl_ctx->adpl_msg_list);
	mutex_init(&ipa3_odl_ctx->adpl_msg_lock);
	mutex_init(&ipa3_odl_ctx->pipe_lock);

	odl_cdev[loop].class = class_create(THIS_MODULE, "ipa_adpl");

+2 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
 */

#ifndef _IPA3_ODL_H_
@@ -51,6 +51,7 @@ struct ipa_odl_context {
	struct ipa3_odl_char_device_context odl_cdev[2];
	struct list_head adpl_msg_list;
	struct mutex adpl_msg_lock;
	struct mutex pipe_lock;
	struct ipa_sys_connect_params odl_sys_param;
	u32 odl_client_hdl;
	struct odl_state_bit_mask odl_state;