From patchwork Fri May 17 16:34:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wajdeczko X-Patchwork-Id: 13667169 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 027CCC25B79 for ; Fri, 17 May 2024 16:34:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2BA4A10E1A9; Fri, 17 May 2024 16:34:33 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="ga038Sy+"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) by gabe.freedesktop.org (Postfix) with ESMTPS id A246210E1A9; Fri, 17 May 2024 16:34:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715963673; x=1747499673; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D/S82XY1PYsu14BMkHYJSmu1H1HAR9GK2B1nHz+VYC0=; b=ga038Sy+HC2oZiG5YKWlZQjWi15k07khETchvXjy8Pvzo6TLOJg+wJPA /82yoiTn8J+7JChqphFz5Gv25TS/zKmJppLoaWIqGp6MjCKs54TzzlQ2X pyHrst/OG0KAQCqI4muITKGF/JFQqoPo8ER/q94u0fR1XgbHR9NFfcmLh 4lF4L/2M/YhZhdq+ATpyAiKIOmEX2+OBxvBDE9vmqpdXlR6UwvAqyBmC+ hnmvlintwqAQuix0xVybApimMC6gF/uLGZWROGZzMEszogEcPmu7zT1JS kGRd8yau6SKv70RnPH1lXzeRf0QyBN99dizDtTfVkotvCU+GIStVktML9 w==; X-CSE-ConnectionGUID: gUomuo3NQfSABsOS6TT3bg== X-CSE-MsgGUID: 1soT3msUQHKVCDWmqnj2Ug== X-IronPort-AV: E=McAfee;i="6600,9927,11075"; a="12022117" X-IronPort-AV: E=Sophos;i="6.08,168,1712646000"; d="scan'208";a="12022117" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2024 09:34:23 -0700 X-CSE-ConnectionGUID: vRfUuQXrRMWzxJqItSy+hg== X-CSE-MsgGUID: uonMGcBUQEepPsePu0wFzw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,168,1712646000"; d="scan'208";a="31986737" Received: from mwajdecz-mobl.ger.corp.intel.com ([10.94.252.59]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2024 09:34:21 -0700 From: Michal Wajdeczko To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Michal Wajdeczko , Jani Nikula Subject: [PATCH v2 1/3] drm/print: Add generic drm dev printk function Date: Fri, 17 May 2024 18:34:04 +0200 Message-Id: <20240517163406.2348-2-michal.wajdeczko@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20240517163406.2348-1-michal.wajdeczko@intel.com> References: <20240517163406.2348-1-michal.wajdeczko@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. Cc: Jani Nikula Signed-off-by: Michal Wajdeczko Reviewed-by: Jani Nikula --- v2: make it static, keep it simple and use braces (Jani) --- drivers/gpu/drm/drm_print.c | 52 +++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index cf2efb44722c..41892491a12c 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -176,6 +176,32 @@ void __drm_printfn_seq_file(struct drm_printer *p, struct va_format *vaf) } EXPORT_SYMBOL(__drm_printfn_seq_file); +static 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 ? " " : ""; + + if (!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); + } +} + void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf) { dev_info(p->arg, "[" DRM_NAME "] %pV", vaf); @@ -187,19 +213,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); @@ -287,12 +306,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 +326,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 +360,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); } From patchwork Fri May 17 16:34:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wajdeczko X-Patchwork-Id: 13667172 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 9E0E6C04FFE for ; Fri, 17 May 2024 16:34:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 55D5D10E3BB; Fri, 17 May 2024 16:34:37 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="GVPiOBIj"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) by gabe.freedesktop.org (Postfix) with ESMTPS id A8CB410E313; Fri, 17 May 2024 16:34:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715963675; x=1747499675; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pYqRiirUIrprG0rOBJNKhIZxAlmsn0IIJjcB5zYHhLY=; b=GVPiOBIjDxuiyUU4SuOWsVzS7JhssREugfh4NmJtOBrP0+gXTCdwdf15 fSjv2CU/fz6kzP42fJ7iK5MinKXwAkOjvvXkjQ7J0hBrmczebhxcXULI0 07QsHGSRLWjK5b6NFCKfncsbUZyUE/VemNUbYuIAwcLwq4U03AKhTojhy Fc3JTj7c10K7B+OJ7qGqJA97oda6kW+DTceR1y5NWLG3kZeYW4AJNOmqV gGt0Pn4XE5czlhiQW2wL2rtqGn8dqXDibV/E2AZovW3Uaam40p2Fht4qw 3wczLe0FLIvuzPrGR7M6V2X6Cdz/vyCJtCg9YhyP7EXsg/O10rbI50jQ4 w==; X-CSE-ConnectionGUID: 26Orh6m/RU2awal6rVR5Fg== X-CSE-MsgGUID: N6kOkkVwRWOtdKjbwORXBw== X-IronPort-AV: E=McAfee;i="6600,9927,11075"; a="12022127" X-IronPort-AV: E=Sophos;i="6.08,168,1712646000"; d="scan'208";a="12022127" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2024 09:34:24 -0700 X-CSE-ConnectionGUID: cb/2nweUTAqb6j+nucgvsg== X-CSE-MsgGUID: eevCYixrSGyTONx+5uFPoQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,168,1712646000"; d="scan'208";a="31986756" Received: from mwajdecz-mobl.ger.corp.intel.com ([10.94.252.59]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2024 09:34:23 -0700 From: Michal Wajdeczko To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Michal Wajdeczko , Jani Nikula Subject: [PATCH v2 2/3] drm/print: Improve drm_dbg_printer Date: Fri, 17 May 2024 18:34:05 +0200 Message-Id: <20240517163406.2348-3-michal.wajdeczko@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20240517163406.2348-1-michal.wajdeczko@intel.com> References: <20240517163406.2348-1-michal.wajdeczko@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. Cc: Jani Nikula Reviewed-by: Jani Nikula Signed-off-by: Michal Wajdeczko --- v2: use full cast to match member (Jani) --- 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 41892491a12c..35d00f0c6d64 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -217,8 +217,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 089950ad8681..bfc5641c6025 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 = (const void *)_THIS_IP_, /* it's fine as we will be inlined */ .prefix = prefix, .category = category, }; From patchwork Fri May 17 16:34:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wajdeczko X-Patchwork-Id: 13667171 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 D6086C25B79 for ; Fri, 17 May 2024 16:34:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BFD6710E313; Fri, 17 May 2024 16:34:36 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="XRMmgi3F"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) by gabe.freedesktop.org (Postfix) with ESMTPS id 366A510E313; Fri, 17 May 2024 16:34:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715963675; x=1747499675; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wMPpnvAgQgbIIEJ7G9U9h+zMQJEGD49kCdXtmeGeICA=; b=XRMmgi3FzAvGI5aLiiNzubU8DWSKbbVphPDHPm5GZqWmfqXyN1MZFZqQ cDIHbVTVKJeB/37V8uMhaOFuKJ1wC6L+LKv8boTyOflb6n53h5lUsWGv7 nPeREs6w/AEcnrMMaO5eDCPfQrOgbD1cV2ienQq1+8B7RSp4PHbZHQUfu 2X82DOg0V9Nt4o1B3qQgafjGwjdbhz+/VE+IJLlONQEb09kjuLrAHWdUY DO3qGs6g7/EcDNoB4FCdGcA81LX0Tv3Ft0B5FBu6WGYPMyZMpD9s1lY5r zDXI0aqCfJDqfYHHDNCL4Pw9GTGWYKDzJGeFnTLpijZUSC69Ido4DQsOD g==; X-CSE-ConnectionGUID: ZfVrnuGSSBuOpb74zp5+tw== X-CSE-MsgGUID: ajdFKS/LTVC8SJlVuzQ0Kw== X-IronPort-AV: E=McAfee;i="6600,9927,11075"; a="12022132" X-IronPort-AV: E=Sophos;i="6.08,168,1712646000"; d="scan'208";a="12022132" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2024 09:34:26 -0700 X-CSE-ConnectionGUID: vVzsqReMSmueLz3R3Y7FtQ== X-CSE-MsgGUID: r7uDcgVXR5yeGzhXw1CkBw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,168,1712646000"; d="scan'208";a="31986785" Received: from mwajdecz-mobl.ger.corp.intel.com ([10.94.252.59]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2024 09:34:24 -0700 From: Michal Wajdeczko To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Michal Wajdeczko , Jani Nikula Subject: [PATCH v2 3/3] drm/i915: Don't use __func__ as prefix for drm_dbg_printer Date: Fri, 17 May 2024 18:34:06 +0200 Message-Id: <20240517163406.2348-4-michal.wajdeczko@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20240517163406.2348-1-michal.wajdeczko@intel.com> References: <20240517163406.2348-1-michal.wajdeczko@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Updated code of drm_dbg_printer() is already printing symbolic name of the caller like drm_dbg() does. Reviewed-by: Jani Nikula Signed-off-by: Michal Wajdeczko --- 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",