From patchwork Wed Jun 1 22:06:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 9148555 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 7EC5460467 for ; Wed, 1 Jun 2016 22:08:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71EA12040D for ; Wed, 1 Jun 2016 22:08:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 66DB2265F9; Wed, 1 Jun 2016 22:08:36 +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_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 240D92040D for ; Wed, 1 Jun 2016 22:08:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 08D866EAC4; Wed, 1 Jun 2016 22:08:00 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 603FC6EAB0 for ; Wed, 1 Jun 2016 22:07:52 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id e3so10583841wme.2 for ; Wed, 01 Jun 2016 15:07:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7+wugVSCTPYMqX/kbDKVF1sy+7vATgW0FGnqrbl0vqo=; b=DaNiUDD/E7JeOj4b5RWbyFMzARHV3USAcy/Q+KSC2J1j74VNXLCqw7pOaeOXBoxl3b tBJLj7cmgnaEcV57japyJUuO5oN3YEk325iCFsMeK3RExQYfA8CE7XHPtBaG0xoJ/wyB iDbtIZ6BYPkzg9Urgz/sfyvm3y/EMmypKf58Y= 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=7+wugVSCTPYMqX/kbDKVF1sy+7vATgW0FGnqrbl0vqo=; b=PKUzzq2s7KxLby/1mjwJl496d3ZA0lEEqfzrPrpXj8C9wBzBhusNo6G2j1PZmKrH4M lFrdriqjqfypv+HzZ6jckRjjj0btIgboIUHWS/iUf/z0la2ltoCfYlMUwdcEQI7oQvmc hwl7rukO39txtKNL7rfSeexuV/ldNkQqw1WB9AEoo7S8KrTpjIrn2GgeWYfj87Dgd1jF 1vpP7PQNPMCCGppIcmlGLg4qNxxKMylfnwbSroXG6CzD18JgSRAU1jNYgSVzhaeLGvuh 50n56H9ezMGN2wwZsQ6PJnECeuOfB/e6nc1A+uyoNi01+kqakt17mrrg0Jk9cwfkSvDI 9Tzg== X-Gm-Message-State: ALyK8tLslax5doOFb0TUMQCpmvhjGw8YaDyFE3Eomj6pO/rEyu8hFEX2GRytqzPbo1x+xA== X-Received: by 10.28.48.17 with SMTP id w17mr23343004wmw.33.1464818870298; Wed, 01 Jun 2016 15:07:50 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:56b5:0:ac27:b86c:7764:9429]) by smtp.gmail.com with ESMTPSA id lf7sm1571508wjb.23.2016.06.01.15.07.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Jun 2016 15:07:48 -0700 (PDT) From: Daniel Vetter To: DRI Development Date: Thu, 2 Jun 2016 00:06:54 +0200 Message-Id: <1464818821-5736-32-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1464818821-5736-1-git-send-email-daniel.vetter@ffwll.ch> References: <1464818821-5736-1-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Vetter , Daniel Vetter , Intel Graphics Development , Tomeu Vizoso , Mark yao Subject: [Intel-gfx] [PATCH 31/38] drm/rockchip: Fix crtc_state->event signalling X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP It's not permissible to look at plane->state from interrupt context, since doing that would need the irq handler to acquire the plane->mutex lock. The other problem is that if we pipeline updates using the new nonblocking atomic helpers new state gets commit before the irq handler fires, resulting in a lost event. Fix both issues by caching the necessary values in vop_win, protected by dev->event_lock. Cc: Tomeu Vizoso Cc: Mark yao Tested-by: Tomeu Vizoso Reviewed-by: Tomeu Vizoso Signed-off-by: Daniel Vetter --- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index 957a6b4917c8..94eaeec29b6b 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -98,7 +98,9 @@ struct vop_win { const struct vop_win_data *data; struct vop *vop; - struct vop_plane_state state; + /* protected by dev->event_lock */ + bool enable; + dma_addr_t yrgb_mst; }; struct vop { @@ -112,6 +114,8 @@ struct vop { bool vsync_work_pending; struct completion dsp_hold_completion; struct completion wait_update_complete; + + /* protected by dev->event_lock */ struct drm_pending_vblank_event *event; const struct vop_data *data; @@ -652,6 +656,11 @@ static void vop_plane_atomic_disable(struct drm_plane *plane, if (!old_state->crtc) return; + spin_lock_irq(&plane->dev->event_lock); + vop_win->enable = false; + vop_win->yrgb_mst = 0; + spin_unlock_irq(&plane->dev->event_lock); + spin_lock(&vop->reg_lock); VOP_WIN_SET(vop, win, enable, 0); @@ -686,7 +695,7 @@ static void vop_plane_atomic_update(struct drm_plane *plane, /* * can't update plane when vop is disabled. */ - if (!crtc) + if (WARN_ON(!crtc)) return; if (WARN_ON(!vop->is_enabled)) @@ -715,6 +724,11 @@ static void vop_plane_atomic_update(struct drm_plane *plane, offset += (src->y1 >> 16) * fb->pitches[0]; vop_plane_state->yrgb_mst = rk_obj->dma_addr + offset + fb->offsets[0]; + spin_lock_irq(&plane->dev->event_lock); + vop_win->enable = true; + vop_win->yrgb_mst = vop_plane_state->yrgb_mst; + spin_unlock_irq(&plane->dev->event_lock); + spin_lock(&vop->reg_lock); VOP_WIN_SET(vop, win, format, vop_plane_state->format); @@ -1074,16 +1088,14 @@ static const struct drm_crtc_funcs vop_crtc_funcs = { static bool vop_win_pending_is_complete(struct vop_win *vop_win) { - struct drm_plane *plane = &vop_win->base; - struct vop_plane_state *state = to_vop_plane_state(plane->state); dma_addr_t yrgb_mst; - if (!state->enable) + if (!vop_win->enable) return VOP_WIN_GET(vop_win->vop, vop_win->data, enable) == 0; yrgb_mst = VOP_WIN_GET_YRGBADDR(vop_win->vop, vop_win->data); - return yrgb_mst == state->yrgb_mst; + return yrgb_mst == vop_win->yrgb_mst; } static void vop_handle_vblank(struct vop *vop)