mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 02:22:34 +03:00
gpu: nvgpu: Use a callback to free struct gk20a
struct gk20a is now part of nvgpu_os_linux in Linux builds. gk20a.c still frees struct gk20a by kfree(struct gk20a *), which is wrong. Create a new function pointer in struct gk20a for freeing the structure and call kfree(struct nvgpu_os_linux *) instead. JIRA NVGPU-259 Change-Id: I412ee993002cb2a42f0db015fc676de43418ec2f Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1591012 GVS: Gerrit_Virtual_Submit Reviewed-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
9f5f029ae2
commit
1e7ba4c76d
@@ -274,3 +274,15 @@ void nvgpu_wait_for_deferred_interrupts(struct gk20a *g)
|
|||||||
atomic_read(&l->sw_irq_nonstall_last_handled))
|
atomic_read(&l->sw_irq_nonstall_last_handled))
|
||||||
<= 0, 0);
|
<= 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void nvgpu_free_gk20a(struct gk20a *g)
|
||||||
|
{
|
||||||
|
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
|
||||||
|
|
||||||
|
kfree(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
void nvgpu_init_gk20a(struct gk20a *g)
|
||||||
|
{
|
||||||
|
g->free = nvgpu_free_gk20a;
|
||||||
|
}
|
||||||
|
|||||||
22
drivers/gpu/nvgpu/common/linux/driver_common.h
Normal file
22
drivers/gpu/nvgpu/common/linux/driver_common.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms and conditions of the GNU General Public License,
|
||||||
|
* version 2, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NVGPU_LINUX_DRIVER_COMMON
|
||||||
|
#define NVGPU_LINUX_DRIVER_COMMON
|
||||||
|
|
||||||
|
void nvgpu_init_gk20a(struct gk20a *g);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -53,6 +53,7 @@
|
|||||||
#include "cde_gm20b.h"
|
#include "cde_gm20b.h"
|
||||||
#include "cde_gp10b.h"
|
#include "cde_gp10b.h"
|
||||||
#include "ctxsw_trace.h"
|
#include "ctxsw_trace.h"
|
||||||
|
#include "driver_common.h"
|
||||||
|
|
||||||
#define CLASS_NAME "nvidia-gpu"
|
#define CLASS_NAME "nvidia-gpu"
|
||||||
/* TODO: Change to e.g. "nvidia-gpu%s" once we have symlinks in place. */
|
/* TODO: Change to e.g. "nvidia-gpu%s" once we have symlinks in place. */
|
||||||
@@ -1027,6 +1028,7 @@ static int gk20a_probe(struct platform_device *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gk20a = &l->g;
|
gk20a = &l->g;
|
||||||
|
nvgpu_init_gk20a(gk20a);
|
||||||
set_gk20a(dev, gk20a);
|
set_gk20a(dev, gk20a);
|
||||||
l->dev = &dev->dev;
|
l->dev = &dev->dev;
|
||||||
gk20a->log_mask = NVGPU_DEFAULT_DBG_MASK;
|
gk20a->log_mask = NVGPU_DEFAULT_DBG_MASK;
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "os_linux.h"
|
#include "os_linux.h"
|
||||||
|
#include "driver_common.h"
|
||||||
|
|
||||||
#define PCI_INTERFACE_NAME "card-%s%%s"
|
#define PCI_INTERFACE_NAME "card-%s%%s"
|
||||||
|
|
||||||
@@ -457,6 +458,7 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
g = &l->g;
|
g = &l->g;
|
||||||
|
nvgpu_init_gk20a(g);
|
||||||
|
|
||||||
nvgpu_kmem_init(g);
|
nvgpu_kmem_init(g);
|
||||||
|
|
||||||
|
|||||||
@@ -518,7 +518,8 @@ static void gk20a_free_cb(struct nvgpu_ref *refcount)
|
|||||||
if (g->remove_support)
|
if (g->remove_support)
|
||||||
g->remove_support(g);
|
g->remove_support(g);
|
||||||
|
|
||||||
kfree(g);
|
if (g->free)
|
||||||
|
g->free(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1070,6 +1070,7 @@ struct nvgpu_gpu_params {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct gk20a {
|
struct gk20a {
|
||||||
|
void (*free)(struct gk20a *g);
|
||||||
struct nvgpu_nvhost_dev *nvhost_dev;
|
struct nvgpu_nvhost_dev *nvhost_dev;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
#include "common/linux/os_linux.h"
|
#include "common/linux/os_linux.h"
|
||||||
#include "common/linux/ioctl.h"
|
#include "common/linux/ioctl.h"
|
||||||
#include "common/linux/scale.h"
|
#include "common/linux/scale.h"
|
||||||
|
#include "common/linux/driver_common.h"
|
||||||
|
|
||||||
#ifdef CONFIG_TEGRA_19x_GPU
|
#ifdef CONFIG_TEGRA_19x_GPU
|
||||||
#include <vgpu/vgpu_t19x.h>
|
#include <vgpu/vgpu_t19x.h>
|
||||||
@@ -657,6 +658,7 @@ int vgpu_probe(struct platform_device *pdev)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
gk20a = &l->g;
|
gk20a = &l->g;
|
||||||
|
nvgpu_init_gk20a(gk20a);
|
||||||
|
|
||||||
nvgpu_kmem_init(gk20a);
|
nvgpu_kmem_init(gk20a);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user