Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp431580rdb; Mon, 22 Jan 2024 08:30:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IHY6/4DoP9Ahsj6PgZd86R175wOTT6ZPX+P0m3JvBdWX010Om6Xi2M21lWLfRPSlqXyi5HP X-Received: by 2002:a17:902:f685:b0:1d7:3121:ffd1 with SMTP id l5-20020a170902f68500b001d73121ffd1mr1448860plg.13.1705941045747; Mon, 22 Jan 2024 08:30:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705941045; cv=pass; d=google.com; s=arc-20160816; b=SgGeinl5E0tjZbmYxcvbclqsslEaD9py9lbc94L0vPQenITPkfu6+x/GEuQwXyl9zE srgctm+3h3g8OUibazfGFQ9Rqbvmo1s4SLSD6ej0dSxvrO2AEEr/PvBiMEp30WbtWidJ jkjUXjltvtTlrZtbbC75n/RJRol33Zx4gakwdnUV3Y7dM65YbMFkDqVQmjd3soytELxH RxfsLy5T8rKwDQwklp6p6L3HjWSOCFG5axsssylcnNkJxrduCiwkwEwNWCptq3F3wLeR +IL98u6wV/TzISz93oQLi1DaKJn98ipGRecQCeDBIH+MrifZuLVh8TCFheQiQvUa9mNO K/oQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=0IKdDmFWp+hULF/4tdzO9O5oLLf0NAo/RWkCQHeXQ74=; fh=l0GTC/lLXpSqRofa9d18+sHwQJVWiSX5dPib+UOsAzE=; b=dBIgY5htqbIUEmdM96q2ms1ERbs9esQHZA7Yr//Ut0fxn88KSQ8OWgT7NCMs0imyiv JReKgAGwV/2c7vRlNXPa6sNL+dRW70soIf8oWZyzN/RVvv5FBfrbvqKSctmQcyTiCLJV vK+2wWVhIKaV9oQ3LUkOjPb4WN7T9KzNH3ZspAhz3ix24DqgheGFfoYL0isHk2N9JB/Y AvV7+SpCCW8CyPvaM5lnbcCJJzgTpBHwStj1VNyWEy0FX1tjb3D9xGf6UssxzwjT/b1u Kszgv4BeHbYnKDbhtV2owo3ZgJWVqPGy0x2geJurZVmJs9wVFSUyCfZ534e7kPe9mIfu Nv2Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=roU1UjhS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-33430-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33430-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id u2-20020a170902e80200b001d72bd623dcsi4801090plg.257.2024.01.22.08.30.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 08:30:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-33430-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=roU1UjhS; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-33430-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33430-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 03739B28E84 for ; Mon, 22 Jan 2024 16:06:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6B1E31272AE; Mon, 22 Jan 2024 15:11:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="roU1UjhS" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CD5C3EA9B; Mon, 22 Jan 2024 15:11:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705936265; cv=none; b=QKF+1o0dteh6sINaFpjgPJCxDgzQpokz+nNThmV8rLv89IOTtFe26WPCQO4ps5oZB1BtDsvXfPI2dFFz3hQouAXgDhXOsXDpF5uQzsB5oeesHONwT1msosUbW6sKZ97pYzE74sq22b1eX5apLZtOlV7TFuw8wrW3yyZyIyqmZfY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705936265; c=relaxed/simple; bh=A5/8WULJogAZ2gq6MyPzXHdGezp6HyRDiKSQy0vu5wc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XTWRXRFnhzycdp1RK8wPs9iPiIp4MZ4M2adNXVHfh4tolo38c5Rrb9TRQMKT32GZvmlSkTSuHL8sxaSnnNZRIWoxqJRX7LQj99WXC3GowwV2O+OLbWFR7/gSjXALblqgDV2JSRj75qzf/4xMw4j/rraZob6jIbcGvc1q0lKykPw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=roU1UjhS; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D519C433A6; Mon, 22 Jan 2024 15:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705936265; bh=A5/8WULJogAZ2gq6MyPzXHdGezp6HyRDiKSQy0vu5wc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=roU1UjhSIyUixOA5DiyL6yRq7dyBVZl4kDmPmC1Ke4eM9JLtfssVxnwDoXotubwQA QUAicmEPWPG56yYsAiHlV3LKDvEB1/ZQy9MbpQXEkfEIkOVm9POPTKkcHndqWI4H7g ioRAD3BBRIXmQmi/USdP+fM809nT5u5ViZz5rrP0busMxcLAISSnULbJCOeZYKZcgJ x1qEuZTyDzzWjgC33qf+6IW5qo4YKkJrxLcl7YOH2iiMwVYQc5+TQOqPHhgCeCQMDI 9CeaLMnz55KvXx9e/KIr/moiiy1UNMBKDZiLcrMYCYwddgeHX7JIYQ6jOLKYtSPFlV wGsmk1zdQTX5A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Douglas Anderson , Maxime Ripard , Marek Szyprowski , Inki Dae , Sasha Levin , sw0312.kim@samsung.com, kyungmin.park@samsung.com, airlied@gmail.com, daniel@ffwll.ch, krzysztof.kozlowski@linaro.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 30/53] drm/exynos: Call drm_atomic_helper_shutdown() at shutdown/unbind time Date: Mon, 22 Jan 2024 10:08:31 -0500 Message-ID: <20240122150949.994249-30-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122150949.994249-1-sashal@kernel.org> References: <20240122150949.994249-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.74 Content-Transfer-Encoding: 8bit From: Douglas Anderson [ Upstream commit 16ac5b21b31b439f03cdf44c153c5f5af94fb3eb ] Based on grepping through the source code this driver appears to be missing a call to drm_atomic_helper_shutdown() at system shutdown time and at driver unbind time. Among other things, this means that if a panel is in use that it won't be cleanly powered off at system shutdown time. The fact that we should call drm_atomic_helper_shutdown() in the case of OS shutdown/restart and at driver remove (or unbind) time comes straight out of the kernel doc "driver instance overview" in drm_drv.c. A few notes about this fix: - When adding drm_atomic_helper_shutdown() to the unbind path, I added it after drm_kms_helper_poll_fini() since that's when other drivers seemed to have it. - Technically with a previous patch, ("drm/atomic-helper: drm_atomic_helper_shutdown(NULL) should be a noop"), we don't actually need to check to see if our "drm" pointer is NULL before calling drm_atomic_helper_shutdown(). We'll leave the "if" test in, though, so that this patch can land without any dependencies. It could potentially be removed later. - This patch also makes sure to set the drvdata to NULL in the case of bind errors to make sure that shutdown can't access freed data. Suggested-by: Maxime Ripard Reviewed-by: Maxime Ripard Signed-off-by: Douglas Anderson Tested-by: Marek Szyprowski Reviewed-by: Marek Szyprowski Signed-off-by: Inki Dae Signed-off-by: Sasha Levin --- drivers/gpu/drm/exynos/exynos_drm_drv.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index 16c539657f73..4095b0d3ac2e 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c @@ -309,6 +309,7 @@ static int exynos_drm_bind(struct device *dev) drm_mode_config_cleanup(drm); exynos_drm_cleanup_dma(drm); kfree(private); + dev_set_drvdata(dev, NULL); err_free_drm: drm_dev_put(drm); @@ -323,6 +324,7 @@ static void exynos_drm_unbind(struct device *dev) exynos_drm_fbdev_fini(drm); drm_kms_helper_poll_fini(drm); + drm_atomic_helper_shutdown(drm); component_unbind_all(drm->dev, drm); drm_mode_config_cleanup(drm); @@ -360,9 +362,18 @@ static int exynos_drm_platform_remove(struct platform_device *pdev) return 0; } +static void exynos_drm_platform_shutdown(struct platform_device *pdev) +{ + struct drm_device *drm = platform_get_drvdata(pdev); + + if (drm) + drm_atomic_helper_shutdown(drm); +} + static struct platform_driver exynos_drm_platform_driver = { .probe = exynos_drm_platform_probe, .remove = exynos_drm_platform_remove, + .shutdown = exynos_drm_platform_shutdown, .driver = { .name = "exynos-drm", .pm = &exynos_drm_pm_ops, -- 2.43.0