crypto: msm: Add mutex in qce_open and qce_close

Add mutex in qce_open and qce_close to prevent the situation where
iounmap was called by one thread while another one is accessing the
HW CE register with another ioremap.

Change-Id: Iba47834a950a213d8c2b982b3a988020a2ef3338
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
This commit is contained in:
Zhen Kong 2014-12-02 14:25:04 -08:00
parent e22a9bf63e
commit cdb95811f0
1 changed files with 7 additions and 2 deletions

View File

@ -45,6 +45,8 @@
#define CE_CLK_DIV 1000000
static DEFINE_MUTEX(bam_register_lock);
static DEFINE_MUTEX(qce_iomap_mutex);
struct bam_registration_info {
struct list_head qlist;
unsigned long handle;
@ -5398,6 +5400,7 @@ void *qce_open(struct platform_device *pdev, int *rc)
}
pce_dev->pdev = &pdev->dev;
mutex_lock(&qce_iomap_mutex);
if (pdev->dev.of_node) {
*rc = __qce_get_device_tree_data(pdev, pce_dev);
if (*rc)
@ -5437,7 +5440,7 @@ void *qce_open(struct platform_device *pdev, int *rc)
goto err;
qce_setup_ce_sps_data(pce_dev);
qce_disable_clk(pce_dev);
mutex_unlock(&qce_iomap_mutex);
return pce_dev;
err:
qce_disable_clk(pce_dev);
@ -5453,6 +5456,7 @@ err_iobase:
if (pce_dev->iobase)
iounmap(pce_dev->iobase);
err_pce_dev:
mutex_unlock(&qce_iomap_mutex);
kfree(pce_dev);
return NULL;
}
@ -5466,6 +5470,7 @@ int qce_close(void *handle)
if (handle == NULL)
return -ENODEV;
mutex_lock(&qce_iomap_mutex);
qce_enable_clk(pce_dev);
qce_sps_exit(pce_dev);
@ -5477,7 +5482,7 @@ int qce_close(void *handle)
qce_disable_clk(pce_dev);
__qce_deinit_clk(pce_dev);
mutex_unlock(&qce_iomap_mutex);
kfree(handle);
return 0;