From patchwork Fri May 17 12:57:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wajdeczko X-Patchwork-Id: 13666979 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 36AE1C25B77 for ; Fri, 17 May 2024 12:57:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 692D310EEAB; Fri, 17 May 2024 12:57:52 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="mBKsihtW"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7DC1810EE9D; Fri, 17 May 2024 12:57:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715950667; x=1747486667; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oU0NCaftCBTeHYvbsvJFGLFjAeV2t5YEWioI7+nHiGk=; b=mBKsihtWb9qevOS15O1lRtK1NXnhyZSN9wge6EnGNT4N+PShSic9q+pN kTLfug/Quz+2U4TG1wXgkgSPShTA9WzWKsNdOfs0nEssbbAa3hanFFfwm kFx457PUAwZKkRSVZnUh/c4ICiYp8YxmoWtvfOKPMNbApGeyY3aqx05Mx bzsbHupF4sYCxdVwqo2RW7SGDfVHZ170WbGLjAwJN5wSYXvC41dWm1am1 uzD2+DVFBGNTnTj0e2gMz8chDHtmDBc8a6GX7TWruH92V2ERSDOvKPrRx njTvDHb/B7kPxryF3qCkZ3LL1UDN5bd4rAWDs+WMPbu92fGJiBueTGVfd w==; X-CSE-ConnectionGUID: dSRDOiHnT4yREoEXstbMPw== X-CSE-MsgGUID: EgE5CH7RRYuV+Adx4KbY3Q== X-IronPort-AV: E=McAfee;i="6600,9927,11074"; a="12314179" X-IronPort-AV: E=Sophos;i="6.08,167,1712646000"; d="scan'208";a="12314179" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2024 05:57:47 -0700 X-CSE-ConnectionGUID: ItxzNLa5Sdm+ckUBTtPL4A== X-CSE-MsgGUID: JOhMxJJ1RzKlOrN594Lu5g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,167,1712646000"; d="scan'208";a="31604891" Received: from mwajdecz-mobl.ger.corp.intel.com ([10.94.252.59]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2024 05:57:46 -0700 From: Michal Wajdeczko To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Michal Wajdeczko , Jani Nikula Subject: [PATCH 1/3] drm/print: Add generic drm dev printk function Date: Fri, 17 May 2024 14:57:28 +0200 Message-Id: <20240517125730.2304-2-michal.wajdeczko@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20240517125730.2304-1-michal.wajdeczko@intel.com> References: <20240517125730.2304-1-michal.wajdeczko@intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" We already have some drm printk functions that need to duplicate a code to get a similar format of the final result, for example: [ ] 0000:00:00.0: [drm:foo] bar [ ] 0000:00:00.0: [drm] foo bar [ ] 0000:00:00.0: [drm] *ERROR* foo Add a generic __drm_dev_vprintk() function that can format the final message like all other existing function do and allows us to keep the formatting code in one place. Signed-off-by: Michal Wajdeczko Cc: Jani Nikula --- drivers/gpu/drm/drm_print.c | 49 ++++++++++++++++++++----------------- include/drm/drm_print.h | 3 +++ 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index cf2efb44722c..a2b60c8245a1 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -187,19 +187,12 @@ void __drm_printfn_dbg(struct drm_printer *p, struct va_format *vaf) const struct drm_device *drm = p->arg; const struct device *dev = drm ? drm->dev : NULL; enum drm_debug_category category = p->category; - const char *prefix = p->prefix ?: ""; - const char *prefix_pad = p->prefix ? " " : ""; if (!__drm_debug_enabled(category)) return; /* Note: __builtin_return_address(0) is useless here. */ - if (dev) - dev_printk(KERN_DEBUG, dev, "[" DRM_NAME "]%s%s %pV", - prefix_pad, prefix, vaf); - else - printk(KERN_DEBUG "[" DRM_NAME "]%s%s %pV", - prefix_pad, prefix, vaf); + __drm_dev_vprintk(dev, KERN_DEBUG, NULL, p->prefix, vaf); } EXPORT_SYMBOL(__drm_printfn_dbg); @@ -277,6 +270,29 @@ void drm_print_bits(struct drm_printer *p, unsigned long value, } EXPORT_SYMBOL(drm_print_bits); +void __drm_dev_vprintk(const struct device *dev, const char *level, + const void *origin, const char *prefix, + struct va_format *vaf) +{ + const char *prefix_pad = prefix ? " " : (prefix = ""); + + if (dev) + if (origin) + dev_printk(level, dev, "[" DRM_NAME ":%ps]%s%s %pV", + origin, prefix_pad, prefix, vaf); + else + dev_printk(level, dev, "[" DRM_NAME "]%s%s %pV", + prefix_pad, prefix, vaf); + else + if (origin) + printk("%s" "[" DRM_NAME ":%ps]%s%s %pV", + level, origin, prefix_pad, prefix, vaf); + else + printk("%s" "[" DRM_NAME "]%s%s %pV", + level, prefix_pad, prefix, vaf); +} +EXPORT_SYMBOL(__drm_dev_vprintk); + void drm_dev_printk(const struct device *dev, const char *level, const char *format, ...) { @@ -287,12 +303,7 @@ void drm_dev_printk(const struct device *dev, const char *level, vaf.fmt = format; vaf.va = &args; - if (dev) - dev_printk(level, dev, "[" DRM_NAME ":%ps] %pV", - __builtin_return_address(0), &vaf); - else - printk("%s" "[" DRM_NAME ":%ps] %pV", - level, __builtin_return_address(0), &vaf); + __drm_dev_vprintk(dev, level, __builtin_return_address(0), NULL, &vaf); va_end(args); } @@ -312,12 +323,7 @@ void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev, vaf.fmt = format; vaf.va = &args; - if (dev) - dev_printk(KERN_DEBUG, dev, "[" DRM_NAME ":%ps] %pV", - __builtin_return_address(0), &vaf); - else - printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV", - __builtin_return_address(0), &vaf); + __drm_dev_vprintk(dev, KERN_DEBUG, __builtin_return_address(0), NULL, &vaf); va_end(args); } @@ -351,8 +357,7 @@ void __drm_err(const char *format, ...) vaf.fmt = format; vaf.va = &args; - printk(KERN_ERR "[" DRM_NAME ":%ps] *ERROR* %pV", - __builtin_return_address(0), &vaf); + __drm_dev_vprintk(NULL, KERN_ERR, __builtin_return_address(0), "*ERROR*", &vaf); va_end(args); } diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 089950ad8681..bb1801c58544 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -366,6 +366,9 @@ static inline struct drm_printer drm_err_printer(struct drm_device *drm, __printf(3, 4) void drm_dev_printk(const struct device *dev, const char *level, const char *format, ...); +void __drm_dev_vprintk(const struct device *dev, const char *level, + const void *origin, const char *prefix, + struct va_format *vaf); struct _ddebug; __printf(4, 5) void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev, From patchwork Fri May 17 12:57:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wajdeczko X-Patchwork-Id: 13666978 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6175BC04FFE for ; Fri, 17 May 2024 12:57:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9442210EE9D; Fri, 17 May 2024 12:57:51 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="bB8SVsoi"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 44C4E10EE9D; Fri, 17 May 2024 12:57:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715950669; x=1747486669; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YHV9VNY9DdbukRehmlOU1kmvyVonvcsK0xGXr7QAG9o=; b=bB8SVsoiVRZcjGQPqPtDeHQ0U6ILAGu/SFuZ29q3juDIT2e8ODkfRyCx qseIg0EzW/+vZ20vgk+mIbNx9Z7e1HmZiluQFJBXrHiyHL7pctZiVfOSt ti9tAMtIL1ZQ9okZiFlIl8zTpf2R1pcqslbtKABzyVKwm7L0yT/0GGpJW 1KhN/lzUjmKXFxzmADCMgVrqvrfPS50Qfi5Svs7IkqNZlHpJhE4kUspCV mCYLXb3f1pFDmMxPPpL0JH1VNUiTh+NpLVwfaAR4f74CsT/C1JLf6vvDK mY4XTvOW5/OJiHQRJ3V02IKiJVi522Tc0tUt4WjIMrIf3jjuAW1n7e0Ft Q==; X-CSE-ConnectionGUID: TRxCDjoDSvqkUd6VWLkXtg== X-CSE-MsgGUID: 3fegpHFZTki0WcYuigzhRQ== X-IronPort-AV: E=McAfee;i="6600,9927,11074"; a="12314180" X-IronPort-AV: E=Sophos;i="6.08,167,1712646000"; d="scan'208";a="12314180" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2024 05:57:49 -0700 X-CSE-ConnectionGUID: NiymBFYeTH+LWBV6DXnjYA== X-CSE-MsgGUID: sggb/BkYTEWCGCbSamf8EA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,167,1712646000"; d="scan'208";a="31604895" Received: from mwajdecz-mobl.ger.corp.intel.com ([10.94.252.59]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2024 05:57:48 -0700 From: Michal Wajdeczko To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Michal Wajdeczko , Jani Nikula Subject: [PATCH 2/3] drm/print: Improve drm_dbg_printer Date: Fri, 17 May 2024 14:57:29 +0200 Message-Id: <20240517125730.2304-3-michal.wajdeczko@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20240517125730.2304-1-michal.wajdeczko@intel.com> References: <20240517125730.2304-1-michal.wajdeczko@intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" With recent introduction of a generic drm dev printk function, we can now store and use location where drm_dbg_printer was invoked and output it's symbolic name like we do for all drm debug prints. Signed-off-by: Michal Wajdeczko Cc: Jani Nikula Reviewed-by: Jani Nikula --- drivers/gpu/drm/drm_print.c | 3 +-- include/drm/drm_print.h | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index a2b60c8245a1..0a205fdee7cf 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -191,8 +191,7 @@ void __drm_printfn_dbg(struct drm_printer *p, struct va_format *vaf) if (!__drm_debug_enabled(category)) return; - /* Note: __builtin_return_address(0) is useless here. */ - __drm_dev_vprintk(dev, KERN_DEBUG, NULL, p->prefix, vaf); + __drm_dev_vprintk(dev, KERN_DEBUG, p->origin, p->prefix, vaf); } EXPORT_SYMBOL(__drm_printfn_dbg); diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index bb1801c58544..761ce01761b7 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -175,6 +175,7 @@ struct drm_printer { void (*printfn)(struct drm_printer *p, struct va_format *vaf); void (*puts)(struct drm_printer *p, const char *str); void *arg; + const void *origin; const char *prefix; enum drm_debug_category category; }; @@ -332,6 +333,7 @@ static inline struct drm_printer drm_dbg_printer(struct drm_device *drm, struct drm_printer p = { .printfn = __drm_printfn_dbg, .arg = drm, + .origin = (void *)_THIS_IP_, /* it's fine as we will be inlined */ .prefix = prefix, .category = category, }; From patchwork Fri May 17 12:57:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wajdeczko X-Patchwork-Id: 13666980 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC7E8C04FFE for ; Fri, 17 May 2024 12:57:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C309710EEA1; Fri, 17 May 2024 12:57:52 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="SDrRiHHW"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id C05FF10EE9D; Fri, 17 May 2024 12:57:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715950670; x=1747486670; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jDUD9kl/7SuXVXJedv7yDSmOwab2maF4Uk++Ri3LouA=; b=SDrRiHHWBVWnIRazH8eq3qsexRtZGBKVrDEhawCSxvVSRRkR2EXHhVEo ABPdCJJjRl2zZU0FO9kOqW3TNBvhiggUJ4ux513Ym1ivVkHR3h8mORZQd qySV573F+xbHmwKROuGR7za0wpqMOpYqWzwrPVZWQodCgwRSvFceKdzj0 i1gdeZH//mHXqQYZ2KxHvK21xj6o+ctpb77al1JMCersdV2x5/9C+7Kde O0xWKtEhXRKSWKvvuhvithVI756Ij+HteTK80ADNijDrS4ESyxWrzs/Bi Kj3q3v5u7+v3yBMOsVSDUOlZnydqwVwjPSTvuya+SqRNnRW+55vmSDMxN Q==; X-CSE-ConnectionGUID: v/8OVSahTK6vDUzfJ6D0AA== X-CSE-MsgGUID: YnCl34l4S9C94yLUOZgGqA== X-IronPort-AV: E=McAfee;i="6600,9927,11074"; a="12314185" X-IronPort-AV: E=Sophos;i="6.08,167,1712646000"; d="scan'208";a="12314185" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2024 05:57:50 -0700 X-CSE-ConnectionGUID: r6Ofe2x/STmNj2hI0TOXeA== X-CSE-MsgGUID: 6bBWGblNQUWhoQW2FJ8gEQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,167,1712646000"; d="scan'208";a="31604899" Received: from mwajdecz-mobl.ger.corp.intel.com ([10.94.252.59]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2024 05:57:50 -0700 From: Michal Wajdeczko To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Michal Wajdeczko Subject: [PATCH 3/3] drm/i915: Don't use __func__ as prefix for drm_dbg_printer Date: Fri, 17 May 2024 14:57:30 +0200 Message-Id: <20240517125730.2304-4-michal.wajdeczko@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20240517125730.2304-1-michal.wajdeczko@intel.com> References: <20240517125730.2304-1-michal.wajdeczko@intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Updated code of drm_dbg_printer() is already printing symbolic name of the caller like drm_dbg() does. Signed-off-by: Michal Wajdeczko Reviewed-by: Jani Nikula --- drivers/gpu/drm/i915/gt/intel_reset.c | 2 +- drivers/gpu/drm/i915/gt/selftest_context.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/intel_reset.c b/drivers/gpu/drm/i915/gt/intel_reset.c index 6161f7a3ff70..735cd23a43c6 100644 --- a/drivers/gpu/drm/i915/gt/intel_reset.c +++ b/drivers/gpu/drm/i915/gt/intel_reset.c @@ -1025,7 +1025,7 @@ void intel_gt_set_wedged(struct intel_gt *gt) if (GEM_SHOW_DEBUG()) { struct drm_printer p = drm_dbg_printer(>->i915->drm, - DRM_UT_DRIVER, __func__); + DRM_UT_DRIVER, NULL); struct intel_engine_cs *engine; enum intel_engine_id id; diff --git a/drivers/gpu/drm/i915/gt/selftest_context.c b/drivers/gpu/drm/i915/gt/selftest_context.c index 12eca750f7d0..5eb46700dc4e 100644 --- a/drivers/gpu/drm/i915/gt/selftest_context.c +++ b/drivers/gpu/drm/i915/gt/selftest_context.c @@ -286,7 +286,7 @@ static int __live_active_context(struct intel_engine_cs *engine) if (intel_engine_pm_is_awake(engine)) { struct drm_printer p = drm_dbg_printer(&engine->i915->drm, - DRM_UT_DRIVER, __func__); + DRM_UT_DRIVER, NULL); intel_engine_dump(engine, &p, "%s is still awake:%d after idle-barriers\n",