From patchwork Tue Jan 9 10:09:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 123859 Delivered-To: patch@linaro.org Received: by 10.80.140.226 with SMTP id r31csp267349edr; Tue, 9 Jan 2018 02:10:51 -0800 (PST) X-Google-Smtp-Source: ACJfBoupVXcUAhvTWk3IZExYnW2TONNoLgTWC1i6S+n7iuXqlqCKSEdBDtaSqOKPI4Q4uUUdGq9v X-Received: by 10.101.72.197 with SMTP id o5mr11508010pgs.298.1515492651646; Tue, 09 Jan 2018 02:10:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515492651; cv=none; d=google.com; s=arc-20160816; b=mRPL4a2VWmgqG3chPFvVME3HLCod03FUBmvrvLak9gaCo+9bOpd8almcwMQpWbNzjv U6YnbrlnAYyCE7bG0gBMQ2ijnauulZq4xgD7dDoqRg/K6xZktJHJg2s2cL6SrnxbT1xV a1nTpCTVlpvPPQJ5gDMF7fD0xqgvkWn/HqPeQsl2RAKay+hm78X+gyYNC2Oy4mzCe3rD Ath1Rr32zeSgp6yZV18+5RTtrQwCbDg6C5u9Jf3le3XjgSDKBSTRM9CPz/9G7yNfFZWC YpdssbbzaGclZ4jEC1WPqDiaR0BRS2ILVRgoaeGOfhDXnpqTbHqpqjrVH1jw2oOvjBlx zxRA== 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=eYW1TjwACjzGNZw3RvrhCcaurHTkQKj5If59dS6xaMU=; b=C6idu8RDt1p12Fzr2yIa8MgKs4UmZc1e0U5yIcWc7PUR35XpaYcxrATD9/kMEO/NZS x5c+Rm7d46MysTl418t8mh/JA4QcEuvGcWnaxx4Ok3Du2OfIURuoearOHpCrc14DRlTW FnyhMXF4URhj2m+LT2Ih+SP45XQ0xQdGJNf0KOypDXGpVE4zajtLk9CB7WskrXPzjqIb 0aceUSP+bHjWMN6yUr+2esKijRRQv4tcf7RHcIRdVa8TLZuKaTlj35XY4uBt4AIs1Jll K7co5O1PekP0WfAkvxoRdgdldi5NTfS7da/O5vpqDDNMe17uH2/jkR9IvLGz3uNQ0hCE VQ2A== 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 u126si8778734pgc.385.2018.01.09.02.10.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jan 2018 02:10:51 -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 356CA6E6F8; Tue, 9 Jan 2018 10:09:53 +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 7220A6E6E9 for ; Tue, 9 Jan 2018 10:09:51 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id C4FB42072D; Tue, 9 Jan 2018 11:09:49 +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 E8B68207B4; Tue, 9 Jan 2018 11:09:32 +0100 (CET) From: Maxime Ripard To: Daniel Vetter , David Airlie , Chen-Yu Tsai , Maxime Ripard Subject: [PATCH v3 12/13] drm/sun4i: backend: Make sure we don't have a commit pending Date: Tue, 9 Jan 2018 11:09:25 +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. Reviewed-by: Chen-Yu Tsai 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,