Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/exynos: added mutex lock and code clean.

Signed-off-by: Inki Dae <inki.dae@samsung.com>

Inki Dae c32b06ef 52c68814

+25 -12
+25 -12
drivers/gpu/drm/exynos/exynos_drm_fimd.c
··· 87 87 u32 vidcon0; 88 88 u32 vidcon1; 89 89 bool suspended; 90 + struct mutex lock; 90 91 91 92 struct fb_videomode *timing; 92 93 }; ··· 138 137 139 138 static void fimd_dpms(struct device *subdrv_dev, int mode) 140 139 { 140 + struct fimd_context *ctx = get_fimd_context(subdrv_dev); 141 + 141 142 DRM_DEBUG_KMS("%s, %d\n", __FILE__, mode); 143 + 144 + mutex_lock(&ctx->lock); 142 145 143 146 switch (mode) { 144 147 case DRM_MODE_DPMS_ON: 145 - pm_runtime_get_sync(subdrv_dev); 148 + /* 149 + * enable fimd hardware only if suspended status. 150 + * 151 + * P.S. fimd_dpms function would be called at booting time so 152 + * clk_enable could be called double time. 153 + */ 154 + if (ctx->suspended) 155 + pm_runtime_get_sync(subdrv_dev); 146 156 break; 147 157 case DRM_MODE_DPMS_STANDBY: 148 158 case DRM_MODE_DPMS_SUSPEND: ··· 164 152 DRM_DEBUG_KMS("unspecified mode %d\n", mode); 165 153 break; 166 154 } 155 + 156 + mutex_unlock(&ctx->lock); 167 157 } 168 158 169 159 static void fimd_apply(struct device *subdrv_dev) ··· 817 803 goto err_req_irq; 818 804 } 819 805 820 - pm_runtime_set_active(dev); 821 - pm_runtime_enable(dev); 822 - pm_runtime_get_sync(dev); 823 - 824 - for (win = 0; win < WINDOWS_NR; win++) 825 - fimd_clear_win(ctx, win); 826 - 827 806 ctx->clkdiv = fimd_calc_clkdiv(ctx, timing); 828 807 ctx->vidcon0 = pdata->vidcon0; 829 808 ctx->vidcon1 = pdata->vidcon1; ··· 838 831 subdrv->manager.display_ops = &fimd_display_ops; 839 832 subdrv->manager.dev = dev; 840 833 834 + mutex_init(&ctx->lock); 835 + 841 836 platform_set_drvdata(pdev, ctx); 837 + 838 + pm_runtime_set_active(dev); 839 + pm_runtime_enable(dev); 840 + pm_runtime_get_sync(dev); 841 + 842 + for (win = 0; win < WINDOWS_NR; win++) 843 + fimd_clear_win(ctx, win); 844 + 842 845 exynos_drm_subdrv_register(subdrv); 843 846 844 847 return 0; ··· 911 894 #ifdef CONFIG_PM_SLEEP 912 895 static int fimd_suspend(struct device *dev) 913 896 { 914 - struct fimd_context *ctx = get_fimd_context(dev); 915 897 int ret; 916 898 917 899 if (pm_runtime_suspended(dev)) ··· 920 904 if (ret < 0) 921 905 return ret; 922 906 923 - ctx->suspended = true; 924 907 return 0; 925 908 } 926 909 927 910 static int fimd_resume(struct device *dev) 928 911 { 929 - struct fimd_context *ctx = get_fimd_context(dev); 930 912 int ret; 931 913 932 914 ret = pm_runtime_resume(dev); ··· 945 931 946 932 pm_runtime_enable(dev); 947 933 948 - ctx->suspended = false; 949 934 return 0; 950 935 } 951 936 #endif