From patchwork Fri Oct 14 23:55:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 9377645 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ADC2060779 for ; Fri, 14 Oct 2016 23:56:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A34628A0B for ; Fri, 14 Oct 2016 23:56:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F2C828B3D; Fri, 14 Oct 2016 23:56:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 25D8828A0B for ; Fri, 14 Oct 2016 23:56:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 54D976ED4C; Fri, 14 Oct 2016 23:56:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-x242.google.com (mail-qk0-x242.google.com [IPv6:2607:f8b0:400d:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8E9406ED4B; Fri, 14 Oct 2016 23:56:12 +0000 (UTC) Received: by mail-qk0-x242.google.com with SMTP id n189so9621294qke.1; Fri, 14 Oct 2016 16:56:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=v83um7KP7mmo2922ftza1ehiLAju1RLYmMR8/qEobnI=; b=R36/odIUfVMhxsnLdoME9QmAb63JG+yYIB1riwBh8Pa+u8HPh1XO+2wYBs4FqpddER /ZnNHj6Djoa8czzRP7IsDtADHlpzHamm7g4UXmBOJ4QlCaLmE63UwGKLEV8vtk49diuY 76etlMLkDgic7HkMHpHjB58prrDn9wFKsNlfiWLo7R9kCG/Aob5/Q6eTz742WR1NZoYB P+8Gp9PbmO3qAuF5IOzc158DVx3jyHiTfgmzoWhrvwNmX5tlQ4JQBoKHqQQLBkan4W/S Jhs7RGS7iccUBdA33dUkhKX+dvvUgIen0t4g81xInNQiuxL/duJzhLrqAvHJYokGztSU xqvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=v83um7KP7mmo2922ftza1ehiLAju1RLYmMR8/qEobnI=; b=AEtDsESEEyadQk0G81zDEKJaUtrypCDfuuXh06T3ajQIy8vCJIfKz1aC8pyms43fcJ ofkcLGcC4A8SMXEe2d8Uk2QyYoj4WRZpEqYp3zdGgv1XH8f/rkw1ZvUADhQ8oUkGUNDL b3xZeaKB1Ziztb8uG4c+9o8W0YS5FriD6dWHVzvm3z8bZRXUcook4HyYxoIWe+psOCu3 smCfM+xJLxcxtqJGCkhfBF4Kv6HOPehjjdtrJE3G9PRm05ZRsUdnozXg98TWg0Cw11Yf n+AdMEkZh1KeE0S+7oaomIQv1oFj2SHMLQSKG+NLw2FBje/YLRXCqTu5ssFLEIdQ3US/ eE7g== X-Gm-Message-State: AA6/9Rk0WXr7LfgDurN580Cb25KntmcZRbot08Fc7qtvLnNBSeAtz/FWHKDx2KdTKOwENw== X-Received: by 10.55.96.7 with SMTP id u7mr16861119qkb.189.1476489371408; Fri, 14 Oct 2016 16:56:11 -0700 (PDT) Received: from localhost ([2601:184:4002:8340:4bc4:6936:53db:a239]) by smtp.gmail.com with ESMTPSA id w29sm8805137qtc.27.2016.10.14.16.56.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Oct 2016 16:56:11 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/6] drm/atomic: add new drm_debug bit to dump atomic state before commit Date: Fri, 14 Oct 2016 19:55:51 -0400 Message-Id: <1476489353-16261-5-git-send-email-robdclark@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476489353-16261-1-git-send-email-robdclark@gmail.com> References: <1476489353-16261-1-git-send-email-robdclark@gmail.com> Cc: freedreno@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Rob Clark --- drivers/gpu/drm/drm_atomic.c | 93 ++++++++++++++++++++++++++++++++++++++++++++ include/drm/drmP.h | 1 + include/drm/drm_crtc.h | 37 ++++++++++++++++++ 3 files changed, 131 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 7ebf375..3cc3cb5 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "drm_crtc_internal.h" @@ -608,6 +609,28 @@ static int drm_atomic_crtc_check(struct drm_crtc *crtc, return 0; } +static void drm_atomic_crtc_print_state(struct drm_print *p, + const struct drm_crtc_state *state) +{ + struct drm_crtc *crtc = state->crtc; + + drm_printf(p, "crtc[%u]: %s\n", crtc->base.id, crtc->name); + drm_printf(p, "\tenable=%d\n", state->enable); + drm_printf(p, "\tactive=%d\n", state->active); + drm_printf(p, "\tplanes_changed=%d\n", state->planes_changed); + drm_printf(p, "\tmode_changed=%d\n", state->mode_changed); + drm_printf(p, "\tactive_changed=%d\n", state->active_changed); + drm_printf(p, "\tconnectors_changed=%d\n", state->connectors_changed); + drm_printf(p, "\tcolor_mgmt_changed=%d\n", state->color_mgmt_changed); + drm_printf(p, "\tplane_mask=%x\n", state->plane_mask); + drm_printf(p, "\tconnector_mask=%x\n", state->connector_mask); + drm_printf(p, "\tencoder_mask=%x\n", state->encoder_mask); + drm_printf(p, "\tmode: " DRM_MODE_FMT "\n", DRM_MODE_ARG(&state->mode)); + + if (crtc->funcs->atomic_print_state) + crtc->funcs->atomic_print_state(p, state); +} + /** * drm_atomic_get_plane_state - get plane state * @state: global atomic state object @@ -895,6 +918,38 @@ static int drm_atomic_plane_check(struct drm_plane *plane, return 0; } +static void drm_atomic_plane_print_state(struct drm_print *p, + const struct drm_plane_state *state) +{ + struct drm_plane *plane = state->plane; + struct drm_rect src = drm_plane_state_src(state); + struct drm_rect dest = drm_plane_state_dest(state); + + drm_printf(p, "plane[%u]: %s\n", plane->base.id, plane->name); + drm_printf(p, "\tcrtc=%s\n", state->crtc ? state->crtc->name : "(null)"); + drm_printf(p, "\tfb=%u\n", state->fb ? state->fb->base.id : 0); + if (state->fb) { + struct drm_framebuffer *fb = state->fb; + int i, n = drm_format_num_planes(fb->pixel_format); + + drm_printf(p, "\t\tformat=%s\n", + drm_get_format_name(fb->pixel_format)); + drm_printf(p, "\t\tsize=%dx%d\n", fb->width, fb->height); + drm_printf(p, "\t\tlayers:\n"); + for (i = 0; i < n; i++) { + drm_printf(p, "\t\t\tpitch[%d]=%u\n", i, fb->pitches[i]); + drm_printf(p, "\t\t\toffset[%d]=%u\n", i, fb->offsets[i]); + drm_printf(p, "\t\t\tmodifier[%d]=0x%llx\n", i, fb->modifier[i]); + } + } + drm_printf(p, "\tcrtc-pos=" DRM_RECT_FMT "\n", DRM_RECT_ARG(&dest)); + drm_printf(p, "\tsrc-pos=" DRM_RECT_FP_FMT "\n", DRM_RECT_FP_ARG(&src)); + drm_printf(p, "\trotation=%x\n", state->rotation); + + if (plane->funcs->atomic_print_state) + plane->funcs->atomic_print_state(p, state); +} + /** * drm_atomic_get_connector_state - get connector state * @state: global atomic state object @@ -1010,6 +1065,18 @@ int drm_atomic_connector_set_property(struct drm_connector *connector, } EXPORT_SYMBOL(drm_atomic_connector_set_property); +static void drm_atomic_connector_print_state(struct drm_print *p, + const struct drm_connector_state *state) +{ + struct drm_connector *connector = state->connector; + + drm_printf(p, "connector[%u]: %s\n", connector->base.id, connector->name); + drm_printf(p, "\tcrtc=%s\n", state->crtc ? state->crtc->name : "(null)"); + + if (connector->funcs->atomic_print_state) + connector->funcs->atomic_print_state(p, state); +} + /** * drm_atomic_connector_get_property - get property value from connector state * @connector: the drm connector to set a property on @@ -1475,6 +1542,29 @@ int drm_atomic_nonblocking_commit(struct drm_atomic_state *state) } EXPORT_SYMBOL(drm_atomic_nonblocking_commit); +static void drm_atomic_print_state(const struct drm_atomic_state *state) +{ + struct drm_print p = drm_print_info(); + struct drm_plane *plane; + struct drm_plane_state *plane_state; + struct drm_crtc *crtc; + struct drm_crtc_state *crtc_state; + struct drm_connector *connector; + struct drm_connector_state *connector_state; + int i; + + DRM_DEBUG_ATOMIC("checking %p\n", state); + + for_each_plane_in_state(state, plane, plane_state, i) + drm_atomic_plane_print_state(&p, plane_state); + + for_each_crtc_in_state(state, crtc, crtc_state, i) + drm_atomic_crtc_print_state(&p, crtc_state); + + for_each_connector_in_state(state, connector, connector_state, i) + drm_atomic_connector_print_state(&p, connector_state); +} + /* * The big monstor ioctl */ @@ -1987,6 +2077,9 @@ retry: */ ret = drm_atomic_check_only(state); } else { + if (unlikely(drm_debug & DRM_UT_STATE)) + drm_atomic_print_state(state); + if (arg->flags & DRM_MODE_ATOMIC_OUT_FENCE) install_out_fence(state, arg->count_out_fences, fence_state); diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 7ffaa35..642d5da 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -133,6 +133,7 @@ struct dma_buf_attachment; #define DRM_UT_PRIME 0x08 #define DRM_UT_ATOMIC 0x10 #define DRM_UT_VBL 0x20 +#define DRM_UT_STATE 0x40 extern __printf(2, 3) void drm_ut_debug_printk(const char *function_name, diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 856fdf8..d74d47a 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -44,6 +44,7 @@ struct drm_framebuffer; struct drm_object_properties; struct drm_file; struct drm_clip_rect; +struct drm_print; struct device_node; struct fence; struct edid; @@ -707,6 +708,18 @@ struct drm_crtc_funcs { const struct drm_crtc_state *state, struct drm_property *property, uint64_t *val); + + /** + * @atomic_print_state: + * + * If driver subclasses struct &drm_crtc_state, it should implement + * this optional hook for printing state. + * + * Do not call this directly, use drm_atomic_crtc_print_state() + * instead. + */ + void (*atomic_print_state)(struct drm_print *p, + const struct drm_crtc_state *state); }; /** @@ -1132,6 +1145,18 @@ struct drm_connector_funcs { const struct drm_connector_state *state, struct drm_property *property, uint64_t *val); + + /** + * @atomic_print_state: + * + * If driver subclasses struct &drm_connector_state, it should + * implement this optional hook for printing state. + * + * Do not call this directly, use drm_atomic_connector_print_state() + * instead. + */ + void (*atomic_print_state)(struct drm_print *p, + const struct drm_connector_state *state); }; /** @@ -1623,6 +1648,18 @@ struct drm_plane_funcs { const struct drm_plane_state *state, struct drm_property *property, uint64_t *val); + + /** + * @atomic_print_state: + * + * If driver subclasses struct &drm_plane_state, it should implement + * this optional hook for printing state. + * + * Do not call this directly, use drm_atomic_plane_print_state() + * instead. + */ + void (*atomic_print_state)(struct drm_print *p, + const struct drm_plane_state *state); }; enum drm_plane_type {