mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: use devm variants to ioremap
While removing nvgpu driver, devm mapped reg mappings are released on driver_unregister. For iGPU, these regs are explicitly unmapped with iounmap(). This results in "Trying to vfree() nonexistent vm area" warnings on driver removal. Address this by using devm* variants to map all IO regions of both iGPU and dGPU and let the driver unregister release these mappings. Also, lock out GPU regs in driver removal path. Bug 1987855 Change-Id: I0388daf90bea3eaf8752255059cfd3ceabf66e7d Signed-off-by: Nitin Kumbhar <nkumbhar@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1730539 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
c8347c8369
commit
4b889fb8b0
@@ -606,7 +606,7 @@ static int gk20a_do_unidle(void *_g)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void __iomem *nvgpu_ioremap_resource(struct platform_device *dev, int i,
|
void __iomem *nvgpu_devm_ioremap_resource(struct platform_device *dev, int i,
|
||||||
struct resource **out)
|
struct resource **out)
|
||||||
{
|
{
|
||||||
struct resource *r = platform_get_resource(dev, IORESOURCE_MEM, i);
|
struct resource *r = platform_get_resource(dev, IORESOURCE_MEM, i);
|
||||||
@@ -618,6 +618,12 @@ void __iomem *nvgpu_ioremap_resource(struct platform_device *dev, int i,
|
|||||||
return devm_ioremap_resource(&dev->dev, r);
|
return devm_ioremap_resource(&dev->dev, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __iomem *nvgpu_devm_ioremap(struct device *dev, resource_size_t offset,
|
||||||
|
resource_size_t size)
|
||||||
|
{
|
||||||
|
return devm_ioremap(dev, offset, size);
|
||||||
|
}
|
||||||
|
|
||||||
static irqreturn_t gk20a_intr_isr_stall(int irq, void *dev_id)
|
static irqreturn_t gk20a_intr_isr_stall(int irq, void *dev_id)
|
||||||
{
|
{
|
||||||
struct gk20a *g = dev_id;
|
struct gk20a *g = dev_id;
|
||||||
@@ -673,30 +679,24 @@ void gk20a_remove_support(struct gk20a *g)
|
|||||||
sim_linux->remove_support_linux(g);
|
sim_linux->remove_support_linux(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free mappings to registers, etc */
|
|
||||||
if (l->regs) {
|
|
||||||
iounmap(l->regs);
|
|
||||||
l->regs = NULL;
|
|
||||||
}
|
|
||||||
if (l->bar1) {
|
|
||||||
iounmap(l->bar1);
|
|
||||||
l->bar1 = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
nvgpu_remove_usermode_support(g);
|
nvgpu_remove_usermode_support(g);
|
||||||
|
|
||||||
nvgpu_free_enabled_flags(g);
|
nvgpu_free_enabled_flags(g);
|
||||||
|
|
||||||
|
gk20a_lockout_registers(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gk20a_init_support(struct platform_device *dev)
|
static int gk20a_init_support(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
int err = -ENOMEM;
|
struct device *dev = &pdev->dev;
|
||||||
struct gk20a *g = get_gk20a(&dev->dev);
|
struct gk20a *g = get_gk20a(dev);
|
||||||
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
|
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
|
||||||
|
int err = -ENOMEM;
|
||||||
|
|
||||||
tegra_register_idle_unidle(gk20a_do_idle, gk20a_do_unidle, g);
|
tegra_register_idle_unidle(gk20a_do_idle, gk20a_do_unidle, g);
|
||||||
|
|
||||||
l->regs = nvgpu_ioremap_resource(dev, GK20A_BAR0_IORESOURCE_MEM,
|
l->regs = nvgpu_devm_ioremap_resource(pdev,
|
||||||
|
GK20A_BAR0_IORESOURCE_MEM,
|
||||||
&l->reg_mem);
|
&l->reg_mem);
|
||||||
if (IS_ERR(l->regs)) {
|
if (IS_ERR(l->regs)) {
|
||||||
nvgpu_err(g, "failed to remap gk20a registers");
|
nvgpu_err(g, "failed to remap gk20a registers");
|
||||||
@@ -704,7 +704,8 @@ static int gk20a_init_support(struct platform_device *dev)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
l->bar1 = nvgpu_ioremap_resource(dev, GK20A_BAR1_IORESOURCE_MEM,
|
l->bar1 = nvgpu_devm_ioremap_resource(pdev,
|
||||||
|
GK20A_BAR1_IORESOURCE_MEM,
|
||||||
&l->bar1_mem);
|
&l->bar1_mem);
|
||||||
if (IS_ERR(l->bar1)) {
|
if (IS_ERR(l->bar1)) {
|
||||||
nvgpu_err(g, "failed to remap gk20a bar1");
|
nvgpu_err(g, "failed to remap gk20a bar1");
|
||||||
@@ -712,7 +713,7 @@ static int gk20a_init_support(struct platform_device *dev)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = nvgpu_init_sim_support_linux(g, dev);
|
err = nvgpu_init_sim_support_linux(g, pdev);
|
||||||
if (err)
|
if (err)
|
||||||
goto fail;
|
goto fail;
|
||||||
err = nvgpu_init_sim_support(g);
|
err = nvgpu_init_sim_support(g);
|
||||||
@@ -725,14 +726,11 @@ static int gk20a_init_support(struct platform_device *dev)
|
|||||||
fail_sim:
|
fail_sim:
|
||||||
nvgpu_remove_sim_support_linux(g);
|
nvgpu_remove_sim_support_linux(g);
|
||||||
fail:
|
fail:
|
||||||
if (l->regs) {
|
if (l->regs)
|
||||||
iounmap(l->regs);
|
|
||||||
l->regs = NULL;
|
l->regs = NULL;
|
||||||
}
|
|
||||||
if (l->bar1) {
|
if (l->bar1)
|
||||||
iounmap(l->bar1);
|
|
||||||
l->bar1 = NULL;
|
l->bar1 = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,10 @@ int nvgpu_quiesce(struct gk20a *g);
|
|||||||
int nvgpu_remove(struct device *dev, struct class *class);
|
int nvgpu_remove(struct device *dev, struct class *class);
|
||||||
void nvgpu_free_irq(struct gk20a *g);
|
void nvgpu_free_irq(struct gk20a *g);
|
||||||
struct device_node *nvgpu_get_node(struct gk20a *g);
|
struct device_node *nvgpu_get_node(struct gk20a *g);
|
||||||
void __iomem *nvgpu_ioremap_resource(struct platform_device *dev, int i,
|
void __iomem *nvgpu_devm_ioremap_resource(struct platform_device *dev, int i,
|
||||||
struct resource **out);
|
struct resource **out);
|
||||||
|
void __iomem *nvgpu_devm_ioremap(struct device *dev, resource_size_t offset,
|
||||||
|
resource_size_t size);
|
||||||
extern struct class nvgpu_class;
|
extern struct class nvgpu_class;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -525,8 +525,9 @@ static int nvgpu_pci_init_support(struct pci_dev *pdev)
|
|||||||
int err = 0;
|
int err = 0;
|
||||||
struct gk20a *g = get_gk20a(&pdev->dev);
|
struct gk20a *g = get_gk20a(&pdev->dev);
|
||||||
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
|
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
|
||||||
|
struct device *dev = &pdev->dev;
|
||||||
|
|
||||||
l->regs = ioremap(pci_resource_start(pdev, 0),
|
l->regs = nvgpu_devm_ioremap(dev, pci_resource_start(pdev, 0),
|
||||||
pci_resource_len(pdev, 0));
|
pci_resource_len(pdev, 0));
|
||||||
if (IS_ERR(l->regs)) {
|
if (IS_ERR(l->regs)) {
|
||||||
nvgpu_err(g, "failed to remap gk20a registers");
|
nvgpu_err(g, "failed to remap gk20a registers");
|
||||||
@@ -534,7 +535,7 @@ static int nvgpu_pci_init_support(struct pci_dev *pdev)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
l->bar1 = ioremap(pci_resource_start(pdev, 1),
|
l->bar1 = nvgpu_devm_ioremap(dev, pci_resource_start(pdev, 1),
|
||||||
pci_resource_len(pdev, 1));
|
pci_resource_len(pdev, 1));
|
||||||
if (IS_ERR(l->bar1)) {
|
if (IS_ERR(l->bar1)) {
|
||||||
nvgpu_err(g, "failed to remap gk20a bar1");
|
nvgpu_err(g, "failed to remap gk20a bar1");
|
||||||
@@ -556,14 +557,11 @@ static int nvgpu_pci_init_support(struct pci_dev *pdev)
|
|||||||
fail_sim:
|
fail_sim:
|
||||||
nvgpu_remove_sim_support_linux_pci(g);
|
nvgpu_remove_sim_support_linux_pci(g);
|
||||||
fail:
|
fail:
|
||||||
if (l->regs) {
|
if (l->regs)
|
||||||
iounmap(l->regs);
|
|
||||||
l->regs = NULL;
|
l->regs = NULL;
|
||||||
}
|
|
||||||
if (l->bar1) {
|
if (l->bar1)
|
||||||
iounmap(l->bar1);
|
|
||||||
l->bar1 = NULL;
|
l->bar1 = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ int nvgpu_init_sim_support_linux(struct gk20a *g,
|
|||||||
return err;
|
return err;
|
||||||
g->sim = &sim_linux->sim;
|
g->sim = &sim_linux->sim;
|
||||||
g->sim->g = g;
|
g->sim->g = g;
|
||||||
sim_linux->regs = nvgpu_ioremap_resource(dev,
|
sim_linux->regs = nvgpu_devm_ioremap_resource(dev,
|
||||||
GK20A_SIM_IORESOURCE_MEM,
|
GK20A_SIM_IORESOURCE_MEM,
|
||||||
&sim_linux->reg_mem);
|
&sim_linux->reg_mem);
|
||||||
if (IS_ERR(sim_linux->regs)) {
|
if (IS_ERR(sim_linux->regs)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user