Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp1152723ima; Fri, 1 Feb 2019 17:39:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN6md191C/0aut9m5q5mHItNa4OfSoVNqbbBSnFC7mLCHwXmXqnYmmDNqvbqOjKsCEXg8/gK X-Received: by 2002:a17:902:bb98:: with SMTP id m24mr40824274pls.71.1549071560653; Fri, 01 Feb 2019 17:39:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549071560; cv=none; d=google.com; s=arc-20160816; b=Eolir1jna+nhUqRpUJJDZkepXHf3wgI8dfdxRTx/BCLy71TMdTI8nOZCGHtJQGts+/ vUH/dDUNTw4Y3CKoTxNStZ1+6x9gGb3TF8LGs2PhJLl82PLzjM6vhAyy9cj+OzvQlRON 9MizKZ3+ZquYZGmSydr5Qn1fyKi2Zcv1+f05XDQSPNr5RBOHk7tV0MbAchLGm96KHxpl O+bzJTzElNO4U1l3nu/Pw689x5tp2MkaockXdq6Hk8ZpSTi5gIqfk7lFIBxQ9i6Z4CTu I0f2uwii8528nrJtI/oiipVlHQGWZCKxWNFWjY8OeUrrXmHrJ5R0t39Mb1WhvAwo5E7m x6Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=2zWh8W1ucy4EnFTTnmXoHKVm1fZKkDe2az3FkOrIkrc=; b=JJ70TQj9lvqbNEhuojmydDZFPrG8v7QuVU+w55y4Kbnu2CMXUkMwR02M0AaPX7ywyF a2Y7CGhYLM2aPKxbpQlii6iB2qDxDnybJoR6FqlEH5Q+WAGCOKbca5ny5xPBtUmZrDjk VePLKS6mrs3fy0U8wI8Q0kd/sRn9Oye5s2SZ0VwCFtmoKRmKKJqk3tJU274l4Cn5FTZC pdj/InHB1qtAcxXI4Ow2DUVXBvqHWV8R8aI33TBO/igc5wwC6C4mwbqMvgAkbeMIivNu T2TOQ/p/oIdc2imkhDoiPMrcGPke6LVs18q6xDvna48I3N7ohE9v9+BAYzzRVbtY3T5M VK5Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q17si9487180pfc.198.2019.02.01.17.39.05; Fri, 01 Feb 2019 17:39:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727454AbfBBBb4 (ORCPT + 99 others); Fri, 1 Feb 2019 20:31:56 -0500 Received: from smtprelay0085.hostedemail.com ([216.40.44.85]:49886 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726193AbfBBBb4 (ORCPT ); Fri, 1 Feb 2019 20:31:56 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id 41E21182CED28; Sat, 2 Feb 2019 01:31:54 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::,RULES_HIT:2:41:69:355:379:599:960:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1535:1593:1594:1605:1730:1747:1777:1792:2393:2559:2562:2828:2911:2919:3138:3139:3140:3141:3142:3622:3865:3866:3867:3868:3870:3871:3872:3874:4050:4119:4321:4419:4425:4605:5007:6119:7875:7903:7974:8603:9545:9592:10004:10848:11026:11232:11473:11658:11914:12043:12291:12296:12438:12555:12663:12683:12740:12760:12895:13160:13229:13439:14659:21060:21067:21080:21324:21433:21451:21611:21627:30054:30070:30075:30091,0,RBL:47.151.153.53:@perches.com:.lbl8.mailshell.net-62.14.0.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:28,LUA_SUMMARY:none X-HE-Tag: way19_1065cc253930e X-Filterd-Recvd-Size: 8330 Received: from XPS-9350.home (unknown [47.151.153.53]) (Authenticated sender: joe@perches.com) by omf08.hostedemail.com (Postfix) with ESMTPA; Sat, 2 Feb 2019 01:31:52 +0000 (UTC) Message-ID: <7399cb84e16538d6ff7c8b4f7718b692c831476b.camel@perches.com> Subject: Re: [PATCH v1 0/19] drm/panel: drmP.h removal and DRM_DEV* From: Joe Perches To: Sam Ravnborg , Thierry Reding Cc: Sean Paul , dri-devel@lists.freedesktop.org, Daniel Vetter , David Airlie , Linus Walleij , Stefan Mavrodiev , linux-kernel@vger.kernel.org Date: Fri, 01 Feb 2019 17:31:51 -0800 In-Reply-To: <20190201133704.GA25680@ravnborg.org> References: <20190131192619.9763-1-sam@ravnborg.org> <20190131200723.GZ114153@art_vandelay> <20190131210312.GA8947@ravnborg.org> <20190131215417.GA13156@mithrandir> <20190201133704.GA25680@ravnborg.org> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.30.1-1build1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2019-02-01 at 14:37 +0100, Sam Ravnborg wrote: > Hi Thierry. > > > I'm slightly on the fence about this patch. > > Please ignore patch 3-19, there is no consensus on the logging changes. > We do not want to apply these and then have to redo parts/all of > it later. > > But the first two patches has not seen any feedback yet: > > [PATCH v1 01/19] drm/panel: drop drmP.h usage > [PATCH v1 02/19] drm/panel: panel-innolux: drop unused variable > > Please consider these, or maybe wait a little to see if someone > find time to review. > > I can resend the patches if this is preferred. My preference would also convert all the DRM_DEV_ uses to drm_dev_ eventually. Also, the macros themselves could change to use a more consistent mechanism. This would make the drm logging mechanisms more like other logging mechanisms used in the kernel. Something like: --- Subject: [PATCH] drm: Improve and standardize logging functions Use a more typical logging style. Add and use drm_printk and drm_dev_printk functions that include the test for KERN_ERR use where '*ERROR*' is added to logging output. Remove the slightly unusual _DRM_PRINTK macro and use the new drm_printk function instead. --- drivers/gpu/drm/drm_print.c | 67 +++++++++++++++++++++++++++++---------------- include/drm/drm_print.h | 51 ++++++++++++++++++++-------------- 2 files changed, 74 insertions(+), 44 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 0e7fc3e7dfb4..4e3ae7b5cce1 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -174,22 +174,59 @@ void drm_printf(struct drm_printer *p, const char *f, ...) } EXPORT_SYMBOL(drm_printf); -void drm_dev_printk(const struct device *dev, const char *level, - const char *format, ...) +void drm_printk(const char *format, ...) { struct va_format vaf; va_list args; + char lvl[PRINTK_MAX_SINGLE_HEADER_LEN + 1] = KERN_DEFAULT; + int level = printk_get_level(format); + size_t size = printk_skip_level(format) - format; + + if (size) { + memcpy(lvl, format, size); + lvl[size] = '\0'; + } va_start(args, format); - vaf.fmt = format; + vaf.fmt = format + size; + vaf.va = &args; + + printk("%s" "[" DRM_NAME ":%ps] %s%pV", + lvl, __builtin_return_address(0), + level == LOGLEVEL_ERR ? "*ERROR* " : "", + &vaf); + + va_end(args); +} +EXPORT_SYMBOL(drm_printk); + +void drm_dev_printk(const struct device *dev, const char *format, ...) +{ + struct va_format vaf; + va_list args; + char lvl[PRINTK_MAX_SINGLE_HEADER_LEN + 1] = KERN_DEFAULT; + int level = printk_get_level(format); + size_t size = printk_skip_level(format) - format; + + if (size) { + memcpy(lvl, format, size); + lvl[size] = '\0'; + } + + va_start(args, format); + vaf.fmt = format + size; vaf.va = &args; if (dev) - dev_printk(level, dev, "[" DRM_NAME ":%ps] %pV", - __builtin_return_address(0), &vaf); + dev_printk(lvl, dev, "[" DRM_NAME ":%ps] %s%pV", + __builtin_return_address(0), + level == LOGLEVEL_ERR ? "*ERROR* " : "", + &vaf); else - printk("%s" "[" DRM_NAME ":%ps] %pV", - level, __builtin_return_address(0), &vaf); + printk("%s" "[" DRM_NAME ":%ps] %s%pV", + lvl, __builtin_return_address(0), + level == LOGLEVEL_ERR ? "*ERROR* " : "", + &vaf); va_end(args); } @@ -237,19 +274,3 @@ void drm_dbg(unsigned int category, const char *format, ...) va_end(args); } EXPORT_SYMBOL(drm_dbg); - -void drm_err(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); diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index afbc3beef089..9d9fd10e6ff8 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -268,9 +268,8 @@ static inline struct drm_printer drm_debug_printer(const char *prefix) #define DRM_UT_LEASE 0x80 #define DRM_UT_DP 0x100 -__printf(3, 4) -void drm_dev_printk(const struct device *dev, const char *level, - const char *format, ...); +__printf(2, 3) +void drm_dev_printk(const struct device *dev, const char *format, ...); __printf(3, 4) void drm_dev_dbg(const struct device *dev, unsigned int category, const char *format, ...); @@ -278,26 +277,38 @@ void drm_dev_dbg(const struct device *dev, unsigned int category, __printf(2, 3) void drm_dbg(unsigned int category, const char *format, ...); __printf(1, 2) -void drm_err(const char *format, ...); +void drm_printk(const char *format, ...); /* Macros to make printk easier */ -#define _DRM_PRINTK(once, level, fmt, ...) \ - printk##once(KERN_##level "[" DRM_NAME "] " fmt, ##__VA_ARGS__) - -#define DRM_INFO(fmt, ...) \ - _DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__) -#define DRM_NOTE(fmt, ...) \ - _DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS__) +#define DRM_ERROR(fmt, ...) \ + drm_printk(KERN_ERR fmt, ##__VA_ARGS__) +#define drm_err DRM_ERROR #define DRM_WARN(fmt, ...) \ - _DRM_PRINTK(, WARNING, fmt, ##__VA_ARGS__) + drm_printk(KERN_WARNING fmt, ##__VA_ARGS__) +#define DRM_NOTE(fmt, ...) \ + drm_printk(KERN_NOTICE fmt, ##__VA_ARGS__) +#define DRM_INFO(fmt, ...) \ + drm_printk(KERN_INFO fmt, ##__VA_ARGS__) + +#define drm_printk_once(fmt, ...) \ +({ \ + static bool __print_once __read_mostly; \ + bool __ret_print_once = !__print_once; \ + \ + if (!__print_once) { \ + __print_once = true; \ + drm_printk(fmt, ##__VA_ARGS__); \ + } \ + unlikely(__ret_print_once); \ +}) -#define DRM_INFO_ONCE(fmt, ...) \ - _DRM_PRINTK(_once, INFO, fmt, ##__VA_ARGS__) -#define DRM_NOTE_ONCE(fmt, ...) \ - _DRM_PRINTK(_once, NOTICE, fmt, ##__VA_ARGS__) #define DRM_WARN_ONCE(fmt, ...) \ - _DRM_PRINTK(_once, WARNING, fmt, ##__VA_ARGS__) + drm_printk_once(KERN_WARNING fmt, ##__VA_ARGS__) +#define DRM_NOTE_ONCE(fmt, ...) \ + drm_printk_once(KERN_NOTICE fmt, ##__VA_ARGS__) +#define DRM_INFO_ONCE(fmt, ...) \ + drm_printk_once(KERN_INFO fmt, ##__VA_ARGS__) /** * Error output. @@ -306,9 +317,7 @@ void drm_err(const char *format, ...); * @fmt: printf() like format string. */ #define DRM_DEV_ERROR(dev, fmt, ...) \ - drm_dev_printk(dev, KERN_ERR, "*ERROR* " fmt, ##__VA_ARGS__) -#define DRM_ERROR(fmt, ...) \ - drm_err(fmt, ##__VA_ARGS__) + drm_dev_printk(dev, KERN_ERR fmt, ##__VA_ARGS__) /** * Rate limited error output. Like DRM_ERROR() but won't flood the log. @@ -329,7 +338,7 @@ void drm_err(const char *format, ...); DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__) #define DRM_DEV_INFO(dev, fmt, ...) \ - drm_dev_printk(dev, KERN_INFO, fmt, ##__VA_ARGS__) + drm_dev_printk(dev, KERN_INFO fmt, ##__VA_ARGS__) #define DRM_DEV_INFO_ONCE(dev, fmt, ...) \ ({ \