From patchwork Wed Mar 22 21:50:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 9640177 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 8A0DC601E9 for ; Wed, 22 Mar 2017 21:52:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CF06201A4 for ; Wed, 22 Mar 2017 21:52:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71C4227D5E; Wed, 22 Mar 2017 21:52:58 +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]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 25AC9201A4 for ; Wed, 22 Mar 2017 21:52:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CB49C6E9CC; Wed, 22 Mar 2017 21:51:27 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 332306E9AB for ; Wed, 22 Mar 2017 21:51:19 +0000 (UTC) Received: by mail-wr0-x243.google.com with SMTP id u108so28698679wrb.2 for ; Wed, 22 Mar 2017 14:51:19 -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=YNIbaqfbtzvYYAl7f2eX4iSEfwpI3MyZmtTlGv99QUo=; b=IhbWITxqBesDmCQ641Fc7vjNRO+R/9moWdWlCmIoYw9pSI7BgA7gki3gb3cSCKN3DT pMXGAEv0O8qKrjEa4b8BPm5/27hCxSRBV+ZuO0oxGYO2fiNWgqxa/2cR+U/uEd8d5hJa 6ad+P2f0HO/k3C7YbMqI7VNxVUKGHUkwziQh0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YNIbaqfbtzvYYAl7f2eX4iSEfwpI3MyZmtTlGv99QUo=; b=EtTA/d0JL60hGo+OexJdNU+Z9SlClstmHpu0IpB2NPHpkzWx6PCktl2NeRuqjKxXwT /ww7TDM+S8miDnzxDB8MaaGur8Hk2TouBIg4j7PxwdeyCtgz2eI7nMD3Oxf+yed3GQWY JJ5NXJSvPbDJ8Z6J8PpqlXRVVEtmNnB8YaYgOfeosiGs0Uoi39iisgP0pqlvKiWsZv2I NP9XebyqgJlrVfPbOItArCRAWYReTjMHG9XQt952rvXr8lnMnzvg+w8vAaAO6NO10M/r v+j9U7GfyC4J+c+njMsAOkOmLC8v7jYJcPCZ6sh0c+kjVH1OdUj5xRP2a+awlaWMW/8Y lLIQ== X-Gm-Message-State: AFeK/H0g6Vmh108iK9qyF9YeO5U+PzHV86GFU5Pu+VkPET7IHZGSsVuuHO009Tyw3y+EBw== X-Received: by 10.223.153.4 with SMTP id x4mr619921wrb.117.1490219477770; Wed, 22 Mar 2017 14:51:17 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:56c9:0:decc:6e78:7e96:b452]) by smtp.gmail.com with ESMTPSA id t85sm1777070wmt.23.2017.03.22.14.51.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Mar 2017 14:51:17 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH 10/19] drm: Roll out acquire context for the page_flip ioctl Date: Wed, 22 Mar 2017 22:50:49 +0100 Message-Id: <20170322215058.8671-11-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170322215058.8671-1-daniel.vetter@ffwll.ch> References: <20170322215058.8671-1-daniel.vetter@ffwll.ch> Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter 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-Virus-Scanned: ClamAV using ClamSMTP Again just prep work. Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_plane.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index 8535dc17db7e..62e833ffeffd 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -803,6 +803,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, struct drm_framebuffer *fb = NULL; struct drm_pending_vblank_event *e = NULL; u32 target_vblank = page_flip->sequence; + struct drm_modeset_acquire_ctx ctx; int ret = -EINVAL; if (!drm_core_check_feature(dev, DRIVER_MODESET)) @@ -866,7 +867,16 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, return -EINVAL; } - drm_modeset_lock_crtc(crtc, crtc->primary); + drm_modeset_acquire_init(&ctx, 0); +retry: + ret = drm_modeset_lock(&crtc->mutex, &ctx); + if (ret) + goto out; + ret = drm_modeset_lock(&crtc->cursor->mutex, &ctx); + if (ret) + goto out; + crtc->acquire_ctx = &ctx; + if (crtc->primary->fb == NULL) { /* The framebuffer is currently unbound, presumably * due to a hotplug event, that userspace has not @@ -944,7 +954,14 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, if (crtc->primary->old_fb) drm_framebuffer_put(crtc->primary->old_fb); crtc->primary->old_fb = NULL; - drm_modeset_unlock_crtc(crtc); + + if (ret == -EDEADLK) { + drm_modeset_backoff(&ctx); + goto retry; + } + + drm_modeset_drop_locks(&ctx); + drm_modeset_acquire_fini(&ctx); return ret; }