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: 8741241 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 35A219F39A for ; Mon, 4 Apr 2016 13:56:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DB6D620263 for ; Mon, 4 Apr 2016 13:56:07 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id E1AB82024F for ; Mon, 4 Apr 2016 13:56:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E6016E5E0; Mon, 4 Apr 2016 13:56:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lb0-x242.google.com (mail-lb0-x242.google.com [IPv6:2a00:1450:4010:c04::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id DFC4D6E5E0 for ; Mon, 4 Apr 2016 13:56:04 +0000 (UTC) Received: by mail-lb0-x242.google.com with SMTP id q4so22552046lbq.3 for ; Mon, 04 Apr 2016 06:56:04 -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=aW5sAvmFZB224hbIrCLBUVsidGOTrSjl/VashQ59ym8BsCe0HLrMtEvXAkcCisth3z QcxfJvyGp4ZzsY1xX16Rb32q0H/ef5GMCH1jQ+UdGUtboKGe06Jctf6M5wD66iTAJkYS //unGryDXKjsUytoQB/kRU3BDv69NLa0MlVwr326X+CMWGc1E3o960hycPrZWUgU8VA7 vR17GFbGYw9WRh+zksCu+Lwf2g2pTVey/MaM+OQvra4DqlSLSgMpVK3qYbjvas3WJBOY 7+Ch42roNAq64fH8LRpEM4b8SNxSkhOVLYjR1qzNPEQqkG0eimfHU45SZZR1PDg/HmsV uNdQ== X-Gm-Message-State: AD7BkJI/KI0aEc6zheLTkgs9nzdOUHcVubTFf6QQiVbkhjpMAz9SfcXCcv1gC2GCyZftVg== 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 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=-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);