diff options
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a.c | 327 |
1 files changed, 160 insertions, 167 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c index f2e6a683..f3bf0517 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a.c | |||
@@ -44,10 +44,6 @@ | |||
44 | 44 | ||
45 | #include <linux/sched.h> | 45 | #include <linux/sched.h> |
46 | 46 | ||
47 | #ifdef CONFIG_TEGRA_GK20A | ||
48 | #include <linux/nvhost.h> | ||
49 | #endif | ||
50 | |||
51 | #include "gk20a.h" | 47 | #include "gk20a.h" |
52 | #include "debug_gk20a.h" | 48 | #include "debug_gk20a.h" |
53 | #include "ctrl_gk20a.h" | 49 | #include "ctrl_gk20a.h" |
@@ -79,7 +75,6 @@ | |||
79 | 75 | ||
80 | #define CLASS_NAME "nvidia-gpu" | 76 | #define CLASS_NAME "nvidia-gpu" |
81 | /* TODO: Change to e.g. "nvidia-gpu%s" once we have symlinks in place. */ | 77 | /* TODO: Change to e.g. "nvidia-gpu%s" once we have symlinks in place. */ |
82 | #define INTERFACE_NAME "nvhost%s-gpu" | ||
83 | 78 | ||
84 | #define GK20A_NUM_CDEVS 7 | 79 | #define GK20A_NUM_CDEVS 7 |
85 | 80 | ||
@@ -92,12 +87,11 @@ u32 gk20a_dbg_ftrace; | |||
92 | 87 | ||
93 | #define GK20A_WAIT_FOR_IDLE_MS 2000 | 88 | #define GK20A_WAIT_FOR_IDLE_MS 2000 |
94 | 89 | ||
95 | static int gk20a_pm_finalize_poweron(struct device *dev); | ||
96 | static int gk20a_pm_prepare_poweroff(struct device *dev); | 90 | static int gk20a_pm_prepare_poweroff(struct device *dev); |
97 | 91 | ||
98 | static inline void set_gk20a(struct platform_device *dev, struct gk20a *gk20a) | 92 | static inline void set_gk20a(struct platform_device *pdev, struct gk20a *gk20a) |
99 | { | 93 | { |
100 | gk20a_get_platform(dev)->g = gk20a; | 94 | gk20a_get_platform(&pdev->dev)->g = gk20a; |
101 | } | 95 | } |
102 | 96 | ||
103 | static const struct file_operations gk20a_channel_ops = { | 97 | static const struct file_operations gk20a_channel_ops = { |
@@ -292,38 +286,38 @@ static void __iomem *gk20a_ioremap_resource(struct platform_device *dev, int i, | |||
292 | } | 286 | } |
293 | 287 | ||
294 | /* TBD: strip from released */ | 288 | /* TBD: strip from released */ |
295 | static int gk20a_init_sim_support(struct platform_device *dev) | 289 | static int gk20a_init_sim_support(struct platform_device *pdev) |
296 | { | 290 | { |
297 | int err = 0; | 291 | int err = 0; |
292 | struct device *dev = &pdev->dev; | ||
298 | struct gk20a *g = get_gk20a(dev); | 293 | struct gk20a *g = get_gk20a(dev); |
299 | struct device *d = &dev->dev; | ||
300 | u64 phys; | 294 | u64 phys; |
301 | 295 | ||
302 | g->sim.g = g; | 296 | g->sim.g = g; |
303 | g->sim.regs = gk20a_ioremap_resource(dev, GK20A_SIM_IORESOURCE_MEM, | 297 | g->sim.regs = gk20a_ioremap_resource(pdev, GK20A_SIM_IORESOURCE_MEM, |
304 | &g->sim.reg_mem); | 298 | &g->sim.reg_mem); |
305 | if (IS_ERR(g->sim.regs)) { | 299 | if (IS_ERR(g->sim.regs)) { |
306 | dev_err(d, "failed to remap gk20a sim regs\n"); | 300 | dev_err(dev, "failed to remap gk20a sim regs\n"); |
307 | err = PTR_ERR(g->sim.regs); | 301 | err = PTR_ERR(g->sim.regs); |
308 | goto fail; | 302 | goto fail; |
309 | } | 303 | } |
310 | 304 | ||
311 | /* allocate sim event/msg buffers */ | 305 | /* allocate sim event/msg buffers */ |
312 | err = alloc_and_kmap_iopage(d, &g->sim.send_bfr.kvaddr, | 306 | err = alloc_and_kmap_iopage(dev, &g->sim.send_bfr.kvaddr, |
313 | &g->sim.send_bfr.phys, | 307 | &g->sim.send_bfr.phys, |
314 | &g->sim.send_bfr.page); | 308 | &g->sim.send_bfr.page); |
315 | 309 | ||
316 | err = err || alloc_and_kmap_iopage(d, &g->sim.recv_bfr.kvaddr, | 310 | err = err || alloc_and_kmap_iopage(dev, &g->sim.recv_bfr.kvaddr, |
317 | &g->sim.recv_bfr.phys, | 311 | &g->sim.recv_bfr.phys, |
318 | &g->sim.recv_bfr.page); | 312 | &g->sim.recv_bfr.page); |
319 | 313 | ||
320 | err = err || alloc_and_kmap_iopage(d, &g->sim.msg_bfr.kvaddr, | 314 | err = err || alloc_and_kmap_iopage(dev, &g->sim.msg_bfr.kvaddr, |
321 | &g->sim.msg_bfr.phys, | 315 | &g->sim.msg_bfr.phys, |
322 | &g->sim.msg_bfr.page); | 316 | &g->sim.msg_bfr.page); |
323 | 317 | ||
324 | if (!(g->sim.send_bfr.kvaddr && g->sim.recv_bfr.kvaddr && | 318 | if (!(g->sim.send_bfr.kvaddr && g->sim.recv_bfr.kvaddr && |
325 | g->sim.msg_bfr.kvaddr)) { | 319 | g->sim.msg_bfr.kvaddr)) { |
326 | dev_err(d, "couldn't allocate all sim buffers\n"); | 320 | dev_err(dev, "couldn't allocate all sim buffers\n"); |
327 | goto fail; | 321 | goto fail; |
328 | } | 322 | } |
329 | 323 | ||
@@ -566,25 +560,25 @@ void gk20a_pbus_isr(struct gk20a *g) | |||
566 | gk20a_err(dev_from_gk20a(g), "pmc_enable : 0x%x", | 560 | gk20a_err(dev_from_gk20a(g), "pmc_enable : 0x%x", |
567 | gk20a_readl(g, mc_enable_r())); | 561 | gk20a_readl(g, mc_enable_r())); |
568 | gk20a_err(dev_from_gk20a(g), "NV_PBUS_INTR_0 : 0x%x", val); | 562 | gk20a_err(dev_from_gk20a(g), "NV_PBUS_INTR_0 : 0x%x", val); |
569 | gk20a_err(&g->dev->dev, | 563 | gk20a_err(g->dev, |
570 | "NV_PTIMER_PRI_TIMEOUT_SAVE_0: 0x%x\n", | 564 | "NV_PTIMER_PRI_TIMEOUT_SAVE_0: 0x%x\n", |
571 | gk20a_readl(g, timer_pri_timeout_save_0_r())); | 565 | gk20a_readl(g, timer_pri_timeout_save_0_r())); |
572 | gk20a_err(&g->dev->dev, | 566 | gk20a_err(g->dev, |
573 | "NV_PTIMER_PRI_TIMEOUT_SAVE_1: 0x%x\n", | 567 | "NV_PTIMER_PRI_TIMEOUT_SAVE_1: 0x%x\n", |
574 | gk20a_readl(g, timer_pri_timeout_save_1_r())); | 568 | gk20a_readl(g, timer_pri_timeout_save_1_r())); |
575 | err_code = gk20a_readl(g, timer_pri_timeout_fecs_errcode_r()); | 569 | err_code = gk20a_readl(g, timer_pri_timeout_fecs_errcode_r()); |
576 | gk20a_err(&g->dev->dev, | 570 | gk20a_err(g->dev, |
577 | "NV_PTIMER_PRI_TIMEOUT_FECS_ERRCODE: 0x%x\n", | 571 | "NV_PTIMER_PRI_TIMEOUT_FECS_ERRCODE: 0x%x\n", |
578 | err_code); | 572 | err_code); |
579 | if (err_code == 0xbadf13) | 573 | if (err_code == 0xbadf13) |
580 | gk20a_err(&g->dev->dev, | 574 | gk20a_err(g->dev, |
581 | "NV_PGRAPH_PRI_GPC0_GPCCS_FS_GPC: 0x%x\n", | 575 | "NV_PGRAPH_PRI_GPC0_GPCCS_FS_GPC: 0x%x\n", |
582 | gk20a_readl(g, gr_gpc0_fs_gpc_r())); | 576 | gk20a_readl(g, gr_gpc0_fs_gpc_r())); |
583 | 577 | ||
584 | } | 578 | } |
585 | 579 | ||
586 | if (val) | 580 | if (val) |
587 | gk20a_err(&g->dev->dev, | 581 | gk20a_err(g->dev, |
588 | "Unhandled pending pbus interrupt\n"); | 582 | "Unhandled pending pbus interrupt\n"); |
589 | 583 | ||
590 | gk20a_writel(g, bus_intr_0_r(), val); | 584 | gk20a_writel(g, bus_intr_0_r(), val); |
@@ -602,7 +596,7 @@ static irqreturn_t gk20a_intr_thread_nonstall(int irq, void *dev_id) | |||
602 | return g->ops.mc.isr_thread_nonstall(g); | 596 | return g->ops.mc.isr_thread_nonstall(g); |
603 | } | 597 | } |
604 | 598 | ||
605 | static void gk20a_remove_support(struct platform_device *dev) | 599 | static void gk20a_remove_support(struct device *dev) |
606 | { | 600 | { |
607 | struct gk20a *g = get_gk20a(dev); | 601 | struct gk20a *g = get_gk20a(dev); |
608 | 602 | ||
@@ -642,7 +636,7 @@ static void gk20a_remove_support(struct platform_device *dev) | |||
642 | static int gk20a_init_support(struct platform_device *dev) | 636 | static int gk20a_init_support(struct platform_device *dev) |
643 | { | 637 | { |
644 | int err = 0; | 638 | int err = 0; |
645 | struct gk20a *g = get_gk20a(dev); | 639 | struct gk20a *g = get_gk20a(&dev->dev); |
646 | 640 | ||
647 | #ifdef CONFIG_TEGRA_COMMON | 641 | #ifdef CONFIG_TEGRA_COMMON |
648 | tegra_register_idle_unidle(gk20a_do_idle, gk20a_do_unidle); | 642 | tegra_register_idle_unidle(gk20a_do_idle, gk20a_do_unidle); |
@@ -689,14 +683,13 @@ static int gk20a_init_support(struct platform_device *dev) | |||
689 | return 0; | 683 | return 0; |
690 | 684 | ||
691 | fail: | 685 | fail: |
692 | gk20a_remove_support(dev); | 686 | gk20a_remove_support(&dev->dev); |
693 | return err; | 687 | return err; |
694 | } | 688 | } |
695 | 689 | ||
696 | static int gk20a_pm_prepare_poweroff(struct device *dev) | 690 | static int gk20a_pm_prepare_poweroff(struct device *dev) |
697 | { | 691 | { |
698 | struct platform_device *pdev = to_platform_device(dev); | 692 | struct gk20a *g = get_gk20a(dev); |
699 | struct gk20a *g = get_gk20a(pdev); | ||
700 | int ret = 0; | 693 | int ret = 0; |
701 | 694 | ||
702 | gk20a_dbg_fn(""); | 695 | gk20a_dbg_fn(""); |
@@ -706,7 +699,7 @@ static int gk20a_pm_prepare_poweroff(struct device *dev) | |||
706 | if (!g->power_on) | 699 | if (!g->power_on) |
707 | goto done; | 700 | goto done; |
708 | 701 | ||
709 | gk20a_scale_suspend(pdev); | 702 | gk20a_scale_suspend(dev); |
710 | 703 | ||
711 | /* cancel any pending cde work */ | 704 | /* cancel any pending cde work */ |
712 | gk20a_cde_suspend(g); | 705 | gk20a_cde_suspend(g); |
@@ -767,11 +760,10 @@ static int gk20a_detect_chip(struct gk20a *g) | |||
767 | return gpu_init_hal(g); | 760 | return gpu_init_hal(g); |
768 | } | 761 | } |
769 | 762 | ||
770 | static int gk20a_pm_finalize_poweron(struct device *dev) | 763 | int gk20a_pm_finalize_poweron(struct device *dev) |
771 | { | 764 | { |
772 | struct platform_device *pdev = to_platform_device(dev); | 765 | struct gk20a *g = get_gk20a(dev); |
773 | struct gk20a *g = get_gk20a(pdev); | 766 | struct gk20a_platform *platform = gk20a_get_platform(dev); |
774 | struct gk20a_platform *platform = gk20a_get_platform(pdev); | ||
775 | int err, nice_value; | 767 | int err, nice_value; |
776 | 768 | ||
777 | gk20a_dbg_fn(""); | 769 | gk20a_dbg_fn(""); |
@@ -904,7 +896,7 @@ static int gk20a_pm_finalize_poweron(struct device *dev) | |||
904 | gk20a_channel_resume(g); | 896 | gk20a_channel_resume(g); |
905 | set_user_nice(current, nice_value); | 897 | set_user_nice(current, nice_value); |
906 | 898 | ||
907 | gk20a_scale_resume(pdev); | 899 | gk20a_scale_resume(dev); |
908 | 900 | ||
909 | trace_gk20a_finalize_poweron_done(dev_name(dev)); | 901 | trace_gk20a_finalize_poweron_done(dev_name(dev)); |
910 | 902 | ||
@@ -955,13 +947,13 @@ static struct of_device_id tegra_gk20a_of_match[] = { | |||
955 | }; | 947 | }; |
956 | 948 | ||
957 | static int gk20a_create_device( | 949 | static int gk20a_create_device( |
958 | struct platform_device *pdev, int devno, const char *cdev_name, | 950 | struct device *dev, int devno, |
951 | const char *interface_name, const char *cdev_name, | ||
959 | struct cdev *cdev, struct device **out, | 952 | struct cdev *cdev, struct device **out, |
960 | const struct file_operations *ops) | 953 | const struct file_operations *ops) |
961 | { | 954 | { |
962 | struct device *dev; | 955 | struct device *subdev; |
963 | int err; | 956 | int err; |
964 | struct gk20a *g = get_gk20a(pdev); | ||
965 | 957 | ||
966 | gk20a_dbg_fn(""); | 958 | gk20a_dbg_fn(""); |
967 | 959 | ||
@@ -970,127 +962,112 @@ static int gk20a_create_device( | |||
970 | 962 | ||
971 | err = cdev_add(cdev, devno, 1); | 963 | err = cdev_add(cdev, devno, 1); |
972 | if (err) { | 964 | if (err) { |
973 | dev_err(&pdev->dev, | 965 | dev_err(dev, "failed to add %s cdev\n", cdev_name); |
974 | "failed to add %s cdev\n", cdev_name); | ||
975 | return err; | 966 | return err; |
976 | } | 967 | } |
977 | 968 | ||
978 | dev = device_create(g->class, NULL, devno, NULL, | 969 | subdev = device_create(&nvgpu_class, NULL, devno, NULL, |
979 | (pdev->id <= 0) ? INTERFACE_NAME : INTERFACE_NAME ".%d", | 970 | interface_name, cdev_name); |
980 | cdev_name, pdev->id); | ||
981 | 971 | ||
982 | if (IS_ERR(dev)) { | 972 | if (IS_ERR(subdev)) { |
983 | err = PTR_ERR(dev); | 973 | err = PTR_ERR(dev); |
984 | cdev_del(cdev); | 974 | cdev_del(cdev); |
985 | dev_err(&pdev->dev, | 975 | dev_err(dev, "failed to create %s device for %s\n", |
986 | "failed to create %s device for %s\n", | 976 | cdev_name, dev_name(dev)); |
987 | cdev_name, pdev->name); | ||
988 | return err; | 977 | return err; |
989 | } | 978 | } |
990 | 979 | ||
991 | *out = dev; | 980 | *out = subdev; |
992 | return 0; | 981 | return 0; |
993 | } | 982 | } |
994 | 983 | ||
995 | void gk20a_user_deinit(struct platform_device *dev) | 984 | void gk20a_user_deinit(struct device *dev) |
996 | { | 985 | { |
997 | struct gk20a *g = get_gk20a(dev); | 986 | struct gk20a *g = gk20a_from_dev(dev); |
998 | 987 | ||
999 | if (g->channel.node) { | 988 | if (g->channel.node) { |
1000 | device_destroy(g->class, g->channel.cdev.dev); | 989 | device_destroy(&nvgpu_class, g->channel.cdev.dev); |
1001 | cdev_del(&g->channel.cdev); | 990 | cdev_del(&g->channel.cdev); |
1002 | } | 991 | } |
1003 | 992 | ||
1004 | if (g->as.node) { | 993 | if (g->as.node) { |
1005 | device_destroy(g->class, g->as.cdev.dev); | 994 | device_destroy(&nvgpu_class, g->as.cdev.dev); |
1006 | cdev_del(&g->as.cdev); | 995 | cdev_del(&g->as.cdev); |
1007 | } | 996 | } |
1008 | 997 | ||
1009 | if (g->ctrl.node) { | 998 | if (g->ctrl.node) { |
1010 | device_destroy(g->class, g->ctrl.cdev.dev); | 999 | device_destroy(&nvgpu_class, g->ctrl.cdev.dev); |
1011 | cdev_del(&g->ctrl.cdev); | 1000 | cdev_del(&g->ctrl.cdev); |
1012 | } | 1001 | } |
1013 | 1002 | ||
1014 | if (g->dbg.node) { | 1003 | if (g->dbg.node) { |
1015 | device_destroy(g->class, g->dbg.cdev.dev); | 1004 | device_destroy(&nvgpu_class, g->dbg.cdev.dev); |
1016 | cdev_del(&g->dbg.cdev); | 1005 | cdev_del(&g->dbg.cdev); |
1017 | } | 1006 | } |
1018 | 1007 | ||
1019 | if (g->prof.node) { | 1008 | if (g->prof.node) { |
1020 | device_destroy(g->class, g->prof.cdev.dev); | 1009 | device_destroy(&nvgpu_class, g->prof.cdev.dev); |
1021 | cdev_del(&g->prof.cdev); | 1010 | cdev_del(&g->prof.cdev); |
1022 | } | 1011 | } |
1023 | 1012 | ||
1024 | if (g->tsg.node) { | 1013 | if (g->tsg.node) { |
1025 | device_destroy(g->class, g->tsg.cdev.dev); | 1014 | device_destroy(&nvgpu_class, g->tsg.cdev.dev); |
1026 | cdev_del(&g->tsg.cdev); | 1015 | cdev_del(&g->tsg.cdev); |
1027 | } | 1016 | } |
1028 | 1017 | ||
1029 | if (g->ctxsw.node) { | 1018 | if (g->ctxsw.node) { |
1030 | device_destroy(g->class, g->ctxsw.cdev.dev); | 1019 | device_destroy(&nvgpu_class, g->ctxsw.cdev.dev); |
1031 | cdev_del(&g->ctxsw.cdev); | 1020 | cdev_del(&g->ctxsw.cdev); |
1032 | } | 1021 | } |
1033 | 1022 | ||
1034 | if (g->cdev_region) | 1023 | if (g->cdev_region) |
1035 | unregister_chrdev_region(g->cdev_region, GK20A_NUM_CDEVS); | 1024 | unregister_chrdev_region(g->cdev_region, GK20A_NUM_CDEVS); |
1036 | |||
1037 | if (g->class) | ||
1038 | class_destroy(g->class); | ||
1039 | } | 1025 | } |
1040 | 1026 | ||
1041 | int gk20a_user_init(struct platform_device *dev) | 1027 | int gk20a_user_init(struct device *dev, const char *interface_name) |
1042 | { | 1028 | { |
1043 | int err; | 1029 | int err; |
1044 | dev_t devno; | 1030 | dev_t devno; |
1045 | struct gk20a *g = get_gk20a(dev); | 1031 | struct gk20a *g = gk20a_from_dev(dev); |
1046 | |||
1047 | g->class = class_create(THIS_MODULE, CLASS_NAME); | ||
1048 | if (IS_ERR(g->class)) { | ||
1049 | err = PTR_ERR(g->class); | ||
1050 | g->class = NULL; | ||
1051 | dev_err(&dev->dev, | ||
1052 | "failed to create " CLASS_NAME " class\n"); | ||
1053 | goto fail; | ||
1054 | } | ||
1055 | 1032 | ||
1056 | err = alloc_chrdev_region(&devno, 0, GK20A_NUM_CDEVS, CLASS_NAME); | 1033 | err = alloc_chrdev_region(&devno, 0, GK20A_NUM_CDEVS, dev_name(dev)); |
1057 | if (err) { | 1034 | if (err) { |
1058 | dev_err(&dev->dev, "failed to allocate devno\n"); | 1035 | dev_err(dev, "failed to allocate devno\n"); |
1059 | goto fail; | 1036 | goto fail; |
1060 | } | 1037 | } |
1061 | g->cdev_region = devno; | 1038 | g->cdev_region = devno; |
1062 | 1039 | ||
1063 | err = gk20a_create_device(dev, devno++, "", | 1040 | err = gk20a_create_device(dev, devno++, interface_name, "", |
1064 | &g->channel.cdev, &g->channel.node, | 1041 | &g->channel.cdev, &g->channel.node, |
1065 | &gk20a_channel_ops); | 1042 | &gk20a_channel_ops); |
1066 | if (err) | 1043 | if (err) |
1067 | goto fail; | 1044 | goto fail; |
1068 | 1045 | ||
1069 | err = gk20a_create_device(dev, devno++, "-as", | 1046 | err = gk20a_create_device(dev, devno++, interface_name, "-as", |
1070 | &g->as.cdev, &g->as.node, | 1047 | &g->as.cdev, &g->as.node, |
1071 | &gk20a_as_ops); | 1048 | &gk20a_as_ops); |
1072 | if (err) | 1049 | if (err) |
1073 | goto fail; | 1050 | goto fail; |
1074 | 1051 | ||
1075 | err = gk20a_create_device(dev, devno++, "-ctrl", | 1052 | err = gk20a_create_device(dev, devno++, interface_name, "-ctrl", |
1076 | &g->ctrl.cdev, &g->ctrl.node, | 1053 | &g->ctrl.cdev, &g->ctrl.node, |
1077 | &gk20a_ctrl_ops); | 1054 | &gk20a_ctrl_ops); |
1078 | if (err) | 1055 | if (err) |
1079 | goto fail; | 1056 | goto fail; |
1080 | 1057 | ||
1081 | err = gk20a_create_device(dev, devno++, "-dbg", | 1058 | err = gk20a_create_device(dev, devno++, interface_name, "-dbg", |
1082 | &g->dbg.cdev, &g->dbg.node, | 1059 | &g->dbg.cdev, &g->dbg.node, |
1083 | &gk20a_dbg_ops); | 1060 | &gk20a_dbg_ops); |
1084 | if (err) | 1061 | if (err) |
1085 | goto fail; | 1062 | goto fail; |
1086 | 1063 | ||
1087 | err = gk20a_create_device(dev, devno++, "-prof", | 1064 | err = gk20a_create_device(dev, devno++, interface_name, "-prof", |
1088 | &g->prof.cdev, &g->prof.node, | 1065 | &g->prof.cdev, &g->prof.node, |
1089 | &gk20a_prof_ops); | 1066 | &gk20a_prof_ops); |
1090 | if (err) | 1067 | if (err) |
1091 | goto fail; | 1068 | goto fail; |
1092 | 1069 | ||
1093 | err = gk20a_create_device(dev, devno++, "-tsg", | 1070 | err = gk20a_create_device(dev, devno++, interface_name, "-tsg", |
1094 | &g->tsg.cdev, &g->tsg.node, | 1071 | &g->tsg.cdev, &g->tsg.node, |
1095 | &gk20a_tsg_ops); | 1072 | &gk20a_tsg_ops); |
1096 | if (err) | 1073 | if (err) |
@@ -1190,7 +1167,7 @@ static void gk20a_pm_shutdown(struct platform_device *pdev) | |||
1190 | #endif | 1167 | #endif |
1191 | 1168 | ||
1192 | /* Be ready for rail-gate after this point */ | 1169 | /* Be ready for rail-gate after this point */ |
1193 | if (gk20a_gpu_is_virtual(pdev)) | 1170 | if (gk20a_gpu_is_virtual(&pdev->dev)) |
1194 | vgpu_pm_prepare_poweroff(&pdev->dev); | 1171 | vgpu_pm_prepare_poweroff(&pdev->dev); |
1195 | else | 1172 | else |
1196 | gk20a_pm_prepare_poweroff(&pdev->dev); | 1173 | gk20a_pm_prepare_poweroff(&pdev->dev); |
@@ -1205,12 +1182,12 @@ static const struct dev_pm_ops gk20a_pm_ops = { | |||
1205 | }; | 1182 | }; |
1206 | #endif | 1183 | #endif |
1207 | 1184 | ||
1208 | static int _gk20a_pm_railgate(struct platform_device *pdev) | 1185 | static int _gk20a_pm_railgate(struct device *dev) |
1209 | { | 1186 | { |
1210 | struct gk20a_platform *platform = platform_get_drvdata(pdev); | 1187 | struct gk20a_platform *platform = dev_get_drvdata(dev); |
1211 | int ret = 0; | 1188 | int ret = 0; |
1212 | if (platform->railgate) | 1189 | if (platform->railgate) |
1213 | ret = platform->railgate(pdev); | 1190 | ret = platform->railgate(dev); |
1214 | return ret; | 1191 | return ret; |
1215 | } | 1192 | } |
1216 | 1193 | ||
@@ -1223,14 +1200,14 @@ static int gk20a_pm_railgate(struct generic_pm_domain *domain) | |||
1223 | return _gk20a_pm_railgate(g->dev); | 1200 | return _gk20a_pm_railgate(g->dev); |
1224 | } | 1201 | } |
1225 | 1202 | ||
1226 | static int _gk20a_pm_unrailgate(struct platform_device *pdev) | 1203 | static int _gk20a_pm_unrailgate(struct device *dev) |
1227 | { | 1204 | { |
1228 | struct gk20a_platform *platform = platform_get_drvdata(pdev); | 1205 | struct gk20a_platform *platform = dev_get_drvdata(dev); |
1229 | int ret = 0; | 1206 | int ret = 0; |
1230 | 1207 | ||
1231 | if (platform->unrailgate) { | 1208 | if (platform->unrailgate) { |
1232 | mutex_lock(&platform->railgate_lock); | 1209 | mutex_lock(&platform->railgate_lock); |
1233 | ret = platform->unrailgate(pdev); | 1210 | ret = platform->unrailgate(dev); |
1234 | mutex_unlock(&platform->railgate_lock); | 1211 | mutex_unlock(&platform->railgate_lock); |
1235 | } | 1212 | } |
1236 | 1213 | ||
@@ -1242,7 +1219,7 @@ static int gk20a_pm_unrailgate(struct generic_pm_domain *domain) | |||
1242 | struct gk20a_domain_data *gk20a_domain = container_of(domain, | 1219 | struct gk20a_domain_data *gk20a_domain = container_of(domain, |
1243 | struct gk20a_domain_data, gpd); | 1220 | struct gk20a_domain_data, gpd); |
1244 | struct gk20a *g = gk20a_domain->gk20a; | 1221 | struct gk20a *g = gk20a_domain->gk20a; |
1245 | trace_gk20a_pm_unrailgate(dev_name(&g->dev->dev)); | 1222 | trace_gk20a_pm_unrailgate(dev_name(g->dev)); |
1246 | 1223 | ||
1247 | return _gk20a_pm_unrailgate(g->dev); | 1224 | return _gk20a_pm_unrailgate(g->dev); |
1248 | } | 1225 | } |
@@ -1273,11 +1250,14 @@ static int gk20a_pm_resume(struct device *dev) | |||
1273 | } | 1250 | } |
1274 | 1251 | ||
1275 | #ifdef CONFIG_PM_GENERIC_DOMAINS_OF | 1252 | #ifdef CONFIG_PM_GENERIC_DOMAINS_OF |
1276 | static int gk20a_pm_initialise_domain(struct platform_device *pdev) | 1253 | static int gk20a_pm_initialise_domain(struct device *dev) |
1277 | { | 1254 | { |
1278 | struct gk20a_platform *platform = platform_get_drvdata(pdev); | 1255 | struct gk20a_platform *platform = dev_get_drvdata(dev); |
1279 | struct dev_power_governor *pm_domain_gov = NULL; | 1256 | struct dev_power_governor *pm_domain_gov = NULL; |
1280 | struct generic_pm_domain *domain = dev_to_genpd(&pdev->dev); | 1257 | struct generic_pm_domain *domain = dev_to_genpd(dev); |
1258 | |||
1259 | if (IS_ERR(domain)) | ||
1260 | return 0; | ||
1281 | 1261 | ||
1282 | #ifdef CONFIG_PM | 1262 | #ifdef CONFIG_PM |
1283 | if (!platform->can_railgate) | 1263 | if (!platform->can_railgate) |
@@ -1288,14 +1268,14 @@ static int gk20a_pm_initialise_domain(struct platform_device *pdev) | |||
1288 | if (platform->railgate_delay) | 1268 | if (platform->railgate_delay) |
1289 | pm_genpd_set_poweroff_delay(domain, platform->railgate_delay); | 1269 | pm_genpd_set_poweroff_delay(domain, platform->railgate_delay); |
1290 | 1270 | ||
1291 | device_set_wakeup_capable(&pdev->dev, 0); | 1271 | device_set_wakeup_capable(dev, 0); |
1292 | return 0; | 1272 | return 0; |
1293 | } | 1273 | } |
1294 | 1274 | ||
1295 | #else | 1275 | #else |
1296 | static int gk20a_pm_initialise_domain(struct platform_device *pdev) | 1276 | static int gk20a_pm_initialise_domain(struct device *dev) |
1297 | { | 1277 | { |
1298 | struct gk20a_platform *platform = platform_get_drvdata(pdev); | 1278 | struct gk20a_platform *platform = dev_get_drvdata(dev); |
1299 | struct dev_power_governor *pm_domain_gov = NULL; | 1279 | struct dev_power_governor *pm_domain_gov = NULL; |
1300 | struct generic_pm_domain *domain = NULL; | 1280 | struct generic_pm_domain *domain = NULL; |
1301 | int ret = 0; | 1281 | int ret = 0; |
@@ -1326,8 +1306,8 @@ static int gk20a_pm_initialise_domain(struct platform_device *pdev) | |||
1326 | domain->dev_ops.suspend = gk20a_pm_suspend; | 1306 | domain->dev_ops.suspend = gk20a_pm_suspend; |
1327 | domain->dev_ops.resume = gk20a_pm_resume; | 1307 | domain->dev_ops.resume = gk20a_pm_resume; |
1328 | 1308 | ||
1329 | device_set_wakeup_capable(&pdev->dev, 0); | 1309 | device_set_wakeup_capable(dev, 0); |
1330 | ret = pm_genpd_add_device(domain, &pdev->dev); | 1310 | ret = pm_genpd_add_device(domain, dev); |
1331 | 1311 | ||
1332 | if (platform->railgate_delay) | 1312 | if (platform->railgate_delay) |
1333 | pm_genpd_set_poweroff_delay(domain, platform->railgate_delay); | 1313 | pm_genpd_set_poweroff_delay(domain, platform->railgate_delay); |
@@ -1336,23 +1316,23 @@ static int gk20a_pm_initialise_domain(struct platform_device *pdev) | |||
1336 | } | 1316 | } |
1337 | #endif | 1317 | #endif |
1338 | 1318 | ||
1339 | static int gk20a_pm_init(struct platform_device *dev) | 1319 | static int gk20a_pm_init(struct device *dev) |
1340 | { | 1320 | { |
1341 | struct gk20a_platform *platform = platform_get_drvdata(dev); | 1321 | struct gk20a_platform *platform = dev_get_drvdata(dev); |
1342 | int err = 0; | 1322 | int err = 0; |
1343 | 1323 | ||
1344 | gk20a_dbg_fn(""); | 1324 | gk20a_dbg_fn(""); |
1345 | 1325 | ||
1346 | /* Initialise pm runtime */ | 1326 | /* Initialise pm runtime */ |
1347 | if (platform->clockgate_delay) { | 1327 | if (platform->clockgate_delay) { |
1348 | pm_runtime_set_autosuspend_delay(&dev->dev, | 1328 | pm_runtime_set_autosuspend_delay(dev, |
1349 | platform->clockgate_delay); | 1329 | platform->clockgate_delay); |
1350 | pm_runtime_use_autosuspend(&dev->dev); | 1330 | pm_runtime_use_autosuspend(dev); |
1351 | } | 1331 | } |
1352 | 1332 | ||
1353 | pm_runtime_enable(&dev->dev); | 1333 | pm_runtime_enable(dev); |
1354 | if (!pm_runtime_enabled(&dev->dev)) | 1334 | if (!pm_runtime_enabled(dev)) |
1355 | gk20a_pm_enable_clk(&dev->dev); | 1335 | gk20a_pm_enable_clk(dev); |
1356 | 1336 | ||
1357 | /* Enable runtime railgating if possible. If not, | 1337 | /* Enable runtime railgating if possible. If not, |
1358 | * turn on the rail now. */ | 1338 | * turn on the rail now. */ |
@@ -1374,7 +1354,7 @@ static int gk20a_secure_page_alloc(struct platform_device *pdev) | |||
1374 | int err = 0; | 1354 | int err = 0; |
1375 | 1355 | ||
1376 | if (platform->secure_page_alloc) { | 1356 | if (platform->secure_page_alloc) { |
1377 | err = platform->secure_page_alloc(pdev); | 1357 | err = platform->secure_page_alloc(&pdev->dev); |
1378 | if (!err) | 1358 | if (!err) |
1379 | platform->secure_alloc_ready = true; | 1359 | platform->secure_alloc_ready = true; |
1380 | } | 1360 | } |
@@ -1418,7 +1398,7 @@ static int gk20a_probe(struct platform_device *dev) | |||
1418 | 1398 | ||
1419 | platform_set_drvdata(dev, platform); | 1399 | platform_set_drvdata(dev, platform); |
1420 | 1400 | ||
1421 | if (gk20a_gpu_is_virtual(dev)) | 1401 | if (gk20a_gpu_is_virtual(&dev->dev)) |
1422 | return vgpu_probe(dev); | 1402 | return vgpu_probe(dev); |
1423 | 1403 | ||
1424 | gk20a = kzalloc(sizeof(struct gk20a), GFP_KERNEL); | 1404 | gk20a = kzalloc(sizeof(struct gk20a), GFP_KERNEL); |
@@ -1437,7 +1417,7 @@ static int gk20a_probe(struct platform_device *dev) | |||
1437 | #endif | 1417 | #endif |
1438 | 1418 | ||
1439 | set_gk20a(dev, gk20a); | 1419 | set_gk20a(dev, gk20a); |
1440 | gk20a->dev = dev; | 1420 | gk20a->dev = &dev->dev; |
1441 | 1421 | ||
1442 | gk20a->irq_stall = platform_get_irq(dev, 0); | 1422 | gk20a->irq_stall = platform_get_irq(dev, 0); |
1443 | gk20a->irq_nonstall = platform_get_irq(dev, 1); | 1423 | gk20a->irq_nonstall = platform_get_irq(dev, 1); |
@@ -1468,7 +1448,7 @@ static int gk20a_probe(struct platform_device *dev) | |||
1468 | disable_irq(gk20a->irq_stall); | 1448 | disable_irq(gk20a->irq_stall); |
1469 | disable_irq(gk20a->irq_nonstall); | 1449 | disable_irq(gk20a->irq_nonstall); |
1470 | 1450 | ||
1471 | err = gk20a_user_init(dev); | 1451 | err = gk20a_user_init(&dev->dev, INTERFACE_NAME); |
1472 | if (err) | 1452 | if (err) |
1473 | return err; | 1453 | return err; |
1474 | 1454 | ||
@@ -1485,10 +1465,10 @@ static int gk20a_probe(struct platform_device *dev) | |||
1485 | platform->reset_control = NULL; | 1465 | platform->reset_control = NULL; |
1486 | #endif | 1466 | #endif |
1487 | 1467 | ||
1488 | gk20a_debug_init(dev); | 1468 | gk20a_debug_init(&dev->dev); |
1489 | 1469 | ||
1490 | /* Initialize the platform interface. */ | 1470 | /* Initialize the platform interface. */ |
1491 | err = platform->probe(dev); | 1471 | err = platform->probe(&dev->dev); |
1492 | if (err) { | 1472 | if (err) { |
1493 | dev_err(&dev->dev, "platform probe failed"); | 1473 | dev_err(&dev->dev, "platform probe failed"); |
1494 | return err; | 1474 | return err; |
@@ -1499,7 +1479,7 @@ static int gk20a_probe(struct platform_device *dev) | |||
1499 | dev_err(&dev->dev, | 1479 | dev_err(&dev->dev, |
1500 | "failed to allocate secure buffer %d\n", err); | 1480 | "failed to allocate secure buffer %d\n", err); |
1501 | 1481 | ||
1502 | err = gk20a_pm_init(dev); | 1482 | err = gk20a_pm_init(&dev->dev); |
1503 | if (err) { | 1483 | if (err) { |
1504 | dev_err(&dev->dev, "pm init failed"); | 1484 | dev_err(&dev->dev, "pm init failed"); |
1505 | return err; | 1485 | return err; |
@@ -1509,7 +1489,7 @@ static int gk20a_probe(struct platform_device *dev) | |||
1509 | 1489 | ||
1510 | /* Initialise scaling */ | 1490 | /* Initialise scaling */ |
1511 | if (IS_ENABLED(CONFIG_GK20A_DEVFREQ)) | 1491 | if (IS_ENABLED(CONFIG_GK20A_DEVFREQ)) |
1512 | gk20a_scale_init(dev); | 1492 | gk20a_scale_init(&dev->dev); |
1513 | 1493 | ||
1514 | /* Set DMA parameters to allow larger sgt lists */ | 1494 | /* Set DMA parameters to allow larger sgt lists */ |
1515 | dev->dev.dma_parms = &gk20a->dma_parms; | 1495 | dev->dev.dma_parms = &gk20a->dma_parms; |
@@ -1547,14 +1527,14 @@ static int gk20a_probe(struct platform_device *dev) | |||
1547 | gk20a->pmu.aelpg_param[4] = APCTRL_CYCLES_PER_SAMPLE_MAX_DEFAULT; | 1527 | gk20a->pmu.aelpg_param[4] = APCTRL_CYCLES_PER_SAMPLE_MAX_DEFAULT; |
1548 | 1528 | ||
1549 | if (platform->late_probe) { | 1529 | if (platform->late_probe) { |
1550 | err = platform->late_probe(dev); | 1530 | err = platform->late_probe(&dev->dev); |
1551 | if (err) { | 1531 | if (err) { |
1552 | dev_err(&dev->dev, "late probe failed"); | 1532 | dev_err(&dev->dev, "late probe failed"); |
1553 | return err; | 1533 | return err; |
1554 | } | 1534 | } |
1555 | } | 1535 | } |
1556 | 1536 | ||
1557 | gk20a_create_sysfs(dev); | 1537 | gk20a_create_sysfs(&dev->dev); |
1558 | 1538 | ||
1559 | #ifdef CONFIG_DEBUG_FS | 1539 | #ifdef CONFIG_DEBUG_FS |
1560 | spin_lock_init(&gk20a->debugfs_lock); | 1540 | spin_lock_init(&gk20a->debugfs_lock); |
@@ -1612,10 +1592,10 @@ static int gk20a_probe(struct platform_device *dev) | |||
1612 | &gk20a->runlist_interleave); | 1592 | &gk20a->runlist_interleave); |
1613 | 1593 | ||
1614 | gr_gk20a_debugfs_init(gk20a); | 1594 | gr_gk20a_debugfs_init(gk20a); |
1615 | gk20a_pmu_debugfs_init(dev); | 1595 | gk20a_pmu_debugfs_init(&dev->dev); |
1616 | gk20a_cde_debugfs_init(dev); | 1596 | gk20a_cde_debugfs_init(&dev->dev); |
1617 | gk20a_alloc_debugfs_init(dev); | 1597 | gk20a_alloc_debugfs_init(dev); |
1618 | gk20a_mm_debugfs_init(dev); | 1598 | gk20a_mm_debugfs_init(&dev->dev); |
1619 | #endif | 1599 | #endif |
1620 | 1600 | ||
1621 | gk20a_init_gr(gk20a); | 1601 | gk20a_init_gr(gk20a); |
@@ -1623,8 +1603,9 @@ static int gk20a_probe(struct platform_device *dev) | |||
1623 | return 0; | 1603 | return 0; |
1624 | } | 1604 | } |
1625 | 1605 | ||
1626 | static int __exit gk20a_remove(struct platform_device *dev) | 1606 | static int __exit gk20a_remove(struct platform_device *pdev) |
1627 | { | 1607 | { |
1608 | struct device *dev = &pdev->dev; | ||
1628 | struct gk20a *g = get_gk20a(dev); | 1609 | struct gk20a *g = get_gk20a(dev); |
1629 | struct gk20a_platform *platform = gk20a_get_platform(dev); | 1610 | struct gk20a_platform *platform = gk20a_get_platform(dev); |
1630 | struct gk20a_domain_data *gk20a_gpd; | 1611 | struct gk20a_domain_data *gk20a_gpd; |
@@ -1632,7 +1613,7 @@ static int __exit gk20a_remove(struct platform_device *dev) | |||
1632 | gk20a_dbg_fn(""); | 1613 | gk20a_dbg_fn(""); |
1633 | 1614 | ||
1634 | if (gk20a_gpu_is_virtual(dev)) | 1615 | if (gk20a_gpu_is_virtual(dev)) |
1635 | return vgpu_remove(dev); | 1616 | return vgpu_remove(pdev); |
1636 | 1617 | ||
1637 | if (platform->has_cde) | 1618 | if (platform->has_cde) |
1638 | gk20a_cde_destroy(g); | 1619 | gk20a_cde_destroy(g); |
@@ -1650,7 +1631,7 @@ static int __exit gk20a_remove(struct platform_device *dev) | |||
1650 | debugfs_remove_recursive(platform->debugfs); | 1631 | debugfs_remove_recursive(platform->debugfs); |
1651 | debugfs_remove_recursive(platform->debugfs_alias); | 1632 | debugfs_remove_recursive(platform->debugfs_alias); |
1652 | 1633 | ||
1653 | gk20a_remove_sysfs(&dev->dev); | 1634 | gk20a_remove_sysfs(dev); |
1654 | 1635 | ||
1655 | if (platform->secure_buffer.destroy) | 1636 | if (platform->secure_buffer.destroy) |
1656 | platform->secure_buffer.destroy(dev, | 1637 | platform->secure_buffer.destroy(dev, |
@@ -1660,15 +1641,15 @@ static int __exit gk20a_remove(struct platform_device *dev) | |||
1660 | gk20a_gpd->gk20a = NULL; | 1641 | gk20a_gpd->gk20a = NULL; |
1661 | kfree(gk20a_gpd); | 1642 | kfree(gk20a_gpd); |
1662 | 1643 | ||
1663 | if (pm_runtime_enabled(&dev->dev)) | 1644 | if (pm_runtime_enabled(dev)) |
1664 | pm_runtime_disable(&dev->dev); | 1645 | pm_runtime_disable(dev); |
1665 | else | 1646 | else |
1666 | gk20a_pm_disable_clk(&dev->dev); | 1647 | gk20a_pm_disable_clk(dev); |
1667 | 1648 | ||
1668 | if (platform->remove) | 1649 | if (platform->remove) |
1669 | platform->remove(dev); | 1650 | platform->remove(dev); |
1670 | 1651 | ||
1671 | set_gk20a(dev, NULL); | 1652 | set_gk20a(pdev, NULL); |
1672 | kfree(g); | 1653 | kfree(g); |
1673 | 1654 | ||
1674 | gk20a_dbg_fn("removed"); | 1655 | gk20a_dbg_fn("removed"); |
@@ -1751,11 +1732,20 @@ static int gk20a_domain_init(struct of_device_id *matches) | |||
1751 | #endif | 1732 | #endif |
1752 | 1733 | ||
1753 | 1734 | ||
1735 | struct class nvgpu_class = { | ||
1736 | .owner = THIS_MODULE, | ||
1737 | .name = CLASS_NAME, | ||
1738 | }; | ||
1739 | |||
1754 | static int __init gk20a_init(void) | 1740 | static int __init gk20a_init(void) |
1755 | { | 1741 | { |
1756 | 1742 | ||
1757 | int ret; | 1743 | int ret; |
1758 | 1744 | ||
1745 | ret = class_register(&nvgpu_class); | ||
1746 | if (ret) | ||
1747 | return ret; | ||
1748 | |||
1759 | ret = gk20a_domain_init(tegra_gpu_domain_match); | 1749 | ret = gk20a_domain_init(tegra_gpu_domain_match); |
1760 | if (ret) | 1750 | if (ret) |
1761 | return ret; | 1751 | return ret; |
@@ -1766,50 +1756,51 @@ static int __init gk20a_init(void) | |||
1766 | static void __exit gk20a_exit(void) | 1756 | static void __exit gk20a_exit(void) |
1767 | { | 1757 | { |
1768 | platform_driver_unregister(&gk20a_driver); | 1758 | platform_driver_unregister(&gk20a_driver); |
1759 | class_unregister(&nvgpu_class); | ||
1769 | } | 1760 | } |
1770 | 1761 | ||
1771 | void gk20a_busy_noresume(struct platform_device *pdev) | 1762 | void gk20a_busy_noresume(struct device *dev) |
1772 | { | 1763 | { |
1773 | pm_runtime_get_noresume(&pdev->dev); | 1764 | pm_runtime_get_noresume(dev); |
1774 | } | 1765 | } |
1775 | 1766 | ||
1776 | int gk20a_busy(struct platform_device *pdev) | 1767 | int gk20a_busy(struct device *dev) |
1777 | { | 1768 | { |
1778 | int ret = 0; | 1769 | int ret = 0; |
1779 | struct gk20a *g = get_gk20a(pdev); | 1770 | struct gk20a *g = get_gk20a(dev); |
1780 | #ifdef CONFIG_PM | 1771 | #ifdef CONFIG_PM |
1781 | struct gk20a_platform *platform = gk20a_get_platform(pdev); | 1772 | struct gk20a_platform *platform = gk20a_get_platform(dev); |
1782 | #endif | 1773 | #endif |
1783 | 1774 | ||
1784 | down_read(&g->busy_lock); | 1775 | down_read(&g->busy_lock); |
1785 | 1776 | ||
1786 | #ifdef CONFIG_PM | 1777 | #ifdef CONFIG_PM |
1787 | if (platform->busy) { | 1778 | if (platform->busy) { |
1788 | ret = platform->busy(pdev); | 1779 | ret = platform->busy(dev); |
1789 | if (ret < 0) { | 1780 | if (ret < 0) { |
1790 | dev_err(&pdev->dev, "%s: failed to poweron platform dependency\n", | 1781 | dev_err(dev, "%s: failed to poweron platform dependency\n", |
1791 | __func__); | 1782 | __func__); |
1792 | goto fail; | 1783 | goto fail; |
1793 | } | 1784 | } |
1794 | } | 1785 | } |
1795 | 1786 | ||
1796 | ret = pm_runtime_get_sync(&pdev->dev); | 1787 | ret = pm_runtime_get_sync(dev); |
1797 | if (ret < 0) { | 1788 | if (ret < 0) { |
1798 | pm_runtime_put_noidle(&pdev->dev); | 1789 | pm_runtime_put_noidle(dev); |
1799 | if (platform->idle) | 1790 | if (platform->idle) |
1800 | platform->idle(pdev); | 1791 | platform->idle(dev); |
1801 | goto fail; | 1792 | goto fail; |
1802 | } | 1793 | } |
1803 | #else | 1794 | #else |
1804 | if (!g->power_on) { | 1795 | if (!g->power_on) { |
1805 | ret = gk20a_gpu_is_virtual(pdev) ? | 1796 | ret = gk20a_gpu_is_virtual(pdev) ? |
1806 | vgpu_pm_finalize_poweron(&pdev->dev) | 1797 | vgpu_pm_finalize_poweron(dev) |
1807 | : gk20a_pm_finalize_poweron(&pdev->dev); | 1798 | : gk20a_pm_finalize_poweron(dev); |
1808 | if (ret) | 1799 | if (ret) |
1809 | goto fail; | 1800 | goto fail; |
1810 | } | 1801 | } |
1811 | #endif | 1802 | #endif |
1812 | gk20a_scale_notify_busy(pdev); | 1803 | gk20a_scale_notify_busy(dev); |
1813 | 1804 | ||
1814 | fail: | 1805 | fail: |
1815 | up_read(&g->busy_lock); | 1806 | up_read(&g->busy_lock); |
@@ -1817,19 +1808,19 @@ fail: | |||
1817 | return ret < 0 ? ret : 0; | 1808 | return ret < 0 ? ret : 0; |
1818 | } | 1809 | } |
1819 | 1810 | ||
1820 | void gk20a_idle(struct platform_device *pdev) | 1811 | void gk20a_idle(struct device *dev) |
1821 | { | 1812 | { |
1822 | #ifdef CONFIG_PM | 1813 | #ifdef CONFIG_PM |
1823 | struct gk20a_platform *platform = gk20a_get_platform(pdev); | 1814 | struct gk20a_platform *platform = gk20a_get_platform(dev); |
1824 | if (atomic_read(&pdev->dev.power.usage_count) == 1) | 1815 | if (atomic_read(&dev->power.usage_count) == 1) |
1825 | gk20a_scale_notify_idle(pdev); | 1816 | gk20a_scale_notify_idle(dev); |
1826 | pm_runtime_mark_last_busy(&pdev->dev); | 1817 | pm_runtime_mark_last_busy(dev); |
1827 | pm_runtime_put_sync_autosuspend(&pdev->dev); | 1818 | pm_runtime_put_sync_autosuspend(dev); |
1828 | 1819 | ||
1829 | if (platform->idle) | 1820 | if (platform->idle) |
1830 | platform->idle(pdev); | 1821 | platform->idle(dev); |
1831 | #else | 1822 | #else |
1832 | gk20a_scale_notify_idle(pdev); | 1823 | gk20a_scale_notify_idle(dev); |
1833 | #endif | 1824 | #endif |
1834 | } | 1825 | } |
1835 | 1826 | ||
@@ -1882,10 +1873,10 @@ void gk20a_reset(struct gk20a *g, u32 units) | |||
1882 | * In success, we hold these locks and return | 1873 | * In success, we hold these locks and return |
1883 | * In failure, we release these locks and return | 1874 | * In failure, we release these locks and return |
1884 | */ | 1875 | */ |
1885 | int __gk20a_do_idle(struct platform_device *pdev, bool force_reset) | 1876 | int __gk20a_do_idle(struct device *dev, bool force_reset) |
1886 | { | 1877 | { |
1887 | struct gk20a *g = get_gk20a(pdev); | 1878 | struct gk20a *g = get_gk20a(dev); |
1888 | struct gk20a_platform *platform = dev_get_drvdata(&pdev->dev); | 1879 | struct gk20a_platform *platform = dev_get_drvdata(dev); |
1889 | unsigned long timeout = jiffies + | 1880 | unsigned long timeout = jiffies + |
1890 | msecs_to_jiffies(GK20A_WAIT_FOR_IDLE_MS); | 1881 | msecs_to_jiffies(GK20A_WAIT_FOR_IDLE_MS); |
1891 | int ref_cnt; | 1882 | int ref_cnt; |
@@ -1898,7 +1889,7 @@ int __gk20a_do_idle(struct platform_device *pdev, bool force_reset) | |||
1898 | mutex_lock(&platform->railgate_lock); | 1889 | mutex_lock(&platform->railgate_lock); |
1899 | 1890 | ||
1900 | /* check if it is already railgated ? */ | 1891 | /* check if it is already railgated ? */ |
1901 | if (platform->is_railgated(pdev)) | 1892 | if (platform->is_railgated(dev)) |
1902 | return 0; | 1893 | return 0; |
1903 | 1894 | ||
1904 | /* | 1895 | /* |
@@ -1906,17 +1897,17 @@ int __gk20a_do_idle(struct platform_device *pdev, bool force_reset) | |||
1906 | * re-acquire railgate_lock | 1897 | * re-acquire railgate_lock |
1907 | */ | 1898 | */ |
1908 | mutex_unlock(&platform->railgate_lock); | 1899 | mutex_unlock(&platform->railgate_lock); |
1909 | pm_runtime_get_sync(&pdev->dev); | 1900 | pm_runtime_get_sync(dev); |
1910 | mutex_lock(&platform->railgate_lock); | 1901 | mutex_lock(&platform->railgate_lock); |
1911 | 1902 | ||
1912 | /* check and wait until GPU is idle (with a timeout) */ | 1903 | /* check and wait until GPU is idle (with a timeout) */ |
1913 | do { | 1904 | do { |
1914 | msleep(1); | 1905 | msleep(1); |
1915 | ref_cnt = atomic_read(&pdev->dev.power.usage_count); | 1906 | ref_cnt = atomic_read(&dev->power.usage_count); |
1916 | } while (ref_cnt != 1 && time_before(jiffies, timeout)); | 1907 | } while (ref_cnt != 1 && time_before(jiffies, timeout)); |
1917 | 1908 | ||
1918 | if (ref_cnt != 1) { | 1909 | if (ref_cnt != 1) { |
1919 | gk20a_err(&pdev->dev, "failed to idle - refcount %d != 1\n", | 1910 | gk20a_err(dev, "failed to idle - refcount %d != 1\n", |
1920 | ref_cnt); | 1911 | ref_cnt); |
1921 | goto fail_drop_usage_count; | 1912 | goto fail_drop_usage_count; |
1922 | } | 1913 | } |
@@ -1931,7 +1922,7 @@ int __gk20a_do_idle(struct platform_device *pdev, bool force_reset) | |||
1931 | * if GPU is now idle, we will have only one ref count, | 1922 | * if GPU is now idle, we will have only one ref count, |
1932 | * drop this ref which will rail gate the GPU | 1923 | * drop this ref which will rail gate the GPU |
1933 | */ | 1924 | */ |
1934 | pm_runtime_put_sync(&pdev->dev); | 1925 | pm_runtime_put_sync(dev); |
1935 | 1926 | ||
1936 | /* add sufficient delay to allow GPU to rail gate */ | 1927 | /* add sufficient delay to allow GPU to rail gate */ |
1937 | msleep(platform->railgate_delay); | 1928 | msleep(platform->railgate_delay); |
@@ -1941,13 +1932,13 @@ int __gk20a_do_idle(struct platform_device *pdev, bool force_reset) | |||
1941 | /* check in loop if GPU is railgated or not */ | 1932 | /* check in loop if GPU is railgated or not */ |
1942 | do { | 1933 | do { |
1943 | msleep(1); | 1934 | msleep(1); |
1944 | is_railgated = platform->is_railgated(pdev); | 1935 | is_railgated = platform->is_railgated(dev); |
1945 | } while (!is_railgated && time_before(jiffies, timeout)); | 1936 | } while (!is_railgated && time_before(jiffies, timeout)); |
1946 | 1937 | ||
1947 | if (is_railgated) { | 1938 | if (is_railgated) { |
1948 | return 0; | 1939 | return 0; |
1949 | } else { | 1940 | } else { |
1950 | gk20a_err(&pdev->dev, "failed to idle in timeout\n"); | 1941 | gk20a_err(dev, "failed to idle in timeout\n"); |
1951 | goto fail_timeout; | 1942 | goto fail_timeout; |
1952 | } | 1943 | } |
1953 | } else { | 1944 | } else { |
@@ -1964,12 +1955,12 @@ int __gk20a_do_idle(struct platform_device *pdev, bool force_reset) | |||
1964 | */ | 1955 | */ |
1965 | 1956 | ||
1966 | /* Save the GPU state */ | 1957 | /* Save the GPU state */ |
1967 | gk20a_pm_prepare_poweroff(&pdev->dev); | 1958 | gk20a_pm_prepare_poweroff(dev); |
1968 | 1959 | ||
1969 | gk20a_pm_disable_clk(&pdev->dev); | 1960 | gk20a_pm_disable_clk(dev); |
1970 | 1961 | ||
1971 | /* railgate GPU */ | 1962 | /* railgate GPU */ |
1972 | platform->railgate(pdev); | 1963 | platform->railgate(dev); |
1973 | 1964 | ||
1974 | udelay(10); | 1965 | udelay(10); |
1975 | 1966 | ||
@@ -1978,7 +1969,7 @@ int __gk20a_do_idle(struct platform_device *pdev, bool force_reset) | |||
1978 | } | 1969 | } |
1979 | 1970 | ||
1980 | fail_drop_usage_count: | 1971 | fail_drop_usage_count: |
1981 | pm_runtime_put_noidle(&pdev->dev); | 1972 | pm_runtime_put_noidle(dev); |
1982 | fail_timeout: | 1973 | fail_timeout: |
1983 | mutex_unlock(&platform->railgate_lock); | 1974 | mutex_unlock(&platform->railgate_lock); |
1984 | up_write(&g->busy_lock); | 1975 | up_write(&g->busy_lock); |
@@ -1997,7 +1988,7 @@ int gk20a_do_idle(void) | |||
1997 | of_find_matching_node(NULL, tegra_gk20a_of_match); | 1988 | of_find_matching_node(NULL, tegra_gk20a_of_match); |
1998 | struct platform_device *pdev = of_find_device_by_node(node); | 1989 | struct platform_device *pdev = of_find_device_by_node(node); |
1999 | 1990 | ||
2000 | int ret = __gk20a_do_idle(pdev, true); | 1991 | int ret = __gk20a_do_idle(&pdev->dev, true); |
2001 | 1992 | ||
2002 | of_node_put(node); | 1993 | of_node_put(node); |
2003 | 1994 | ||
@@ -2007,25 +1998,25 @@ int gk20a_do_idle(void) | |||
2007 | /** | 1998 | /** |
2008 | * __gk20a_do_unidle() - unblock all the tasks blocked by __gk20a_do_idle() | 1999 | * __gk20a_do_unidle() - unblock all the tasks blocked by __gk20a_do_idle() |
2009 | */ | 2000 | */ |
2010 | int __gk20a_do_unidle(struct platform_device *pdev) | 2001 | int __gk20a_do_unidle(struct device *dev) |
2011 | { | 2002 | { |
2012 | struct gk20a *g = get_gk20a(pdev); | 2003 | struct gk20a *g = get_gk20a(dev); |
2013 | struct gk20a_platform *platform = dev_get_drvdata(&pdev->dev); | 2004 | struct gk20a_platform *platform = dev_get_drvdata(dev); |
2014 | 2005 | ||
2015 | if (g->forced_reset) { | 2006 | if (g->forced_reset) { |
2016 | /* | 2007 | /* |
2017 | * If we did a forced-reset/railgate | 2008 | * If we did a forced-reset/railgate |
2018 | * then unrailgate the GPU here first | 2009 | * then unrailgate the GPU here first |
2019 | */ | 2010 | */ |
2020 | platform->unrailgate(pdev); | 2011 | platform->unrailgate(dev); |
2021 | 2012 | ||
2022 | gk20a_pm_enable_clk(&pdev->dev); | 2013 | gk20a_pm_enable_clk(dev); |
2023 | 2014 | ||
2024 | /* restore the GPU state */ | 2015 | /* restore the GPU state */ |
2025 | gk20a_pm_finalize_poweron(&pdev->dev); | 2016 | gk20a_pm_finalize_poweron(dev); |
2026 | 2017 | ||
2027 | /* balance GPU usage counter */ | 2018 | /* balance GPU usage counter */ |
2028 | pm_runtime_put_sync(&pdev->dev); | 2019 | pm_runtime_put_sync(dev); |
2029 | 2020 | ||
2030 | g->forced_reset = false; | 2021 | g->forced_reset = false; |
2031 | } | 2022 | } |
@@ -2046,7 +2037,7 @@ int gk20a_do_unidle(void) | |||
2046 | of_find_matching_node(NULL, tegra_gk20a_of_match); | 2037 | of_find_matching_node(NULL, tegra_gk20a_of_match); |
2047 | struct platform_device *pdev = of_find_device_by_node(node); | 2038 | struct platform_device *pdev = of_find_device_by_node(node); |
2048 | 2039 | ||
2049 | int ret = __gk20a_do_unidle(pdev); | 2040 | int ret = __gk20a_do_unidle(&pdev->dev); |
2050 | 2041 | ||
2051 | of_node_put(node); | 2042 | of_node_put(node); |
2052 | 2043 | ||
@@ -2057,7 +2048,7 @@ int gk20a_do_unidle(void) | |||
2057 | int gk20a_init_gpu_characteristics(struct gk20a *g) | 2048 | int gk20a_init_gpu_characteristics(struct gk20a *g) |
2058 | { | 2049 | { |
2059 | struct nvgpu_gpu_characteristics *gpu = &g->gpu_characteristics; | 2050 | struct nvgpu_gpu_characteristics *gpu = &g->gpu_characteristics; |
2060 | struct gk20a_platform *platform = platform_get_drvdata(g->dev); | 2051 | struct gk20a_platform *platform = dev_get_drvdata(g->dev); |
2061 | 2052 | ||
2062 | gpu->L2_cache_size = g->ops.ltc.determine_L2_size_bytes(g); | 2053 | gpu->L2_cache_size = g->ops.ltc.determine_L2_size_bytes(g); |
2063 | gpu->on_board_video_memory_size = 0; /* integrated GPU */ | 2054 | gpu->on_board_video_memory_size = 0; /* integrated GPU */ |
@@ -2164,7 +2155,7 @@ do_request_firmware(struct device *dev, const char *prefix, const char *fw_name) | |||
2164 | const struct firmware * | 2155 | const struct firmware * |
2165 | gk20a_request_firmware(struct gk20a *g, const char *fw_name) | 2156 | gk20a_request_firmware(struct gk20a *g, const char *fw_name) |
2166 | { | 2157 | { |
2167 | struct device *dev = &g->dev->dev; | 2158 | struct device *dev = g->dev; |
2168 | const struct firmware *fw; | 2159 | const struct firmware *fw; |
2169 | 2160 | ||
2170 | /* current->fs is NULL when calling from SYS_EXIT. | 2161 | /* current->fs is NULL when calling from SYS_EXIT. |
@@ -2177,8 +2168,10 @@ gk20a_request_firmware(struct gk20a *g, const char *fw_name) | |||
2177 | 2168 | ||
2178 | #ifdef CONFIG_TEGRA_GK20A | 2169 | #ifdef CONFIG_TEGRA_GK20A |
2179 | /* TO BE REMOVED - Support loading from legacy SOC specific path. */ | 2170 | /* TO BE REMOVED - Support loading from legacy SOC specific path. */ |
2180 | if (!fw) | 2171 | if (!fw) { |
2181 | fw = nvhost_client_request_firmware(g->dev, fw_name); | 2172 | struct gk20a_platform *platform = gk20a_get_platform(dev); |
2173 | fw = do_request_firmware(dev, platform->soc_name, fw_name); | ||
2174 | } | ||
2182 | #endif | 2175 | #endif |
2183 | 2176 | ||
2184 | if (!fw) { | 2177 | if (!fw) { |