summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/os/linux/module.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/os/linux/module.c')
-rw-r--r--drivers/gpu/nvgpu/os/linux/module.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/drivers/gpu/nvgpu/os/linux/module.c b/drivers/gpu/nvgpu/os/linux/module.c
index 2df8ab42..28ade90f 100644
--- a/drivers/gpu/nvgpu/os/linux/module.c
+++ b/drivers/gpu/nvgpu/os/linux/module.c
@@ -606,8 +606,8 @@ static int gk20a_do_unidle(void *_g)
606} 606}
607#endif 607#endif
608 608
609void __iomem *nvgpu_ioremap_resource(struct platform_device *dev, int i, 609void __iomem *nvgpu_devm_ioremap_resource(struct platform_device *dev, int i,
610 struct resource **out) 610 struct resource **out)
611{ 611{
612 struct resource *r = platform_get_resource(dev, IORESOURCE_MEM, i); 612 struct resource *r = platform_get_resource(dev, IORESOURCE_MEM, i);
613 613
@@ -618,6 +618,12 @@ void __iomem *nvgpu_ioremap_resource(struct platform_device *dev, int i,
618 return devm_ioremap_resource(&dev->dev, r); 618 return devm_ioremap_resource(&dev->dev, r);
619} 619}
620 620
621void __iomem *nvgpu_devm_ioremap(struct device *dev, resource_size_t offset,
622 resource_size_t size)
623{
624 return devm_ioremap(dev, offset, size);
625}
626
621static irqreturn_t gk20a_intr_isr_stall(int irq, void *dev_id) 627static irqreturn_t gk20a_intr_isr_stall(int irq, void *dev_id)
622{ 628{
623 struct gk20a *g = dev_id; 629 struct gk20a *g = dev_id;
@@ -673,46 +679,41 @@ void gk20a_remove_support(struct gk20a *g)
673 sim_linux->remove_support_linux(g); 679 sim_linux->remove_support_linux(g);
674 } 680 }
675 681
676 /* free mappings to registers, etc */
677 if (l->regs) {
678 iounmap(l->regs);
679 l->regs = NULL;
680 }
681 if (l->bar1) {
682 iounmap(l->bar1);
683 l->bar1 = NULL;
684 }
685
686 nvgpu_remove_usermode_support(g); 682 nvgpu_remove_usermode_support(g);
687 683
688 nvgpu_free_enabled_flags(g); 684 nvgpu_free_enabled_flags(g);
685
686 gk20a_lockout_registers(g);
689} 687}
690 688
691static int gk20a_init_support(struct platform_device *dev) 689static int gk20a_init_support(struct platform_device *pdev)
692{ 690{
693 int err = -ENOMEM; 691 struct device *dev = &pdev->dev;
694 struct gk20a *g = get_gk20a(&dev->dev); 692 struct gk20a *g = get_gk20a(dev);
695 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); 693 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
694 int err = -ENOMEM;
696 695
697 tegra_register_idle_unidle(gk20a_do_idle, gk20a_do_unidle, g); 696 tegra_register_idle_unidle(gk20a_do_idle, gk20a_do_unidle, g);
698 697
699 l->regs = nvgpu_ioremap_resource(dev, GK20A_BAR0_IORESOURCE_MEM, 698 l->regs = nvgpu_devm_ioremap_resource(pdev,
700 &l->reg_mem); 699 GK20A_BAR0_IORESOURCE_MEM,
700 &l->reg_mem);
701 if (IS_ERR(l->regs)) { 701 if (IS_ERR(l->regs)) {
702 nvgpu_err(g, "failed to remap gk20a registers"); 702 nvgpu_err(g, "failed to remap gk20a registers");
703 err = PTR_ERR(l->regs); 703 err = PTR_ERR(l->regs);
704 goto fail; 704 goto fail;
705 } 705 }
706 706
707 l->bar1 = nvgpu_ioremap_resource(dev, GK20A_BAR1_IORESOURCE_MEM, 707 l->bar1 = nvgpu_devm_ioremap_resource(pdev,
708 &l->bar1_mem); 708 GK20A_BAR1_IORESOURCE_MEM,
709 &l->bar1_mem);
709 if (IS_ERR(l->bar1)) { 710 if (IS_ERR(l->bar1)) {
710 nvgpu_err(g, "failed to remap gk20a bar1"); 711 nvgpu_err(g, "failed to remap gk20a bar1");
711 err = PTR_ERR(l->bar1); 712 err = PTR_ERR(l->bar1);
712 goto fail; 713 goto fail;
713 } 714 }
714 715
715 err = nvgpu_init_sim_support_linux(g, dev); 716 err = nvgpu_init_sim_support_linux(g, pdev);
716 if (err) 717 if (err)
717 goto fail; 718 goto fail;
718 err = nvgpu_init_sim_support(g); 719 err = nvgpu_init_sim_support(g);
@@ -725,14 +726,11 @@ static int gk20a_init_support(struct platform_device *dev)
725fail_sim: 726fail_sim:
726 nvgpu_remove_sim_support_linux(g); 727 nvgpu_remove_sim_support_linux(g);
727fail: 728fail:
728 if (l->regs) { 729 if (l->regs)
729 iounmap(l->regs);
730 l->regs = NULL; 730 l->regs = NULL;
731 } 731
732 if (l->bar1) { 732 if (l->bar1)
733 iounmap(l->bar1);
734 l->bar1 = NULL; 733 l->bar1 = NULL;
735 }
736 734
737 return err; 735 return err;
738} 736}