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: Praveen Kurapati <pkurapat@codeaurora.org>
This commit is contained in:
parent
e30ed885a2
commit
5e982dac99
@ -1,6 +1,6 @@
|
||||
// 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");
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* 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;
|
||||
|
Loading…
Reference in New Issue
Block a user