From patchwork Thu Sep 21 19:26:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13394394 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 D52BCE7D0A6 for ; Thu, 21 Sep 2023 19:28:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JmegA+QKNaLR7KtuVxeBbLDQEfA6O8BUNhskKqx+R98=; b=vjPpKChk1E41BK kJrRAsJ9JPKLRuGfoYEEHrwVrska+WptNKCy2FFd3kTBQlwqU62rv2S/R2B16uprDtr9d12Ts7KFD 12/dLNedR8Apq9gFHKQJpIZVXBWgaNzjPXmdNhH7p8/4chAs0SZp07n9D9fppmzGXiavvf3yNLuVJ zdMd/t9PnxzdAVqfHAkqsXJDjM9FKofjOIff7Pm0kOe3yN61SQECShWJXRo/X1sJ7e7H4+/9geXy0 VNaX/+TtM8SJ87x4/OBfD/V9sMT92HQ/mn33y38x0TrKHswxCrD3DoL6uX4zygpH7nKavgZXBmNtU ETWwewItImx3sIOlqq1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qjPLi-006y3q-2H; Thu, 21 Sep 2023 19:28:30 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qjPLe-006y0u-1S for linux-arm-kernel@lists.infradead.org; Thu, 21 Sep 2023 19:28:27 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1c453379020so11153605ad.1 for ; Thu, 21 Sep 2023 12:28:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695324503; x=1695929303; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qhFda07Eo+JhAQAACXr7n7to50ItTosGgo10Du+RGvo=; b=jSvVrEbQvvc678lzm4VNLfrOdKsvMPspuFMbY160F8IZNajO66HsWHb4SXofOVXlch 14vIJtWs51yorlPhMCOIysmZY2DgpA3VABmhH7PC69DF/m/q+SfbVRhiHEt1P32mJK7p 41FD+sKYZwARSxNO9eAptmfLKIGTxhwPw+nXE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695324503; x=1695929303; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qhFda07Eo+JhAQAACXr7n7to50ItTosGgo10Du+RGvo=; b=UmOOB1VvDMP47J1JVHX1eQBfAk35niNClfkOzsv9aUXihfBSjeYKy5gL1AZ01lmHZH HdYApC2/+BgM/ii0vnaMONV0wdlp00nlcioqt/PghoEvk09THplymHVIcHUCDw8z4wdF U06R2Ib++ccXIgiJCyheog8bfJ/azlO2qi0O3S2ts9jDerzpjFfw/txfHbaaSpQlb+ZA FtYin+3gmtKiU7MkWF5NNn+Gl778p/I/X3sIhHuH2k8uxnWSW3FSMczmPFpDm9idtZfr pwnbKjK1B/RTO2tnpvJzO9hoktCFNtb+hDVjhRVNe16djFEWPOAns1fFoCR6tW7V+d+a hzBw== X-Gm-Message-State: AOJu0YzIY4SGdWbdBZbtGbofM+Cgq0B9DH/bgdgPFRxJ8Ty//7z1D6r1 4XrjAjB6HUdYNEOn7W5pLlHEuA== X-Google-Smtp-Source: AGHT+IH0nh1V6SVusdyeEYE29qugLYksEX+ehkYFjSjdH7aYyfOGlzf+vImX/ZKutU0AaIJ59ga9tA== X-Received: by 2002:a17:902:f80a:b0:1c5:deaa:d72e with SMTP id ix10-20020a170902f80a00b001c5deaad72emr1042601plb.30.1695324503552; Thu, 21 Sep 2023 12:28:23 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:e6ed:6d49:f262:8041]) by smtp.gmail.com with ESMTPSA id w8-20020a1709029a8800b001b9f032bb3dsm1892875plp.3.2023.09.21.12.28.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 12:28:22 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , Fei Shao , airlied@gmail.com, angelogioacchino.delregno@collabora.com, chunkuang.hu@kernel.org, daniel@ffwll.ch, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com, p.zabel@pengutronix.de Subject: [RFT PATCH v2 03/12] drm/mediatek: Call drm_atomic_helper_shutdown() at shutdown time Date: Thu, 21 Sep 2023 12:26:46 -0700 Message-ID: <20230921122641.RFT.v2.3.I2b014f90afc4729b6ecc7b5ddd1f6dedcea4625b@changeid> X-Mailer: git-send-email 2.42.0.515.g380fc7ccd1-goog In-Reply-To: <20230921192749.1542462-1-dianders@chromium.org> References: <20230921192749.1542462-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230921_122826_500270_C9217A7B X-CRM114-Status: GOOD ( 20.13 ) 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 we know that if the "drm" pointer in our private data is non-NULL then we need to call drm_atomic_helper_shutdown(). 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. Suggested-by: Maxime Ripard Reviewed-by: Maxime Ripard Reviewed-by: Fei Shao Tested-by: Fei Shao Signed-off-by: Douglas Anderson --- Changes in v2: - Rebased and resolved conflicts. drivers/gpu/drm/mediatek/mtk_drm_drv.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c index d16cc8219105..6bab360c0c1a 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c @@ -919,6 +919,14 @@ 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); + + if (private->drm) + drm_atomic_helper_shutdown(private->drm); +} + static int mtk_drm_sys_prepare(struct device *dev) { struct mtk_drm_private *private = dev_get_drvdata(dev); @@ -950,6 +958,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,