From patchwork Tue Dec 6 18:58:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 9463677 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 C826160459 for ; Wed, 7 Dec 2016 00:55:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8A9D284D9 for ; Wed, 7 Dec 2016 00:55:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD241284F2; Wed, 7 Dec 2016 00:55:54 +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=unavailable 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 BF399284D9 for ; Wed, 7 Dec 2016 00:55:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 894BB6E506; Wed, 7 Dec 2016 00:55:29 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id C63F36E417 for ; Tue, 6 Dec 2016 18:58:20 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id g23so23341213wme.1 for ; Tue, 06 Dec 2016 10:58:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ursulin-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CH2z9HNGyY6mezGSFj4RVx0AFsixsbkF6Cd00illH88=; b=kLFGLXMJHLj2371Kw553LxjzBo8MSigLzJlpC1Hk6/s57uHVKYF3t9dru4Edq8ka0B oD7gEXlPFvAM6v+pcsfVbbWHv4AeFl6m8qppcvt7V+9z4Y0YJhMDgTd7ZfyO0CjohB6r uJgQptHQVos7evAS4CnsjvuU7/YQcgaSW2Idmm51i+rnhNyWUCyu/kt25qR1weDGy7a5 duuHR3Oe2EuzqbU7TKJxpkQ60qJ5Q+g11m5DFBOjFHCycSTBTV2ReqTWCHGlvIVlPkO+ TsZT3CCy65DxWbUwA9Wuk0bNEAMVSOm6kDGa8bHyScMmThPGQene5PcesJjUFoewI+0W EM7Q== 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=CH2z9HNGyY6mezGSFj4RVx0AFsixsbkF6Cd00illH88=; b=XOMS4c58epHHJiPvk0oLX1OhL+/h0Ywn3+04aA5B/mq6GZQnCdBQ/Yh3Uy4ykCLq9O CD0eEkWfW3d+lmTFQAe+Ycqt0hL5J1EkcSPhIGAikcnT/u0HeCbnoKvXGkwh7Ojxx2Kf 5YkM/QbyWeWL0KqsIJlWaz8rOl8UJPaJmGp3XHK8HVb3iv+KF8mfvZw/GTBcLSWClbG9 6eqJqML+rEoVA/i7BQj8MFxmpToWtM8UGZWGbUVWLsdhsmeD2YEx3PFurjXdBqbaYc0f mksDE4F4ure7VktFhcgkAmr9uKkyubE7Zd9cVuRcSTit5jdupS1IuiBRAwDXk21xNHzp 2kRg== X-Gm-Message-State: AKaTC01HEOYR1CcKrO6VBsynnzR9oHNAaQPXj37OZ/xRHz2q2fUYR46OB3mei/zzz6v4hA== X-Received: by 10.28.19.196 with SMTP id 187mr36964wmt.81.1481050699079; Tue, 06 Dec 2016 10:58:19 -0800 (PST) Received: from t460p.intel ([2a02:c7d:9bd6:b000:f37e:1e07:a7d8:46cd]) by smtp.gmail.com with ESMTPSA id r7sm27173177wjp.43.2016.12.06.10.58.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Dec 2016 10:58:18 -0800 (PST) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Subject: [RFC 4/5] drm: Use drm_printk for all logging macros Date: Tue, 6 Dec 2016 18:58:00 +0000 Message-Id: <1481050681-23416-5-git-send-email-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481050681-23416-1-git-send-email-tvrtko.ursulin@linux.intel.com> References: <1481050681-23416-1-git-send-email-tvrtko.ursulin@linux.intel.com> X-Mailman-Approved-At: Wed, 07 Dec 2016 00:54:15 +0000 Cc: Tvrtko Ursulin , dri-devel@lists.freedesktop.org, tursulin@ursulin.net 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 From: Tvrtko Ursulin Eliminate _DRM_PRINTK macro and use drm_printk for all log levels. This required drm_printk to vary the verbosity level of the logged metadata depending on the log level. Signed-off-by: Tvrtko Ursulin --- drivers/gpu/drm/drm_drv.c | 31 ++++++++++++++++++++++--------- include/drm/drmP.h | 44 ++++++++++++++++++++++++++++++-------------- 2 files changed, 52 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index a2f4eb4509b9..bda4639c73e4 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -80,12 +80,21 @@ void drm_dev_printk(const struct device *dev, const char *level, vaf.fmt = format; vaf.va = &args; - if (dev) - dev_printk(level, dev, "[%s:%ps]%s %pV", - driver, function_name, prefix, &vaf); - else - printk("%s[%s:%ps]%s %pV", - level, driver, function_name, prefix, &vaf); + if (level[1] != KERN_DEBUG[1]) { + if (dev) + dev_printk(level, dev, "[%s]%s %pV", + driver, prefix, &vaf); + else + printk("%s[%s]%s %pV", + level, driver, prefix, &vaf); + } else { + if (dev) + dev_printk(level, dev, "[%s:%ps]%s %pV", + driver, function_name, prefix, &vaf); + else + printk("%s[%s:%ps]%s %pV", + level, driver, function_name, prefix, &vaf); + } va_end(args); } @@ -104,9 +113,13 @@ void drm_printk(const char *level, unsigned int category, vaf.fmt = format; vaf.va = &args; - printk("%s[%s:%ps]%s %pV", - level, driver, __builtin_return_address(0), - strcmp(level, KERN_ERR) == 0 ? " *ERROR*" : "", &vaf); + if (level[1] != KERN_DEBUG[1]) + printk("%s[%s]%s %pV", + level, driver, + strcmp(level, KERN_ERR) == 0 ? " *ERROR*" : "", &vaf); + else + printk("%s[%s:%ps] %pV", + level, driver, __builtin_return_address(0), &vaf); va_end(args); } diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 8661045ffaf1..b8f9dcd49b36 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -146,25 +146,41 @@ struct dma_buf_attachment; /** \name Macros to make printk easier */ /*@{*/ -#define _DRM_PRINTK(once, level, fmt, ...) \ - do { \ - printk##once(KERN_##level "[" DRM_NAME "] " fmt, \ - ##__VA_ARGS__); \ - } while (0) - #define DRM_INFO(fmt, ...) \ - _DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__) -#define DRM_NOTE(fmt, ...) \ - _DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS__) -#define DRM_WARN(fmt, ...) \ - _DRM_PRINTK(, WARNING, fmt, ##__VA_ARGS__) + drm_printk(KERN_INFO, DRM_UT_NONE, DRM_NAME, fmt, ##__VA_ARGS__) #define DRM_INFO_ONCE(fmt, ...) \ - _DRM_PRINTK(_once, INFO, fmt, ##__VA_ARGS__) +({ \ + static bool __print_once __read_mostly; \ + if (!__print_once) { \ + __print_once = true; \ + DRM_INFO(fmt, ##__VA_ARGS__); \ + } \ +}) + +#define DRM_NOTE(fmt, ...) \ + drm_printk(KERN_NOTICE, DRM_UT_NONE, DRM_NAME, fmt, ##__VA_ARGS__) + #define DRM_NOTE_ONCE(fmt, ...) \ - _DRM_PRINTK(_once, NOTICE, fmt, ##__VA_ARGS__) +({ \ + static bool __print_once __read_mostly; \ + if (!__print_once) { \ + __print_once = true; \ + DRM_NOTE(fmt, ##__VA_ARGS__); \ + } \ +}) + +#define DRM_WARN(fmt, ...) \ + drm_printk(KERN_WARNING, DRM_UT_NONE, DRM_NAME, fmt, ##__VA_ARGS__) + #define DRM_WARN_ONCE(fmt, ...) \ - _DRM_PRINTK(_once, WARNING, fmt, ##__VA_ARGS__) +({ \ + static bool __print_once __read_mostly; \ + if (!__print_once) { \ + __print_once = true; \ + DRM_WARN(fmt, ##__VA_ARGS__); \ + } \ +}) /** * Error output.