Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/msm: move debugfs code to it's own file

Signed-off-by: Rob Clark <robdclark@gmail.com>

Rob Clark edcd60ce 824815c4

+196 -152
+1
drivers/gpu/drm/msm/Makefile
··· 39 39 mdp/mdp5/mdp5_plane.o \ 40 40 mdp/mdp5/mdp5_smp.o \ 41 41 msm_atomic.o \ 42 + msm_debugfs.o \ 42 43 msm_drv.o \ 43 44 msm_fb.o \ 44 45 msm_gem.o \
+168
drivers/gpu/drm/msm/msm_debugfs.c
··· 1 + /* 2 + * Copyright (C) 2013-2016 Red Hat 3 + * Author: Rob Clark <robdclark@gmail.com> 4 + * 5 + * This program is free software; you can redistribute it and/or modify it 6 + * under the terms of the GNU General Public License version 2 as published by 7 + * the Free Software Foundation. 8 + * 9 + * This program is distributed in the hope that it will be useful, but WITHOUT 10 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 + * more details. 13 + * 14 + * You should have received a copy of the GNU General Public License along with 15 + * this program. If not, see <http://www.gnu.org/licenses/>. 16 + */ 17 + 18 + #ifdef CONFIG_DEBUG_FS 19 + #include "msm_drv.h" 20 + #include "msm_gpu.h" 21 + 22 + static int msm_gpu_show(struct drm_device *dev, struct seq_file *m) 23 + { 24 + struct msm_drm_private *priv = dev->dev_private; 25 + struct msm_gpu *gpu = priv->gpu; 26 + 27 + if (gpu) { 28 + seq_printf(m, "%s Status:\n", gpu->name); 29 + gpu->funcs->show(gpu, m); 30 + } 31 + 32 + return 0; 33 + } 34 + 35 + static int msm_gem_show(struct drm_device *dev, struct seq_file *m) 36 + { 37 + struct msm_drm_private *priv = dev->dev_private; 38 + struct msm_gpu *gpu = priv->gpu; 39 + 40 + if (gpu) { 41 + seq_printf(m, "Active Objects (%s):\n", gpu->name); 42 + msm_gem_describe_objects(&gpu->active_list, m); 43 + } 44 + 45 + seq_printf(m, "Inactive Objects:\n"); 46 + msm_gem_describe_objects(&priv->inactive_list, m); 47 + 48 + return 0; 49 + } 50 + 51 + static int msm_mm_show(struct drm_device *dev, struct seq_file *m) 52 + { 53 + return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm); 54 + } 55 + 56 + static int msm_fb_show(struct drm_device *dev, struct seq_file *m) 57 + { 58 + struct msm_drm_private *priv = dev->dev_private; 59 + struct drm_framebuffer *fb, *fbdev_fb = NULL; 60 + 61 + if (priv->fbdev) { 62 + seq_printf(m, "fbcon "); 63 + fbdev_fb = priv->fbdev->fb; 64 + msm_framebuffer_describe(fbdev_fb, m); 65 + } 66 + 67 + mutex_lock(&dev->mode_config.fb_lock); 68 + list_for_each_entry(fb, &dev->mode_config.fb_list, head) { 69 + if (fb == fbdev_fb) 70 + continue; 71 + 72 + seq_printf(m, "user "); 73 + msm_framebuffer_describe(fb, m); 74 + } 75 + mutex_unlock(&dev->mode_config.fb_lock); 76 + 77 + return 0; 78 + } 79 + 80 + static int show_locked(struct seq_file *m, void *arg) 81 + { 82 + struct drm_info_node *node = (struct drm_info_node *) m->private; 83 + struct drm_device *dev = node->minor->dev; 84 + int (*show)(struct drm_device *dev, struct seq_file *m) = 85 + node->info_ent->data; 86 + int ret; 87 + 88 + ret = mutex_lock_interruptible(&dev->struct_mutex); 89 + if (ret) 90 + return ret; 91 + 92 + ret = show(dev, m); 93 + 94 + mutex_unlock(&dev->struct_mutex); 95 + 96 + return ret; 97 + } 98 + 99 + static struct drm_info_list msm_debugfs_list[] = { 100 + {"gpu", show_locked, 0, msm_gpu_show}, 101 + {"gem", show_locked, 0, msm_gem_show}, 102 + { "mm", show_locked, 0, msm_mm_show }, 103 + { "fb", show_locked, 0, msm_fb_show }, 104 + }; 105 + 106 + static int late_init_minor(struct drm_minor *minor) 107 + { 108 + int ret; 109 + 110 + if (!minor) 111 + return 0; 112 + 113 + ret = msm_rd_debugfs_init(minor); 114 + if (ret) { 115 + dev_err(minor->dev->dev, "could not install rd debugfs\n"); 116 + return ret; 117 + } 118 + 119 + ret = msm_perf_debugfs_init(minor); 120 + if (ret) { 121 + dev_err(minor->dev->dev, "could not install perf debugfs\n"); 122 + return ret; 123 + } 124 + 125 + return 0; 126 + } 127 + 128 + int msm_debugfs_late_init(struct drm_device *dev) 129 + { 130 + int ret; 131 + ret = late_init_minor(dev->primary); 132 + if (ret) 133 + return ret; 134 + ret = late_init_minor(dev->render); 135 + if (ret) 136 + return ret; 137 + ret = late_init_minor(dev->control); 138 + return ret; 139 + } 140 + 141 + int msm_debugfs_init(struct drm_minor *minor) 142 + { 143 + struct drm_device *dev = minor->dev; 144 + int ret; 145 + 146 + ret = drm_debugfs_create_files(msm_debugfs_list, 147 + ARRAY_SIZE(msm_debugfs_list), 148 + minor->debugfs_root, minor); 149 + 150 + if (ret) { 151 + dev_err(dev->dev, "could not install msm_debugfs_list\n"); 152 + return ret; 153 + } 154 + 155 + return 0; 156 + } 157 + 158 + void msm_debugfs_cleanup(struct drm_minor *minor) 159 + { 160 + drm_debugfs_remove_files(msm_debugfs_list, 161 + ARRAY_SIZE(msm_debugfs_list), minor); 162 + if (!minor->dev->dev_private) 163 + return; 164 + msm_rd_debugfs_cleanup(minor); 165 + msm_perf_debugfs_cleanup(minor); 166 + } 167 + #endif 168 +
+26
drivers/gpu/drm/msm/msm_debugfs.h
··· 1 + /* 2 + * Copyright (C) 2016 Red Hat 3 + * Author: Rob Clark <robdclark@gmail.com> 4 + * 5 + * This program is free software; you can redistribute it and/or modify it 6 + * under the terms of the GNU General Public License version 2 as published by 7 + * the Free Software Foundation. 8 + * 9 + * This program is distributed in the hope that it will be useful, but WITHOUT 10 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 + * more details. 13 + * 14 + * You should have received a copy of the GNU General Public License along with 15 + * this program. If not, see <http://www.gnu.org/licenses/>. 16 + */ 17 + 18 + #ifndef __MSM_DEBUGFS_H__ 19 + #define __MSM_DEBUGFS_H__ 20 + 21 + #ifdef CONFIG_DEBUG_FS 22 + int msm_debugfs_init(struct drm_minor *minor); 23 + void msm_debugfs_cleanup(struct drm_minor *minor); 24 + #endif 25 + 26 + #endif /* __MSM_DEBUGFS_H__ */
+1 -152
drivers/gpu/drm/msm/msm_drv.c
··· 16 16 */ 17 17 18 18 #include "msm_drv.h" 19 + #include "msm_debugfs.h" 19 20 #include "msm_gpu.h" 20 21 #include "msm_kms.h" 21 22 ··· 535 534 DBG("dev=%p, crtc=%u", dev, pipe); 536 535 vblank_ctrl_queue_work(priv, pipe, false); 537 536 } 538 - 539 - /* 540 - * DRM debugfs: 541 - */ 542 - 543 - #ifdef CONFIG_DEBUG_FS 544 - static int msm_gpu_show(struct drm_device *dev, struct seq_file *m) 545 - { 546 - struct msm_drm_private *priv = dev->dev_private; 547 - struct msm_gpu *gpu = priv->gpu; 548 - 549 - if (gpu) { 550 - seq_printf(m, "%s Status:\n", gpu->name); 551 - gpu->funcs->show(gpu, m); 552 - } 553 - 554 - return 0; 555 - } 556 - 557 - static int msm_gem_show(struct drm_device *dev, struct seq_file *m) 558 - { 559 - struct msm_drm_private *priv = dev->dev_private; 560 - struct msm_gpu *gpu = priv->gpu; 561 - 562 - if (gpu) { 563 - seq_printf(m, "Active Objects (%s):\n", gpu->name); 564 - msm_gem_describe_objects(&gpu->active_list, m); 565 - } 566 - 567 - seq_printf(m, "Inactive Objects:\n"); 568 - msm_gem_describe_objects(&priv->inactive_list, m); 569 - 570 - return 0; 571 - } 572 - 573 - static int msm_mm_show(struct drm_device *dev, struct seq_file *m) 574 - { 575 - return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm); 576 - } 577 - 578 - static int msm_fb_show(struct drm_device *dev, struct seq_file *m) 579 - { 580 - struct msm_drm_private *priv = dev->dev_private; 581 - struct drm_framebuffer *fb, *fbdev_fb = NULL; 582 - 583 - if (priv->fbdev) { 584 - seq_printf(m, "fbcon "); 585 - fbdev_fb = priv->fbdev->fb; 586 - msm_framebuffer_describe(fbdev_fb, m); 587 - } 588 - 589 - mutex_lock(&dev->mode_config.fb_lock); 590 - list_for_each_entry(fb, &dev->mode_config.fb_list, head) { 591 - if (fb == fbdev_fb) 592 - continue; 593 - 594 - seq_printf(m, "user "); 595 - msm_framebuffer_describe(fb, m); 596 - } 597 - mutex_unlock(&dev->mode_config.fb_lock); 598 - 599 - return 0; 600 - } 601 - 602 - static int show_locked(struct seq_file *m, void *arg) 603 - { 604 - struct drm_info_node *node = (struct drm_info_node *) m->private; 605 - struct drm_device *dev = node->minor->dev; 606 - int (*show)(struct drm_device *dev, struct seq_file *m) = 607 - node->info_ent->data; 608 - int ret; 609 - 610 - ret = mutex_lock_interruptible(&dev->struct_mutex); 611 - if (ret) 612 - return ret; 613 - 614 - ret = show(dev, m); 615 - 616 - mutex_unlock(&dev->struct_mutex); 617 - 618 - return ret; 619 - } 620 - 621 - static struct drm_info_list msm_debugfs_list[] = { 622 - {"gpu", show_locked, 0, msm_gpu_show}, 623 - {"gem", show_locked, 0, msm_gem_show}, 624 - { "mm", show_locked, 0, msm_mm_show }, 625 - { "fb", show_locked, 0, msm_fb_show }, 626 - }; 627 - 628 - static int late_init_minor(struct drm_minor *minor) 629 - { 630 - int ret; 631 - 632 - if (!minor) 633 - return 0; 634 - 635 - ret = msm_rd_debugfs_init(minor); 636 - if (ret) { 637 - dev_err(minor->dev->dev, "could not install rd debugfs\n"); 638 - return ret; 639 - } 640 - 641 - ret = msm_perf_debugfs_init(minor); 642 - if (ret) { 643 - dev_err(minor->dev->dev, "could not install perf debugfs\n"); 644 - return ret; 645 - } 646 - 647 - return 0; 648 - } 649 - 650 - int msm_debugfs_late_init(struct drm_device *dev) 651 - { 652 - int ret; 653 - ret = late_init_minor(dev->primary); 654 - if (ret) 655 - return ret; 656 - ret = late_init_minor(dev->render); 657 - if (ret) 658 - return ret; 659 - ret = late_init_minor(dev->control); 660 - return ret; 661 - } 662 - 663 - static int msm_debugfs_init(struct drm_minor *minor) 664 - { 665 - struct drm_device *dev = minor->dev; 666 - int ret; 667 - 668 - ret = drm_debugfs_create_files(msm_debugfs_list, 669 - ARRAY_SIZE(msm_debugfs_list), 670 - minor->debugfs_root, minor); 671 - 672 - if (ret) { 673 - dev_err(dev->dev, "could not install msm_debugfs_list\n"); 674 - return ret; 675 - } 676 - 677 - return 0; 678 - } 679 - 680 - static void msm_debugfs_cleanup(struct drm_minor *minor) 681 - { 682 - drm_debugfs_remove_files(msm_debugfs_list, 683 - ARRAY_SIZE(msm_debugfs_list), minor); 684 - if (!minor->dev->dev_private) 685 - return; 686 - msm_rd_debugfs_cleanup(minor); 687 - msm_perf_debugfs_cleanup(minor); 688 - } 689 - #endif 690 537 691 538 /* 692 539 * Fences: