From patchwork Wed Jan 9 04:08:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 13928 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 4977823E33 for ; Wed, 9 Jan 2013 04:09:14 +0000 (UTC) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by fiordland.canonical.com (Postfix) with ESMTP id E414DA18EA5 for ; Wed, 9 Jan 2013 04:09:13 +0000 (UTC) Received: by mail-vc0-f173.google.com with SMTP id f13so1162666vcb.4 for ; Tue, 08 Jan 2013 20:09:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:dkim-signature:x-received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references:x-gm-message-state; bh=HrI6bakw+5agz16GPSicVTWpf8V8p952mMp6T0toins=; b=QKsw/9a5IS6Td5e6Vrd9ZVwK4b/slE3TfOwcLyw1iDC+fRdKJ4zqllBnIJUKfRkYUs 6LHosmqGjp1FMmuJnPU41YBCiXXhcPqt+PGfrJ3NzPtaiUAXCVIcaKJWKyXWJOiEclw1 3bT+uZNDyNK0mtvhvMQbF1W4vheuJGfdKvruhA6fi1CLWtcxv61UsQPXRdQTlWoW7CBB pV9CHK3sjMpfsy2g2QlB3rjVk06HhjAafYBJEuue07a1SnZKQ9UNY/S5I2zjcVaSwbQs 2GHWjJX/aLR+zbRgqrjMlLUyXW24jMiy++M2jlnPtI4S3YSYPjobMmKaljb7o++sHjJt Xd4Q== X-Received: by 10.52.18.147 with SMTP id w19mr77424882vdd.94.1357704553425; Tue, 08 Jan 2013 20:09:13 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp144863veb; Tue, 8 Jan 2013 20:09:12 -0800 (PST) X-Received: by 10.68.225.232 with SMTP id rn8mr204886555pbc.34.1357704552357; Tue, 08 Jan 2013 20:09:12 -0800 (PST) Received: from mail-da0-f49.google.com (mail-da0-f49.google.com [209.85.210.49]) by mx.google.com with ESMTPS id p7si65174654pav.50.2013.01.08.20.09.12 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 Jan 2013 20:09:12 -0800 (PST) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 209.85.210.49 as permitted sender) client-ip=209.85.210.49; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robdclark@gmail.com designates 209.85.210.49 as permitted sender) smtp.mail=robdclark@gmail.com; dkim=pass header.i=@gmail.com Received: by mail-da0-f49.google.com with SMTP id v40so529753dad.8 for ; Tue, 08 Jan 2013 20:09:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=HrI6bakw+5agz16GPSicVTWpf8V8p952mMp6T0toins=; b=Y5s/EPV7Ir6Dq768bgCH9oSQqxHPkma8TiuTbTAmYMlslZmDV7KpFHeR1sYGXl2klZ WoZsFdaalVSfZiewjKcEUhlZO/o0o0X1wX4KOxrhJPzz/2TXvYCt9PwzZWOrTDJr+Rq2 yuJ6R0fVG+lHCCpB1cXX1SCFVkzsdojqqhygvyEvlaDzsgANVQfVNAdfzqCXF5l1FDAh F9N5rV0wipghwW7TUP8apNwI9/3JuWn3NlGXNyvUxn7JxUVFWTLTPen9ahXe7lIqZxik BGpsfy7ZZAnlMIdaR36IYoUuEEATj7EKLy9QXwZFSiU/nJYZQmthf/PoWYOztN3wQsib FTrw== X-Received: by 10.66.90.1 with SMTP id bs1mr185725200pab.19.1357704551999; Tue, 08 Jan 2013 20:09:11 -0800 (PST) Received: from localhost (pool-74-100-87-234.lsanca.fios.verizon.net. [74.100.87.234]) by mx.google.com with ESMTPS id qn3sm38653714pbb.56.2013.01.08.20.09.10 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 Jan 2013 20:09:11 -0800 (PST) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: patches@linaro.org, Rob Clark Subject: [PATCH 2/4] drm/cma: add debugfs helpers Date: Tue, 8 Jan 2013 22:08:44 -0600 Message-Id: <1357704526-3447-3-git-send-email-robdclark@gmail.com> X-Mailer: git-send-email 1.8.0.2 In-Reply-To: <1357704526-3447-1-git-send-email-robdclark@gmail.com> References: <1357704526-3447-1-git-send-email-robdclark@gmail.com> X-Gm-Message-State: ALoCoQlROeWKHyDnXwl4IGSEqVGUTvX/HtZM+BEKg+wU6fM7LgY5S+1/ooWnz0UtLLJ/4C6sZO6M Add helper to display fb's which can be used directly in drm_info_list: static struct drm_info_list foo_debugfs_list[] = { ... { "fb", drm_fb_cma_debugfs_show, 0 }, }; to display information about CMA fb objects, as well as a drm_gem_cma_describe() which can be used if the driver bothers to keep a list of CMA GEM objects. Signed-off-by: Rob Clark --- drivers/gpu/drm/drm_fb_cma_helper.c | 53 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_gem_cma_helper.c | 21 ++++++++++++++ include/drm/drm_fb_cma_helper.h | 5 ++++ include/drm/drm_gem_cma_helper.h | 4 +++ 4 files changed, 83 insertions(+) diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c index fd9d0af..18866ee 100644 --- a/drivers/gpu/drm/drm_fb_cma_helper.c +++ b/drivers/gpu/drm/drm_fb_cma_helper.c @@ -180,6 +180,59 @@ struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct drm_framebuffer *fb, } EXPORT_SYMBOL_GPL(drm_fb_cma_get_gem_obj); +#ifdef CONFIG_DEBUG_FS +/** + * drm_fb_cma_describe() - Helper to dump information about a single + * CMA framebuffer object + */ +void drm_fb_cma_describe(struct drm_framebuffer *fb, struct seq_file *m) +{ + struct drm_fb_cma *fb_cma = to_fb_cma(fb); + int i, n = drm_format_num_planes(fb->pixel_format); + + seq_printf(m, "fb: %dx%d@%4.4s\n", fb->width, fb->height, + (char *)&fb->pixel_format); + + for (i = 0; i < n; i++) { + seq_printf(m, " %d: offset=%d pitch=%d, obj: ", + i, fb->offsets[i], fb->pitches[i]); + drm_gem_cma_describe(fb_cma->obj[i], m); + } +} +EXPORT_SYMBOL_GPL(drm_fb_cma_describe); + +/** + * drm_fb_cma_debugfs_show() - Helper to list CMA framebuffer objects + * in debugfs. + */ +int drm_fb_cma_debugfs_show(struct seq_file *m, void *arg) +{ + struct drm_info_node *node = (struct drm_info_node *) m->private; + struct drm_device *dev = node->minor->dev; + struct drm_framebuffer *fb; + int ret; + + ret = mutex_lock_interruptible(&dev->mode_config.mutex); + if (ret) + return ret; + + ret = mutex_lock_interruptible(&dev->struct_mutex); + if (ret) { + mutex_unlock(&dev->mode_config.mutex); + return ret; + } + + list_for_each_entry(fb, &dev->mode_config.fb_list, head) + drm_fb_cma_describe(fb, m); + + mutex_unlock(&dev->struct_mutex); + mutex_unlock(&dev->mode_config.mutex); + + return 0; +} +EXPORT_SYMBOL_GPL(drm_fb_cma_debugfs_show); +#endif + static struct fb_ops drm_fbdev_cma_ops = { .owner = THIS_MODULE, .fb_fillrect = sys_fillrect, diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c index 1aa8fee..0a7e011 100644 --- a/drivers/gpu/drm/drm_gem_cma_helper.c +++ b/drivers/gpu/drm/drm_gem_cma_helper.c @@ -249,3 +249,24 @@ int drm_gem_cma_dumb_destroy(struct drm_file *file_priv, return drm_gem_handle_delete(file_priv, handle); } EXPORT_SYMBOL_GPL(drm_gem_cma_dumb_destroy); + +#ifdef CONFIG_DEBUG_FS +void drm_gem_cma_describe(struct drm_gem_cma_object *cma_obj, struct seq_file *m) +{ + struct drm_gem_object *obj = &cma_obj->base; + struct drm_device *dev = obj->dev; + uint64_t off = 0; + + WARN_ON(!mutex_is_locked(&dev->struct_mutex)); + + if (obj->map_list.map) + off = (uint64_t)obj->map_list.hash.key; + + seq_printf(m, "%2d (%2d) %08llx %08Zx %p %d", + obj->name, obj->refcount.refcount.counter, + off, cma_obj->paddr, cma_obj->vaddr, obj->size); + + seq_printf(m, "\n"); +} +EXPORT_SYMBOL_GPL(drm_gem_cma_describe); +#endif diff --git a/include/drm/drm_fb_cma_helper.h b/include/drm/drm_fb_cma_helper.h index 76c7098..4a3fc24 100644 --- a/include/drm/drm_fb_cma_helper.h +++ b/include/drm/drm_fb_cma_helper.h @@ -23,5 +23,10 @@ struct drm_framebuffer *drm_fb_cma_create(struct drm_device *dev, struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct drm_framebuffer *fb, unsigned int plane); +#ifdef CONFIG_DEBUG_FS +void drm_fb_cma_describe(struct drm_framebuffer *fb, struct seq_file *m); +int drm_fb_cma_debugfs_show(struct seq_file *m, void *arg); +#endif + #endif diff --git a/include/drm/drm_gem_cma_helper.h b/include/drm/drm_gem_cma_helper.h index f0f6b1a..63397ce 100644 --- a/include/drm/drm_gem_cma_helper.h +++ b/include/drm/drm_gem_cma_helper.h @@ -41,4 +41,8 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, extern const struct vm_operations_struct drm_gem_cma_vm_ops; +#ifdef CONFIG_DEBUG_FS +void drm_gem_cma_describe(struct drm_gem_cma_object *obj, struct seq_file *m); +#endif + #endif /* __DRM_GEM_CMA_HELPER_H__ */