From patchwork Tue Jun 11 17:27:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13694046 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1E3FCC27C65 for ; Tue, 11 Jun 2024 17:28:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=Ek9nYHCEplYURM/7b1b2h5qMkLqR/eL+WowxP0vSWY4=; b=4tvJtQUcI3+bGUJ5jPVTZPoJTa 8nrqA1UBBR6NzZ+nrSTCG7BQvAe3PKYx5qWEiPTDsZ0vREe6GO3CU+YGEMJ2MxN735+5LC7G8dceZ qKkKzGl9h9VKftAJW4lQ/9ZacT8M2izHYYCOQRAXOnSvqR1sTCMyWAomvkwHjC/4DvrzYh9SFWywa QjyueoNkGt9+Pccla3OS55Q6b8/jV8o2pj6dHxq1slB9DUXQF5oM0civOwqAd3sPvRKepuN3XLc+R y91BWwxzOegwqLzK5yApi71UnO70Ygb8GNTp0cD6IZZkJvIjjXdeklUyv3z7B4/n9s1a3t0Q2MKiZ 6gGJbRcg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sH5IM-00000009foj-428V; Tue, 11 Jun 2024 17:28:30 +0000 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sH5IJ-00000009fnw-3yqK for linux-arm-kernel@lists.infradead.org; Tue, 11 Jun 2024 17:28:29 +0000 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-6818e31e5baso4859913a12.1 for ; Tue, 11 Jun 2024 10:28:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718126905; x=1718731705; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Ek9nYHCEplYURM/7b1b2h5qMkLqR/eL+WowxP0vSWY4=; b=dkEGnqlQxu0kirRsuVa8SRVsoZe2gp8yUAlbUTSpDQ5+ibb1tPdrZpmrFIP7o2hUE2 MUZ5K6GtAmPnIpSxS8ooZr1lxpS3lDlLRWToQwitmDnZBxHccKqcYwUM9y8mOW/5/byI 9O7pRSfpDlDb9fRb3sCAszIauooPlhVVzvqTE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718126905; x=1718731705; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ek9nYHCEplYURM/7b1b2h5qMkLqR/eL+WowxP0vSWY4=; b=eOwlrT15POooajx30ctS7eoJbry6/WXSyeqW7huecMAmsFp12TiD86Zf94Vfx8gjNX UfX07VDiqogHVG9rrDvgYUEb226COk2j1lYJFZoO5viLNSSDK4YPK1qxv6iLhyddzP7l nbvdRmWvP/7rl78aSpYO96cCDpzLYWOQAHkqvKhLk7razrw0AUz/CiqX9Nq4beNNWsjp 1U9+sqURz9dtyKeP9+ADJOKmi3QHl1dMoDSzNuxXdf81eIEWGYz0SGUscV+ULtidfQdL mJeJ3+MCqCsNYZ4kC47+L6tVIwGEWwniX5OojjL4tAQPCUq7DEMU2lF2Fb18h0PtRfti qqNQ== X-Forwarded-Encrypted: i=1; AJvYcCU0we+EbHCQ6+gOry9XAbX5/tK/3VaN7Mp8oGEH/ITjSKxcvYNA4manRYjFSEJ4hm4ISaz6gLnGVk7ptv1VxSSnXAjETlgXGaxV/IWgqtWtou6YsCE= X-Gm-Message-State: AOJu0YyUEg/2+aPtmyNIoseYgCqMwLNAdrtdQukGFEdHeFZhACsyjYGH eGb4B2O8WByHzJq2mEladhqj/hbCEkqYBeZtVoEKQLoatiUghR0qUvnhVToYtd+ZGa88EzNpzfo = X-Google-Smtp-Source: AGHT+IFJ4n9j/I8+bwf5nby7cNuNSwpvL75gc72i3EraZAd14f2XpX1hujkn20i8r/RxoP3yzvg2rg== X-Received: by 2002:a17:903:244d:b0:1f7:eb9:947e with SMTP id d9443c01a7336-1f70eb99809mr68387405ad.63.1718126904826; Tue, 11 Jun 2024 10:28:24 -0700 (PDT) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:f410:2f13:37e2:37d]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f6e7858544sm75714375ad.75.2024.06.11.10.28.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 10:28:24 -0700 (PDT) From: Douglas Anderson To: Chun-Kuang Hu , Philipp Zabel Cc: Linus Walleij , Neil Armstrong , Fei Shao , Maxime Ripard , Douglas Anderson , AngeloGioacchino Del Regno , Daniel Vetter , David Airlie , Matthias Brugger , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2] drm/mediatek: Call drm_atomic_helper_shutdown() at shutdown time Date: Tue, 11 Jun 2024 10:27:44 -0700 Message-ID: <20240611102744.v2.1.I2b014f90afc4729b6ecc7b5ddd1f6dedcea4625b@changeid> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240611_102828_075554_30E3761D X-CRM114-Status: GOOD ( 21.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Based on grepping through the source code this driver appears to be missing a call to drm_atomic_helper_shutdown() at system shutdown 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 comes straight out of the kernel doc "driver instance overview" in drm_drv.c. This driver users the component model and shutdown happens in the base driver. The "drvdata" for this driver will always be valid if shutdown() is called and as of commit 2a073968289d ("drm/atomic-helper: drm_atomic_helper_shutdown(NULL) should be a noop") we don't need to confirm that "drm" is non-NULL. Suggested-by: Maxime Ripard Reviewed-by: Maxime Ripard Reviewed-by: Fei Shao Tested-by: Fei Shao Signed-off-by: Douglas Anderson Reviewed-by: Linus Walleij --- v1 of this patch was part of a series [1]. It got tested and reviewed but never landed. Reposting separately in the hopes that Mediatek DRM folks will land it. If, instead, Mediatek DRM folks want to Ack it I'm happy to land through drm-misc. I noticed that this was missing when I failed to add "mediatek" to my patch series IDing which DRM modeset drivers did this properly [2]. Assuming my patch lands, that means that Mediatek devices will start getting more warnings printed. [1] https://lore.kernel.org/r/20230901164111.RFT.5.I2b014f90afc4729b6ecc7b5ddd1f6dedcea4625b@changeid [2] https://lore.kernel.org/r/20240611074846.1.Ieb287c2c3ee3f6d3b0d5f49b29f746b93621749c@changeid Changes in v2: - Removed NULL check since it's not needed since 6.7 - Rebased on ToT. drivers/gpu/drm/mediatek/mtk_drm_drv.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c index b5f605751b0a..de811e2265da 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c @@ -952,6 +952,13 @@ static void mtk_drm_remove(struct platform_device *pdev) of_node_put(private->comp_node[i]); } +static void mtk_drm_shutdown(struct platform_device *pdev) +{ + struct mtk_drm_private *private = platform_get_drvdata(pdev); + + drm_atomic_helper_shutdown(private->drm); +} + static int mtk_drm_sys_prepare(struct device *dev) { struct mtk_drm_private *private = dev_get_drvdata(dev); @@ -983,6 +990,7 @@ static const struct dev_pm_ops mtk_drm_pm_ops = { static struct platform_driver mtk_drm_platform_driver = { .probe = mtk_drm_probe, .remove_new = mtk_drm_remove, + .shutdown = mtk_drm_shutdown, .driver = { .name = "mediatek-drm", .pm = &mtk_drm_pm_ops,