video: tegra: host: Alloc iomem before module init
Terje Bergstrom [Mon, 9 Sep 2013 07:46:28 +0000 (10:46 +0300)]
Allocate and request IOMEM resources for all clients before calling
nvhost_module_init(). Also moves setting of callbacks to the SoC
specific file.

Bug 1355069

Change-Id: Ic7483dba969be8e5e985d5abbba11393afdc2a2d
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/271960
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Juha Tukkinen <jtukkinen@nvidia.com>

14 files changed:
drivers/video/tegra/host/gk20a/gk20a.c
drivers/video/tegra/host/gk20a/gk20a.h
drivers/video/tegra/host/gr2d/gr2d.c
drivers/video/tegra/host/gr3d/gr3d.c
drivers/video/tegra/host/isp/isp.c
drivers/video/tegra/host/mpe/mpe.c
drivers/video/tegra/host/msenc/msenc.c
drivers/video/tegra/host/t114/t114.c
drivers/video/tegra/host/t124/t124.c
drivers/video/tegra/host/t148/t148.c
drivers/video/tegra/host/tsec/tsec.c
drivers/video/tegra/host/vi/vi.c
drivers/video/tegra/host/vic03/vic03.c
include/linux/nvhost.h

index b038dcf..53b65bc 100644 (file)
@@ -55,8 +55,6 @@ static inline void set_gk20a(struct platform_device *dev, struct gk20a *gk20a)
        nvhost_set_private_data(dev, gk20a);
 }
 
-static void nvhost_gk20a_deinit(struct platform_device *dev);
-
 /* TBD: should be able to put in the list below. */
 static struct resource gk20a_intr = {
        .start = TEGRA_GK20A_INTR,
@@ -563,7 +561,7 @@ int nvhost_gk20a_init(struct platform_device *dev)
        return 0;
 }
 
-static void nvhost_gk20a_deinit(struct platform_device *dev)
+void nvhost_gk20a_deinit(struct platform_device *dev)
 {
        nvhost_dbg_fn("");
 #ifndef CONFIG_PM_RUNTIME
@@ -809,22 +807,12 @@ static int gk20a_probe(struct platform_device *dev)
        pdata->pdev = dev;
        mutex_init(&pdata->lock);
        platform_set_drvdata(dev, pdata);
-       nvhost_module_init(dev);
 
-       pdata->init                     = nvhost_gk20a_init;
-       pdata->deinit                   = nvhost_gk20a_deinit;
-       pdata->alloc_hwctx_handler      = nvhost_gk20a_alloc_hwctx_handler;
-       pdata->prepare_poweroff         = nvhost_gk20a_prepare_poweroff;
-       pdata->finalize_poweron         = nvhost_gk20a_finalize_poweron;
-
-       if (IS_ENABLED(CONFIG_TEGRA_GK20A_DEVFREQ)) {
-               pdata->busy             = nvhost_gk20a_scale_notify_busy;
-               pdata->idle             = nvhost_gk20a_scale_notify_idle;
-               pdata->scaling_init     = nvhost_gk20a_scale_init;
-               pdata->scaling_deinit   = nvhost_gk20a_scale_deinit;
-               pdata->suspend_ndev     = nvhost_scale3d_suspend;
-               pdata->devfreq_governor = &nvhost_podgov;
-       }
+       err = nvhost_client_device_get_resources(dev);
+       if (err)
+               return err;
+
+       nvhost_module_init(dev);
 
        gk20a = kzalloc(sizeof(struct gk20a), GFP_KERNEL);
        if (!gk20a) {
@@ -836,10 +824,6 @@ static int gk20a_probe(struct platform_device *dev)
        gk20a->dev = dev;
        gk20a->host = nvhost_get_host(dev);
 
-       err = nvhost_client_device_get_resources(dev);
-       if (err)
-               return err;
-
        nvhost_init_gk20a_support(dev);
 
 #ifdef CONFIG_PM_GENERIC_DOMAINS
index dce6413..b30c078 100644 (file)
@@ -211,6 +211,7 @@ static inline void gk20a_gr_flush_channel_tlb(struct gr_gk20a *gr)
  * 2. client opens gk20a ctrl node.
  */
 int nvhost_gk20a_init(struct platform_device *dev);
+void nvhost_gk20a_deinit(struct platform_device *dev);
 
 /* classes that the device supports */
 /* TBD: get these from an open-sourced SDK? */
@@ -233,6 +234,10 @@ static inline int support_gk20a_pmu(void){return 0;}
 
 int nvhost_gk20a_finalize_poweron(struct platform_device *dev);
 int nvhost_gk20a_prepare_poweroff(struct platform_device *dev);
+void nvhost_gk20a_scale_notify_idle(struct platform_device *pdev);
+void nvhost_gk20a_scale_notify_busy(struct platform_device *pdev);
+void nvhost_gk20a_scale_init(struct platform_device *pdev);
+void nvhost_gk20a_scale_deinit(struct platform_device *pdev);
 
 void gk20a_create_sysfs(struct platform_device *dev);
 
index f101abf..31d7a7d 100644 (file)
@@ -80,6 +80,11 @@ static int gr2d_probe(struct platform_device *dev)
        pdata->pdev = dev;
        mutex_init(&pdata->lock);
        platform_set_drvdata(dev, pdata);
+
+       err = nvhost_client_device_get_resources(dev);
+       if (err)
+               return err;
+
        nvhost_module_init(dev);
 
 #ifdef CONFIG_PM_GENERIC_DOMAINS
index 1b68743..4f8fb5e 100644 (file)
@@ -221,6 +221,11 @@ static int gr3d_probe(struct platform_device *dev)
        pdata->pdev = dev;
        mutex_init(&pdata->lock);
        platform_set_drvdata(dev, pdata);
+
+       err = nvhost_client_device_get_resources(dev);
+       if (err)
+               return err;
+
        nvhost_module_init(dev);
 
 #ifdef CONFIG_PM_GENERIC_DOMAINS
index d722edf..c1ef46c 100644 (file)
@@ -92,6 +92,11 @@ static int isp_probe(struct platform_device *dev)
        pdata->pdev = dev;
        mutex_init(&pdata->lock);
        platform_set_drvdata(dev, pdata);
+
+       err = nvhost_client_device_get_resources(dev);
+       if (err)
+               return err;
+
        nvhost_module_init(dev);
 
 #ifdef CONFIG_PM_GENERIC_DOMAINS
@@ -102,10 +107,6 @@ static int isp_probe(struct platform_device *dev)
        err = nvhost_module_add_domain(&pdata->pd, dev);
 #endif
 
-       err = nvhost_client_device_get_resources(dev);
-       if (err)
-               return err;
-
        err = nvhost_client_device_init(dev);
        if (err)
                return err;
index 66926e1..05bfce7 100644 (file)
@@ -670,12 +670,13 @@ static int mpe_probe(struct platform_device *dev)
        pdata->pdev = dev;
        mutex_init(&pdata->lock);
        platform_set_drvdata(dev, pdata);
-       nvhost_module_init(dev);
 
        err = nvhost_client_device_get_resources(dev);
        if (err)
                return err;
 
+       nvhost_module_init(dev);
+
 #ifdef CONFIG_PM_GENERIC_DOMAINS
        pdata->pd.name = "mpe";
 
index 4c7456a..8e3873b 100644 (file)
@@ -447,13 +447,12 @@ static int msenc_probe(struct platform_device *dev)
        }
 
        pdata->pdev = dev;
-       pdata->init = nvhost_msenc_init;
-       pdata->deinit = nvhost_msenc_deinit;
-       pdata->finalize_poweron = nvhost_msenc_finalize_poweron;
-
        mutex_init(&pdata->lock);
-
        platform_set_drvdata(dev, pdata);
+       err = nvhost_client_device_get_resources(dev);
+       if (err)
+               return err;
+
        dev->dev.platform_data = NULL;
 
        /* get the module clocks to sane state */
@@ -467,10 +466,6 @@ static int msenc_probe(struct platform_device *dev)
        err = nvhost_module_add_domain(&pdata->pd, dev);
 #endif
 
-       err = nvhost_client_device_get_resources(dev);
-       if (err)
-               return err;
-
        err = nvhost_client_device_init(dev);
 
        return 0;
index 8723ac5..cc9f261 100644 (file)
@@ -269,6 +269,9 @@ struct nvhost_device_data t11_msenc_info = {
        .powergate_delay = 100,
        .can_powergate = true,
        .moduleid       = NVHOST_MODULE_MSENC,
+       .init           = nvhost_msenc_init,
+       .deinit         = nvhost_msenc_deinit,
+       .finalize_poweron = nvhost_msenc_finalize_poweron,
 };
 
 static struct platform_device tegra_msenc02_device = {
@@ -302,6 +305,8 @@ struct nvhost_device_data t11_tsec_info = {
        NVHOST_MODULE_NO_POWERGATE_IDS,
        NVHOST_DEFAULT_CLOCKGATE_DELAY,
        .moduleid       = NVHOST_MODULE_TSEC,
+       .init          = nvhost_tsec_init,
+       .deinit        = nvhost_tsec_deinit,
 };
 
 static struct platform_device tegra_tsec01_device = {
index 23143ee..baa59f5 100644 (file)
@@ -37,6 +37,7 @@
 #include "tsec/tsec.h"
 #include "vi/vi.h"
 #include "isp/isp.h"
+#include "gr3d/pod_scaling.h"
 
 #include "nvhost_memmgr.h"
 #include "chip_support.h"
@@ -310,6 +311,9 @@ struct nvhost_device_data t124_msenc_info = {
        .powergate_ids  = { TEGRA_POWERGATE_MPE, -1 },
        .powergate_delay = 100,
        .can_powergate  = true,
+       .init           = nvhost_msenc_init,
+       .deinit         = nvhost_msenc_deinit,
+       .finalize_poweron = nvhost_msenc_finalize_poweron,
        .scaling_init   = nvhost_scale_init,
        .scaling_deinit = nvhost_scale_deinit,
        .actmon_regs    = HOST1X_CHANNEL_ACTMON1_REG_BASE,
@@ -345,6 +349,8 @@ struct nvhost_device_data t124_tsec_info = {
        NVHOST_MODULE_NO_POWERGATE_IDS,
        NVHOST_DEFAULT_CLOCKGATE_DELAY,
        .moduleid      = NVHOST_MODULE_TSEC,
+       .init          = nvhost_tsec_init,
+       .deinit        = nvhost_tsec_deinit,
 };
 
 static struct platform_device tegra_tsec01_device = {
@@ -378,6 +384,10 @@ struct nvhost_device_data t124_vic_info = {
        .can_powergate          = true,
        .powergate_delay        = 500,
        .powergate_ids          = { TEGRA_POWERGATE_VIC, -1 },
+       .init                   = nvhost_vic03_init,
+       .deinit                 = nvhost_vic03_deinit,
+       .alloc_hwctx_handler    = nvhost_vic03_alloc_hwctx_handler,
+       .finalize_poweron       = nvhost_vic03_finalize_poweron,
        .prepare_poweroff       = nvhost_vic03_prepare_poweroff,
        .scaling_init           = nvhost_scale_init,
        .scaling_deinit         = nvhost_scale_deinit,
@@ -428,6 +438,19 @@ struct nvhost_device_data tegra_gk20a_info = {
        .alloc_hwctx_handler    = nvhost_gk20a_alloc_hwctx_handler,
        .ctrl_ops               = &tegra_gk20a_ctrl_ops,
        .moduleid               = NVHOST_MODULE_GPU,
+       .init                   = nvhost_gk20a_init,
+       .deinit                 = nvhost_gk20a_deinit,
+       .alloc_hwctx_handler    = nvhost_gk20a_alloc_hwctx_handler,
+       .prepare_poweroff       = nvhost_gk20a_prepare_poweroff,
+       .finalize_poweron       = nvhost_gk20a_finalize_poweron,
+#ifdef CONFIG_TEGRA_GK20A_DEVFREQ
+       .busy                   = nvhost_gk20a_scale_notify_busy,
+       .idle                   = nvhost_gk20a_scale_notify_idle,
+       .scaling_init           = nvhost_gk20a_scale_init,
+       .scaling_deinit         = nvhost_gk20a_scale_deinit,
+       .suspend_ndev           = nvhost_scale3d_suspend,
+       .devfreq_governor       = &nvhost_podgov,
+#endif
 };
 
 struct platform_device tegra_gk20a_device = {
index 98d7baa..b10e27d 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Tegra Graphics Init for T148 Architecture Chips
  *
- * Copyright (c) 2012-2013, NVIDIA Corporation.
+ * Copyright (c) 2012-2013, NVIDIA Corporation.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -269,6 +269,9 @@ struct nvhost_device_data t14_msenc_info = {
        .can_powergate = true,
        .moduleid       = NVHOST_MODULE_MSENC,
        .powerup_reset  = true,
+       .init           = nvhost_msenc_init,
+       .deinit         = nvhost_msenc_deinit,
+       .finalize_poweron = nvhost_msenc_finalize_poweron,
 };
 
 static struct platform_device tegra_msenc03_device = {
@@ -302,6 +305,8 @@ struct nvhost_device_data t14_tsec_info = {
        NVHOST_MODULE_NO_POWERGATE_IDS,
        NVHOST_DEFAULT_CLOCKGATE_DELAY,
        .moduleid       = NVHOST_MODULE_TSEC,
+       .init          = nvhost_tsec_init,
+       .deinit        = nvhost_tsec_deinit,
 };
 
 static struct platform_device tegra_tsec01_device = {
index 80d4380..8f48b02 100644 (file)
@@ -565,18 +565,15 @@ static int tsec_probe(struct platform_device *dev)
        }
 
        pdata->pdev = dev;
-       pdata->init = nvhost_tsec_init;
-       pdata->deinit = nvhost_tsec_deinit;
-
        mutex_init(&pdata->lock);
-
        platform_set_drvdata(dev, pdata);
-       nvhost_module_init(dev);
 
        err = nvhost_client_device_get_resources(dev);
        if (err)
                return err;
 
+       nvhost_module_init(dev);
+
        tsec = dev;
 
 #ifdef CONFIG_PM_GENERIC_DOMAINS
index 579d3e9..5e03efb 100644 (file)
@@ -92,6 +92,14 @@ static int vi_probe(struct platform_device *dev)
                return -ENODATA;
        }
 
+       pdata->pdev = dev;
+       mutex_init(&pdata->lock);
+       platform_set_drvdata(dev, pdata);
+
+       err = nvhost_client_device_get_resources(dev);
+       if (err)
+               return err;
+
        i2c_ctrl = pdata->private_data;
 
        dev_info(&dev->dev, "%s: ++\n", __func__);
@@ -118,9 +126,6 @@ static int vi_probe(struct platform_device *dev)
        }
 #endif
 
-       pdata->pdev = dev;
-       mutex_init(&pdata->lock);
-       platform_set_drvdata(dev, pdata);
        nvhost_module_init(dev);
 
 #ifdef CONFIG_PM_GENERIC_DOMAINS
@@ -131,10 +136,6 @@ static int vi_probe(struct platform_device *dev)
        err = nvhost_module_add_domain(&pdata->pd, dev);
 #endif
 
-       err = nvhost_client_device_get_resources(dev);
-       if (err)
-               goto camera_unregister;
-
        err = nvhost_client_device_init(dev);
        if (err)
                goto camera_unregister;
index 2e92290..cd909d6 100644 (file)
@@ -623,16 +623,14 @@ static int vic03_probe(struct platform_device *dev)
 
        nvhost_dbg_fn("dev:%p pdata:%p", dev, pdata);
 
-       pdata->init                     = nvhost_vic03_init;
-       pdata->deinit                   = nvhost_vic03_deinit;
-       pdata->finalize_poweron         = nvhost_vic03_finalize_poweron;
-       pdata->alloc_hwctx_handler      = nvhost_vic03_alloc_hwctx_handler;
-
        pdata->pdev = dev;
-
        mutex_init(&pdata->lock);
-
        platform_set_drvdata(dev, pdata);
+
+       err = nvhost_client_device_get_resources(dev);
+       if (err)
+               return err;
+
        dev->dev.platform_data = NULL;
 
        nvhost_module_init(dev);
@@ -643,10 +641,6 @@ static int vic03_probe(struct platform_device *dev)
        err = nvhost_module_add_domain(&pdata->pd, dev);
 #endif
 
-       err = nvhost_client_device_get_resources(dev);
-       if (err)
-               return err;
-
        err = nvhost_client_device_init(dev);
        if (err) {
                nvhost_dbg_fn("failed to init client device for %s",
index dd93f91..60136ba 100644 (file)
@@ -225,7 +225,7 @@ struct nvhost_device_data {
         * Reset the unit. Used for timeout recovery, resetting the unit on
         * probe and when un-powergating.
         */
-       int (*reset)(struct platform_device *dev);
+       void (*reset)(struct platform_device *dev);
 
        /* Device is busy. */
        void (*busy)(struct platform_device *);