From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66F91C12002 for ; Wed, 21 Jul 2021 17:56:18 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 37CC861029 for ; Wed, 21 Jul 2021 17:56:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37CC861029 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=poorly.run Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 841436EC03; Wed, 21 Jul 2021 17:56:17 +0000 (UTC) Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by gabe.freedesktop.org (Postfix) with ESMTPS id D094F6EC03 for ; Wed, 21 Jul 2021 17:56:15 +0000 (UTC) Received: by mail-qk1-x72b.google.com with SMTP id z9so2878737qkg.5 for ; Wed, 21 Jul 2021 10:56:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QcEOQT1kQoqA3mviD8Rd9pRAGego5zppJEfeNqRzIp4=; b=S/oEvj+Jib2aFF5a7uzAbFAEIdIabsTHecFSrbBbGAMDho4Q/U8/jbys9Dl2SpfLvq GYoVI9ztA5heEizubyLQ98D0r/tlj+rYpCcwIiCfo4vdG4Otbrlslz9Ob07GPNtuh5Hx wiNMWYMoBVrz9ZiwI6VOc+PGnpWKYlydHZZnmtPppoHLx7D6NRs8/+lMSXd0MBBkYDp/ gTlGV6Ll9BriNj/Y6N1uFUoRtTvYNmmvpdpibdVX7oynRZ5ZiKv4TiyU77zQ3wTtlxLY vfJm8P7IC948Assydk2W27ULN8rV1ydqB9CQ1jQFHzYWqwoDjNoZXtZvhwz5eypm1zKh qa8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QcEOQT1kQoqA3mviD8Rd9pRAGego5zppJEfeNqRzIp4=; b=PnN+CvrSi2ZKi4VdCJYSybP518PkcKdOlLe7hs4hs9S8RIkGjMI4Pr9C2VonCn4s3C hAuQPXFBSWWCwZoNcnggpwWINzegtdJ0o+RU1KHX9zcNZKUyytaRivRDRitMS6ux+Qas 7B4n6TYP0sVcMvD3J21UL1HLowA395+p8CAFNmRMiXwzfGjpu2bkKa5sK5JxU+bqdapw iDBNTQ5ajGpi0NpapmAvITqcNBA1qdBAwCWsZA1NjQd9UnBtFQsnHqp7shXNF1COH3pe XXVX7NRCagWj/tI/MoqD7E9BtIM4pPIq2CsRquFvfCcorCH0uMCAY1QcfKgdL/MK14gh RgSg== X-Gm-Message-State: AOAM531aOQ0k7FCYeT+GLoltjwrTncquSayQ/zPm/4tFIVPAt5AmwGJT DoDOL5dnUlofbYn67jbiGdOEVqcuyn9xdw== X-Google-Smtp-Source: ABdhPJzZ6m++H+LaawkWeY2kU793ys2RMNwErbYX4cgWUn/tDVVYPTtjshAULyRzTZl+YFG20NHsFQ== X-Received: by 2002:a37:a544:: with SMTP id o65mr35707898qke.68.1626890174944; Wed, 21 Jul 2021 10:56:14 -0700 (PDT) Received: from localhost ([167.100.64.199]) by smtp.gmail.com with ESMTPSA id a5sm3391090qkf.88.2021.07.21.10.56.14 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Jul 2021 10:56:14 -0700 (PDT) From: Sean Paul To: dri-devel@lists.freedesktop.org, ppaalanen@gmail.com, maarten.lankhorst@linux.intel.com, tzimmermann@suse.de, airlied@linux.ie, daniel.vetter@ffwll.ch Subject: [RESEND PATCH v6 10/14] drm/print: Add drm_debug_category_printer Date: Wed, 21 Jul 2021 13:55:17 -0400 Message-Id: <20210721175526.22020-11-sean@poorly.run> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210721175526.22020-1-sean@poorly.run> References: <20210721175526.22020-1-sean@poorly.run> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: , Cc: Sean Paul Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Sean Paul This patch adds a new printer which will select the appropriate output for a given debug category. Currently there is only one output target, which is syslog. However in the future we'll have tracefs and it will be useful to print to syslog, tracefs, or both. Drivers just need to create the printer for the appropriate category and the printer will decide where to send the output. Signed-off-by: Sean Paul Link: https://patchwork.freedesktop.org/patch/msgid/20200608210505.48519-11-sean@poorly.run #v5 Changes in v5: -Added to the set Changes in v6: -None --- drivers/gpu/drm/drm_print.c | 5 +++++ include/drm/drm_print.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 2ff7a6ecc632..4d984a01b3a3 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -172,6 +172,11 @@ void __drm_printfn_err(struct drm_printer *p, struct va_format *vaf) } EXPORT_SYMBOL(__drm_printfn_err); +void __drm_printfn_noop(struct drm_printer *p, struct va_format *vaf) +{ +} +EXPORT_SYMBOL(__drm_printfn_noop); + /** * drm_puts - print a const string to a &drm_printer stream * @p: the &drm printer diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 2ea0ffd9c1ce..af31beeb82a1 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -87,6 +87,7 @@ 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_syslog(struct drm_printer *p, struct va_format *vaf); void __drm_printfn_err(struct drm_printer *p, struct va_format *vaf); +void __drm_printfn_noop(struct drm_printer *p, struct va_format *vaf); __printf(2, 3) void drm_printf(struct drm_printer *p, const char *f, ...); @@ -329,6 +330,33 @@ static inline bool drm_debug_enabled(enum drm_debug_category category) return drm_debug_syslog_enabled(category); } +/** + * drm_debug_category_printer - construct a &drm_printer that outputs to + * pr_debug() if enabled for the given category. + * @category: the DRM_UT_* message category this message belongs to + * @prefix: trace output prefix + * + * RETURNS: + * The &drm_printer object + */ +static inline struct drm_printer +drm_debug_category_printer(enum drm_debug_category category, + const char *prefix) +{ + struct drm_printer p = { + .prefix = prefix + }; + + if (drm_debug_syslog_enabled(category)) { + p.printfn = __drm_printfn_debug_syslog; + } else { + WARN(1, "Debug category %d is inactive.", category); + p.printfn = __drm_printfn_noop; + } + + return p; +} + /* * struct device based logging * -- Sean Paul, Software Engineer, Google / Chromium OS