From patchwork Thu Jul 20 13:01:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 9854927 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 B5DF4600F5 for ; Thu, 20 Jul 2017 13:01:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A75342878E for ; Thu, 20 Jul 2017 13:01:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BCEF28787; Thu, 20 Jul 2017 13:01:42 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32C1928787 for ; Thu, 20 Jul 2017 13:01:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935413AbdGTNBl (ORCPT ); Thu, 20 Jul 2017 09:01:41 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:40434 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935432AbdGTNBY (ORCPT ); Thu, 20 Jul 2017 09:01:24 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id 6636720868; Thu, 20 Jul 2017 15:01:21 +0200 (CEST) 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 42ADF20823; Thu, 20 Jul 2017 15:01:21 +0200 (CEST) From: Maxime Ripard To: Daniel Vetter , David Airlie , Jani Nikula , Sean Paul , Inki Dae , Joonyoung Shim , Seung-Woo Kim , Kyungmin Park , Kukjin Kim , Krzysztof Kozlowski , Laurent Pinchart , Mark Yao , Heiko Stuebner , Chen-Yu Tsai , Maxime Ripard Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-rockchip@lists.infradead.org Subject: [PATCH v2 4/4] drm/sun4i: make sure we don't have a commit pending Date: Thu, 20 Jul 2017 15:01:19 +0200 Message-Id: <8763c55f9d77b270b3e6ae8a812c16fe79b5874c.1500555652.git-series.maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the earlier display engine designs, any register access while a commit is pending is forbidden. One of the symptoms is that reading a register will return another, random, register value which can lead to register corruptions if we ever do a read/modify/write cycle. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun4i_backend.c | 14 ++++++++++++++ drivers/gpu/drm/sun4i/sun4i_crtc.c | 1 + 2 files changed, 15 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c index cf480218daa5..ce1f40f7511e 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.c +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c @@ -67,6 +67,19 @@ static void sun4i_backend_commit(struct sunxi_engine *engine) SUN4I_BACKEND_REGBUFFCTL_LOADCTL); } +static int sun4i_backend_commit_poll(struct sunxi_engine *engine) +{ + u32 val; + + DRM_DEBUG_DRIVER("Polling for the commit to end\n"); + + return regmap_read_poll_timeout(engine->regs, + SUN4I_BACKEND_REGBUFFCTL_REG, + val, + !(val & SUN4I_BACKEND_REGBUFFCTL_LOADCTL), + 100, 50000); +} + void sun4i_backend_layer_enable(struct sun4i_backend *backend, int layer, bool enable) { @@ -330,6 +343,7 @@ static int sun4i_backend_of_get_id(struct device_node *node) static const struct sunxi_engine_ops sun4i_backend_engine_ops = { .commit = sun4i_backend_commit, + .commit_poll = sun4i_backend_commit_poll, .layers_init = sun4i_layers_init, .apply_color_correction = sun4i_backend_apply_color_correction, .disable_color_correction = sun4i_backend_disable_color_correction, diff --git a/drivers/gpu/drm/sun4i/sun4i_crtc.c b/drivers/gpu/drm/sun4i/sun4i_crtc.c index 2eba1d8639d8..31550493fa1d 100644 --- a/drivers/gpu/drm/sun4i/sun4i_crtc.c +++ b/drivers/gpu/drm/sun4i/sun4i_crtc.c @@ -34,6 +34,7 @@ static void sun4i_crtc_atomic_begin(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { struct sun4i_crtc *scrtc = drm_crtc_to_sun4i_crtc(crtc); + struct sunxi_engine *engine = scrtc->engine; struct drm_device *dev = crtc->dev; unsigned long flags;