From patchwork Tue Jan 16 13:07:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 13520788 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 06F0FC47DA2 for ; Tue, 16 Jan 2024 13:08:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 40C5310E54F; Tue, 16 Jan 2024 13:08:10 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8EEDB10E54F; Tue, 16 Jan 2024 13:08:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705410489; x=1736946489; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=InbTkfRui2wcrj8u5F2mtdR8VHMKODP/LMwsMEh3hxw=; b=GgmPfFs8wXP4OGDsvI4RKPLnMMlQyFJoMy5rxAaa8v242HvB/sHl3EYT mrxSWF5pKZIBlzPxgzWN599IWXkuzuktTW4fsEx0GnbV2keXQQIR1OGFq jsDW5EapCXRNp0AiRX8H/2+iFMfnbLYtu32f7s9sQ2jpb73tGATQ4Abag 7tHWlIfhTNanO/3JsvDUloeiRqXtJoEAgzMkx1+iB19dfev9wOkEU1xkL dRBdZrVnq/KJ8J/6Cu/XgTlpA9VzRT5yR8k2iRXVuS5tiXmp+L14p3iVF y0e8y+9E5n3O64v84+hQY0IM+AY9Nh/RPcIGLoTphil79jT5xllgR/xll A==; X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="6949403" X-IronPort-AV: E=Sophos;i="6.05,199,1701158400"; d="scan'208";a="6949403" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 05:08:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="777046930" X-IronPort-AV: E=Sophos;i="6.05,199,1701158400"; d="scan'208";a="777046930" Received: from jfunnell-mobl.ger.corp.intel.com (HELO localhost) ([10.252.39.52]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 05:07:54 -0800 From: Jani Nikula To: dri-devel@lists.freedesktop.org Subject: [PATCH 03/10] drm/print: add drm_dbg_printer() for drm device specific printer Date: Tue, 16 Jan 2024 15:07:28 +0200 Message-Id: <48607d58e5cdf8341ffdd522257542fa2ce41a19.1705410327.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo 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: , Cc: jani.nikula@intel.com, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" We've lacked a device specific debug printer. Add one. Take category into account too. __builtin_return_address(0) is inaccurate here, so don't use it. If necessary, we can later pass __func__ to drm_dbg_printer() by wrapping it inside a macro. Signed-off-by: Jani Nikula Reviewed-by: Luca Coelho --- drivers/gpu/drm/drm_print.c | 21 +++++++++++++++++++++ include/drm/drm_print.h | 24 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 91dbcdeaad3f..673b29c732ea 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -189,6 +189,27 @@ void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf) } EXPORT_SYMBOL(__drm_printfn_debug); +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); +} +EXPORT_SYMBOL(__drm_printfn_dbg); + void __drm_printfn_err(struct drm_printer *p, struct va_format *vaf) { struct drm_device *drm = p->arg; diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index b8b4cb9bb878..27e23c06dad4 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -176,6 +176,7 @@ struct drm_printer { void (*puts)(struct drm_printer *p, const char *str); void *arg; const char *prefix; + enum drm_debug_category category; }; void __drm_printfn_coredump(struct drm_printer *p, struct va_format *vaf); @@ -184,6 +185,7 @@ void __drm_printfn_seq_file(struct drm_printer *p, struct va_format *vaf); void __drm_puts_seq_file(struct drm_printer *p, const char *str); void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf); void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf); +void __drm_printfn_dbg(struct drm_printer *p, struct va_format *vaf); void __drm_printfn_err(struct drm_printer *p, struct va_format *vaf); __printf(2, 3) @@ -331,6 +333,28 @@ static inline struct drm_printer drm_debug_printer(const char *prefix) return p; } +/** + * drm_dbg_printer - construct a &drm_printer for drm device specific output + * @drm: the &struct drm_device pointer, or NULL + * @category: the debug category to use + * @prefix: debug output prefix, or NULL for no prefix + * + * RETURNS: + * The &drm_printer object + */ +static inline struct drm_printer drm_dbg_printer(struct drm_device *drm, + enum drm_debug_category category, + const char *prefix) +{ + struct drm_printer p = { + .printfn = __drm_printfn_dbg, + .arg = drm, + .prefix = prefix, + .category = category, + }; + return p; +} + /** * drm_err_printer - construct a &drm_printer that outputs to drm_err() * @drm: the &struct drm_device pointer