From patchwork Thu Aug 30 18:36:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 10582583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A748217DB for ; Thu, 30 Aug 2018 18:43:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 977992C400 for ; Thu, 30 Aug 2018 18:43:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89F842C402; Thu, 30 Aug 2018 18:43:28 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 33E0D2C400 for ; Thu, 30 Aug 2018 18:43:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8AB8A6E7B2; Thu, 30 Aug 2018 18:43:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtprelay.hostedemail.com (smtprelay0180.hostedemail.com [216.40.44.180]) by gabe.freedesktop.org (Postfix) with ESMTPS id C6B6A6E7B0; Thu, 30 Aug 2018 18:43:24 +0000 (UTC) Received: from smtprelay.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by smtpgrave03.hostedemail.com (Postfix) with ESMTP id F2D461804DACE; Thu, 30 Aug 2018 18:36:35 +0000 (UTC) Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id 0729A182CF671; Thu, 30 Aug 2018 18:36:33 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: fight27_1be00dda49d1c X-Filterd-Recvd-Size: 4479 Received: from joe-laptop.perches.com (unknown [47.151.153.53]) (Authenticated sender: joe@perches.com) by omf02.hostedemail.com (Postfix) with ESMTPA; Thu, 30 Aug 2018 18:36:31 +0000 (UTC) From: Joe Perches To: Ben Skeggs Subject: [PATCH 1/2] drm/nouveau: Add new logging function nv_cli_printk Date: Thu, 30 Aug 2018 11:36:26 -0700 Message-Id: <89bd597dc1b130af25371f815af10cefed732422.1535654026.git.joe@perches.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: References: X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP NV_PRINTK is a macro that adds the "%s: ", nouveau_cli.name to logging output. Save a few KB by creating a specific function to add that name and change the users of theh NV_PRINTK macros to use the new logging function. (size -t drivers/gpu/drm/nouveau/built-in.a x86/64 defconfig with nouveau) text data bss dec hex filename 1737254 108484 1048 1846786 1c2e02 (TOTALS) (new) 1740706 108484 1048 1850238 1c3b7e (TOTALS) (old) Signed-off-by: Joe Perches --- drivers/gpu/drm/nouveau/nouveau_drm.c | 21 +++++++++++++++++++++ drivers/gpu/drm/nouveau/nouveau_drv.h | 34 ++++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index c7ec86d6c3c9..aeca2ea3c4d1 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -1153,6 +1153,27 @@ nouveau_platform_device_create(const struct nvkm_device_tegra_func *func, return ERR_PTR(err); } +void nouveau_cli_printk(struct nouveau_cli *cli, const char *fmt, ...) +{ + struct va_format vaf; + va_list args; + char level[2] = {KERN_SOH_ASCII, 0}; + + level[1] = printk_get_level(fmt); + if (level[1] == 0) + level[1] = 'd'; + + va_start(args, fmt); + + vaf.fmt = printk_skip_headers(fmt); + vaf.va = &args; + + dev_printk(level, cli->drm->dev->dev, "%s: %pV", + cli->name, &vaf); + + va_end(args); +} + static int __init nouveau_drm_init(void) { diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index 6e1acaec3400..6110730d5df0 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -244,18 +244,28 @@ void nouveau_drm_device_remove(struct drm_device *dev); struct nouveau_cli *_cli = (c); \ dev_##l(_cli->drm->dev->dev, "%s: "f, _cli->name, ##a); \ } while(0) -#define NV_FATAL(drm,f,a...) NV_PRINTK(crit, &(drm)->client, f, ##a) -#define NV_ERROR(drm,f,a...) NV_PRINTK(err, &(drm)->client, f, ##a) -#define NV_WARN(drm,f,a...) NV_PRINTK(warn, &(drm)->client, f, ##a) -#define NV_INFO(drm,f,a...) NV_PRINTK(info, &(drm)->client, f, ##a) -#define NV_DEBUG(drm,f,a...) do { \ - if (unlikely(drm_debug & DRM_UT_DRIVER)) \ - NV_PRINTK(info, &(drm)->client, f, ##a); \ -} while(0) -#define NV_ATOMIC(drm,f,a...) do { \ - if (unlikely(drm_debug & DRM_UT_ATOMIC)) \ - NV_PRINTK(info, &(drm)->client, f, ##a); \ -} while(0) + +__printf(2, 3) +void nouveau_cli_printk(struct nouveau_cli *cli, const char *fmt, ...); + +#define NV_FATAL(drm, fmt, ...) \ + nouveau_cli_printk(&(drm)->client, KERN_CRIT fmt, ##__VA_ARGS__) +#define NV_ERROR(drm, fmt, ...) \ + nouveau_cli_printk(&(drm)->client, KERN_ERR fmt, ##__VA_ARGS__) +#define NV_WARN(drm, fmt, ...) \ + nouveau_cli_printk(&(drm)->client, KERN_WARNING fmt, ##__VA_ARGS__) +#define NV_INFO(drm, fmt, ...) \ + nouveau_cli_printk(&(drm)->client, KERN_INFO fmt, ##__VA_ARGS__) +#define NV_DEBUG(drm, fmt, ...) \ +do { \ + if (unlikely(drm_debug & DRM_UT_DRIVER)) \ + NV_INFO(drm, fmt, ##__VA_ARGS__); \ +} while (0) +#define NV_ATOMIC(drm, fmt, ...) \ +do { \ + if (unlikely(drm_debug & DRM_UT_ATOMIC)) \ + NV_INFO(drm, fmt, ##__VA_ARGS__); \ +} while (0) extern int nouveau_modeset;