summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/linux/module.c
diff options
context:
space:
mode:
authorDebarshi Dutta <ddutta@nvidia.com>2017-11-22 02:50:19 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2017-11-29 01:50:27 -0500
commit312f6c2c5f8b2ad6ab95300896ec4e7be9d5f833 (patch)
treec9a9148202fdd4f8487097d37d81c29efef6f66c /drivers/gpu/nvgpu/common/linux/module.c
parent830d3f10ca1f3d8a045542ef4548c84440a8e548 (diff)
gpu: nvgpu: remove dependency on linux header for sim_gk20a*
This patch removes linux dependencies from sim_gk20a.h under gk20a/sim_gk20a.h. The following changes are made in this patch. 1) Created a linux based structure sim_gk20a_linux that contains a common sim_gk20a struct inside it. The common struct sim_gk20a doesn't contain any linux specific structs. 2) The common struct sim_gk20a contains an added function pointer which is used to invoke gk20a_sim_esc_readl() method. 3) sim_gk20a.c is moved to nvgpu/common/linux along with a new header sim_gk20a.h that contains the definition of struct sim_gk20a_linux. 4) struct gk20a now contains a pointer of sim_gk20a instead of the entire object. The memory for this struct is allocated and initialized during gk20a_init_support() and freed during invocation of gk20_remove_support(). 5) We first obtain the pointer for struct sim_gk20a_linux from the pointer of sim_gk20a using the container_of method in order to work on the struct. JIRA NVGPU-386 Change-Id: Ic82b8702642377f82694577a53c3ca0b9c1bb2ab Signed-off-by: Debarshi Dutta <ddutta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1603073 GVS: Gerrit_Virtual_Submit Reviewed-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/module.c')
-rw-r--r--drivers/gpu/nvgpu/common/linux/module.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/module.c b/drivers/gpu/nvgpu/common/linux/module.c
index 4af62d5f..950b1581 100644
--- a/drivers/gpu/nvgpu/common/linux/module.c
+++ b/drivers/gpu/nvgpu/common/linux/module.c
@@ -47,6 +47,7 @@
47#include "intr.h" 47#include "intr.h"
48#include "cde.h" 48#include "cde.h"
49#include "ioctl.h" 49#include "ioctl.h"
50#include "sim_gk20a.h"
50#ifdef CONFIG_TEGRA_19x_GPU 51#ifdef CONFIG_TEGRA_19x_GPU
51#include "nvgpu_gpuid_t19x.h" 52#include "nvgpu_gpuid_t19x.h"
52#ifdef CONFIG_TEGRA_GR_VIRTUALIZATION 53#ifdef CONFIG_TEGRA_GR_VIRTUALIZATION
@@ -637,11 +638,10 @@ void gk20a_remove_support(struct gk20a *g)
637 if (g->mm.remove_support) 638 if (g->mm.remove_support)
638 g->mm.remove_support(&g->mm); 639 g->mm.remove_support(&g->mm);
639 640
640 if (g->sim.remove_support) 641 if (g->sim->remove_support)
641 g->sim.remove_support(&g->sim); 642 g->sim->remove_support(g->sim);
642 643
643 /* free mappings to registers, etc */ 644 /* free mappings to registers, etc */
644
645 if (l->regs) { 645 if (l->regs) {
646 iounmap(l->regs); 646 iounmap(l->regs);
647 l->regs = NULL; 647 l->regs = NULL;
@@ -661,6 +661,11 @@ static int gk20a_init_support(struct platform_device *dev)
661 int err = 0; 661 int err = 0;
662 struct gk20a *g = get_gk20a(&dev->dev); 662 struct gk20a *g = get_gk20a(&dev->dev);
663 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); 663 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
664 struct sim_gk20a_linux *sim_linux = nvgpu_kzalloc(g, sizeof(*sim_linux));
665 if (!sim_linux)
666 goto fail;
667
668 g->sim = &sim_linux->sim;
664 669
665 tegra_register_idle_unidle(gk20a_do_idle, gk20a_do_unidle, g); 670 tegra_register_idle_unidle(gk20a_do_idle, gk20a_do_unidle, g);
666 671
@@ -681,13 +686,13 @@ static int gk20a_init_support(struct platform_device *dev)
681 } 686 }
682 687
683 if (nvgpu_platform_is_simulation(g)) { 688 if (nvgpu_platform_is_simulation(g)) {
684 g->sim.g = g; 689 g->sim->g = g;
685 g->sim.regs = gk20a_ioremap_resource(dev, 690 sim_linux->regs = gk20a_ioremap_resource(dev,
686 GK20A_SIM_IORESOURCE_MEM, 691 GK20A_SIM_IORESOURCE_MEM,
687 &g->sim.reg_mem); 692 &sim_linux->reg_mem);
688 if (IS_ERR(g->sim.regs)) { 693 if (IS_ERR(sim_linux->regs)) {
689 nvgpu_err(g, "failed to remap gk20a sim regs"); 694 nvgpu_err(g, "failed to remap gk20a sim regs");
690 err = PTR_ERR(g->sim.regs); 695 err = PTR_ERR(sim_linux->regs);
691 goto fail; 696 goto fail;
692 } 697 }
693 698
@@ -703,6 +708,8 @@ static int gk20a_init_support(struct platform_device *dev)
703 return 0; 708 return 0;
704 709
705fail: 710fail:
711 nvgpu_kfree(g, sim_linux);
712 g->sim = NULL;
706 return err; 713 return err;
707} 714}
708 715