From patchwork Tue Mar 22 15:08:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 8643611 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1E02F9F294 for ; Tue, 22 Mar 2016 15:08:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 468C9201F5 for ; Tue, 22 Mar 2016 15:08:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 81A81202FE for ; Tue, 22 Mar 2016 15:08:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E49296E7BD; Tue, 22 Mar 2016 15:08:18 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@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 8F75F6E7BD for ; Tue, 22 Mar 2016 15:08:16 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id l68so30379398wml.3 for ; Tue, 22 Mar 2016 08:08:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=if621pHzzV1ibMpSu/Il6JVM0jTKrSmcaz0DuLTcPPU=; b=SeAcBF19gvBq+lh0AJ0IQsGq6x1vBMPrD3rCPeH2/6ybure1v4BKB/gnIJS2dKJ09k MgRA2/WWKI+lGVe+/qogjIM/dtS1sV+RYmQ6OP8/eZDoolEFTWF0wb8JLjZL1mh5YmuJ UgeLKlreal+pfO05/2DNdIGehesMdv5NEGmqpC6w7qw46di38e+yI1n7AttzxABykIUu JmxECY+2GuiNXt5DDC7oVrM51Zx9oNa0ROeSLZllMqyzzYbkMQP/o7LtNTfVu+E81d9V Qad3FxJAtHxXrFCM/VsqTfsbGgtW3TyS4Vg/RS5yjJmnNk3VcqonPbKfPq37d9zvIgr5 SBiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=if621pHzzV1ibMpSu/Il6JVM0jTKrSmcaz0DuLTcPPU=; b=aYCjRgfdVlo/Sa7wH69dFWPGQkM0VZrW55ZXRSh093/FFFlK1foGf8i9OE9IYpwYg+ F+SvG/hA4+r1OgIq1vlHDLHpjQCLgCfIpMxSrxlgp2W1ylVoCFGRyqtxfM9QtPnCXlQ3 5QnMwndNhv8d1/kVbBTkafZu/JHltN3GNp0cHuYzAPbTYKfvGw+7BUWzplUIuCYVtVC/ yLJ8VCMxQ6YOPMbtcr6tM74PjENF7v+WWA+leJceU6GTk2wE9S1bbljiFeyFM1SZJ1az TV7ZSncCUNybQ0ArANVRZwzuutYL/WLZ4O+SGj4mQbg9ZKtyv2MLXE4Gn2dgm2YGl/5w 5rsg== X-Gm-Message-State: AD7BkJL4h49+XC1UXMQ8jhXgxzwCx/rD1FlHErPyehNaVvuIEzsqajAyO9Jb4GEHAyqwjg== X-Received: by 10.28.88.81 with SMTP id m78mr21470471wmb.58.1458659294532; Tue, 22 Mar 2016 08:08:14 -0700 (PDT) Received: from cizrna.lan ([109.72.12.28]) by smtp.gmail.com with ESMTPSA id t7sm30728473wjf.39.2016.03.22.08.08.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Mar 2016 08:08:13 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Subject: [PATCH v2] drm/rockchip: vop: Disable planes when disabling CRTC Date: Tue, 22 Mar 2016 16:08:04 +0100 Message-Id: <1458659284-14039-1-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.5.0 Cc: Tomeu Vizoso , dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When a VOP is re-enabled, it will start scanning right away the framebuffers that were configured from the last time, even if those have been destroyed already. To prevent the VOP from trying to access freed memory, disable all its windows when the CRTC is being disabled, then each window will get a valid framebuffer address before it's enabled again. Signed-off-by: Tomeu Vizoso Link: http://lkml.kernel.org/g/CAAObsKAv+05ih5U+=4kic_NsjGMhfxYheHR8xXXmacZs+p5SHw@mail.gmail.com --- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index 5e57f5b2e4b0..e2118e62345b 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -499,10 +499,25 @@ err_disable_hclk: static void vop_crtc_disable(struct drm_crtc *crtc) { struct vop *vop = to_vop(crtc); + int i; if (!vop->is_enabled) return; + /* + * We need to make sure that all windows are disabled before we + * disable that crtc. Otherwise we might try to scan from a destroyed + * buffer later. + */ + for (i = 0; i < vop->data->win_size; i++) { + struct vop_win *vop_win = &vop->win[i]; + const struct vop_win_data *win = vop_win->data; + + spin_lock(&vop->reg_lock); + VOP_WIN_SET(vop, win, enable, 0); + spin_unlock(&vop->reg_lock); + } + drm_crtc_vblank_off(crtc); /*