media_clock: change the spinlock into the mutexlock to avoid crash.

PD#150369: change the spinlock into the mutexlock to avoid crash.

Change-Id: I96528c1e496d0bc4ff984036a5d36b373732c932
Signed-off-by: Nanxin Qin <nanxin.qin@amlogic.com>
This commit is contained in:
Nanxin Qin
2017-09-04 23:16:51 +08:00
committed by Dongjin Kim
parent 8f480325ae
commit db869884eb
3 changed files with 17 additions and 29 deletions

View File

@@ -495,14 +495,12 @@ static int hcodec_clock_set(int clk)
static void vdec_clock_on(void)
{
spin_lock_irqsave(&gclk.vdec_mux_node->lock,
gclk.vdec_mux_node->flags);
mutex_lock(&gclk.vdec_mux_node->mutex);
if (!gclk.vdec_mux_node->ref_count)
clk_prepare_enable(gclk.vdec_mux_node->clk);
gclk.vdec_mux_node->ref_count++;
spin_unlock_irqrestore(&gclk.vdec_mux_node->lock,
gclk.vdec_mux_node->flags);
mutex_unlock(&gclk.vdec_mux_node->mutex);
pr_info("the %-15s clock on, ref cnt: %d\n",
gclk.vdec_mux_node->name,
@@ -511,15 +509,13 @@ static void vdec_clock_on(void)
static void vdec_clock_off(void)
{
spin_lock_irqsave(&gclk.vdec_mux_node->lock,
gclk.vdec_mux_node->flags);
mutex_lock(&gclk.vdec_mux_node->mutex);
gclk.vdec_mux_node->ref_count--;
if (!gclk.vdec_mux_node->ref_count)
clk_disable_unprepare(gclk.vdec_mux_node->clk);
clock_real_clk[VDEC_1] = 0;
spin_unlock_irqrestore(&gclk.vdec_mux_node->lock,
gclk.vdec_mux_node->flags);
mutex_unlock(&gclk.vdec_mux_node->mutex);
pr_info("the %-15s clock off, ref cnt: %d\n",
gclk.vdec_mux_node->name,
@@ -528,14 +524,12 @@ static void vdec_clock_off(void)
static void hcodec_clock_on(void)
{
spin_lock_irqsave(&gclk.hcodec_mux_node->lock,
gclk.hcodec_mux_node->flags);
mutex_lock(&gclk.hcodec_mux_node->mutex);
if (!gclk.hcodec_mux_node->ref_count)
clk_prepare_enable(gclk.hcodec_mux_node->clk);
gclk.hcodec_mux_node->ref_count++;
spin_unlock_irqrestore(&gclk.hcodec_mux_node->lock,
gclk.hcodec_mux_node->flags);
mutex_unlock(&gclk.hcodec_mux_node->mutex);
pr_info("the %-15s clock on, ref cnt: %d\n",
gclk.hcodec_mux_node->name,
@@ -544,14 +538,12 @@ static void hcodec_clock_on(void)
static void hcodec_clock_off(void)
{
spin_lock_irqsave(&gclk.hcodec_mux_node->lock,
gclk.hcodec_mux_node->flags);
mutex_lock(&gclk.hcodec_mux_node->mutex);
gclk.hcodec_mux_node->ref_count--;
if (!gclk.hcodec_mux_node->ref_count)
clk_disable_unprepare(gclk.hcodec_mux_node->clk);
spin_unlock_irqrestore(&gclk.hcodec_mux_node->lock,
gclk.hcodec_mux_node->flags);
mutex_unlock(&gclk.hcodec_mux_node->mutex);
pr_info("the %-15s clock off, ref cnt: %d\n",
gclk.hcodec_mux_node->name,
@@ -560,15 +552,13 @@ static void hcodec_clock_off(void)
static void hevc_clock_on(void)
{
spin_lock_irqsave(&gclk.hevc_mux_node->lock,
gclk.hevc_mux_node->flags);
mutex_lock(&gclk.hevc_mux_node->mutex);
if (!gclk.hevc_mux_node->ref_count)
clk_prepare_enable(gclk.hevc_mux_node->clk);
gclk.hevc_mux_node->ref_count++;
WRITE_VREG(DOS_GCLK_EN3, 0xffffffff);
spin_unlock_irqrestore(&gclk.hevc_mux_node->lock,
gclk.hevc_mux_node->flags);
mutex_unlock(&gclk.hevc_mux_node->mutex);
pr_info("the %-15s clock on, ref cnt: %d\n",
gclk.hevc_mux_node->name,
@@ -577,15 +567,13 @@ static void hevc_clock_on(void)
static void hevc_clock_off(void)
{
spin_lock_irqsave(&gclk.hevc_mux_node->lock,
gclk.hevc_mux_node->flags);
mutex_lock(&gclk.hevc_mux_node->mutex);
gclk.hevc_mux_node->ref_count--;
if (!gclk.hevc_mux_node->ref_count)
clk_disable_unprepare(gclk.hevc_mux_node->clk);
clock_real_clk[VDEC_HEVC] = 0;
spin_unlock_irqrestore(&gclk.hevc_mux_node->lock,
gclk.hevc_mux_node->flags);
mutex_unlock(&gclk.hevc_mux_node->mutex);
pr_info("the %-15s clock off, ref cnt: %d\n",
gclk.hevc_mux_node->name,

View File

@@ -90,7 +90,7 @@ int amports_clock_gate_init(struct device *dev)
gates[i].clk);
}
gates[i].ref_count = 0;
spin_lock_init(&gates[i].lock);
mutex_init(&gates[i].mutex);
}
set_clock_gate(gates, ARRAY_SIZE(gates));
@@ -101,7 +101,7 @@ EXPORT_SYMBOL(amports_clock_gate_init);
static int amports_gate_clk(struct gate_switch_node *gate_node, int enable)
{
spin_lock_irqsave(&gate_node->lock, gate_node->flags);
mutex_lock(&gate_node->mutex);
if (enable) {
if (gate_node->ref_count == 0)
clk_prepare_enable(gate_node->clk);
@@ -120,7 +120,8 @@ static int amports_gate_clk(struct gate_switch_node *gate_node, int enable)
pr_info("the %-15s clock off, ref cnt: %d\n",
gate_node->name, gate_node->ref_count);
}
spin_unlock_irqrestore(&gate_node->lock, gate_node->flags);
mutex_unlock(&gate_node->mutex);
return 0;
}

View File

@@ -22,8 +22,7 @@
struct gate_switch_node {
struct clk *clk;
const char *name;
spinlock_t lock;
unsigned long flags;
struct mutex mutex;
int ref_count;
};