From 312f6c2c5f8b2ad6ab95300896ec4e7be9d5f833 Mon Sep 17 00:00:00 2001 From: Debarshi Dutta Date: Wed, 22 Nov 2017 13:20:19 +0530 Subject: 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 Reviewed-on: https://git-master.nvidia.com/r/1603073 GVS: Gerrit_Virtual_Submit Reviewed-by: Deepak Nibade Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/module.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'drivers/gpu/nvgpu/common/linux/module.c') 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 @@ #include "intr.h" #include "cde.h" #include "ioctl.h" +#include "sim_gk20a.h" #ifdef CONFIG_TEGRA_19x_GPU #include "nvgpu_gpuid_t19x.h" #ifdef CONFIG_TEGRA_GR_VIRTUALIZATION @@ -637,11 +638,10 @@ void gk20a_remove_support(struct gk20a *g) if (g->mm.remove_support) g->mm.remove_support(&g->mm); - if (g->sim.remove_support) - g->sim.remove_support(&g->sim); + if (g->sim->remove_support) + g->sim->remove_support(g->sim); /* free mappings to registers, etc */ - if (l->regs) { iounmap(l->regs); l->regs = NULL; @@ -661,6 +661,11 @@ static int gk20a_init_support(struct platform_device *dev) int err = 0; struct gk20a *g = get_gk20a(&dev->dev); struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); + struct sim_gk20a_linux *sim_linux = nvgpu_kzalloc(g, sizeof(*sim_linux)); + if (!sim_linux) + goto fail; + + g->sim = &sim_linux->sim; tegra_register_idle_unidle(gk20a_do_idle, gk20a_do_unidle, g); @@ -681,13 +686,13 @@ static int gk20a_init_support(struct platform_device *dev) } if (nvgpu_platform_is_simulation(g)) { - g->sim.g = g; - g->sim.regs = gk20a_ioremap_resource(dev, + g->sim->g = g; + sim_linux->regs = gk20a_ioremap_resource(dev, GK20A_SIM_IORESOURCE_MEM, - &g->sim.reg_mem); - if (IS_ERR(g->sim.regs)) { + &sim_linux->reg_mem); + if (IS_ERR(sim_linux->regs)) { nvgpu_err(g, "failed to remap gk20a sim regs"); - err = PTR_ERR(g->sim.regs); + err = PTR_ERR(sim_linux->regs); goto fail; } @@ -703,6 +708,8 @@ static int gk20a_init_support(struct platform_device *dev) return 0; fail: + nvgpu_kfree(g, sim_linux); + g->sim = NULL; return err; } -- cgit v1.2.2