From 5bac50c04406dd88bd4aad285601067620c540d4 Mon Sep 17 00:00:00 2001 From: Aingara Paramakuru Date: Mon, 3 Nov 2014 11:55:48 -0500 Subject: gpu: nvgpu: vgpu: debugger interface fixes To run CUDA apps, the following minimal changes have been made: - power-gating is disabled for vgpu - regop rd/wr returns -ENOSYS Tools (debugger/profiler) support is known to not work and not needed at this time. Bug 200043227 Change-Id: I923caad78450e72d310fb9290cf2849ed5460ad5 Signed-off-by: Aingara Paramakuru Reviewed-on: http://git-master/r/592878 Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c | 4 ++-- drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c | 8 +++++++- drivers/gpu/nvgpu/gk20a/gk20a.c | 8 +++++--- drivers/gpu/nvgpu/gk20a/gk20a.h | 16 +++++++++++----- drivers/gpu/nvgpu/gk20a/regops_gk20a.c | 11 +++++++++++ 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c index 3bcbdfd9..34351f93 100644 --- a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c @@ -258,7 +258,6 @@ long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg struct zbc_entry *zbc_val; struct zbc_query_params *zbc_tbl; int i, err = 0; - struct gk20a_platform *platform = platform_get_drvdata(dev); gk20a_dbg_fn(""); @@ -320,7 +319,8 @@ long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg case NVGPU_GPU_IOCTL_ZBC_SET_TABLE: set_table_args = (struct nvgpu_gpu_zbc_set_table_args *)buf; - if (platform->virtual_dev) + /* not supported for vgpu */ + if (gk20a_gpu_is_virtual(dev)) return -ENOMEM; zbc_val = kzalloc(sizeof(struct zbc_entry), GFP_KERNEL); diff --git a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c index bd24e269..72998280 100644 --- a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c @@ -90,6 +90,11 @@ static int gk20a_dbg_gpu_do_dev_open(struct inode *inode, dbg_session->g = g; dbg_session->is_profiler = is_profiler; dbg_session->is_pg_disabled = false; + /* For vgpu, all power-gating features are currently disabled + * in the server. Set is_pg_disable to true to reflect this + * on the client side. */ + if (gk20a_gpu_is_virtual(pdev)) + dbg_session->is_pg_disabled = true; INIT_LIST_HEAD(&dbg_session->dbg_s_list_node); init_waitqueue_head(&dbg_session->dbg_events.wait_queue); @@ -492,7 +497,8 @@ static int nvgpu_ioctl_channel_reg_ops(struct dbg_session_gk20a *dbg_s, } /* be sure that ctx info is in place */ - if (!gr_context_info_available(dbg_s, &g->gr)) { + if (!gk20a_gpu_is_virtual(dbg_s->pdev) && + !gr_context_info_available(dbg_s, &g->gr)) { gk20a_err(dev, "gr context data not available\n"); return -ENODEV; } diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c index 7b0db427..419b8675 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a.c @@ -1299,7 +1299,7 @@ static int gk20a_probe(struct platform_device *dev) platform_set_drvdata(dev, platform); - if (platform->virtual_dev) + if (gk20a_gpu_is_virtual(dev)) return vgpu_probe(dev); gk20a = kzalloc(sizeof(struct gk20a), GFP_KERNEL); @@ -1449,7 +1449,7 @@ static int __exit gk20a_remove(struct platform_device *dev) gk20a_dbg_fn(""); - if (platform->virtual_dev) + if (gk20a_gpu_is_virtual(dev)) return vgpu_remove(dev); if (platform->has_cde) @@ -1527,7 +1527,9 @@ int gk20a_busy(struct platform_device *pdev) { int ret = 0; struct gk20a *g = get_gk20a(pdev); +#ifdef CONFIG_PM_RUNTIME struct gk20a_platform *platform = gk20a_get_platform(pdev); +#endif down_read(&g->busy_lock); @@ -1549,7 +1551,7 @@ int gk20a_busy(struct platform_device *pdev) } #else if (!g->power_on) { - ret = platform->virtual_dev ? + ret = gk20a_gpu_is_virtual(pdev) ? vgpu_pm_finalize_poweron(&pdev->dev) : gk20a_pm_finalize_poweron(&pdev->dev); if (ret) diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index afe1447e..ca6a8ae0 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -713,15 +713,21 @@ enum { KEPLER_CHANNEL_GPFIFO_C = 0xA26F, }; +static inline bool gk20a_gpu_is_virtual(struct platform_device *dev) +{ + struct gk20a_platform *platform = gk20a_get_platform(dev); + + return platform->virtual_dev; +} + static inline int support_gk20a_pmu(struct platform_device *dev) { if (IS_ENABLED(CONFIG_GK20A_PMU)) { - struct gk20a_platform *platform = gk20a_get_platform(dev); + /* gPMU is not supported for vgpu */ + return !gk20a_gpu_is_virtual(dev); + } - /* we have not supported GPU PMU for virtualization now */ - return !platform->virtual_dev; - } else - return 0; + return 0; } void gk20a_create_sysfs(struct platform_device *dev); diff --git a/drivers/gpu/nvgpu/gk20a/regops_gk20a.c b/drivers/gpu/nvgpu/gk20a/regops_gk20a.c index fe444c78..cbdd1a55 100644 --- a/drivers/gpu/nvgpu/gk20a/regops_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/regops_gk20a.c @@ -392,6 +392,17 @@ int exec_regops_gk20a(struct dbg_session_gk20a *dbg_s, ch = dbg_s->ch; + /* For vgpu, the regops routines need to be handled in the + * context of the server and support for that does not exist. + * + * The two users of the regops interface are the compute driver + * and tools. The compute driver will work without a functional + * regops implementation, so we return -ENOSYS. This will allow + * compute apps to run with vgpu. Tools will not work in this + * configuration and are not required to work at this time. */ + if (gk20a_gpu_is_virtual(dbg_s->pdev)) + return -ENOSYS; + ok = g->allow_all || validate_reg_ops(dbg_s, &ctx_rd_count, &ctx_wr_count, ops, num_ops); -- cgit v1.2.2