From patchwork Thu Nov 29 15:04:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10704745 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3C7CE17F0 for ; Thu, 29 Nov 2018 15:04:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D62E2F4C5 for ; Thu, 29 Nov 2018 15:04:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F8AC2F4C4; Thu, 29 Nov 2018 15:04:35 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 92E342F47D for ; Thu, 29 Nov 2018 15:04:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9435F6E333; Thu, 29 Nov 2018 15:04:33 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yb1-xb42.google.com (mail-yb1-xb42.google.com [IPv6:2607:f8b0:4864:20::b42]) by gabe.freedesktop.org (Postfix) with ESMTPS id 41CB36E333 for ; Thu, 29 Nov 2018 15:04:32 +0000 (UTC) Received: by mail-yb1-xb42.google.com with SMTP id h187-v6so843848ybg.10 for ; Thu, 29 Nov 2018 07:04:32 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=liz+WkLE78sx1SyHc2+iCPAUYaTGSVq2T8DJTudIYdk=; b=YPTPedObqq2q8M3JIw35X3qorpAGgYu3g7LzfxfceDxs5t2RxK0QbtxZydAUqbfzUR tLxOax7UI0+VNgLcbVdJXhqlQZg7twtFY4bg6P0A3xWNUIzePkgybEuTeqF2cgHouHjt Pivpns7mHvupPPTktCuJ8M96eUekgtYrx6Cojq5RCrwRXZ0l0ihJQKlMR8gABz5kmZG1 VLcTa8b/LEji5hqe1NMsKEggLxYFBBIzpa3bHwGt0OXZ7vCF2t0RbVq/bpEJ9vWNe3qB /pJc+VsDINNhe49tz+KGeqIIIeMjCbbSzijyzoYCBDZDOTSSjtZXODFWed/vDqJBQz/d O6xw== X-Gm-Message-State: AA+aEWYEwiKxfRw4SI1va8uFbQNARtpHFqD4Us27/Trq63azYthjNTm+ JxfUPHem2MBv8TM7EHmsOPVrj0P90oeA2w== X-Google-Smtp-Source: AFSGD/VHPXNWF7QGXthVnB4KReDgGGdPH26b92q2Pg77WDhIdl1g9QJCUtXqq9dyTqLGDTc3vdxW8Q== X-Received: by 2002:a25:ddc3:: with SMTP id u186-v6mr1593177ybg.440.1543503871217; Thu, 29 Nov 2018 07:04:31 -0800 (PST) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:ad55:b1db:adfe:3b9f]) by smtp.gmail.com with ESMTPSA id r20sm2434656ywa.13.2018.11.29.07.04.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 07:04:30 -0800 (PST) From: Sean Paul To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 2/4] drm: Move drm_mode_setcrtc() local re-init to failure path Date: Thu, 29 Nov 2018 10:04:15 -0500 Message-Id: <20181129150423.239081-2-sean@poorly.run> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog In-Reply-To: <20181129150423.239081-1-sean@poorly.run> References: <20181129150423.239081-1-sean@poorly.run> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , David Airlie , Sean Paul , Sean Paul Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Sean Paul Instead of always re-initializing the variables we need to clean up on out, move the re-initialization into the branch that goes back to retry label. This is a lateral move right now, but will allow us to pull out the modeset locking into common code. I kept this change separate to make things easier to review. Changes in v2: - None Reviewed-by: Daniel Vetter Signed-off-by: Sean Paul --- drivers/gpu/drm/drm_crtc.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 268a182ae1893..af4b94ce8e942 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -570,9 +570,9 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, struct drm_mode_crtc *crtc_req = data; struct drm_crtc *crtc; struct drm_plane *plane; - struct drm_connector **connector_set, *connector; - struct drm_framebuffer *fb; - struct drm_display_mode *mode; + struct drm_connector **connector_set = NULL, *connector; + struct drm_framebuffer *fb = NULL; + struct drm_display_mode *mode = NULL; struct drm_mode_set set; uint32_t __user *set_connectors_ptr; struct drm_modeset_acquire_ctx ctx; @@ -601,10 +601,6 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, mutex_lock(&crtc->dev->mode_config.mutex); drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE); retry: - connector_set = NULL; - fb = NULL; - mode = NULL; - ret = drm_modeset_lock_all_ctx(crtc->dev, &ctx); if (ret) goto out; @@ -766,6 +762,12 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, } kfree(connector_set); drm_mode_destroy(dev, mode); + + /* In case we need to retry... */ + connector_set = NULL; + fb = NULL; + mode = NULL; + if (ret == -EDEADLK) { ret = drm_modeset_backoff(&ctx); if (!ret)