Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3628389imu; Mon, 28 Jan 2019 08:05:53 -0800 (PST) X-Google-Smtp-Source: ALg8bN58k0+OU5X1YQdFG33obiIqEyiODMISxQzKmSh5dhlOLf/ZMtLr62vcieFy66FSHtVj8Dn3 X-Received: by 2002:a17:902:6bc9:: with SMTP id m9mr22009203plt.173.1548691553741; Mon, 28 Jan 2019 08:05:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691553; cv=none; d=google.com; s=arc-20160816; b=OJmOMJNRthGwCJQDNYBJEcxti0TB1TxeTWsVB1PPzaEHFK+ACgIfS7DgnH4X1WbcOq 2Ib1MhBV2B2ZbijeBrIGloUXWBnNzLzrV0PuSGZlOQknatKyhoH+HUkqqlmQt+oN8Dgm ET2+vOf8n68uwE0jc72gLXQSPZPMGC86xK+XSCpaolmPKFYT095mf60qSSW1uw8rPkme a+v9si7IT7KhqPU+CRXcN6sLEHiMdm5As1VJQxNd2Lf5WqOdmobPvVI24RLg5g2q+PGx xxuth4eL0iniREFjHq33y2cILrTdZLhVoG0D2+kvcO4qAeEEjaIEcpdwbGs/sba0wD5B f3Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=A+nY7kAh1/0AFBhKP5+/YZ0otppPn/b2Ysp+LxK8IbM=; b=wpg66CNHfuP8lpTWnbMvvyo7sRIKV8EIDQStrDwoft3gqgmijhbQXGjsfObAfJPY10 a0uEoNzOp9iBAbheRjHJsuEtb/pREta18DJlmzpJucxffRZwvZ73DlWP3y4yxThQtGTh EruC1EiQbeFg/IYfQFt2btzJ92xRnLHXcUtnYAR6nV0KgPkctojC76H7Aw6U4+MjxVkH EZkZ8s+IU/0Wdc8jMGNcUHhsIpzGjdDlnOizvU1cWV/827AU1gJVwvxfaPMhWqlyFnEa e0qeUu5D+8mtwAzRrK0/kcdFgLjfXIhyf8QJZ5pzhXBQfc1f4jQpi7wqhOHD2r3nr6ux IUSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="LCsV/I++"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x73si11638519pfk.53.2019.01.28.08.05.38; Mon, 28 Jan 2019 08:05:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="LCsV/I++"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731394AbfA1QD1 (ORCPT + 99 others); Mon, 28 Jan 2019 11:03:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:48740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731015AbfA1QDZ (ORCPT ); Mon, 28 Jan 2019 11:03:25 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 85AC521852; Mon, 28 Jan 2019 16:03:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691404; bh=UFJggQPt5EUCWOOOp4WGeOIH3pVZBgu7PDnMbBXmJIU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LCsV/I++zHjzfc3/XL8YBHrerfQZtzU6XOCieAqDrEPiBOXpcFrodrVYphe3mKxdl ViOoR16FXtPMAMX8h92mIpcJ/vylE85U+Za9PRthJseEWuzat4ulIzAs+j5lkzeEKb axIKBRCoO5jyoDKyS0jmdEb+O1YNYw+XXeHT4WJc= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sean Paul , Sasha Levin , dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 4.19 083/258] drm: Move drm_mode_setcrtc() local re-init to failure path Date: Mon, 28 Jan 2019 10:56:29 -0500 Message-Id: <20190128155924.51521-83-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Paul [ Upstream commit c232e9f41b136c141df9938024e521191a7b910d ] 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 Link: https://patchwork.freedesktop.org/patch/msgid/20181129150423.239081-2-sean@poorly.run Signed-off-by: Sasha Levin --- 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 9cbe8f5c9aca..ed9d7fc4cb2c 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -567,9 +567,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; @@ -598,10 +598,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; @@ -763,6 +759,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) -- 2.19.1