From patchwork Tue Jun 27 14:59:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 9812149 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 8BE4360351 for ; Tue, 27 Jun 2017 15:00:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DC91286AA for ; Tue, 27 Jun 2017 15:00:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72160286C3; Tue, 27 Jun 2017 15:00:19 +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=ham 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 117F8286CA for ; Tue, 27 Jun 2017 15:00:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D8F8A6E3DD; Tue, 27 Jun 2017 14:59:52 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id B4EA16E3D4 for ; Tue, 27 Jun 2017 14:59:50 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id y5so6274493wmh.3 for ; Tue, 27 Jun 2017 07:59:50 -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=90KgIvxUx63m5LSTsGHsgSbK1/AnEZatylbKwiZOsBI=; b=WYZEv5U+/ueUWmCRqwFdo01TpLxaryl7T6H81+OZz7cghU/bdiWTqiZZhJVH5H5K/H ZWs/q5oqi0B0Ct0lpPf+uZU5gRPeP8kZww0P0H9//0RmpAxGm/pzgkFovTlJm8ZYBPZO LWrCQdnTwqJUzmSt4eEBq+HL5xBzqTmSo4ldY= 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=90KgIvxUx63m5LSTsGHsgSbK1/AnEZatylbKwiZOsBI=; b=d/ogKo715MhHVDfmISkvXV7zcl+Ns1mE7s2l/SC3JF3oqK3LhC/eSBRZfarTJ5Qvlh QC0/titVzTqC+x6dJJuJmdxWI0Y2b8+1syC4FrGE28pbNZ5aWyBofdwK7mVq7L+PzQ+2 08byPOdd3H7ve6mPeI2zolhIfk9wzLuMn3c9uPcuvknbTRZKijvBAaY81hNWc3wSutDP v1c/PWDsJt93iysMnm0vcO4z5Y1eneDN5i8pELphqwvjYHonDq0nKWQXoR1TDxW5Ukl8 FhVsF8+D0xBg8y83JgRLczdwyyobqwcxZZCIroLmlRq38sajAMY3AJOrkfI2zC8gLPjU F4vA== X-Gm-Message-State: AKS2vOxVVUF/LeAWJyu7JjGSFKl465IJqBLgI6yMY/UMvpNmSIjiUcgX K7JRsh36wQJ+pKgZ7Rk= X-Received: by 10.80.183.4 with SMTP id g4mr4295462ede.138.1498575589420; Tue, 27 Jun 2017 07:59:49 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:5640:0:960b:2678:e223:c1c6]) by smtp.gmail.com with ESMTPSA id x44sm1557561edx.38.2017.06.27.07.59.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Jun 2017 07:59:48 -0700 (PDT) From: Daniel Vetter To: DRI Development Date: Tue, 27 Jun 2017 16:59:29 +0200 Message-Id: <20170627145936.18983-7-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170627145936.18983-1-daniel.vetter@ffwll.ch> References: <20170627145936.18983-1-daniel.vetter@ffwll.ch> Cc: Daniel Vetter , Intel Graphics Development , Thierry Reding , John Stultz , Daniel Vetter Subject: [Intel-gfx] [PATCH 06/13] drm/fb-helper: Push locking into pan_display_atomic|legacy 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 For the legacy path we'll keep drm_modeset_lock_all, for the atomic one we drop the use of the magic implicit context and wire it up properly. Cc: John Stultz Cc: Thierry Reding Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_fb_helper.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 13330c22e6bf..5d8bf7dfa618 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -1331,7 +1331,6 @@ int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) { struct drm_fb_helper *fb_helper = info->par; - struct drm_device *dev = fb_helper->dev; struct drm_mode_set *mode_set; struct drm_crtc *crtc; int ret = 0; @@ -1522,12 +1521,17 @@ static int pan_display_atomic(struct fb_var_screeninfo *var, struct drm_plane *plane; int i, ret; unsigned int plane_mask; + struct drm_modeset_acquire_ctx ctx; + + drm_modeset_acquire_init(&ctx, 0); state = drm_atomic_state_alloc(dev); - if (!state) - return -ENOMEM; + if (!state) { + ret = -ENOMEM; + goto out_ctx; + } - state->acquire_ctx = dev->mode_config.acquire_ctx; + state->acquire_ctx = &ctx; retry: plane_mask = 0; for (i = 0; i < fb_helper->crtc_count; i++) { @@ -1540,7 +1544,7 @@ static int pan_display_atomic(struct fb_var_screeninfo *var, ret = __drm_atomic_helper_set_config(mode_set, state); if (ret != 0) - goto fail; + goto out_state; plane = mode_set->crtc->primary; plane_mask |= (1 << drm_plane_index(plane)); @@ -1549,23 +1553,27 @@ static int pan_display_atomic(struct fb_var_screeninfo *var, ret = drm_atomic_commit(state); if (ret != 0) - goto fail; + goto out_state; info->var.xoffset = var->xoffset; info->var.yoffset = var->yoffset; -fail: +out_state: drm_atomic_clean_old_fb(dev, plane_mask, ret); if (ret == -EDEADLK) goto backoff; drm_atomic_state_put(state); +out_ctx: + drm_modeset_drop_locks(&ctx); + drm_modeset_acquire_fini(&ctx); + return ret; backoff: drm_atomic_state_clear(state); - drm_atomic_legacy_backoff(state); + drm_modeset_backoff(&ctx); goto retry; } @@ -1578,6 +1586,7 @@ static int pan_display_legacy(struct fb_var_screeninfo *var, int ret = 0; int i; + drm_modeset_lock_all(fb_helper->dev); for (i = 0; i < fb_helper->crtc_count; i++) { modeset = &fb_helper->crtc_info[i].mode_set; @@ -1592,6 +1601,7 @@ static int pan_display_legacy(struct fb_var_screeninfo *var, } } } + drm_modeset_unlock_all(fb_helper->dev); return ret; } @@ -1617,12 +1627,10 @@ int drm_fb_helper_pan_display(struct fb_var_screeninfo *var, return -EBUSY; } - drm_modeset_lock_all(dev); if (drm_drv_uses_atomic_modeset(dev)) ret = pan_display_atomic(var, info); else ret = pan_display_legacy(var, info); - drm_modeset_unlock_all(dev); mutex_unlock(&fb_helper->lock); return ret;