slim-msm: Synchronize SSR callbacks

Subsystem will restart within short timeframe.
Synchronise subsytem up/down callback notifications
to avoid functionality failures.
Use mutex locks to achieve synchronization.

CAF-Change-Id: I5881c7d468507bb8402a2e9f8178b9c31e57e8a5
Signed-off-by: Dilip Kota <dkota@codeaurora.org>
CVE-2016-10291
[haggertk]: Backport to 3.4/msm8974

Change-Id: Ib513590dc749addf45ae96779035501f2d5f8d83
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
This commit is contained in:
Dilip Kota 2016-03-21 11:28:51 +05:30 committed by Francescodario Cuzzocrea
parent 550de6c095
commit 07824583d3
2 changed files with 7 additions and 1 deletions

View File

@ -1293,11 +1293,13 @@ static void ngd_adsp_down(struct work_struct *work)
struct slim_controller *ctrl = &dev->ctrl;
struct slim_device *sbdev;
mutex_lock(&dev->ssr_lock);
ngd_slim_enable(dev, false);
/* device up should be called again after SSR */
list_for_each_entry(sbdev, &ctrl->devs, dev_list)
slim_report_absent(sbdev);
SLIM_INFO(dev, "SLIM ADSP SSR (DOWN) done\n");
mutex_unlock(&dev->ssr_lock);
}
static void ngd_adsp_up(struct work_struct *work)
@ -1306,7 +1308,9 @@ static void ngd_adsp_up(struct work_struct *work)
container_of(work, struct msm_slim_qmi, ssr_up);
struct msm_slim_ctrl *dev =
container_of(qmi, struct msm_slim_ctrl, qmi);
mutex_lock(&dev->ssr_lock);
ngd_slim_enable(dev, true);
mutex_unlock(&dev->ssr_lock);
}
static ssize_t show_mask(struct device *device, struct device_attribute *attr,
@ -1459,6 +1463,7 @@ static int __devinit ngd_slim_probe(struct platform_device *pdev)
init_completion(&dev->reconf);
init_completion(&dev->ctrl_up);
mutex_init(&dev->tx_lock);
mutex_init(&dev->ssr_lock);
mutex_init(&dev->tx_buf_lock);
spin_lock_init(&dev->rx_lock);
dev->ee = 1;

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-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
@ -255,6 +255,7 @@ struct msm_slim_ctrl {
struct clk *rclk;
struct clk *hclk;
struct mutex tx_lock;
struct mutex ssr_lock;
struct mutex tx_buf_lock;
u8 pgdla;
enum msm_slim_msgq use_rx_msgqs;