···11+/*22+ * Copyright (C) 2013-2016 Red Hat33+ * Author: Rob Clark <robdclark@gmail.com>44+ *55+ * This program is free software; you can redistribute it and/or modify it66+ * under the terms of the GNU General Public License version 2 as published by77+ * the Free Software Foundation.88+ *99+ * This program is distributed in the hope that it will be useful, but WITHOUT1010+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or1111+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for1212+ * more details.1313+ *1414+ * You should have received a copy of the GNU General Public License along with1515+ * this program. If not, see <http://www.gnu.org/licenses/>.1616+ */1717+1818+#ifdef CONFIG_DEBUG_FS1919+#include "msm_drv.h"2020+#include "msm_gpu.h"2121+2222+static int msm_gpu_show(struct drm_device *dev, struct seq_file *m)2323+{2424+ struct msm_drm_private *priv = dev->dev_private;2525+ struct msm_gpu *gpu = priv->gpu;2626+2727+ if (gpu) {2828+ seq_printf(m, "%s Status:\n", gpu->name);2929+ gpu->funcs->show(gpu, m);3030+ }3131+3232+ return 0;3333+}3434+3535+static int msm_gem_show(struct drm_device *dev, struct seq_file *m)3636+{3737+ struct msm_drm_private *priv = dev->dev_private;3838+ struct msm_gpu *gpu = priv->gpu;3939+4040+ if (gpu) {4141+ seq_printf(m, "Active Objects (%s):\n", gpu->name);4242+ msm_gem_describe_objects(&gpu->active_list, m);4343+ }4444+4545+ seq_printf(m, "Inactive Objects:\n");4646+ msm_gem_describe_objects(&priv->inactive_list, m);4747+4848+ return 0;4949+}5050+5151+static int msm_mm_show(struct drm_device *dev, struct seq_file *m)5252+{5353+ return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm);5454+}5555+5656+static int msm_fb_show(struct drm_device *dev, struct seq_file *m)5757+{5858+ struct msm_drm_private *priv = dev->dev_private;5959+ struct drm_framebuffer *fb, *fbdev_fb = NULL;6060+6161+ if (priv->fbdev) {6262+ seq_printf(m, "fbcon ");6363+ fbdev_fb = priv->fbdev->fb;6464+ msm_framebuffer_describe(fbdev_fb, m);6565+ }6666+6767+ mutex_lock(&dev->mode_config.fb_lock);6868+ list_for_each_entry(fb, &dev->mode_config.fb_list, head) {6969+ if (fb == fbdev_fb)7070+ continue;7171+7272+ seq_printf(m, "user ");7373+ msm_framebuffer_describe(fb, m);7474+ }7575+ mutex_unlock(&dev->mode_config.fb_lock);7676+7777+ return 0;7878+}7979+8080+static int show_locked(struct seq_file *m, void *arg)8181+{8282+ struct drm_info_node *node = (struct drm_info_node *) m->private;8383+ struct drm_device *dev = node->minor->dev;8484+ int (*show)(struct drm_device *dev, struct seq_file *m) =8585+ node->info_ent->data;8686+ int ret;8787+8888+ ret = mutex_lock_interruptible(&dev->struct_mutex);8989+ if (ret)9090+ return ret;9191+9292+ ret = show(dev, m);9393+9494+ mutex_unlock(&dev->struct_mutex);9595+9696+ return ret;9797+}9898+9999+static struct drm_info_list msm_debugfs_list[] = {100100+ {"gpu", show_locked, 0, msm_gpu_show},101101+ {"gem", show_locked, 0, msm_gem_show},102102+ { "mm", show_locked, 0, msm_mm_show },103103+ { "fb", show_locked, 0, msm_fb_show },104104+};105105+106106+static int late_init_minor(struct drm_minor *minor)107107+{108108+ int ret;109109+110110+ if (!minor)111111+ return 0;112112+113113+ ret = msm_rd_debugfs_init(minor);114114+ if (ret) {115115+ dev_err(minor->dev->dev, "could not install rd debugfs\n");116116+ return ret;117117+ }118118+119119+ ret = msm_perf_debugfs_init(minor);120120+ if (ret) {121121+ dev_err(minor->dev->dev, "could not install perf debugfs\n");122122+ return ret;123123+ }124124+125125+ return 0;126126+}127127+128128+int msm_debugfs_late_init(struct drm_device *dev)129129+{130130+ int ret;131131+ ret = late_init_minor(dev->primary);132132+ if (ret)133133+ return ret;134134+ ret = late_init_minor(dev->render);135135+ if (ret)136136+ return ret;137137+ ret = late_init_minor(dev->control);138138+ return ret;139139+}140140+141141+int msm_debugfs_init(struct drm_minor *minor)142142+{143143+ struct drm_device *dev = minor->dev;144144+ int ret;145145+146146+ ret = drm_debugfs_create_files(msm_debugfs_list,147147+ ARRAY_SIZE(msm_debugfs_list),148148+ minor->debugfs_root, minor);149149+150150+ if (ret) {151151+ dev_err(dev->dev, "could not install msm_debugfs_list\n");152152+ return ret;153153+ }154154+155155+ return 0;156156+}157157+158158+void msm_debugfs_cleanup(struct drm_minor *minor)159159+{160160+ drm_debugfs_remove_files(msm_debugfs_list,161161+ ARRAY_SIZE(msm_debugfs_list), minor);162162+ if (!minor->dev->dev_private)163163+ return;164164+ msm_rd_debugfs_cleanup(minor);165165+ msm_perf_debugfs_cleanup(minor);166166+}167167+#endif168168+
+26
drivers/gpu/drm/msm/msm_debugfs.h
···11+/*22+ * Copyright (C) 2016 Red Hat33+ * Author: Rob Clark <robdclark@gmail.com>44+ *55+ * This program is free software; you can redistribute it and/or modify it66+ * under the terms of the GNU General Public License version 2 as published by77+ * the Free Software Foundation.88+ *99+ * This program is distributed in the hope that it will be useful, but WITHOUT1010+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or1111+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for1212+ * more details.1313+ *1414+ * You should have received a copy of the GNU General Public License along with1515+ * this program. If not, see <http://www.gnu.org/licenses/>.1616+ */1717+1818+#ifndef __MSM_DEBUGFS_H__1919+#define __MSM_DEBUGFS_H__2020+2121+#ifdef CONFIG_DEBUG_FS2222+int msm_debugfs_init(struct drm_minor *minor);2323+void msm_debugfs_cleanup(struct drm_minor *minor);2424+#endif2525+2626+#endif /* __MSM_DEBUGFS_H__ */
+1-152
drivers/gpu/drm/msm/msm_drv.c
···1616 */17171818#include "msm_drv.h"1919+#include "msm_debugfs.h"1920#include "msm_gpu.h"2021#include "msm_kms.h"2122···535534 DBG("dev=%p, crtc=%u", dev, pipe);536535 vblank_ctrl_queue_work(priv, pipe, false);537536}538538-539539-/*540540- * DRM debugfs:541541- */542542-543543-#ifdef CONFIG_DEBUG_FS544544-static int msm_gpu_show(struct drm_device *dev, struct seq_file *m)545545-{546546- struct msm_drm_private *priv = dev->dev_private;547547- struct msm_gpu *gpu = priv->gpu;548548-549549- if (gpu) {550550- seq_printf(m, "%s Status:\n", gpu->name);551551- gpu->funcs->show(gpu, m);552552- }553553-554554- return 0;555555-}556556-557557-static int msm_gem_show(struct drm_device *dev, struct seq_file *m)558558-{559559- struct msm_drm_private *priv = dev->dev_private;560560- struct msm_gpu *gpu = priv->gpu;561561-562562- if (gpu) {563563- seq_printf(m, "Active Objects (%s):\n", gpu->name);564564- msm_gem_describe_objects(&gpu->active_list, m);565565- }566566-567567- seq_printf(m, "Inactive Objects:\n");568568- msm_gem_describe_objects(&priv->inactive_list, m);569569-570570- return 0;571571-}572572-573573-static int msm_mm_show(struct drm_device *dev, struct seq_file *m)574574-{575575- return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm);576576-}577577-578578-static int msm_fb_show(struct drm_device *dev, struct seq_file *m)579579-{580580- struct msm_drm_private *priv = dev->dev_private;581581- struct drm_framebuffer *fb, *fbdev_fb = NULL;582582-583583- if (priv->fbdev) {584584- seq_printf(m, "fbcon ");585585- fbdev_fb = priv->fbdev->fb;586586- msm_framebuffer_describe(fbdev_fb, m);587587- }588588-589589- mutex_lock(&dev->mode_config.fb_lock);590590- list_for_each_entry(fb, &dev->mode_config.fb_list, head) {591591- if (fb == fbdev_fb)592592- continue;593593-594594- seq_printf(m, "user ");595595- msm_framebuffer_describe(fb, m);596596- }597597- mutex_unlock(&dev->mode_config.fb_lock);598598-599599- return 0;600600-}601601-602602-static int show_locked(struct seq_file *m, void *arg)603603-{604604- struct drm_info_node *node = (struct drm_info_node *) m->private;605605- struct drm_device *dev = node->minor->dev;606606- int (*show)(struct drm_device *dev, struct seq_file *m) =607607- node->info_ent->data;608608- int ret;609609-610610- ret = mutex_lock_interruptible(&dev->struct_mutex);611611- if (ret)612612- return ret;613613-614614- ret = show(dev, m);615615-616616- mutex_unlock(&dev->struct_mutex);617617-618618- return ret;619619-}620620-621621-static struct drm_info_list msm_debugfs_list[] = {622622- {"gpu", show_locked, 0, msm_gpu_show},623623- {"gem", show_locked, 0, msm_gem_show},624624- { "mm", show_locked, 0, msm_mm_show },625625- { "fb", show_locked, 0, msm_fb_show },626626-};627627-628628-static int late_init_minor(struct drm_minor *minor)629629-{630630- int ret;631631-632632- if (!minor)633633- return 0;634634-635635- ret = msm_rd_debugfs_init(minor);636636- if (ret) {637637- dev_err(minor->dev->dev, "could not install rd debugfs\n");638638- return ret;639639- }640640-641641- ret = msm_perf_debugfs_init(minor);642642- if (ret) {643643- dev_err(minor->dev->dev, "could not install perf debugfs\n");644644- return ret;645645- }646646-647647- return 0;648648-}649649-650650-int msm_debugfs_late_init(struct drm_device *dev)651651-{652652- int ret;653653- ret = late_init_minor(dev->primary);654654- if (ret)655655- return ret;656656- ret = late_init_minor(dev->render);657657- if (ret)658658- return ret;659659- ret = late_init_minor(dev->control);660660- return ret;661661-}662662-663663-static int msm_debugfs_init(struct drm_minor *minor)664664-{665665- struct drm_device *dev = minor->dev;666666- int ret;667667-668668- ret = drm_debugfs_create_files(msm_debugfs_list,669669- ARRAY_SIZE(msm_debugfs_list),670670- minor->debugfs_root, minor);671671-672672- if (ret) {673673- dev_err(dev->dev, "could not install msm_debugfs_list\n");674674- return ret;675675- }676676-677677- return 0;678678-}679679-680680-static void msm_debugfs_cleanup(struct drm_minor *minor)681681-{682682- drm_debugfs_remove_files(msm_debugfs_list,683683- ARRAY_SIZE(msm_debugfs_list), minor);684684- if (!minor->dev->dev_private)685685- return;686686- msm_rd_debugfs_cleanup(minor);687687- msm_perf_debugfs_cleanup(minor);688688-}689689-#endif690537691538/*692539 * Fences: