From 1fd722f592c2e0523c5e399a2406a4e387057188 Mon Sep 17 00:00:00 2001 From: Aingara Paramakuru Date: Mon, 5 May 2014 21:14:22 -0400 Subject: gpu: nvgpu: support gk20a virtualization The nvgpu driver now supports using the Tegra graphics virtualization interfaces to support gk20a in a virtualized environment. Bug 1509608 Change-Id: I6ede15ee7bf0b0ad8a13e8eb5f557c3516ead676 Signed-off-by: Aingara Paramakuru Reviewed-on: http://git-master/r/440122 Reviewed-by: Terje Bergstrom Tested-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/gk20a.c | 46 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a/gk20a.c') diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c index 0816878a..3499cc89 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -57,6 +58,9 @@ #include "dbg_gpu_gk20a.h" #include "hal.h" #include "nvhost_acm.h" +#ifdef CONFIG_TEGRA_GR_VIRTUALIZATION +#include "vgpu/vgpu.h" +#endif #define CREATE_TRACE_POINTS #include @@ -737,6 +741,17 @@ static int gk20a_init_client(struct platform_device *dev) gk20a_dbg_fn(""); +#ifdef CONFIG_TEGRA_GR_VIRTUALIZATION + { + struct gk20a_platform *platform = gk20a_get_platform(dev); + + if (platform->virtual_dev) { + err = vgpu_pm_finalize_poweron(&dev->dev); + if (err) + return err; + } + } +#endif #ifndef CONFIG_PM_RUNTIME gk20a_pm_finalize_poweron(&dev->dev); #endif @@ -753,6 +768,16 @@ static int gk20a_init_client(struct platform_device *dev) static void gk20a_deinit_client(struct platform_device *dev) { gk20a_dbg_fn(""); +#ifdef CONFIG_TEGRA_GR_VIRTUALIZATION + { + struct gk20a_platform *platform = gk20a_get_platform(dev); + + if (platform->virtual_dev) { + vgpu_pm_prepare_poweroff(&dev->dev); + return; + } + } +#endif #ifndef CONFIG_PM_RUNTIME gk20a_pm_prepare_poweroff(&dev->dev); #endif @@ -1006,6 +1031,10 @@ static struct of_device_id tegra_gk20a_of_match[] = { .data = &gk20a_tegra_platform }, { .compatible = "nvidia,tegra210-gm20b", .data = &gm20b_tegra_platform }, +#ifdef CONFIG_TEGRA_GR_VIRTUALIZATION + { .compatible = "nvidia,tegra124-gk20a-vgpu", + .data = &vgpu_tegra_platform }, +#endif #else { .compatible = "nvidia,tegra124-gk20a", .data = &gk20a_generic_platform }, @@ -1057,7 +1086,7 @@ static int gk20a_create_device( return 0; } -static void gk20a_user_deinit(struct platform_device *dev) +void gk20a_user_deinit(struct platform_device *dev) { struct gk20a *g = get_gk20a(dev); @@ -1098,7 +1127,7 @@ static void gk20a_user_deinit(struct platform_device *dev) class_destroy(g->class); } -static int gk20a_user_init(struct platform_device *dev) +int gk20a_user_init(struct platform_device *dev) { int err; dev_t devno; @@ -1403,6 +1432,11 @@ static int gk20a_probe(struct platform_device *dev) platform_set_drvdata(dev, platform); +#ifdef CONFIG_TEGRA_GR_VIRTUALIZATION + if (platform->virtual_dev) + return vgpu_probe(dev); +#endif + gk20a = kzalloc(sizeof(struct gk20a), GFP_KERNEL); if (!gk20a) { dev_err(&dev->dev, "couldn't allocate gk20a support"); @@ -1546,8 +1580,16 @@ static int gk20a_probe(struct platform_device *dev) static int __exit gk20a_remove(struct platform_device *dev) { struct gk20a *g = get_gk20a(dev); +#ifdef CONFIG_TEGRA_GR_VIRTUALIZATION + struct gk20a_platform *platform = gk20a_get_platform(dev); +#endif gk20a_dbg_fn(""); +#ifdef CONFIG_TEGRA_GR_VIRTUALIZATION + if (platform->virtual_dev) + return vgpu_remove(dev); +#endif + #ifdef CONFIG_INPUT_CFBOOST if (g->boost_added) cfb_remove_device(&dev->dev); -- cgit v1.2.2