From patchwork Mon Dec 18 14:57:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 122224 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2936646qgn; Mon, 18 Dec 2017 06:58:42 -0800 (PST) X-Google-Smtp-Source: ACJfBovCFMMdXKTBYZ9Oi1LZwjRo9x89tDtWruNbfmVAbdXgBUWjOMr2cix1BTipDe1Xtb/26dTD X-Received: by 10.159.234.68 with SMTP id c4mr102266plr.305.1513609122051; Mon, 18 Dec 2017 06:58:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513609122; cv=none; d=google.com; s=arc-20160816; b=ia4JUEomex6sex9AzbipViCIroJgJFRu9c1YFDfgM/RRnlF31LliuDWcAekV5W/dK0 uolhCekXZhZnF9wp1rBkCzeDoMv5u5tFMBENVbBpLrqIXh3ItIeX/D9HBMOMpOGMzy2x fxav4kL8NiEWM4GIvuCBk16bNPTysv2Hcxid8WTb+hHGg/lngrMyJrWjZRqGfiPaL2D2 xv22ONe8FVW8utltI1uT7zcwxnbyNZD5xY+decxFvUWf8tRGLCvL9U6KTiTkkKktYEVx rbPYt/pd9iZsxKwOIwQSagP3WddTeNRj0prFiVSM0ftrYdTjdRULR6JJjpLBe6wEbajO 4U9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:cc:references:in-reply-to:references:in-reply-to :message-id:date:subject:to:from:delivered-to :arc-authentication-results; bh=48fPzZ4q1RPLrpWgN8vdtl2yjP4dKZX/BBwz54a8ghc=; b=B51/qpwPkikTkIT6U5jhJ0fJik8Uyj+yomBdNtVgTGC7NArhjsZwJLk69A6839DtEN D2ITZMBJR1oNd06gfuiAKwCotPY4DgL0NVixdvLGIgD8w58McLCPggpATPwOhZ5uuAdX XcImbeF3ww0MJcu6btH5+UCmeQNERC54faLzsY2rqzUpv4QzknTxG0RyJ/sKB0bqJpC2 QD7PPx0RK/53/tVPqYa2rXLT65icOsxVrJZHCP1qPV5etGOazdRVtRE5Fub/wgMaGhCR 4hv30ePCiwWR31RQs4A0YDI126fqJatrpIAz5gAZS676MyuPsLdlICWuwe1zTkDiEOio E91Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id r76si9595001pfl.194.2017.12.18.06.58.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 06:58:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) 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 882E96E1C5; Mon, 18 Dec 2017 14:58:10 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by gabe.freedesktop.org (Postfix) with ESMTP id 10D0A89C0A for ; Mon, 18 Dec 2017 14:58:08 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 1CE0A207C8; Mon, 18 Dec 2017 15:58:07 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id E92A020378; Mon, 18 Dec 2017 15:58:06 +0100 (CET) From: Maxime Ripard To: Daniel Vetter , David Airlie , Chen-Yu Tsai , Maxime Ripard Subject: [PATCH v2 11/12] drm/sun4i: backend: Make sure we don't have a commit pending Date: Mon, 18 Dec 2017 15:57:58 +0100 Message-Id: X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: Thomas Petazzoni , narmstrong@baylibre.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, thomas@vitsch.nl 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" If we try to read the backend registers while it fetches the new values, we end up with the value of some random register instead of the one we asked for. In order to prevent that, let's make sure that the very first thing we do during our atomic modesetting is to let the commit bit come to a rest. We don't have to worry about anything else since the only time we will trigger a new transaction is during the atomic_commit which comes much later. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun4i_backend.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c index 4642f933765e..a18c86a15748 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.c +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c @@ -297,6 +297,17 @@ static bool sun4i_backend_plane_uses_frontend(struct drm_plane_state *state) return sun4i_backend_plane_uses_scaler(state); } +static void sun4i_backend_atomic_begin(struct sunxi_engine *engine, + struct drm_crtc_state *old_state) +{ + u32 val; + + WARN_ON(regmap_read_poll_timeout(engine->regs, + SUN4I_BACKEND_REGBUFFCTL_REG, + val, !(val & SUN4I_BACKEND_REGBUFFCTL_LOADCTL), + 100, 50000)); +} + static int sun4i_backend_atomic_check(struct sunxi_engine *engine, struct drm_crtc_state *crtc_state) { @@ -478,6 +489,7 @@ static struct sun4i_frontend *sun4i_backend_find_frontend(struct sun4i_drv *drv, } static const struct sunxi_engine_ops sun4i_backend_engine_ops = { + .atomic_begin = sun4i_backend_atomic_begin, .atomic_check = sun4i_backend_atomic_check, .commit = sun4i_backend_commit, .layers_init = sun4i_layers_init,