Commit 00b2f4ee authored by Richard Zhao's avatar Richard Zhao Committed by Alexey Mednyy

ENGR00142351 mxc_gpu: autogating: add pending flag

pending indicate the timer has been fired but clock not yet disabled.

This patch fixs the bug that sometimes in irq handle it tries to enable
clock and cause BUG.
Signed-off-by: default avatarRichard Zhao <>
parent 83ab7212
......@@ -30,6 +30,8 @@ typedef struct _gsl_autogate_t {
struct timer_list timer;
spinlock_t lock;
int active;
/* pending indicate the timer has been fired but clock not yet disabled. */
int pending;
int timeout;
gsl_device_t *dev;
struct work_struct dis_task;
......@@ -47,6 +49,7 @@ static void clk_disable_task(struct work_struct *work)
if (autogate->dev->ftbl.device_idle)
autogate->dev->ftbl.device_idle(autogate->dev, GSL_TIMEOUT_DEFAULT);
kgsl_clock(autogate->dev->id, 0);
autogate->pending = 0;
static int _kgsl_device_active(gsl_device_t *dev, int all)
......@@ -62,7 +65,7 @@ static int _kgsl_device_active(gsl_device_t *dev, int all)
spin_lock_irqsave(&autogate->lock, flags);
if (in_interrupt()) {
if (!autogate->active)
if (!autogate->active && !autogate->pending)
} else {
to_active = !autogate->active;
......@@ -99,6 +102,7 @@ static void kgsl_device_inactive(unsigned long data)
WARN(!autogate->active, "GPU Device %d is already inactive\n", autogate->dev->id);
if (autogate->active) {
autogate->active = 0;
autogate->pending = 1;
spin_unlock_irqrestore(&autogate->lock, flags);
......@@ -128,7 +132,7 @@ int kgsl_device_autogate_init(gsl_device_t *dev)
gsl_autogate_t *autogate;
// printk(KERN_ERR "%s:%d id %d\n", __func__, __LINE__, dev->id);
autogate = kmalloc(sizeof(gsl_autogate_t), GFP_KERNEL);
autogate = kzalloc(sizeof(gsl_autogate_t), GFP_KERNEL);
if (!autogate) {
printk(KERN_ERR "%s: out of memory!\n", __func__);
return -ENOMEM;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment