video: tegra: add some missing mutex locking to nvhost_cdma
authorPrajakta Gudadhe <pgudadhe@nvidia.com>
Tue, 1 Feb 2011 22:56:00 +0000 (14:56 -0800)
committerErik Gilling <konkers@android.com>
Tue, 15 Feb 2011 01:51:44 +0000 (17:51 -0800)
Change-Id: Ie4606d9a5154090274168babc110ea2d79747c05
Signed-off-by: Erik Gilling <konkers@android.com>
drivers/video/tegra/host/nvhost_cdma.c
drivers/video/tegra/host/nvhost_channel.c

index f27656bac07b314f0fadf9e2b823331649398c2a..d2a91d117b527dfd904a481b54f015f7688ae6b0 100644 (file)
@@ -522,16 +522,14 @@ void nvhost_cdma_stop(struct nvhost_cdma *cdma)
 {
        void __iomem *chan_regs = cdma_to_channel(cdma)->aperture;
 
-       if (!cdma->running)
-               return;
-
        mutex_lock(&cdma->lock);
-       wait_cdma(cdma, CDMA_EVENT_SYNC_QUEUE_EMPTY);
+       if (cdma->running) {
+               wait_cdma(cdma, CDMA_EVENT_SYNC_QUEUE_EMPTY);
+               writel(nvhost_channel_dmactrl(true, false, false),
+                       chan_regs + HOST1X_CHANNEL_DMACTRL);
+               cdma->running = false;
+       }
        mutex_unlock(&cdma->lock);
-       writel(nvhost_channel_dmactrl(true, false, false),
-               chan_regs + HOST1X_CHANNEL_DMACTRL);
-
-       cdma->running = false;
 }
 
 /**
@@ -539,9 +537,9 @@ void nvhost_cdma_stop(struct nvhost_cdma *cdma)
  */
 void nvhost_cdma_begin(struct nvhost_cdma *cdma)
 {
+       mutex_lock(&cdma->lock);
        if (!cdma->running)
                start_cdma(cdma);
-       mutex_lock(&cdma->lock);
        cdma->slots_free = 0;
        cdma->slots_used = 0;
 }
index 40b67181c33d0deb14cecc5d8a685d7e18eb062d..3a6998909ed50646079fd1c5b1e33e916ca7db6a 100644 (file)
@@ -163,7 +163,8 @@ void nvhost_channel_suspend(struct nvhost_channel *ch)
 {
        mutex_lock(&ch->reflock);
        BUG_ON(nvhost_module_powered(&ch->mod));
-       nvhost_cdma_stop(&ch->cdma);
+       if (ch->refcount)
+               nvhost_cdma_stop(&ch->cdma);
        mutex_unlock(&ch->reflock);
 }