From patchwork Thu Apr 6 20:02:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 9668341 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 6040C602B8 for ; Thu, 6 Apr 2017 20:03:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76C44285CC for ; Thu, 6 Apr 2017 20:03:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B939285D3; Thu, 6 Apr 2017 20:03:08 +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 BD342285CC for ; Thu, 6 Apr 2017 20:03:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AC1F66EA14; Thu, 6 Apr 2017 20:03:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 34B1C6EA14 for ; Thu, 6 Apr 2017 20:03:04 +0000 (UTC) Received: by mail-wr0-x244.google.com with SMTP id u18so6366512wrc.1 for ; Thu, 06 Apr 2017 13:03:04 -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; bh=wf1i6mVVV717pWheiNVt+xWa1tmOUzz5fumZOTjM4Lo=; b=Io1p/E3gwtbEUQanhD46CelryJ9scrbXgrpmX2za0kL/TwyuOI+S8f38FUbEe7I2E8 lc4xMBn00jnGjdvf8Uj2GkHWvDxQTAPx5LuuHzhqNNPJllQ/bCSlfnHTzWX7wWtCgR2J E7J0+Wmj6gnQBMhkTt3EoADdgNeJlFj5XsI5o= 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; bh=wf1i6mVVV717pWheiNVt+xWa1tmOUzz5fumZOTjM4Lo=; b=iuR1WWAhKRnHmB93Bf0PdNTx8QeSLWxgT3c4GuAc3CKistxs0alGQxPzXRUm/8dlOL Ex57QlSGN4fSE/BUlSXcRTBDuPEAdmTNw8BukHP3dCZH/igiST+weZE80CT+7+S+JWTf DBbdfV3Nkl+dEptHYW9AxfzklkMYzvQk+5qvcRj9H9c0sJLuyKMkmoseOsh0CGrO1GI8 Ulm1WxsiiTSWm+GRmG4aHc6VMnTXMVWp6ONe8EqyNYWzrH357Vidmqc90BmeGOwxuIFY kjgxdTZ3zKL6PncOnoplGazsZvarzTJGW6pT2lqR6zS6qLaVxKGhJoZdJjRCyD7Gt7dP bASA== X-Gm-Message-State: AN3rC/60VDhK/bqZ5jhiVojaL8Sm6cmg6okFeO5rN95ssiRosB0MEtN2OqkarsohZojgtA== X-Received: by 10.28.184.73 with SMTP id i70mr1081515wmf.104.1491508982721; Thu, 06 Apr 2017 13:03:02 -0700 (PDT) Received: from phenom.ffwll.local (212-51-149-109.fiber7.init7.net. [212.51.149.109]) by smtp.gmail.com with ESMTPSA id a66sm3327197wrc.58.2017.04.06.13.03.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Apr 2017 13:03:02 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH] drm/vmwgfx: Fix fbdev emulation using legacy functions Date: Thu, 6 Apr 2017 22:02:56 +0200 Message-Id: <20170406200256.26040-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.11.0 Cc: Daniel Vetter , Thomas Hellstrom , 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 I've broken this by removing the backoff handling from the set_config2atomic helper in commit 38b6441e4e75c0b319cfe4d9364c1059fc1e3c2b Author: Daniel Vetter Date: Wed Mar 22 22:50:58 2017 +0100 drm/atomic-helper: Remove the backoff hack from set_config Fixing this properly would mean we get to wire the acquire_ctx all the way through vmwgfx fbdev code, and doing the same was tricky for the shared fbdev layer. Probably much better to look into refactoring the entire code to use the helpers, but since that's not a viable long-term solution fix the issue by open-coding a vmwgfx version of set_config, that does the legacy backoff dance internally. Note: Just compile-tested. The idea is to take drm_mode_set_config_internal(), remove the "is this a legacy driver" check, and whack the drm_atomic_legacy_backoff trickery at the end. Since drm_atomic_legacy_backoff is for atomic commits only we need to open-code it. Cc: Thomas Hellstrom Signed-off-by: Daniel Vetter Reviewed-by: Thomas Hellstrom --- drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 58 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c index 09e120d50e65..6f4cb4678cbc 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c @@ -418,6 +418,60 @@ static int vmw_fb_compute_depth(struct fb_var_screeninfo *var, return 0; } +static int vmwgfx_set_config_internal(struct drm_mode_set *set) +{ + struct drm_crtc *crtc = set->crtc; + struct drm_framebuffer *fb; + struct drm_crtc *tmp; + struct drm_modeset_acquire_ctx *ctx; + struct drm_device *dev = set->crtc->dev; + int ret; + + ctx = dev->mode_config.acquire_ctx; + +restart: + /* + * NOTE: ->set_config can also disable other crtcs (if we steal all + * connectors from it), hence we need to refcount the fbs across all + * crtcs. Atomic modeset will have saner semantics ... + */ + drm_for_each_crtc(tmp, dev) + tmp->primary->old_fb = tmp->primary->fb; + + fb = set->fb; + + ret = crtc->funcs->set_config(set, ctx); + if (ret == 0) { + crtc->primary->crtc = crtc; + crtc->primary->fb = fb; + } + + drm_for_each_crtc(tmp, dev) { + if (tmp->primary->fb) + drm_framebuffer_get(tmp->primary->fb); + if (tmp->primary->old_fb) + drm_framebuffer_put(tmp->primary->old_fb); + tmp->primary->old_fb = NULL; + } + + if (ret == -EDEADLK) { + dev->mode_config.acquire_ctx = NULL; + +retry_locking: + drm_modeset_backoff(ctx); + + ret = drm_modeset_lock_all_ctx(dev, ctx); + if (ret) + goto retry_locking; + + dev->mode_config.acquire_ctx = ctx; + + goto restart; + } + + return ret; +} + static int vmw_fb_kms_detach(struct vmw_fb_par *par, bool detach_bo, bool unref_bo) @@ -436,7 +490,7 @@ static int vmw_fb_kms_detach(struct vmw_fb_par *par, set.fb = NULL; set.num_connectors = 0; set.connectors = &par->con; - ret = drm_mode_set_config_internal(&set); + ret = vmwgfx_set_config_internal(&set); if (ret) { DRM_ERROR("Could not unset a mode.\n"); return ret; @@ -578,7 +632,7 @@ static int vmw_fb_set_par(struct fb_info *info) set.num_connectors = 1; set.connectors = &par->con; - ret = drm_mode_set_config_internal(&set); + ret = vmwgfx_set_config_internal(&set); if (ret) goto out_unlock;