From patchwork Mon Apr 4 13:55:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 8741301 Return-Path: X-Original-To: patchwork-linux-arm@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 C3A1C9F7C9 for ; Mon, 4 Apr 2016 13:58:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D29FD20219 for ; Mon, 4 Apr 2016 13:58:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F40222025A for ; Mon, 4 Apr 2016 13:58:08 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1an4zd-0006U5-2f; Mon, 04 Apr 2016 13:56:37 +0000 Received: from mail-lb0-x244.google.com ([2a00:1450:4010:c04::244]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1an4zR-0006Dd-Q9; Mon, 04 Apr 2016 13:56:28 +0000 Received: by mail-lb0-x244.google.com with SMTP id gk8so20282161lbc.2; Mon, 04 Apr 2016 06:56:05 -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=3+A+EV3Pyqypw2Dq+EjxnR4mdqpkT5MmUnXakAGHF+g=; b=xo/N/tbyr6Lq/pN3irwXSLRTnNMF0p5QbCj+MfAuT7gRanhFi80kl9PpfZYeitdc3s dQ4WSNB3d+RLnpe3dwOIOufjFmS1Guj/VIwW0tPuKbzN92npa/RK0j7buCrw0JcYsiVm RcwIzmDKN7Bsx/f8zqnEOK+7eGSaOTPoeFBbV1MzPivFGZDTVqtcTWuDtxpHsEe8fNEi vqDZxJyHYAlECRlswXiZyDJ8aXii3aEEoJXjrbuLrnntSW4c/oVXDfBFYBp7xZx4+nnS d8ICw+Omu/6m78a1BuyWefB9m385zgK+nJ/ijefiqI/5Ot/Qo5Z8S8UiTxf4j3YAeAXg lDbA== 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=3+A+EV3Pyqypw2Dq+EjxnR4mdqpkT5MmUnXakAGHF+g=; b=Du5kODP0fxEwtT/2QT20g9anRCrtgC5QF9GP8NERPBrD7YOncd8sI2DcRigrZjl+TK Cs9pe0FrmhNdo/FbBbCrg3rsPItDo6dI1p61ETkh30G9KT3AIiLPjTQZXozRcN5kzHu5 AHMLf3b0j790T+yY4a1eg77p3hFgzj0dvU1eKh2l1hTg/oQsojEjn7j1L7iWTzYweGco pJ6yhszOUSYsQkimuMA4vP+rAHfCMfLlXzC9Hrb3PaD2xgHv6SPPIhNvGlBqKyzMul8N AcrGzpsHXFKbEpPikqR3j4Gx3/ZGPBtc5t0exevU3S6WAk4txDPfbSzc83mOPBM8Kw+A W3TA== X-Gm-Message-State: AD7BkJJ4huwW9HKhBWH+2Pv+Rj4wzb66QWKWuUrae00ijpRzJ+VljTDYKogdnPur8LFMdw== X-Received: by 10.28.212.19 with SMTP id l19mr12197055wmg.97.1459778163275; Mon, 04 Apr 2016 06:56:03 -0700 (PDT) Received: from cizrna.lan ([109.72.12.130]) by smtp.gmail.com with ESMTPSA id js8sm29107033wjc.37.2016.04.04.06.56.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Apr 2016 06:56:02 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Subject: [PATCH] drm/rockchip: Return -EBUSY if there's already a pending flip event v3 Date: Mon, 4 Apr 2016 15:55:34 +0200 Message-Id: <1459778134-30693-1-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.5.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160404_065626_172333_F9E5C14B X-CRM114-Status: GOOD ( 12.07 ) X-Spam-Score: -2.4 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , Tomeu Vizoso , David Airlie , dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Mark Yao MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 As per the docs, atomic_commit should return -EBUSY "if an asycnhronous updated is requested and there is an earlier updated pending". v2: Use the status of the workqueue instead of vop->event, and don't add a superfluous wait on the workqueue. v3: Drop work_busy, as there's a sizeable delay when the worker finishes, which introduces a race in which the client has already received the last flip event but the next page flip ioctl will still return -EBUSY because work_busy returns outdated information. Signed-off-by: Tomeu Vizoso --- drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 1 + drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 13 ++++++++++++- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 5 +++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h index 3529f692edb8..37952eefd33d 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h @@ -69,6 +69,7 @@ int rockchip_register_crtc_funcs(struct drm_crtc *crtc, void rockchip_unregister_crtc_funcs(struct drm_crtc *crtc); int rockchip_drm_crtc_mode_config(struct drm_crtc *crtc, int connector_type, int out_mode); +bool rockchip_drm_crtc_has_pending_event(struct drm_crtc *crtc); int rockchip_drm_dma_attach_device(struct drm_device *drm_dev, struct device *dev); void rockchip_drm_dma_detach_device(struct drm_device *drm_dev, diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c index 3b8f652698f8..8305bbd2a4d7 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c @@ -280,7 +280,18 @@ int rockchip_drm_atomic_commit(struct drm_device *dev, { struct rockchip_drm_private *private = dev->dev_private; struct rockchip_atomic_commit *commit = &private->commit; - int ret; + struct drm_crtc_state *crtc_state; + struct drm_crtc *crtc; + int i, ret; + + if (async) { + for_each_crtc_in_state(state, crtc, crtc_state, i) { + if (crtc->state->event || + rockchip_drm_crtc_has_pending_event(crtc)) { + return -EBUSY; + } + } + } ret = drm_atomic_helper_prepare_planes(dev, state); if (ret) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index e2118e62345b..5bcdd8dc7499 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -848,6 +848,11 @@ int rockchip_drm_crtc_mode_config(struct drm_crtc *crtc, } EXPORT_SYMBOL_GPL(rockchip_drm_crtc_mode_config); +bool rockchip_drm_crtc_has_pending_event(struct drm_crtc *crtc) +{ + return to_vop(crtc)->event; +} + static int vop_crtc_enable_vblank(struct drm_crtc *crtc) { struct vop *vop = to_vop(crtc);