From patchwork Fri Aug 12 17:00:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 9277493 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1A9ED60752 for ; Fri, 12 Aug 2016 17:01:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07F2528A9C for ; Fri, 12 Aug 2016 17:01:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F122228ABE; Fri, 12 Aug 2016 17:01:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6B1CE28A9C for ; Fri, 12 Aug 2016 17:01:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F15466E306; Fri, 12 Aug 2016 17:01:02 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-x233.google.com (mail-qk0-x233.google.com [IPv6:2607:f8b0:400d:c09::233]) by gabe.freedesktop.org (Postfix) with ESMTPS id 10DA96E306 for ; Fri, 12 Aug 2016 17:01:01 +0000 (UTC) Received: by mail-qk0-x233.google.com with SMTP id l2so30610808qkf.3 for ; Fri, 12 Aug 2016 10:01:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rKyiP08skfBD5AANDYfondAGKmgQzDBmYKRmQMBoOo4=; b=YkzMff/GKjNpNFY6GHXf/DDHfKgTclxnFHfn9irlLkAgRuE7P6pk8xQ1PLt+IcUhzz 7NiFL1oZ4o9u2z/EU/MFStumBGr9PsEcCnSW3l87ft/0aTo8GR2KipVUOzoKoErmznH9 C8VU5nTEThMyBnVmjp+lRVZ4PU3F+tSkJqg8Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rKyiP08skfBD5AANDYfondAGKmgQzDBmYKRmQMBoOo4=; b=XwqOAJQdZrHcm+a2prmVUh/vwbHAij4I2A17kUXrwFlXdkbfMDDFPXR9dcTj7Qz+Xg FNB1+3pHGhPMbPLklEpv/U0O+yZIl9EB+PvjulARIkpMoZPB4EVE/nDxWvMcN5DFEAqu KhhQ9e+oNnNmw9U8Xh4Y0yb67dXjgWYpWB9Toh+aaD9ndGSjY+QYlxtuyZI1TiFNmk/7 o2t8hoVDU9ipVO8GUw4lKdbU05H6/aNVKBm06zVYupxywBRK1WogsSyxbmKRlnPxUpD4 u/zzWeq5OUGM2s7b0VhgmpB9s44fE8UKmPqx0Qfjb30bhI1lTknYjX2h4Cz22xZLjByc xDAA== X-Gm-Message-State: AEkoouszWvfDfKOQOYZDJ/C+fwDeEqiJIEqOFNyjcnCDh8gFoXzzg11XWqy0spgEOgeC+AWU X-Received: by 10.55.24.234 with SMTP id 103mr18354009qky.201.1471021260166; Fri, 12 Aug 2016 10:01:00 -0700 (PDT) Received: from boxwood.roam.corp.google.com (cpe-75-189-128-87.nc.res.rr.com. [75.189.128.87]) by smtp.gmail.com with ESMTPSA id f130sm3625043qkb.7.2016.08.12.10.00.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Aug 2016 10:00:59 -0700 (PDT) From: Sean Paul To: dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org Subject: [PATCH 1/2] drm: Introduce DRM_DEV_* log messages Date: Fri, 12 Aug 2016 13:00:53 -0400 Message-Id: <1471021254-2563-2-git-send-email-seanpaul@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1471021254-2563-1-git-send-email-seanpaul@chromium.org> References: <1471021254-2563-1-git-send-email-seanpaul@chromium.org> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch consolodates all the various log functions/macros into one uber function, drm_log. It also introduces some new DRM_DEV_* variants that print the device name to delineate multiple devices of the same type. Signed-off-by: Sean Paul --- drivers/gpu/drm/drm_drv.c | 31 +++++------ include/drm/drmP.h | 133 ++++++++++++++++++++++++---------------------- 2 files changed, 82 insertions(+), 82 deletions(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 57ce973..e8595f0 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -63,37 +63,30 @@ static struct idr drm_minors_idr; static struct dentry *drm_debugfs_root; -void drm_err(const char *format, ...) +void drm_log(const struct device *dev, const char *level, unsigned int category, + const char *function_name, const char *prefix, + const char *format, ...) { struct va_format vaf; va_list args; - va_start(args, format); - - vaf.fmt = format; - vaf.va = &args; - - printk(KERN_ERR "[" DRM_NAME ":%ps] *ERROR* %pV", - __builtin_return_address(0), &vaf); - - va_end(args); -} -EXPORT_SYMBOL(drm_err); - -void drm_ut_debug_printk(const char *function_name, const char *format, ...) -{ - struct va_format vaf; - va_list args; + if (category != DRM_UT_NONE && !(drm_debug & category)) + return; va_start(args, format); vaf.fmt = format; vaf.va = &args; - printk(KERN_DEBUG "[" DRM_NAME ":%s] %pV", function_name, &vaf); + if (dev) + printk("%s%s [" DRM_NAME ":%s]%s %pV", level, + dev_name(dev), function_name, prefix, &vaf); + else + printk("%s[" DRM_NAME ":%s]%s %pV", level, function_name, + prefix, &vaf); va_end(args); } -EXPORT_SYMBOL(drm_ut_debug_printk); +EXPORT_SYMBOL(drm_log); /* * DRM Minors diff --git a/include/drm/drmP.h b/include/drm/drmP.h index f8e87fd..9a6ace2 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -127,6 +127,7 @@ struct dma_buf_attachment; * run-time by echoing the debug value in its sysfs node: * # echo 0xf > /sys/module/drm/parameters/debug */ +#define DRM_UT_NONE 0x00 #define DRM_UT_CORE 0x01 #define DRM_UT_DRIVER 0x02 #define DRM_UT_KMS 0x04 @@ -134,11 +135,10 @@ struct dma_buf_attachment; #define DRM_UT_ATOMIC 0x10 #define DRM_UT_VBL 0x20 -extern __printf(2, 3) -void drm_ut_debug_printk(const char *function_name, - const char *format, ...); -extern __printf(1, 2) -void drm_err(const char *format, ...); +extern __printf(6, 7) +void drm_log(const struct device *dev, const char *level, unsigned int category, + const char *function_name, const char *prefix, + const char *format, ...); /***********************************************************************/ /** \name DRM template customization defaults */ @@ -169,8 +169,10 @@ void drm_err(const char *format, ...); * \param fmt printf() like format string. * \param arg arguments */ -#define DRM_ERROR(fmt, ...) \ - drm_err(fmt, ##__VA_ARGS__) +#define DRM_DEV_ERROR(dev, fmt, ...) \ + drm_log(dev, KERN_ERR, DRM_UT_NONE, __func__, " *ERROR*", fmt, \ + ##__VA_ARGS__) +#define DRM_ERROR(fmt, ...) DRM_DEV_ERROR(NULL, fmt, ##__VA_ARGS__) /** * Rate limited error output. Like DRM_ERROR() but won't flood the log. @@ -178,21 +180,31 @@ void drm_err(const char *format, ...); * \param fmt printf() like format string. * \param arg arguments */ -#define DRM_ERROR_RATELIMITED(fmt, ...) \ +#define DRM_DEV_ERROR_RATELIMITED(dev, fmt, ...) \ ({ \ static DEFINE_RATELIMIT_STATE(_rs, \ DEFAULT_RATELIMIT_INTERVAL, \ DEFAULT_RATELIMIT_BURST); \ \ if (__ratelimit(&_rs)) \ - drm_err(fmt, ##__VA_ARGS__); \ + DRM_DEV_ERROR(dev, fmt, ##__VA_ARGS__); \ }) +#define DRM_ERROR_RATELIMITED(fmt, ...) \ + DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__) -#define DRM_INFO(fmt, ...) \ - printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__) +#define DRM_DEV_INFO(dev, fmt, ...) \ + drm_log(dev, KERN_INFO, DRM_UT_NONE, __func__, "", fmt, ##__VA_ARGS__) +#define DRM_INFO(fmt, ...) DRM_DEV_INFO(NULL, fmt, ##__VA_ARGS__) -#define DRM_INFO_ONCE(fmt, ...) \ - printk_once(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__) +#define DRM_DEV_INFO_ONCE(dev, fmt, ...) \ +({ \ + static bool __print_once __read_mostly; \ + if (!__print_once) { \ + __print_once = true; \ + DRM_DEV_INFO(dev, fmt, ##__VA_ARGS__); \ + } \ +}) +#define DRM_INFO_ONCE(fmt, ...) DRM_DEV_INFO_ONCE(NULL, fmt, ##__VA_ARGS__) /** * Debug output. @@ -200,52 +212,39 @@ void drm_err(const char *format, ...); * \param fmt printf() like format string. * \param arg arguments */ -#define DRM_DEBUG(fmt, args...) \ - do { \ - if (unlikely(drm_debug & DRM_UT_CORE)) \ - drm_ut_debug_printk(__func__, fmt, ##args); \ - } while (0) - -#define DRM_DEBUG_DRIVER(fmt, args...) \ - do { \ - if (unlikely(drm_debug & DRM_UT_DRIVER)) \ - drm_ut_debug_printk(__func__, fmt, ##args); \ - } while (0) -#define DRM_DEBUG_KMS(fmt, args...) \ - do { \ - if (unlikely(drm_debug & DRM_UT_KMS)) \ - drm_ut_debug_printk(__func__, fmt, ##args); \ - } while (0) -#define DRM_DEBUG_PRIME(fmt, args...) \ - do { \ - if (unlikely(drm_debug & DRM_UT_PRIME)) \ - drm_ut_debug_printk(__func__, fmt, ##args); \ - } while (0) -#define DRM_DEBUG_ATOMIC(fmt, args...) \ - do { \ - if (unlikely(drm_debug & DRM_UT_ATOMIC)) \ - drm_ut_debug_printk(__func__, fmt, ##args); \ - } while (0) -#define DRM_DEBUG_VBL(fmt, args...) \ - do { \ - if (unlikely(drm_debug & DRM_UT_VBL)) \ - drm_ut_debug_printk(__func__, fmt, ##args); \ - } while (0) - -#define _DRM_DEFINE_DEBUG_RATELIMITED(level, fmt, args...) \ - do { \ - if (unlikely(drm_debug & DRM_UT_ ## level)) { \ - static DEFINE_RATELIMIT_STATE( \ - _rs, \ - DEFAULT_RATELIMIT_INTERVAL, \ - DEFAULT_RATELIMIT_BURST); \ - \ - if (__ratelimit(&_rs)) { \ - drm_ut_debug_printk(__func__, fmt, \ - ##args); \ - } \ - } \ - } while (0) +#define DRM_DEV_DEBUG(dev, fmt, args...) \ + drm_log(dev, KERN_DEBUG, DRM_UT_CORE, __func__, "", fmt, ##args) +#define DRM_DEBUG(fmt, args...) DRM_DEV_DEBUG(NULL, fmt, ##args) + +#define DRM_DEV_DEBUG_DRIVER(dev, fmt, args...) \ + drm_log(dev, KERN_DEBUG, DRM_UT_DRIVER, __func__, "", fmt, ##args) +#define DRM_DEBUG_DRIVER(fmt, args...) DRM_DEV_DEBUG_DRIVER(NULL, fmt, ##args) + +#define DRM_DEV_DEBUG_KMS(dev, fmt, args...) \ + drm_log(dev, KERN_DEBUG, DRM_UT_KMS, __func__, "", fmt, ##args) +#define DRM_DEBUG_KMS(fmt, args...) DRM_DEV_DEBUG_KMS(NULL, fmt, ##args) + +#define DRM_DEV_DEBUG_PRIME(dev, fmt, args...) \ + drm_log(dev, KERN_DEBUG, DRM_UT_PRIME, __func__, "", fmt, ##args) +#define DRM_DEBUG_PRIME(fmt, args...) DRM_DEV_DEBUG_PRIME(NULL, fmt, ##args) + +#define DRM_DEV_DEBUG_ATOMIC(dev, fmt, args...) \ + drm_log(dev, KERN_DEBUG, DRM_UT_ATOMIC, __func__, "", fmt, ##args) +#define DRM_DEBUG_ATOMIC(fmt, args...) DRM_DEV_DEBUG_ATOMIC(NULL, fmt, ##args) + +#define DRM_DEV_DEBUG_VBL(dev, fmt, args...) \ + drm_log(dev, KERN_DEBUG, DRM_UT_VBL, __func__, "", fmt, ##args) +#define DRM_DEBUG_VBL(fmt, args...) DRM_DEV_DEBUG_VBL(NULL, fmt, ##args) + +#define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, level, fmt, args...) \ +({ \ + static DEFINE_RATELIMIT_STATE(_rs, \ + DEFAULT_RATELIMIT_INTERVAL, \ + DEFAULT_RATELIMIT_BURST); \ + if (__ratelimit(&_rs)) \ + drm_log(dev, KERN_DEBUG, DRM_UT_ ## level, __func__, \ + "", fmt, ##args); \ +}) /** * Rate limited debug output. Like DRM_DEBUG() but won't flood the log. @@ -253,14 +252,22 @@ void drm_err(const char *format, ...); * \param fmt printf() like format string. * \param arg arguments */ +#define DRM_DEV_DEBUG_RATELIMITED(dev, fmt, args...) \ + DEV__DRM_DEFINE_DEBUG_RATELIMITED(dev, CORE, fmt, ##args) #define DRM_DEBUG_RATELIMITED(fmt, args...) \ - _DRM_DEFINE_DEBUG_RATELIMITED(CORE, fmt, ##args) + DRM_DEV_DEBUG_RATELIMITED(NULL, fmt, ##args) +#define DRM_DEV_DEBUG_DRIVER_RATELIMITED(dev, fmt, args...) \ + _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRIVER, fmt, ##args) #define DRM_DEBUG_DRIVER_RATELIMITED(fmt, args...) \ - _DRM_DEFINE_DEBUG_RATELIMITED(DRIVER, fmt, ##args) + DRM_DEV_DEBUG_DRIVER_RATELIMITED(NULL, fmt, ##args) +#define DRM_DEV_DEBUG_KMS_RATELIMITED(dev, fmt, args...) \ + _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, KMS, fmt, ##args) #define DRM_DEBUG_KMS_RATELIMITED(fmt, args...) \ - _DRM_DEFINE_DEBUG_RATELIMITED(KMS, fmt, ##args) + DRM_DEV_DEBUG_KMS_RATELIMITED(NULL, fmt, ##args) +#define DRM_DEV_DEBUG_PRIME_RATELIMITED(dev, fmt, args...) \ + _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, PRIME, fmt, ##args) #define DRM_DEBUG_PRIME_RATELIMITED(fmt, args...) \ - _DRM_DEFINE_DEBUG_RATELIMITED(PRIME, fmt, ##args) + DRM_DEV_DEBUG_PRIME_RATELIMITED(NULL, fmt, ##args) /*@}*/