From 6c6936858af4902ca0e170da03ddf92e32b74ae1 Mon Sep 17 00:00:00 2001 From: Matt Pedro Date: Sun, 11 May 2014 22:57:48 -0400 Subject: Revert "gpu: nvgpu: Keep host1x on when GPU on" This reverts commit 20d48a759b032116e3092e1df76518065da59879. Change-Id: I93718a314b70ee9284a83ca69964883e670ad78d Signed-off-by: Matt Pedro Reviewed-on: http://git-master/r/407969 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Terje Bergstrom Tested-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/as_gk20a.c | 4 +- drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 48 +++++++++++------------ drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c | 4 +- drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c | 4 +- drivers/gpu/nvgpu/gk20a/gk20a.c | 57 ++++++++++++++++++---------- drivers/gpu/nvgpu/gk20a/gk20a.h | 2 + drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c | 4 +- 7 files changed, 70 insertions(+), 53 deletions(-) diff --git a/drivers/gpu/nvgpu/gk20a/as_gk20a.c b/drivers/gpu/nvgpu/gk20a/as_gk20a.c index 42fa2167..ea0fb8f5 100644 --- a/drivers/gpu/nvgpu/gk20a/as_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/as_gk20a.c @@ -231,7 +231,7 @@ long gk20a_as_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) return -EFAULT; } - err = gk20a_busy(g->dev); + err = gk20a_channel_busy(g->dev); if (err) return err; @@ -288,7 +288,7 @@ long gk20a_as_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) break; } - gk20a_idle(g->dev); + gk20a_channel_idle(g->dev); if ((err == 0) && (_IOC_DIR(cmd) & _IOC_READ)) err = copy_to_user((void __user *)arg, buf, _IOC_SIZE(cmd)); diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index 344223ae..60f7d4e3 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c @@ -697,14 +697,14 @@ int gk20a_channel_release(struct inode *inode, struct file *filp) trace_gk20a_channel_release(dev_name(&g->dev->dev)); - err = gk20a_busy(ch->g->dev); + err = gk20a_channel_busy(ch->g->dev); if (err) { gk20a_err(dev_from_gk20a(g), "failed to release channel %d", ch->hw_chid); return err; } gk20a_free_channel(ch, true); - gk20a_idle(ch->g->dev); + gk20a_channel_idle(ch->g->dev); gk20a_put_client(g); filp->private_data = NULL; @@ -767,14 +767,14 @@ static int __gk20a_channel_open(struct gk20a *g, struct file *filp) return err; } - err = gk20a_busy(g->dev); + err = gk20a_channel_busy(g->dev); if (err) { gk20a_put_client(g); gk20a_err(dev_from_gk20a(g), "failed to power on, %d", err); return err; } ch = gk20a_open_new_channel(g); - gk20a_idle(g->dev); + gk20a_channel_idle(g->dev); if (!ch) { gk20a_put_client(g); gk20a_err(dev_from_gk20a(g), @@ -1417,7 +1417,7 @@ void gk20a_channel_update(struct channel_gk20a *c, int nr_completed) list_del_init(&job->list); kfree(job); - gk20a_idle(g->dev); + gk20a_channel_idle(g->dev); } /* @@ -1436,7 +1436,7 @@ void gk20a_channel_update(struct channel_gk20a *c, int nr_completed) mutex_unlock(&c->submit_lock); for (i = 0; i < nr_completed; i++) - gk20a_idle(c->g->dev); + gk20a_channel_idle(c->g->dev); } void add_wait_cmd(u32 *ptr, u32 id, u32 thresh) @@ -1484,7 +1484,7 @@ static int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, gk20a_dbg_info("channel %d", c->hw_chid); /* gk20a_channel_update releases this ref. */ - err = gk20a_busy(g->dev); + err = gk20a_channel_busy(g->dev); if (err) { gk20a_err(d, "failed to host gk20a to submit gpfifo"); return err; @@ -1645,7 +1645,7 @@ clean_up: gk20a_err(d, "fail"); free_priv_cmdbuf(c, wait_cmd); free_priv_cmdbuf(c, incr_cmd); - gk20a_idle(g->dev); + gk20a_channel_idle(g->dev); return err; } @@ -2079,7 +2079,7 @@ long gk20a_channel_ioctl(struct file *filp, case NVHOST_IOCTL_CHANNEL_SET_NVMAP_FD: break; case NVHOST_IOCTL_CHANNEL_ALLOC_OBJ_CTX: - err = gk20a_busy(dev); + err = gk20a_channel_busy(dev); if (err) { dev_err(&dev->dev, "%s: failed to host gk20a for ioctl cmd: 0x%x", @@ -2088,10 +2088,10 @@ long gk20a_channel_ioctl(struct file *filp, } err = gk20a_alloc_obj_ctx(ch, (struct nvhost_alloc_obj_ctx_args *)buf); - gk20a_idle(dev); + gk20a_channel_idle(dev); break; case NVHOST_IOCTL_CHANNEL_FREE_OBJ_CTX: - err = gk20a_busy(dev); + err = gk20a_channel_busy(dev); if (err) { dev_err(&dev->dev, "%s: failed to host gk20a for ioctl cmd: 0x%x", @@ -2100,10 +2100,10 @@ long gk20a_channel_ioctl(struct file *filp, } err = gk20a_free_obj_ctx(ch, (struct nvhost_free_obj_ctx_args *)buf); - gk20a_idle(dev); + gk20a_channel_idle(dev); break; case NVHOST_IOCTL_CHANNEL_ALLOC_GPFIFO: - err = gk20a_busy(dev); + err = gk20a_channel_busy(dev); if (err) { dev_err(&dev->dev, "%s: failed to host gk20a for ioctl cmd: 0x%x", @@ -2112,14 +2112,14 @@ long gk20a_channel_ioctl(struct file *filp, } err = gk20a_alloc_channel_gpfifo(ch, (struct nvhost_alloc_gpfifo_args *)buf); - gk20a_idle(dev); + gk20a_channel_idle(dev); break; case NVHOST_IOCTL_CHANNEL_SUBMIT_GPFIFO: err = gk20a_ioctl_channel_submit_gpfifo(ch, (struct nvhost_submit_gpfifo_args *)buf); break; case NVHOST_IOCTL_CHANNEL_WAIT: - err = gk20a_busy(dev); + err = gk20a_channel_busy(dev); if (err) { dev_err(&dev->dev, "%s: failed to host gk20a for ioctl cmd: 0x%x", @@ -2128,10 +2128,10 @@ long gk20a_channel_ioctl(struct file *filp, } err = gk20a_channel_wait(ch, (struct nvhost_wait_args *)buf); - gk20a_idle(dev); + gk20a_channel_idle(dev); break; case NVHOST_IOCTL_CHANNEL_ZCULL_BIND: - err = gk20a_busy(dev); + err = gk20a_channel_busy(dev); if (err) { dev_err(&dev->dev, "%s: failed to host gk20a for ioctl cmd: 0x%x", @@ -2140,10 +2140,10 @@ long gk20a_channel_ioctl(struct file *filp, } err = gk20a_channel_zcull_bind(ch, (struct nvhost_zcull_bind_args *)buf); - gk20a_idle(dev); + gk20a_channel_idle(dev); break; case NVHOST_IOCTL_CHANNEL_SET_ERROR_NOTIFIER: - err = gk20a_busy(dev); + err = gk20a_channel_busy(dev); if (err) { dev_err(&dev->dev, "%s: failed to host gk20a for ioctl cmd: 0x%x", @@ -2152,11 +2152,11 @@ long gk20a_channel_ioctl(struct file *filp, } err = gk20a_init_error_notifier(ch, (struct nvhost_set_error_notifier *)buf); - gk20a_idle(dev); + gk20a_channel_idle(dev); break; #ifdef CONFIG_GK20A_CYCLE_STATS case NVHOST_IOCTL_CHANNEL_CYCLE_STATS: - err = gk20a_busy(dev); + err = gk20a_channel_busy(dev); if (err) { dev_err(&dev->dev, "%s: failed to host gk20a for ioctl cmd: 0x%x", @@ -2165,7 +2165,7 @@ long gk20a_channel_ioctl(struct file *filp, } err = gk20a_channel_cycle_stats(ch, (struct nvhost_cycle_stats_args *)buf); - gk20a_idle(dev); + gk20a_channel_idle(dev); break; #endif case NVHOST_IOCTL_CHANNEL_SET_TIMEOUT: @@ -2195,7 +2195,7 @@ long gk20a_channel_ioctl(struct file *filp, ch->has_timedout; break; case NVHOST_IOCTL_CHANNEL_SET_PRIORITY: - err = gk20a_busy(dev); + err = gk20a_channel_busy(dev); if (err) { dev_err(&dev->dev, "%s: failed to host gk20a for ioctl cmd: 0x%x", @@ -2204,7 +2204,7 @@ long gk20a_channel_ioctl(struct file *filp, } gk20a_channel_set_priority(ch, ((struct nvhost_set_priority_args *)buf)->priority); - gk20a_idle(dev); + gk20a_channel_idle(dev); break; default: dev_err(&dev->dev, "unrecognized ioctl cmd: 0x%x", cmd); diff --git a/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c index 55ee5181..dd93fb4a 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.c @@ -227,14 +227,14 @@ static int __gk20a_channel_syncpt_incr(struct gk20a_channel_sync *s, if (register_irq) { /* nvhost action_gpfifo_submit_complete releases this ref. */ - err = gk20a_busy(c->g->dev); + err = gk20a_channel_busy(c->g->dev); if (!err) { err = nvhost_intr_register_notifier(sp->host1x_pdev, sp->id, thresh, gk20a_channel_syncpt_update, c); if (err) - gk20a_idle(c->g->dev); + gk20a_channel_idle(c->g->dev); } /* Adding interrupt action should never fail. A proper error diff --git a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c index 77806a5e..9fe1729f 100644 --- a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c @@ -573,7 +573,7 @@ static int dbg_set_powergate(struct dbg_session_gk20a *dbg_s, gk20a_dbg(gpu_dbg_gpu_dbg | gpu_dbg_fn, "module busy"); gk20a_busy(g->dev); - err = gk20a_busy(dbg_s->pdev); + err = gk20a_channel_busy(dbg_s->pdev); if (err) return -EPERM; @@ -618,7 +618,7 @@ static int dbg_set_powergate(struct dbg_session_gk20a *dbg_s, gk20a_pmu_enable_elpg(g); gk20a_dbg(gpu_dbg_gpu_dbg | gpu_dbg_fn, "module idle"); - gk20a_idle(dbg_s->pdev); + gk20a_channel_idle(dbg_s->pdev); gk20a_idle(g->dev); } diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c index 96711c0c..7617c70a 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a.c @@ -740,10 +740,10 @@ void gk20a_put_client(struct gk20a *g) WARN_ON(g->client_refcount < 0); } -static int gk20a_pm_prepare_poweroff(struct device *dev) +static int gk20a_pm_prepare_poweroff(struct device *_dev) { - struct platform_device *pdev = to_platform_device(dev); - struct gk20a *g = get_gk20a(pdev); + struct platform_device *dev = to_platform_device(_dev); + struct gk20a *g = get_gk20a(dev); int ret = 0; gk20a_dbg_fn(""); @@ -770,8 +770,6 @@ static int gk20a_pm_prepare_poweroff(struct device *dev) /* Disable GPCPLL */ ret |= gk20a_suspend_clk_support(g); - - gk20a_platform_channel_idle(pdev); g->power_on = false; return ret; @@ -795,18 +793,14 @@ static void gk20a_detect_chip(struct gk20a *g) g->gpu_characteristics.rev); } -static int gk20a_pm_finalize_poweron(struct device *dev) +static int gk20a_pm_finalize_poweron(struct device *_dev) { - struct platform_device *pdev = to_platform_device(dev); - struct gk20a *g = get_gk20a(pdev); + struct platform_device *dev = to_platform_device(_dev); + struct gk20a *g = get_gk20a(dev); int err, nice_value; gk20a_dbg_fn(""); - err = gk20a_platform_channel_busy(pdev); - if (err) - return err; - if (g->power_on) return 0; @@ -855,7 +849,7 @@ static int gk20a_pm_finalize_poweron(struct device *dev) saving features (blcg/slcg) are enabled. For now, do it here. */ err = gk20a_init_clk_support(g); if (err) { - gk20a_err(dev, "failed to init gk20a clk"); + gk20a_err(&dev->dev, "failed to init gk20a clk"); goto done; } @@ -874,7 +868,7 @@ static int gk20a_pm_finalize_poweron(struct device *dev) err = gk20a_init_fifo_reset_enable_hw(g); if (err) { - gk20a_err(dev, "failed to reset gk20a fifo"); + gk20a_err(&dev->dev, "failed to reset gk20a fifo"); goto done; } @@ -883,43 +877,43 @@ static int gk20a_pm_finalize_poweron(struct device *dev) err = gk20a_init_mm_support(g); if (err) { - gk20a_err(dev, "failed to init gk20a mm"); + gk20a_err(&dev->dev, "failed to init gk20a mm"); goto done; } err = gk20a_init_pmu_support(g); if (err) { - gk20a_err(dev, "failed to init gk20a pmu"); + gk20a_err(&dev->dev, "failed to init gk20a pmu"); goto done; } err = gk20a_init_fifo_support(g); if (err) { - gk20a_err(dev, "failed to init gk20a fifo"); + gk20a_err(&dev->dev, "failed to init gk20a fifo"); goto done; } err = gk20a_init_gr_support(g); if (err) { - gk20a_err(dev, "failed to init gk20a gr"); + gk20a_err(&dev->dev, "failed to init gk20a gr"); goto done; } err = gk20a_init_pmu_setup_hw2(g); if (err) { - gk20a_err(dev, "failed to init gk20a pmu_hw2"); + gk20a_err(&dev->dev, "failed to init gk20a pmu_hw2"); goto done; } err = gk20a_init_therm_support(g); if (err) { - gk20a_err(dev, "failed to init gk20a therm"); + gk20a_err(&dev->dev, "failed to init gk20a therm"); goto done; } err = gk20a_init_gpu_characteristics(g); if (err) { - gk20a_err(dev, "failed to init gk20a gpu characteristics"); + gk20a_err(&dev->dev, "failed to init gk20a gpu characteristics"); goto done; } @@ -1546,6 +1540,27 @@ void gk20a_busy_noresume(struct platform_device *pdev) pm_runtime_get_noresume(&pdev->dev); } +int gk20a_channel_busy(struct platform_device *pdev) +{ + int ret = 0; + + ret = gk20a_platform_channel_busy(pdev); + if (ret) + return ret; + + ret = gk20a_busy(pdev); + if (ret) + gk20a_platform_channel_idle(pdev); + + return ret; +} + +void gk20a_channel_idle(struct platform_device *pdev) +{ + gk20a_idle(pdev); + gk20a_platform_channel_idle(pdev); +} + int gk20a_busy(struct platform_device *pdev) { int ret = 0; diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index fc488a28..13d385f5 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -550,6 +550,8 @@ int clk_gk20a_debugfs_init(struct platform_device *dev); void gk20a_busy_noresume(struct platform_device *pdev); int gk20a_busy(struct platform_device *pdev); void gk20a_idle(struct platform_device *pdev); +int gk20a_channel_busy(struct platform_device *pdev); +void gk20a_channel_idle(struct platform_device *pdev); void gk20a_disable(struct gk20a *g, u32 units); void gk20a_enable(struct gk20a *g, u32 units); void gk20a_reset(struct gk20a *g, u32 units); diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c index 9ebc5bab..2d2cf220 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c @@ -301,7 +301,7 @@ static ssize_t elpg_enable_store(struct device *device, * Since elpg is refcounted, we should not unnecessarily call * enable/disable if it is already so. */ - err = gk20a_busy(g->dev); + err = gk20a_channel_busy(g->dev); if (err) return -EAGAIN; @@ -312,7 +312,7 @@ static ssize_t elpg_enable_store(struct device *device, g->elpg_enabled = false; gk20a_pmu_disable_elpg(g); } - gk20a_idle(g->dev); + gk20a_channel_idle(g->dev); dev_info(device, "ELPG is %s.\n", g->elpg_enabled ? "enabled" : "disabled"); -- cgit v1.2.2