From patchwork Thu Nov 7 21:03:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 11233773 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3704F14E5 for ; Thu, 7 Nov 2019 21:03:24 +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 1EF9D21D79 for ; Thu, 7 Nov 2019 21:03:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1EF9D21D79 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 93FF76F7BF; Thu, 7 Nov 2019 21:03:22 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yw1-xc43.google.com (mail-yw1-xc43.google.com [IPv6:2607:f8b0:4864:20::c43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 93EA66F7BB for ; Thu, 7 Nov 2019 21:03:20 +0000 (UTC) Received: by mail-yw1-xc43.google.com with SMTP id y64so1132405ywe.3 for ; Thu, 07 Nov 2019 13:03:20 -0800 (PST) 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=oygH01nqalvIc07wdgdaNh2D6+M1eA2NsoFjJs/rDb0=; b=RRgq4G0gZVkNDX4zfUXtYtoJRes6T0f3+zUYbRt7tIxSFkqPNMcNfCGd2BgHHlmxaQ Df6S14tvEkTt4cBL0UAiKk3WF8lJpY78MHTrP7ab3vD2ptzWw2oOVcBl9WGOuqwFdCHt 0jt1ZwWvvL6mvjJ2jGCPIrC5wm6zD2n+3TYrXC2qNYbh7p1h9yKmJo41ZwZhcQ5Ef6WX wz1qu4ZdAGXMPlHjxLCwsagpLxZhUDCTPM5kUEBemESjmwG6X9kkrE/uFZ1IRxH1f+3T 5Go0/HY4bP6WFxoLz9IzwrizjZQRyiB/zk5mPlB+GR8Efx+MSvuR3xOMkZVaGk/TAwlA 1Pow== X-Gm-Message-State: APjAAAXfLe9+Sne8QM33hokgfq+j8OGwsfCG5njx8tShRYDlw85/IJDJ f6mgZi41OBH4GkyDPqNhTDQ+qO+ZScQ= X-Google-Smtp-Source: APXvYqybyUG3wYkJ3VuqgaYSln7LF9ZLFNUkASeuMvWC6u9J0rW2V9pyns2Zw600jfzNSnsYKf2Odw== X-Received: by 2002:a0d:cc91:: with SMTP id o139mr4228911ywd.373.1573160599586; Thu, 07 Nov 2019 13:03:19 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id r14sm1064196ywl.97.2019.11.07.13.03.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2019 13:03:19 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/6] drm: trace: Make the vblank queued/delivered events classed Date: Thu, 7 Nov 2019 16:03:00 -0500 Message-Id: <20191107210316.143216-2-sean@poorly.run> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191107210316.143216-1-sean@poorly.run> References: <20191107210316.143216-1-sean@poorly.run> MIME-Version: 1.0 X-Mailman-Original-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=oygH01nqalvIc07wdgdaNh2D6+M1eA2NsoFjJs/rDb0=; b=KTF28fihFWzJ8ff6rJKJ6Ewe+3QwnTlEM+4+QqV2AVD2G0sa2z+oq4pKP0eMDaOyZe rjq55tk25mxy1+cj7P/8sZazXnIGyGCNscjnNZbOH57Lq8TDBz+078xFG6GgJgCLdR53 dUQdZ62QsUYAcudkbrltrYYVZl+alVFkjiseQEsExitp7nu4/dLrkU0b++IOdx3TL4Cr HOeFAETYYf9baKQegpnuBAMMAfNH/UfkyYTNV8jmfzmanXwGqU3pdW/MMfqxE1aLQx3R PjuuQWpma1NXbKYTrNRGgRKYOAP8/7lxtvK+WHE5A9SgwEbfvbeHhR2WpXry+S3zxQtC AA+A== 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: daniel.vetter@ffwll.ch, Sean Paul , tzimmermann@suse.de Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Sean Paul We can use an event class to remove some boilerplate for the event queued/delivered trace events. Signed-off-by: Sean Paul --- drivers/gpu/drm/drm_trace.h | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/drm_trace.h b/drivers/gpu/drm/drm_trace.h index 11c6dd577e8ed..487bc3478efec 100644 --- a/drivers/gpu/drm/drm_trace.h +++ b/drivers/gpu/drm/drm_trace.h @@ -32,7 +32,7 @@ TRACE_EVENT(drm_vblank_event, __entry->high_prec ? "true" : "false") ); -TRACE_EVENT(drm_vblank_event_queued, +DECLARE_EVENT_CLASS(class_drm_vblank_event, TP_PROTO(struct drm_file *file, int crtc, unsigned int seq), TP_ARGS(file, crtc, seq), TP_STRUCT__entry( @@ -45,25 +45,16 @@ TRACE_EVENT(drm_vblank_event_queued, __entry->crtc = crtc; __entry->seq = seq; ), - TP_printk("file=%p, crtc=%d, seq=%u", __entry->file, __entry->crtc, \ + TP_printk("file=%p, crtc=%d, seq=%u", __entry->file, __entry->crtc, __entry->seq) ); - -TRACE_EVENT(drm_vblank_event_delivered, - TP_PROTO(struct drm_file *file, int crtc, unsigned int seq), - TP_ARGS(file, crtc, seq), - TP_STRUCT__entry( - __field(struct drm_file *, file) - __field(int, crtc) - __field(unsigned int, seq) - ), - TP_fast_assign( - __entry->file = file; - __entry->crtc = crtc; - __entry->seq = seq; - ), - TP_printk("file=%p, crtc=%d, seq=%u", __entry->file, __entry->crtc, \ - __entry->seq) +DEFINE_EVENT(class_drm_vblank_event, drm_vblank_event_queued, + TP_PROTO(struct drm_file *file, int crtc, unsigned int seq), + TP_ARGS(file, crtc, seq) +); +DEFINE_EVENT(class_drm_vblank_event, drm_vblank_event_delivered, + TP_PROTO(struct drm_file *file, int crtc, unsigned int seq), + TP_ARGS(file, crtc, seq) ); #endif /* _DRM_TRACE_H_ */ From patchwork Thu Nov 7 21:03:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 11233775 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A8384139A for ; Thu, 7 Nov 2019 21:03:26 +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 8FEC721D79 for ; Thu, 7 Nov 2019 21:03:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8FEC721D79 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 A17BC6F7C0; Thu, 7 Nov 2019 21:03:24 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yw1-xc42.google.com (mail-yw1-xc42.google.com [IPv6:2607:f8b0:4864:20::c42]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7DF496F7BB for ; Thu, 7 Nov 2019 21:03:22 +0000 (UTC) Received: by mail-yw1-xc42.google.com with SMTP id y64so1132458ywe.3 for ; Thu, 07 Nov 2019 13:03:22 -0800 (PST) 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=KC2BYUStyaQkIOsxmJMEfiQ0fY/TMGO96+PzuKi2DJc=; b=K67exyRfdqt+Vj3uBXpaRz6tKrt5C1eZ4MtluswHwXMmhObjE+BJZCWn+EFB1IgUmO X3gX+rzEcb1EkSCifPAT/uHktNb0lIcbCWBmkJdRhpyri09G7rjnZHFMdg8GAD+XXvTH nLi08WL8SPTtnyKBp95fXBcNz4ZMcWTsaHcgUU6SHr5Lqki2/1ipK0q11p79f6cO+mUe QhmkYi6xEALUe1v0x0K7recHKuMCgMR0cRj28185TfNClu1U6sJRlWgQDAmmwD/Sy1kh 0UxnyktTvJ7BYYgzyhn20v88+bt4Huwi8YxWl7zwzYZjpu6hEOt/0gOhRBIeQWDUY2bD vYsg== X-Gm-Message-State: APjAAAXWmdJNA/zOBoOAhIYS+Z8ucCJTH0ZjjRln10OmWoqZ7A29IQtO e7vxwCqBvikg8sVWqZ9k2iaDmS92Tq8= X-Google-Smtp-Source: APXvYqzfibwXErR/EA/byC5kF15E4MvEvfW1qd1LMC5jKits8K7Thg64+dk8r8vIRPpj56gzvxsgfA== X-Received: by 2002:a81:5ac6:: with SMTP id o189mr1149824ywb.110.1573160601381; Thu, 07 Nov 2019 13:03:21 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id r14sm1064196ywl.97.2019.11.07.13.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2019 13:03:20 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/6] drm: trace: Introduce drm_trace() and trace event classes Date: Thu, 7 Nov 2019 16:03:01 -0500 Message-Id: <20191107210316.143216-3-sean@poorly.run> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191107210316.143216-1-sean@poorly.run> References: <20191107210316.143216-1-sean@poorly.run> MIME-Version: 1.0 X-Mailman-Original-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=KC2BYUStyaQkIOsxmJMEfiQ0fY/TMGO96+PzuKi2DJc=; b=X6pw+z6SxoXc3DzqXjLqzRChFgreSAmqyw1VA/DalFdyvrpzXb23rv3L3QlBtiN8fp ii89eqm9cdWh4YK2tkqVkAGz3Dn17QDYL1oWWmZ71TxQf6CJCrA3GGRrs4xtl4xwEn8E 58XIIiA8EeK3ljen+gkdducb/bqg1LWVxE7V23zmGNxXvsy21F0kRhNAULpaRN/CENXz sfAryRet3rwqI15DLJcLhkKHwxoTWEMl4sW0eBBBZkWa1d2qxTT9Dd+4uVcUsyfJlWX3 FcXqyykQCS8YBCY5Ca+AAIXiWOZS0AmqZ1MwpAJOOiIRQza0KLIrqleP17jX8FTWfo6x hCYA== 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: daniel.vetter@ffwll.ch, Sean Paul , tzimmermann@suse.de Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Sean Paul This patch is the first step in expanding trace events in drm. It introduces a new enum used to classify trace events as well as a couple helper macros to issue trace events from around drm. It's a bit of a toy right now since we're just converting one class (vblank) and there aren't any error events in this class. However later patches in this series will add more interesting classes. Signed-off-by: Sean Paul --- Documentation/gpu/drm-internals.rst | 9 +++ drivers/gpu/drm/drm_trace.h | 109 ++++++++++++++++++++++++++-- drivers/gpu/drm/drm_vblank.c | 8 +- 3 files changed, 114 insertions(+), 12 deletions(-) diff --git a/Documentation/gpu/drm-internals.rst b/Documentation/gpu/drm-internals.rst index 966bd2d9f0ccd..ac87a94b7057a 100644 --- a/Documentation/gpu/drm-internals.rst +++ b/Documentation/gpu/drm-internals.rst @@ -176,6 +176,15 @@ Printer .. kernel-doc:: drivers/gpu/drm/drm_print.c :export: +Tracing +------- + +.. kernel-doc:: drivers/gpu/drm/drm_trace.h + :doc: overview + +.. kernel-doc:: drivers/gpu/drm/drm_trace.h + :internal: + Utilities --------- diff --git a/drivers/gpu/drm/drm_trace.h b/drivers/gpu/drm/drm_trace.h index 487bc3478efec..19e5f04210586 100644 --- a/drivers/gpu/drm/drm_trace.h +++ b/drivers/gpu/drm/drm_trace.h @@ -7,21 +7,109 @@ #include struct drm_file; +/** + * DOC: overview + * + * DRM trace events can be used to trace important moments occurring in the DRM + * core or helpers without incurring a significant performance penalty (like you + * would with console logging). + */ + +#if !defined(_DRM_TRACE_EVENT_CLASS_ENUM) +#define _DRM_TRACE_EVENT_CLASS_ENUM + +/** + * enum drm_trace_event_class - the trace class of an event + * + * Trace events are broken into different classes (much the same as we do for + * console logging) to make sifting through the logs easier. If you want to + * isolate one or more classes (or disable a subset of classes), you can write + * an expession using the event_class entry field as a tracepoints filter. The + * event_class field is not printed as part of the trace log, it's just there + * for filtering. + * + * The classes are bitfields to make filtering easier, but also to allow trace + * events to be classified under multiple classes (ie: if you're tracing an + * error that occurred with a crtc, you can ensure that these events are + * surfaced for filters looking for either crtc or error classes). + * + * An example filter is: + * Assume you want to view all trace events in failure paths, you would + * write a filter which isolates events with the drm_trace_class_error bit + * set in their event_class field. This allows you to enable all trace + * events in the drm trace system and only consume errors. + * + * ; echo "event_class & 0x1" > /sys/kernel/tracing/events/drm/filter + * ; echo 1 > /sys/kernel/tracing/events/drm/enable + * + * Similarly, to view all vblank traces plus any error traces, you select + * both classes in the filter. + * + * ; echo "event_class & 0x3" > /sys/kernel/tracing/events/drm/filter + */ +enum drm_trace_event_class { + /** + * @drm_trace_class_error: Denotes that the trace event is coming from + * an error path. + */ + drm_trace_class_error = BIT(0), + + /** + * @drm_trace_class_vblank: Use this to track trace events that track + * vblanks and vblank events. + */ + drm_trace_class_vblank = BIT(1), +}; + +/** + * drm_trace - add a drm trace event + * @_c: class name (the part that comes after drm_trace_class_) + * @_e: event name (the part that comes after drm_$class_) + * + * Use this macro to simplify adding a trace event for non-failure paths in + * drm code. The macro simply assembles the trace event from the class and name, + * and sets the correct event_code for this trace. + * + * It's recommended that this macro is not used in failure paths. For failure + * paths, use drm_trace_err(). + */ +#define drm_trace(_c, _e, ...) \ + trace_drm_##_c##_##_e(drm_trace_class_##_c, __VA_ARGS__) + +/** + * drm_trace_err - add a drm trace event in a failure path + * @_c: class name (the part that comes after drm_trace_class_) + * @_e: event name (the part that comes after drm_$class_) + * + * This is virtually the same as drm_trace(), however it sets the error class on + * the event as well. This is beneficial for those filtering events by + * class_error. + * + * For non-failure paths, please use drm_trace(). + */ +#define drm_trace_err(_c, _e, ...) \ + trace_drm_##_c##_##_e(drm_trace_class_##_c | drm_trace_class_error, \ + __VA_ARGS__) + +#endif #undef TRACE_SYSTEM #define TRACE_SYSTEM drm #define TRACE_INCLUDE_FILE drm_trace TRACE_EVENT(drm_vblank_event, - TP_PROTO(int crtc, unsigned int seq, ktime_t time, bool high_prec), - TP_ARGS(crtc, seq, time, high_prec), + TP_PROTO(unsigned int event_class, int crtc, unsigned int seq, + ktime_t time, bool high_prec), + TP_ARGS(event_class, crtc, seq, time, high_prec), TP_STRUCT__entry( + __field(unsigned int, event_class) __field(int, crtc) __field(unsigned int, seq) __field(ktime_t, time) __field(bool, high_prec) ), TP_fast_assign( + __entry->event_class = event_class; __entry->crtc = crtc; __entry->seq = seq; __entry->time = time; @@ -33,14 +121,17 @@ TRACE_EVENT(drm_vblank_event, ); DECLARE_EVENT_CLASS(class_drm_vblank_event, - TP_PROTO(struct drm_file *file, int crtc, unsigned int seq), - TP_ARGS(file, crtc, seq), + TP_PROTO(unsigned int event_class, struct drm_file *file, + int crtc, unsigned int seq), + TP_ARGS(event_class, file, crtc, seq), TP_STRUCT__entry( + __field(unsigned int, event_class) __field(struct drm_file *, file) __field(int, crtc) __field(unsigned int, seq) ), TP_fast_assign( + __entry->event_class = event_class; __entry->file = file; __entry->crtc = crtc; __entry->seq = seq; @@ -49,12 +140,14 @@ DECLARE_EVENT_CLASS(class_drm_vblank_event, __entry->seq) ); DEFINE_EVENT(class_drm_vblank_event, drm_vblank_event_queued, - TP_PROTO(struct drm_file *file, int crtc, unsigned int seq), - TP_ARGS(file, crtc, seq) + TP_PROTO(unsigned int event_class, struct drm_file *file, int crtc, + unsigned int seq), + TP_ARGS(event_class, file, crtc, seq) ); DEFINE_EVENT(class_drm_vblank_event, drm_vblank_event_delivered, - TP_PROTO(struct drm_file *file, int crtc, unsigned int seq), - TP_ARGS(file, crtc, seq) + TP_PROTO(unsigned int event_class, struct drm_file *file, int crtc, + unsigned int seq), + TP_ARGS(event_class, file, crtc, seq) ); #endif /* _DRM_TRACE_H_ */ diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index 1659b13b178c2..19a63a94586ad 100644 --- a/drivers/gpu/drm/drm_vblank.c +++ b/drivers/gpu/drm/drm_vblank.c @@ -880,7 +880,7 @@ static void send_vblank_event(struct drm_device *dev, e->event.seq.time_ns = ktime_to_ns(now); break; } - trace_drm_vblank_event_delivered(e->base.file_priv, e->pipe, seq); + drm_trace(vblank, event_delivered, e->base.file_priv, e->pipe, seq); drm_send_event_locked(dev, &e->base); } @@ -1529,7 +1529,7 @@ static int drm_queue_vblank_event(struct drm_device *dev, unsigned int pipe, DRM_DEBUG("event on vblank count %llu, current %llu, crtc %u\n", req_seq, seq, pipe); - trace_drm_vblank_event_queued(file_priv, pipe, req_seq); + drm_trace(vblank, event_queued, file_priv, pipe, req_seq); e->sequence = req_seq; if (vblank_passed(seq, req_seq)) { @@ -1760,8 +1760,8 @@ static void drm_handle_vblank_events(struct drm_device *dev, unsigned int pipe) send_vblank_event(dev, e, seq, now); } - trace_drm_vblank_event(pipe, seq, now, - dev->driver->get_vblank_timestamp != NULL); + drm_trace(vblank, event, pipe, seq, now, + dev->driver->get_vblank_timestamp != NULL); } /** From patchwork Thu Nov 7 21:03:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 11233777 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E8233139A for ; Thu, 7 Nov 2019 21:03:28 +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 CFCAF21D79 for ; Thu, 7 Nov 2019 21:03:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFCAF21D79 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 1BA136F7C2; Thu, 7 Nov 2019 21:03:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yw1-xc44.google.com (mail-yw1-xc44.google.com [IPv6:2607:f8b0:4864:20::c44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 258516F7BB for ; Thu, 7 Nov 2019 21:03:24 +0000 (UTC) Received: by mail-yw1-xc44.google.com with SMTP id p128so1115445ywc.11 for ; Thu, 07 Nov 2019 13:03:24 -0800 (PST) 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=TuhlZU4MLBpT2FZLEA5wlpltGz8l0CcErofYatLylqE=; b=jLDy5bouZYIhguPJg9lB+I5quPKRtXtLwSldPDjs4IBXGHWDKynHg0f2nPiCq0y9t3 3pO6ShX38PtEq75zt3+D6GSaXygwtVOFhx9R48UR3XjxjeqHFQlM1N8p6Z/2uuZUIC6w JNg+41HwVfLzZiV8sUpoq4xq3n0fG7HrTZ5ygaPq3hm+Yiu+7giAEqoQLiBfAQR0Ai5J Vcl09T69uc2SM02aESATgWpr8MJdizHQtfslJ6Q33CzsP59EhApYtKezWmlKWr16N57u huOfSsSSEGzPnmAqIayKqjgHIUYtKnSi7gmUI62pMFl3/o/l13Zg8eVlogrqcu3Em8dD 9AKg== X-Gm-Message-State: APjAAAVK6pj5EeuNOuyiKw5IGRmwELZPFIn6J5Z25/FU/PJWmfFWY9Pa hrF8fdJCJuEzSqsHCA/NE4/Tt1Yerlo= X-Google-Smtp-Source: APXvYqy63NYJbFcfRtVKUKzqDVf4mprNJJzrb6yLolBs2cyoJgP44AQxLCvNtKGbtqREGJ6nJhJjRw== X-Received: by 2002:a81:6fd6:: with SMTP id k205mr4313950ywc.401.1573160603071; Thu, 07 Nov 2019 13:03:23 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id r14sm1064196ywl.97.2019.11.07.13.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2019 13:03:22 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/6] drm: trace: Add trace events for atomic state lifetime Date: Thu, 7 Nov 2019 16:03:02 -0500 Message-Id: <20191107210316.143216-4-sean@poorly.run> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191107210316.143216-1-sean@poorly.run> References: <20191107210316.143216-1-sean@poorly.run> MIME-Version: 1.0 X-Mailman-Original-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=TuhlZU4MLBpT2FZLEA5wlpltGz8l0CcErofYatLylqE=; b=K34R4yVAdDFJhBqw2gyb2Ab4iHyk4vPJHqWnKexmfwuKP2/JTP/xFkTQpqrCPi4X/u louE6dk/mEXtpkctljjgj1aHL8oLwBvOrX7FqG5Ik27bRAYYVXJYY0naw9EAuW4Gqe9m qWBlS3n2ClWq36BRIODqSW36s5vzminTsik85YDDQSK9ylIKQdMP5GAS932/8rp0ovxP m1CfUaRGDpJSmi0f0hBFfBFnHEGt4aMBKH5cRGcVWUyCOxsFopBL9OJjsdkFSz3yacYi zwzK+w4iO45G3eENL+I4v9j8gBlnTW78q3r/O8YjJmCzMvou0PHoK62YxBZLRTg8hFrU mFdw== 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: daniel.vetter@ffwll.ch, Sean Paul , tzimmermann@suse.de Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Sean Paul Mirror some atomic debug messages which track a state through allocation/clear/check/commit/free Change-Id: I0387ddf4b2f1d84137a5b471e347878c04c6d0af Signed-off-by: Sean Paul --- drivers/gpu/drm/drm_atomic.c | 19 +++++--- drivers/gpu/drm/drm_trace.h | 84 ++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 14aeaf7363210..93ca64af67f55 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -41,6 +41,7 @@ #include "drm_crtc_internal.h" #include "drm_internal.h" +#include "drm_trace.h" void __drm_crtc_commit_free(struct kref *kref) { @@ -118,10 +119,11 @@ struct drm_atomic_state * drm_atomic_state_alloc(struct drm_device *dev) { struct drm_mode_config *config = &dev->mode_config; + struct drm_atomic_state *state; - if (!config->funcs->atomic_state_alloc) { - struct drm_atomic_state *state; - + if (config->funcs->atomic_state_alloc) { + state = config->funcs->atomic_state_alloc(dev); + } else { state = kzalloc(sizeof(*state), GFP_KERNEL); if (!state) return NULL; @@ -129,10 +131,10 @@ drm_atomic_state_alloc(struct drm_device *dev) kfree(state); return NULL; } - return state; } - return config->funcs->atomic_state_alloc(dev); + drm_trace(atomic, alloc, state); + return state; } EXPORT_SYMBOL(drm_atomic_state_alloc); @@ -239,6 +241,7 @@ void drm_atomic_state_clear(struct drm_atomic_state *state) struct drm_device *dev = state->dev; struct drm_mode_config *config = &dev->mode_config; + drm_trace(atomic, clear, state); if (config->funcs->atomic_state_clear) config->funcs->atomic_state_clear(state); else @@ -261,6 +264,7 @@ void __drm_atomic_state_free(struct kref *ref) drm_atomic_state_clear(state); DRM_DEBUG_ATOMIC("Freeing atomic state %p\n", state); + drm_trace(atomic, free, state); if (config->funcs->atomic_state_free) { config->funcs->atomic_state_free(state); @@ -1145,6 +1149,7 @@ int drm_atomic_check_only(struct drm_atomic_state *state) int i, ret = 0; DRM_DEBUG_ATOMIC("checking %p\n", state); + drm_trace(atomic, check, state); for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) { ret = drm_atomic_plane_check(old_plane_state, new_plane_state); @@ -1179,6 +1184,7 @@ int drm_atomic_check_only(struct drm_atomic_state *state) if (ret) { DRM_DEBUG_ATOMIC("atomic driver check for %p failed: %d\n", state, ret); + drm_trace_err(atomic, check_failed, state); return ret; } } @@ -1193,6 +1199,7 @@ int drm_atomic_check_only(struct drm_atomic_state *state) } } + drm_trace(atomic, check_passed, state); return 0; } EXPORT_SYMBOL(drm_atomic_check_only); @@ -1221,6 +1228,7 @@ int drm_atomic_commit(struct drm_atomic_state *state) return ret; DRM_DEBUG_ATOMIC("committing %p\n", state); + drm_trace(atomic, commit, state); return config->funcs->atomic_commit(state->dev, state, false); } @@ -1250,6 +1258,7 @@ int drm_atomic_nonblocking_commit(struct drm_atomic_state *state) return ret; DRM_DEBUG_ATOMIC("committing %p nonblocking\n", state); + drm_trace(atomic, commit_nonblock, state); return config->funcs->atomic_commit(state->dev, state, true); } diff --git a/drivers/gpu/drm/drm_trace.h b/drivers/gpu/drm/drm_trace.h index 19e5f04210586..5d56365d0b439 100644 --- a/drivers/gpu/drm/drm_trace.h +++ b/drivers/gpu/drm/drm_trace.h @@ -2,6 +2,9 @@ #if !defined(_DRM_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ) #define _DRM_TRACE_H_ +#include + +#include #include #include #include @@ -59,6 +62,12 @@ enum drm_trace_event_class { * vblanks and vblank events. */ drm_trace_class_vblank = BIT(1), + + /** + * @drm_trace_class_atomic: This class is used to track the top-level + * atomic state from alloc to free and everywhere in between. + */ + drm_trace_class_atomic = BIT(2), }; /** @@ -150,6 +159,81 @@ DEFINE_EVENT(class_drm_vblank_event, drm_vblank_event_delivered, TP_ARGS(event_class, file, crtc, seq) ); +DECLARE_EVENT_CLASS(class_drm_atomic, + TP_PROTO(unsigned int event_class, + const struct drm_atomic_state *state), + TP_ARGS(event_class, state), + TP_STRUCT__entry( + __field(unsigned int, event_class) + __field(const struct drm_atomic_state *, state) + __field(unsigned int, ref) + __field(bool, allow_modeset) + __field(bool, legacy_cursor_update) + __field(bool, async_update) + __field(bool, duplicated) + __field(unsigned int, num_connector) + __field(unsigned int, num_private_objs) + ), + TP_fast_assign( + __entry->event_class = event_class; + __entry->state = state; /* Do not de-reference! */ + __entry->ref = kref_read(&state->ref); + __entry->allow_modeset = state->allow_modeset; + __entry->legacy_cursor_update = state->legacy_cursor_update; + __entry->async_update = state->async_update; + __entry->duplicated = state->duplicated; + __entry->num_connector = state->num_connector; + __entry->num_private_objs = state->num_private_objs; + ), + TP_printk("state=%pK ref=%d allow_modeset=%d legacy_cursor=%d " + "async_update=%d duplicated=%d num_conn=%d num_priv_objs=%d", + __entry->state, __entry->ref, __entry->allow_modeset, + __entry->legacy_cursor_update, __entry->async_update, + __entry->duplicated, __entry->num_connector, + __entry->num_private_objs) +); +DEFINE_EVENT_PRINT(class_drm_atomic, drm_atomic_alloc, + TP_PROTO(unsigned int event_class, + const struct drm_atomic_state *state), + TP_ARGS(event_class, state), + TP_printk("state=%pK", __entry->state) +); +DEFINE_EVENT(class_drm_atomic, drm_atomic_clear, + TP_PROTO(unsigned int event_class, + const struct drm_atomic_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_atomic, drm_atomic_free, + TP_PROTO(unsigned int event_class, + const struct drm_atomic_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_atomic, drm_atomic_check, + TP_PROTO(unsigned int event_class, + const struct drm_atomic_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_atomic, drm_atomic_commit, + TP_PROTO(unsigned int event_class, + const struct drm_atomic_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_atomic, drm_atomic_commit_nonblock, + TP_PROTO(unsigned int event_class, + const struct drm_atomic_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_atomic, drm_atomic_check_passed, + TP_PROTO(unsigned int event_class, + const struct drm_atomic_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_atomic, drm_atomic_check_failed, + TP_PROTO(unsigned int event_class, + const struct drm_atomic_state *state), + TP_ARGS(event_class, state) +); + #endif /* _DRM_TRACE_H_ */ /* This part must be outside protection */ From patchwork Thu Nov 7 21:03:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 11233779 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9073D1864 for ; Thu, 7 Nov 2019 21:03:31 +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 785F821D7B for ; Thu, 7 Nov 2019 21:03:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 785F821D7B 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 DE9766F7C1; Thu, 7 Nov 2019 21:03:29 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yb1-xb43.google.com (mail-yb1-xb43.google.com [IPv6:2607:f8b0:4864:20::b43]) by gabe.freedesktop.org (Postfix) with ESMTPS id B7E466F7BB for ; Thu, 7 Nov 2019 21:03:25 +0000 (UTC) Received: by mail-yb1-xb43.google.com with SMTP id g38so1542765ybe.11 for ; Thu, 07 Nov 2019 13:03:25 -0800 (PST) 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=xGh+vladbK5S5J/7R3/WQq7QKvHfGB+VRsU4EM+UiUg=; b=kSf9EOABDCrUtrkEDt5PomhawO5nEFNuiwGSg1L+FOxqsQEuAZOhUcUek6Sk/TWumH jn8DwdhuvnvvkbiZcJlFm11qNiKZOynqRW6VO09K1lI7MmL/eMgpQVJQLoCp1hRBRYtj CYWpeqzQsrCpWx06J8dFzWHIfNpZOV6cAcanqh/0eP9isK1iONzmbBi0i/vs/LFkORgW CWdv+Khc8neQdDglUQonNfWKA1XvaiAT5jyUXg+InVXKfdBJ1pYxONnJF3u7dXau4kaD rXj5h3PtiUD/AR+XEDnh05S0Exqq/hhPs1GZiCiBJAfhar58/yIHKERscyoceOAABeOA Rj3g== X-Gm-Message-State: APjAAAXun+hB7caJibodK04i9UuV4DAffEjt+n/Wa9Rd+9fZsGzp1wK/ 6Q3+CN+/8qDSEKOY84j3NFw4Fq/+eNM= X-Google-Smtp-Source: APXvYqyX83BuN8S5ZbDSlSkoH4GuXiFzZZqaNpV2RrQEYtsDcbJNJ0Arsx0+4/uXq/WLFv6Jn4kJNg== X-Received: by 2002:a5b:710:: with SMTP id g16mr5564697ybq.181.1573160604520; Thu, 07 Nov 2019 13:03:24 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id r14sm1064196ywl.97.2019.11.07.13.03.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2019 13:03:24 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/6] drm: trace: Add crtc state trace events Date: Thu, 7 Nov 2019 16:03:03 -0500 Message-Id: <20191107210316.143216-5-sean@poorly.run> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191107210316.143216-1-sean@poorly.run> References: <20191107210316.143216-1-sean@poorly.run> MIME-Version: 1.0 X-Mailman-Original-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=xGh+vladbK5S5J/7R3/WQq7QKvHfGB+VRsU4EM+UiUg=; b=XueJ/KNEzS3khxpdYJVtLOLd/3s0gkJ5hZhAvZsFOvR/vss6+3H+k/8qXR1BJm/3dw +1XpwgWSACq5KXlnWFzxZSZHYyB0zshyDPsmNHiBwPhgiLlza8r9sakQFerl09MLB8Fs 90yXezX0z1aWfhCkRUppFP0vs9SoOSIkEWT0cJ1N0D1t3Ii5QGV5Lky5ualwctBRR8md rcJwDe9/Gf577xgYDoyZwlNX34rhG7FcGcSDfW/7Ukau6xOXVGNQpV1cARcioYXX3yPO oJX1Vrs17K5ae48b3YqyxVF9iSmYDSDa9MLx7ZEoWRvDnIBQZUYSfLrGPYKpoj/OCjod gEcw== 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: daniel.vetter@ffwll.ch, Sean Paul , tzimmermann@suse.de Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Sean Paul Add tracing which tracks important crtc_state events through the atomic core. Signed-off-by: Sean Paul --- drivers/gpu/drm/drm_atomic.c | 14 +++++ drivers/gpu/drm/drm_trace.h | 109 +++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 93ca64af67f55..955650729115d 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -319,6 +319,7 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state, DRM_DEBUG_ATOMIC("Added [CRTC:%d:%s] %p state to %p\n", crtc->base.id, crtc->name, crtc_state, state); + drm_trace(crtc, add, crtc_state); return crtc_state; } @@ -340,6 +341,8 @@ static int drm_atomic_crtc_check(const struct drm_crtc_state *old_crtc_state, if (new_crtc_state->active && !new_crtc_state->enable) { DRM_DEBUG_ATOMIC("[CRTC:%d:%s] active without enabled\n", crtc->base.id, crtc->name); + drm_trace_err(crtc, check_fail_active_not_enabled, + new_crtc_state); return -EINVAL; } @@ -350,6 +353,7 @@ static int drm_atomic_crtc_check(const struct drm_crtc_state *old_crtc_state, WARN_ON(new_crtc_state->enable && !new_crtc_state->mode_blob)) { DRM_DEBUG_ATOMIC("[CRTC:%d:%s] enabled without mode blob\n", crtc->base.id, crtc->name); + drm_trace_err(crtc, check_fail_enable_no_mode, new_crtc_state); return -EINVAL; } @@ -357,6 +361,7 @@ static int drm_atomic_crtc_check(const struct drm_crtc_state *old_crtc_state, WARN_ON(!new_crtc_state->enable && new_crtc_state->mode_blob)) { DRM_DEBUG_ATOMIC("[CRTC:%d:%s] disabled with mode blob\n", crtc->base.id, crtc->name); + drm_trace_err(crtc, check_fail_mode_no_enable, new_crtc_state); return -EINVAL; } @@ -374,9 +379,12 @@ static int drm_atomic_crtc_check(const struct drm_crtc_state *old_crtc_state, !new_crtc_state->active && !old_crtc_state->active) { DRM_DEBUG_ATOMIC("[CRTC:%d:%s] requesting event but off\n", crtc->base.id, crtc->name); + drm_trace_err(crtc, check_fail_event_not_active, + new_crtc_state); return -EINVAL; } + drm_trace(crtc, check_passed, new_crtc_state); return 0; } @@ -1057,6 +1065,8 @@ drm_atomic_add_affected_connectors(struct drm_atomic_state *state, DRM_DEBUG_ATOMIC("Adding all current connectors for [CRTC:%d:%s] to %p\n", crtc->base.id, crtc->name, state); + drm_trace(crtc, add_affected_connectors, crtc_state); + /* * Changed connectors are already in @state, so only need to look @@ -1111,6 +1121,7 @@ drm_atomic_add_affected_planes(struct drm_atomic_state *state, DRM_DEBUG_ATOMIC("Adding all current planes for [CRTC:%d:%s] to %p\n", crtc->base.id, crtc->name, state); + drm_trace(crtc, add_affected_planes, old_crtc_state); drm_for_each_plane_mask(plane, state->dev, old_crtc_state->plane_mask) { struct drm_plane_state *plane_state = @@ -1165,6 +1176,7 @@ int drm_atomic_check_only(struct drm_atomic_state *state) if (ret) { DRM_DEBUG_ATOMIC("[CRTC:%d:%s] atomic core check failed\n", crtc->base.id, crtc->name); + drm_trace_err(crtc, check_failed, new_crtc_state); return ret; } } @@ -1194,6 +1206,8 @@ int drm_atomic_check_only(struct drm_atomic_state *state) if (drm_atomic_crtc_needs_modeset(new_crtc_state)) { DRM_DEBUG_ATOMIC("[CRTC:%d:%s] requires full modeset\n", crtc->base.id, crtc->name); + drm_trace_err(crtc, check_fail_modeset_required, + new_crtc_state); return -EINVAL; } } diff --git a/drivers/gpu/drm/drm_trace.h b/drivers/gpu/drm/drm_trace.h index 5d56365d0b439..91880f650a7b3 100644 --- a/drivers/gpu/drm/drm_trace.h +++ b/drivers/gpu/drm/drm_trace.h @@ -3,6 +3,7 @@ #define _DRM_TRACE_H_ #include +#include #include #include @@ -68,6 +69,12 @@ enum drm_trace_event_class { * atomic state from alloc to free and everywhere in between. */ drm_trace_class_atomic = BIT(2), + + /** + * @drm_trace_class_crtc: This class is used to track crtc state through + * the atomic core and helpers. + */ + drm_trace_class_crtc = BIT(3), }; /** @@ -234,6 +241,108 @@ DEFINE_EVENT(class_drm_atomic, drm_atomic_check_failed, TP_ARGS(event_class, state) ); +DECLARE_EVENT_CLASS(class_drm_crtc, + TP_PROTO(unsigned int event_class, const struct drm_crtc_state *state), + TP_ARGS(event_class, state), + TP_STRUCT__entry( + __field(unsigned int, event_class) + __field(const struct drm_atomic_state *, state) + __field(const struct drm_crtc_state *, crtc_state) + __field(const struct drm_crtc_commit *, commit) + __field(uint32_t, crtc_id) + __field(bool, enable) + __field(bool, active) + __field(bool, planes_changed) + __field(bool, mode_changed) + __field(bool, active_changed) + __field(bool, connectors_changed) + __field(bool, zpos_changed) + __field(bool, color_mgmt_changed) + __field(bool, no_vblank) + __field(bool, async_flip) + __field(bool, vrr_enabled) + __field(bool, self_refresh_active) + __field(u32, plane_mask) + __field(u32, connector_mask) + __field(u32, encoder_mask) + ), + TP_fast_assign( + __entry->event_class = event_class; + __entry->state = state->state; + __entry->crtc_state = state; + __entry->crtc_id = state->crtc->base.id; + __entry->commit = state->commit; + __entry->enable = state->enable; + __entry->active = state->active; + __entry->planes_changed = state->planes_changed; + __entry->mode_changed = state->mode_changed; + __entry->active_changed = state->active_changed; + __entry->connectors_changed = state->connectors_changed; + __entry->zpos_changed = state->zpos_changed; + __entry->color_mgmt_changed = state->color_mgmt_changed; + __entry->no_vblank = state->no_vblank; + __entry->async_flip = state->async_flip; + __entry->vrr_enabled = state->vrr_enabled; + __entry->self_refresh_active = state->self_refresh_active; + __entry->plane_mask = state->plane_mask; + __entry->connector_mask = state->connector_mask; + __entry->encoder_mask = state->encoder_mask; + ), + TP_printk("crtc_id=%u crtc_state=%pK state=%pK commit=%pK changed(" + "planes=%d mode=%d active=%d conn=%d zpos=%d color_mgmt=%d) " + "state(enable=%d active=%d async_flip=%d vrr_enabled=%d " + "self_refresh_active=%d no_vblank=%d) mask(plane=%x conn=%x " + "enc=%x)", + __entry->crtc_id, __entry->crtc_state, __entry->state, + __entry->commit, __entry->planes_changed, + __entry->mode_changed, __entry->active_changed, + __entry->connectors_changed, __entry->zpos_changed, + __entry->color_mgmt_changed, __entry->enable, __entry->active, + __entry->async_flip, __entry->vrr_enabled, + __entry->self_refresh_active, __entry->no_vblank, + __entry->plane_mask, __entry->connector_mask, + __entry->encoder_mask) +); +DEFINE_EVENT(class_drm_crtc, drm_crtc_add, + TP_PROTO(unsigned int event_class, const struct drm_crtc_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_crtc, drm_crtc_check_passed, + TP_PROTO(unsigned int event_class, const struct drm_crtc_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_crtc, drm_crtc_check_failed, + TP_PROTO(unsigned int event_class, const struct drm_crtc_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_crtc, drm_crtc_check_fail_active_not_enabled, + TP_PROTO(unsigned int event_class, const struct drm_crtc_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_crtc, drm_crtc_check_fail_enable_no_mode, + TP_PROTO(unsigned int event_class, const struct drm_crtc_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_crtc, drm_crtc_check_fail_mode_no_enable, + TP_PROTO(unsigned int event_class, const struct drm_crtc_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_crtc, drm_crtc_check_fail_event_not_active, + TP_PROTO(unsigned int event_class, const struct drm_crtc_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_crtc, drm_crtc_check_fail_modeset_required, + TP_PROTO(unsigned int event_class, const struct drm_crtc_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_crtc, drm_crtc_add_affected_connectors, + TP_PROTO(unsigned int event_class, const struct drm_crtc_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_crtc, drm_crtc_add_affected_planes, + TP_PROTO(unsigned int event_class, const struct drm_crtc_state *state), + TP_ARGS(event_class, state) +); #endif /* _DRM_TRACE_H_ */ /* This part must be outside protection */ From patchwork Thu Nov 7 21:03:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 11233781 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A41DA14E5 for ; Thu, 7 Nov 2019 21:03:33 +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 874C521D79 for ; Thu, 7 Nov 2019 21:03:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 874C521D79 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 DEA7E6F7C3; Thu, 7 Nov 2019 21:03:29 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yb1-xb41.google.com (mail-yb1-xb41.google.com [IPv6:2607:f8b0:4864:20::b41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 50E5E6F7BB for ; Thu, 7 Nov 2019 21:03:27 +0000 (UTC) Received: by mail-yb1-xb41.google.com with SMTP id f6so1572369ybp.1 for ; Thu, 07 Nov 2019 13:03:27 -0800 (PST) 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=DCIetvL2sFAtzIbRkVaL/k0b03YvmcpikNtClFvRPLM=; b=nvAgitLK9YlqnELLd3yKefFXDrjU5ufaDTe565pJNrY/BNXZJ/WN3U3/E16X8bdrp1 RuWLNZwDm6I2zuCOgtx4Oe9Yd3zev4a51GFgXLEwqxlkgWQ8ftvC9L+YzP++TSwEq+v1 56mjhPjg9LyZS9yiXJ/dN8h0oefyNX07eQ6q6FEGxisPYM0v7adQyYrLf/DGSE+BEdE6 S5fWtxP4tfvPwLWr5CiAW/C5juQDpPrVLp99ufCmNWYS/9WoorPZDQDFha+bQ2HzqPgb qsZ7u+04VB2fcDMMhFJP/HdLcVxSLT1mPQXny+wP6oEvW5+Q8ptrRM2hhGuQCXce65Nv QcYw== X-Gm-Message-State: APjAAAWrKhfy0ViME1d/4Uv9qXTe4lQiF9iWidq8ThIQzKVWHPSmOFH5 dezW3stOHR9T/71PbmzMI1qgfAw5cJg= X-Google-Smtp-Source: APXvYqzsGClOS4gWyHCOwR/d6wC3TDn0ieyRvjSjGG0MN2DpJWNuTTC/7lXZHwX92hhcIyZgbbzwIQ== X-Received: by 2002:a25:da52:: with SMTP id n79mr5440792ybf.194.1573160606046; Thu, 07 Nov 2019 13:03:26 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id r14sm1064196ywl.97.2019.11.07.13.03.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2019 13:03:25 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org Subject: [PATCH 5/6] drm: trace: Add connector state tracing Date: Thu, 7 Nov 2019 16:03:04 -0500 Message-Id: <20191107210316.143216-6-sean@poorly.run> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191107210316.143216-1-sean@poorly.run> References: <20191107210316.143216-1-sean@poorly.run> MIME-Version: 1.0 X-Mailman-Original-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=DCIetvL2sFAtzIbRkVaL/k0b03YvmcpikNtClFvRPLM=; b=WIbo9UxT+TE/pXxHow/UsNMel2kT2Mjlj1no6LWtMxy76vpMgdqZU80loIZmo0rRiu 8VITLzdrA4fHf3prorYWO5T2bexABuYZSsQZAwgNPoZyvkwKHHFrtKU2G/ZEDanoBbHz F9j/jMMY54+hIPeG/3oVrpKfQifIWpKjc1kCge5WY1mMUpCroV3pr6mMaG2XmS/Ml1dq 9Gx6aqmY3iHpezfv394c6Y+ozq0Yn26EhzT0+UNVjhq2dnVmyKgqkz0umf2x21+TOxRA tWEvcG+9YQu9/76/RSbH6N3zUF0RoQPxlcXKCcdXJZRJf+syavUW2B9/W3ZaNwlFkVhH aXbg== 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: daniel.vetter@ffwll.ch, Sean Paul , tzimmermann@suse.de Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Sean Paul Add tracing which tracks important connector_state events through the atomic core. Signed-off-by: Sean Paul --- drivers/gpu/drm/drm_atomic.c | 12 ++++- drivers/gpu/drm/drm_trace.h | 101 +++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 955650729115d..5dcaf145f22ff 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -422,12 +422,15 @@ static int drm_atomic_connector_check(struct drm_connector *connector, if (connector->max_bpc_property) state->max_bpc = min(state->max_bpc, state->max_requested_bpc); - if ((connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK) || !writeback_job) + if ((connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK) || !writeback_job) { + drm_trace(connector, check_passed, state); return 0; + } if (writeback_job->fb && !state->crtc) { DRM_DEBUG_ATOMIC("[CONNECTOR:%d:%s] framebuffer without CRTC\n", connector->base.id, connector->name); + drm_trace_err(connector, check_fail_writeback_no_crtc, state); return -EINVAL; } @@ -439,6 +442,8 @@ static int drm_atomic_connector_check(struct drm_connector *connector, DRM_DEBUG_ATOMIC("[CONNECTOR:%d:%s] has framebuffer, but [CRTC:%d] is off\n", connector->base.id, connector->name, state->crtc->base.id); + drm_trace_err(connector, check_fail_writeback_not_active, + state); return -EINVAL; } @@ -446,6 +451,8 @@ static int drm_atomic_connector_check(struct drm_connector *connector, if (writeback_job->out_fence) { DRM_DEBUG_ATOMIC("[CONNECTOR:%d:%s] requesting out-fence without framebuffer\n", connector->base.id, connector->name); + drm_trace_err(connector, + check_fail_writeback_fence_no_fb, state); return -EINVAL; } @@ -453,6 +460,7 @@ static int drm_atomic_connector_check(struct drm_connector *connector, state->writeback_job = NULL; } + drm_trace(connector, check_passed, state); return 0; } @@ -996,6 +1004,7 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state, DRM_DEBUG_ATOMIC("Added [CONNECTOR:%d:%s] %p state to %p\n", connector->base.id, connector->name, connector_state, state); + drm_trace(connector, add, connector_state); if (connector_state->crtc) { struct drm_crtc_state *crtc_state; @@ -1186,6 +1195,7 @@ int drm_atomic_check_only(struct drm_atomic_state *state) if (ret) { DRM_DEBUG_ATOMIC("[CONNECTOR:%d:%s] atomic core check failed\n", conn->base.id, conn->name); + drm_trace_err(connector, check_failed, conn_state); return ret; } } diff --git a/drivers/gpu/drm/drm_trace.h b/drivers/gpu/drm/drm_trace.h index 91880f650a7b3..c610e8d8c71ce 100644 --- a/drivers/gpu/drm/drm_trace.h +++ b/drivers/gpu/drm/drm_trace.h @@ -3,7 +3,9 @@ #define _DRM_TRACE_H_ #include +#include #include +#include #include #include @@ -75,6 +77,12 @@ enum drm_trace_event_class { * the atomic core and helpers. */ drm_trace_class_crtc = BIT(3), + + /** + * @drm_trace_class_connector: This class is used to track connector + * state through the atomic core and helpers. + */ + drm_trace_class_connector = BIT(4), }; /** @@ -343,6 +351,99 @@ DEFINE_EVENT(class_drm_crtc, drm_crtc_add_affected_planes, TP_PROTO(unsigned int event_class, const struct drm_crtc_state *state), TP_ARGS(event_class, state) ); + +DECLARE_EVENT_CLASS(class_drm_connector, + TP_PROTO(unsigned int event_class, + const struct drm_connector_state *state), + TP_ARGS(event_class, state), + TP_STRUCT__entry( + __field(unsigned int, event_class) + __field(uint32_t, conn_id) + __field(const struct drm_connector_state *, conn_state) + __field(const struct drm_atomic_state *, state) + __field(const struct drm_crtc_commit *, commit) + __field(uint32_t, crtc_id) + __field(uint32_t, best_encoder_id) + __field(enum drm_link_status, link_status) + __field(bool, self_refresh_aware) + __field(enum hdmi_picture_aspect, picture_aspect_ratio) + __field(unsigned int, content_type) + __field(unsigned int, hdcp_content_type) + __field(unsigned int, content_protection) + __field(unsigned int, scaling_mode) + __field(u32, colorspace) + __field(const struct drm_writeback_job *, writeback_job) + __field(u8, max_requested_bpc) + __field(u8, max_bpc) + ), + TP_fast_assign( + __entry->event_class = event_class; + __entry->conn_id = state->connector->base.id; + __entry->conn_state = state; + __entry->state = state->state; + __entry->commit = state->commit; + __entry->crtc_id = state->crtc ? state->crtc->base.id : 0; + __entry->best_encoder_id = state->best_encoder ? + state->best_encoder->base.id : 0; + __entry->link_status = state->link_status; + __entry->self_refresh_aware = state->self_refresh_aware; + __entry->picture_aspect_ratio= state->picture_aspect_ratio; + __entry->content_type = state->content_type; + __entry->hdcp_content_type = state->hdcp_content_type; + __entry->content_protection = state->content_protection; + __entry->scaling_mode = state->scaling_mode; + __entry->colorspace = state->colorspace; + __entry->writeback_job = state->writeback_job; + __entry->max_requested_bpc = state->max_requested_bpc; + __entry->max_bpc = state->max_bpc; + ), + TP_printk("conn_id=%u conn_state=%pK state=%pK commit=%pK crtc_id=%u " + "best_encoder_id=%u link_status=%d self_refresh_aware=%d " + "picture_aspect_ratio=%d content_type=%u " + "hdcp_content_type=%u content_protection=%u scaling_mode=%u " + "colorspace=%u writeback_job=%pK max_requested_bpc=%u " + "max_bpc=%u", + __entry->conn_id, __entry->conn_state, __entry->state, + __entry->commit, __entry->crtc_id, __entry->best_encoder_id, + __entry->link_status, __entry->self_refresh_aware, + __entry->picture_aspect_ratio, __entry->content_type, + __entry->hdcp_content_type, __entry->content_protection, + __entry->scaling_mode, __entry->colorspace, + __entry->writeback_job, __entry->max_requested_bpc, + __entry->max_bpc) +); +DEFINE_EVENT(class_drm_connector, drm_connector_add, + TP_PROTO(unsigned int event_class, + const struct drm_connector_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_connector, drm_connector_check_passed, + TP_PROTO(unsigned int event_class, + const struct drm_connector_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_connector, drm_connector_check_failed, + TP_PROTO(unsigned int event_class, + const struct drm_connector_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_connector, drm_connector_check_fail_writeback_no_crtc, + TP_PROTO(unsigned int event_class, + const struct drm_connector_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_connector, drm_connector_check_fail_writeback_not_active, + TP_PROTO(unsigned int event_class, + const struct drm_connector_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_connector, + drm_connector_check_fail_writeback_fence_no_fb, + TP_PROTO(unsigned int event_class, + const struct drm_connector_state *state), + TP_ARGS(event_class, state) +); + #endif /* _DRM_TRACE_H_ */ /* This part must be outside protection */ From patchwork Thu Nov 7 21:03:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 11233783 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D834112B for ; Thu, 7 Nov 2019 21:03:35 +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 658AC21D79 for ; Thu, 7 Nov 2019 21:03:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 658AC21D79 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 4A3FC6F7C4; Thu, 7 Nov 2019 21:03:33 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yw1-xc42.google.com (mail-yw1-xc42.google.com [IPv6:2607:f8b0:4864:20::c42]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2BCC46F7C1 for ; Thu, 7 Nov 2019 21:03:29 +0000 (UTC) Received: by mail-yw1-xc42.google.com with SMTP id i2so1114564ywg.13 for ; Thu, 07 Nov 2019 13:03:29 -0800 (PST) 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=wy9BemAoYd4Z5atAYY3UWgEeloIWr7ynHkmEsWwjyOc=; b=stDcvuwwowboYAwazc9vgUgLKESjYNnB/rhozdjZ7n0nZO9jhty0W5Aqp0gPSclttk V6G/xvTjAAsF2KMQlT9OiZw993AeCIVCYABcFxscRue3FmT4cKfWGGsW5CKHsIfCozRP RfErrCLzBAYCa1rJVkEz+MEaB4yFIrUUpR/hvNt4JXUW5jvNd7NjXTMAI2BRBcr3AS6l UBhl1Loi0kC15+9R5dYv+dikW3PZODOhFer9NKZ9zXiUob+2euFsC1LQFNH4flzwoTt4 COJpq4702KEUKrDNWVpnarSTMSFR6svysErWnV8J5VVNUD2ONmJJk5PAr4iCbpC3vjux xjjQ== X-Gm-Message-State: APjAAAWAgd8DURarFLI32aib2rwKNxUZi3XQ12qWRpB8moto6kwuyti7 hYm9YC8E/PCJ/BOJDTR9AVWkifwdPmE= X-Google-Smtp-Source: APXvYqx8LwNpuoWP05gfi0XSKnuzFwI98CQRFs9Z547QIvrfwzoT1E8+hyzT2VYdo7w3TOcn3rGftQ== X-Received: by 2002:a81:8415:: with SMTP id u21mr4320479ywf.129.1573160607773; Thu, 07 Nov 2019 13:03:27 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id r14sm1064196ywl.97.2019.11.07.13.03.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2019 13:03:27 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org Subject: [PATCH 6/6] drm: trace: Add plane state tracing Date: Thu, 7 Nov 2019 16:03:05 -0500 Message-Id: <20191107210316.143216-7-sean@poorly.run> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191107210316.143216-1-sean@poorly.run> References: <20191107210316.143216-1-sean@poorly.run> MIME-Version: 1.0 X-Mailman-Original-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=wy9BemAoYd4Z5atAYY3UWgEeloIWr7ynHkmEsWwjyOc=; b=cSR+q2Bv2BymfeZYJCJ55Bx9/JZNwd6AsxMy8QnygA2oKll7w7oaYtil4Fi7/7Xdj+ BV1K+WT2uC8cyYHI/eqpErsM7Koic7k4aHV4YXJWAxpeSr7Y0oQ9kV95UkU59tHXJP9f D+5kHHA3asU9XiGOI+B/P0hST8UcL5G+iVpugJYeEUseNzYu5wq+gsDMECj5iOfPYeG+ FDU6VNm47oPky6aFmhJFuN7vBjIwI/7V9d2rMD1T75I7vbCs3P4q7RdKTOQItUnQMqCN +jmpL3uOe31DHGhiNW7d/2xpz4lmaW8UfaW6AOVnzytukb2TZeYUqbG5UF8cwhZeQqpT B0Yg== 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: daniel.vetter@ffwll.ch, Sean Paul , tzimmermann@suse.de Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Sean Paul Add tracing which tracks important plane_state events through the atomic core. Signed-off-by: Sean Paul --- drivers/gpu/drm/drm_atomic.c | 16 +++- drivers/gpu/drm/drm_trace.h | 143 +++++++++++++++++++++++++++++++++++ 2 files changed, 158 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 5dcaf145f22ff..f68240d1d9ecf 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -513,6 +513,7 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state, DRM_DEBUG_ATOMIC("Added [PLANE:%d:%s] %p state to %p\n", plane->base.id, plane->name, plane_state, state); + drm_trace(plane, add, plane_state); if (plane_state->crtc) { struct drm_crtc_state *crtc_state; @@ -570,22 +571,27 @@ static int drm_atomic_plane_check(const struct drm_plane_state *old_plane_state, if (crtc && !fb) { DRM_DEBUG_ATOMIC("[PLANE:%d:%s] CRTC set but no FB\n", plane->base.id, plane->name); + drm_trace_err(plane, check_fail_crtc_no_fb, new_plane_state); return -EINVAL; } else if (fb && !crtc) { DRM_DEBUG_ATOMIC("[PLANE:%d:%s] FB set but no CRTC\n", plane->base.id, plane->name); + drm_trace_err(plane, check_fail_fb_no_crtc, new_plane_state); return -EINVAL; } /* if disabled, we don't care about the rest of the state: */ - if (!crtc) + if (!crtc) { + drm_trace(plane, check_passed, new_plane_state); return 0; + } /* Check whether this plane is usable on this CRTC */ if (!(plane->possible_crtcs & drm_crtc_mask(crtc))) { DRM_DEBUG_ATOMIC("Invalid [CRTC:%d:%s] for [PLANE:%d:%s]\n", crtc->base.id, crtc->name, plane->base.id, plane->name); + drm_trace_err(plane, check_fail_crtc_impossible, new_plane_state); return -EINVAL; } @@ -599,6 +605,7 @@ static int drm_atomic_plane_check(const struct drm_plane_state *old_plane_state, drm_get_format_name(fb->format->format, &format_name), fb->modifier); + drm_trace_err(plane, check_fail_format, new_plane_state); return ret; } @@ -611,6 +618,7 @@ static int drm_atomic_plane_check(const struct drm_plane_state *old_plane_state, plane->base.id, plane->name, new_plane_state->crtc_w, new_plane_state->crtc_h, new_plane_state->crtc_x, new_plane_state->crtc_y); + drm_trace_err(plane, check_fail_crtc_coords, new_plane_state); return -ERANGE; } @@ -634,6 +642,7 @@ static int drm_atomic_plane_check(const struct drm_plane_state *old_plane_state, new_plane_state->src_y >> 16, ((new_plane_state->src_y & 0xffff) * 15625) >> 10, fb->width, fb->height); + drm_trace_err(plane, check_fail_src_coords, new_plane_state); return -ENOSPC; } @@ -651,6 +660,7 @@ static int drm_atomic_plane_check(const struct drm_plane_state *old_plane_state, DRM_DEBUG_ATOMIC("[PLANE:%d:%s] invalid damage clip %d %d %d %d\n", plane->base.id, plane->name, clips->x1, clips->y1, clips->x2, clips->y2); + drm_trace_err(plane, check_fail_damage_clip, new_plane_state); return -EINVAL; } clips++; @@ -660,9 +670,12 @@ static int drm_atomic_plane_check(const struct drm_plane_state *old_plane_state, if (plane_switching_crtc(old_plane_state, new_plane_state)) { DRM_DEBUG_ATOMIC("[PLANE:%d:%s] switching CRTC directly\n", plane->base.id, plane->name); + drm_trace_err(plane, check_fail_switch_old, old_plane_state); + drm_trace_err(plane, check_fail_switch_new, new_plane_state); return -EINVAL; } + drm_trace(plane, check_passed, new_plane_state); return 0; } @@ -1176,6 +1189,7 @@ int drm_atomic_check_only(struct drm_atomic_state *state) if (ret) { DRM_DEBUG_ATOMIC("[PLANE:%d:%s] atomic core check failed\n", plane->base.id, plane->name); + drm_trace_err(plane, check_failed, new_plane_state); return ret; } } diff --git a/drivers/gpu/drm/drm_trace.h b/drivers/gpu/drm/drm_trace.h index c610e8d8c71ce..7708810bbd660 100644 --- a/drivers/gpu/drm/drm_trace.h +++ b/drivers/gpu/drm/drm_trace.h @@ -6,6 +6,9 @@ #include #include #include +#include +#include +#include #include #include @@ -83,6 +86,12 @@ enum drm_trace_event_class { * state through the atomic core and helpers. */ drm_trace_class_connector = BIT(4), + + /** + * @drm_trace_class_plane: This class is used to track plane state + * through the atomic core and helpers. + */ + drm_trace_class_plane = BIT(5), }; /** @@ -444,6 +453,140 @@ DEFINE_EVENT(class_drm_connector, TP_ARGS(event_class, state) ); +DECLARE_EVENT_CLASS(class_drm_plane, + TP_PROTO(unsigned int event_class, const struct drm_plane_state *state), + TP_ARGS(event_class, state), + TP_STRUCT__entry( + __field(unsigned int, event_class) + __field(uint32_t, plane_id) + __field(const struct drm_plane_state *, plane_state) + __field(const struct drm_atomic_state *, state) + __field(const struct drm_crtc_commit *, commit) + __field(uint32_t, crtc_id) + __field(uint32_t, fb_id) + __field(uint32_t, fb_format) + __field(uint8_t, fb_planes) + __field(uint64_t, fb_modifier) + __field(const struct dma_fence *, fence) + __array(u8, crtc_coords, sizeof(struct drm_rect)) + __array(u8, src_coords, sizeof(struct drm_rect)) + __field(u32, alpha) + __field(uint32_t, pixel_blend_mode) + __field(unsigned int, rotation) + __field(unsigned int, zpos) + __field(unsigned int, normalized_zpos) + __field(enum drm_color_encoding, color_encoding) + __field(enum drm_color_range, color_range) + __field(bool, visible) + __array(u8, src, sizeof(struct drm_rect)) + __array(u8, dst, sizeof(struct drm_rect)) + ), + TP_fast_assign( + __entry->event_class = event_class; + __entry->plane_id = state->plane->base.id; + __entry->plane_state = state; + __entry->state = state->state; + __entry->commit = state->commit; + __entry->crtc_id = state->crtc ? state->crtc->base.id : 0; + __entry->fb_id = state->fb ? state->fb->base.id : 0; + __entry->fb_format = state->fb ? state->fb->format->format : + 'E' << 24 | 'O' << 16 | + 'N' << 8 | 'N'; + __entry->fb_planes = state->fb ? state->fb->format->num_planes : + 0; + __entry->fb_modifier = state->fb ? state->fb->modifier : 0; + __entry->fence = state->fence; + ((struct drm_rect *)__entry->crtc_coords)->x1 = state->crtc_x; + ((struct drm_rect *)__entry->crtc_coords)->y1 = state->crtc_y; + ((struct drm_rect *)__entry->crtc_coords)->x1 = state->crtc_w; + ((struct drm_rect *)__entry->crtc_coords)->y2 = state->crtc_h; + ((struct drm_rect *)__entry->src_coords)->x1 = state->src_x; + ((struct drm_rect *)__entry->src_coords)->y1 = state->src_y; + ((struct drm_rect *)__entry->src_coords)->x1 = state->src_w; + ((struct drm_rect *)__entry->src_coords)->y2 = state->src_h; + __entry->alpha = state->alpha; + __entry->pixel_blend_mode = state->pixel_blend_mode; + __entry->rotation = state->rotation; + __entry->zpos = state->zpos; + __entry->normalized_zpos = state->normalized_zpos; + __entry->color_encoding = state->color_encoding; + __entry->color_range = state->color_range; + __entry->visible = state->visible; + memcpy(__entry->src, &state->src, sizeof(__entry->src)); + memcpy(__entry->dst, &state->dst, sizeof(__entry->dst)); + ), + TP_printk("plane_id=%u plane_state=%pK state=%pK commit=%pK crtc_id=%u " + "fb(id=%u fmt=%c%c%c%c planes=%u mod=%llu) fence=%pK crtc(" + DRM_RECT_FMT") src("DRM_RECT_FP_FMT") alpha=%u " + "pixel_blend_mode=%u rotation=%u zpos=%u " + "normalized_zpos=%u color_encoding=%d color_range=%d " + "visible=%d src_rect("DRM_RECT_FP_FMT") dst_rect(" + DRM_RECT_FMT")", + __entry->plane_id, __entry->plane_state, __entry->state, + __entry->commit, __entry->crtc_id, __entry->fb_id, + __entry->fb_format & 0xff, + (__entry->fb_format >> 8) & 0xff, + (__entry->fb_format >> 16) & 0xff, + (__entry->fb_format >> 24) & 0x7f, __entry->fb_planes, + __entry->fb_modifier, __entry->fence, + DRM_RECT_ARG((const struct drm_rect *)__entry->crtc_coords), + DRM_RECT_FP_ARG((const struct drm_rect *)__entry->src_coords), + __entry->alpha, __entry->pixel_blend_mode, __entry->rotation, + __entry->zpos, __entry->normalized_zpos, + __entry->color_encoding, __entry->color_range, + __entry->visible, + DRM_RECT_FP_ARG((const struct drm_rect *)__entry->src), + DRM_RECT_ARG((const struct drm_rect *)__entry->dst)) +); +DEFINE_EVENT(class_drm_plane, drm_plane_add, + TP_PROTO(unsigned int event_class, const struct drm_plane_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_plane, drm_plane_check_fail_crtc_no_fb, + TP_PROTO(unsigned int event_class, const struct drm_plane_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_plane, drm_plane_check_fail_fb_no_crtc, + TP_PROTO(unsigned int event_class, const struct drm_plane_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_plane, drm_plane_check_fail_crtc_impossible, + TP_PROTO(unsigned int event_class, const struct drm_plane_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_plane, drm_plane_check_fail_format, + TP_PROTO(unsigned int event_class, const struct drm_plane_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_plane, drm_plane_check_fail_crtc_coords, + TP_PROTO(unsigned int event_class, const struct drm_plane_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_plane, drm_plane_check_fail_src_coords, + TP_PROTO(unsigned int event_class, const struct drm_plane_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_plane, drm_plane_check_fail_damage_clip, + TP_PROTO(unsigned int event_class, const struct drm_plane_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_plane, drm_plane_check_fail_switch_old, + TP_PROTO(unsigned int event_class, const struct drm_plane_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_plane, drm_plane_check_fail_switch_new, + TP_PROTO(unsigned int event_class, const struct drm_plane_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_plane, drm_plane_check_failed, + TP_PROTO(unsigned int event_class, const struct drm_plane_state *state), + TP_ARGS(event_class, state) +); +DEFINE_EVENT(class_drm_plane, drm_plane_check_passed, + TP_PROTO(unsigned int event_class, const struct drm_plane_state *state), + TP_ARGS(event_class, state) +); + #endif /* _DRM_TRACE_H_ */ /* This part must be outside protection */