[RFT,v2,09/12] drm/exynos: Call drm_atomic_helper_shutdown() at shutdown/unbind time
Message ID | 20230921122641.RFT.v2.9.Iea33274908b6b258955f45a8aaf6f5bba24ad6cd@changeid |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5256999vqi; Thu, 21 Sep 2023 18:34:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGFQWpKudd4M6Mc5RhOZ3BeWqyLHhyEq/vbtGfjPow4MymwgT2rPZGD5lOsdSKPbnfLNg02 X-Received: by 2002:a05:6a20:a127:b0:135:38b5:7e4e with SMTP id q39-20020a056a20a12700b0013538b57e4emr7724554pzk.59.1695346461108; Thu, 21 Sep 2023 18:34:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695346461; cv=none; d=google.com; s=arc-20160816; b=Uv+cEOBYPQCFWTPtXOzjzrxC4LYt7uQ07esKNjFoAGBwKeuXTHY/fPk5v8Y3vhVnGD X8NizCMWJ9MgNHzBg9UXKTLoxa9aNLfhJy/B+TnHKDUUe0wOiLkbJkEWKZ0URazU3j3P PcVGSQtYldg68CfOl/hqee0MG7UQBa39AK+hL71j5wxOyvX2ZUoXxkJ4IFxxbrEIfLQQ gILMB+vM2MxEA8pYF9/O/J+7n0tlht8kZFKJIJwB28Xy3HYtHCr8v/Bw6Gln2DNp6ocB GHmm3zCNPqPyZfc+s1v3Oyzyujf2qKLiyrt03gJzn7hf+zoz1/KqPX4zGUq1bZzq3P/c nN0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iA2li7ELqa/hnFznycO86SuLFz051HXi1UIFyEU+SsY=; fh=7RwYEj0fYLncuLc25mzncyIkG8D2UUpxIRGivT/XvxQ=; b=lkIAA/nsHhiduiLz4n7BUmrJO8EoGKs26V9Y+LriyaLTBwu3Sk/Fhj6w7avNCe7Bg+ d3i+ZcqWM7G0M4i2rkUrtLXL0gBe0ppw1yfRIdYF63iN7mPN21BY29ZHBh94A/V4wGQs 6IGo7+ii+D7Nu+f/eir7jUjhEoJ4eJ6QgUMLoO4AdP8AB5lJ53IIDecT4wyY4R6Fx1OU DP3cBHf7wJGsaTECKI2hjZZJ+Tn1fxi0inkB8A+4kCCfxkF6b8WpIj2PIUc+oc6qZh8/ b014HNieoj4fFOZcWilSCVCgATrZNRzD7nARP3LEQk9oqIp76Tk61st2ruLmoDDMLllg FYJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BGmAnpIi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id g15-20020a17090a300f00b00268137c2f12si5185335pjb.2.2023.09.21.18.34.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 18:34:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BGmAnpIi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 525978339393; Thu, 21 Sep 2023 12:49:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231145AbjIUTtL (ORCPT <rfc822;ruipengqi7@gmail.com> + 28 others); Thu, 21 Sep 2023 15:49:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230370AbjIUTso (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 21 Sep 2023 15:48:44 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC3B983CA for <linux-kernel@vger.kernel.org>; Thu, 21 Sep 2023 12:28:41 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1c465d59719so11303875ad.1 for <linux-kernel@vger.kernel.org>; Thu, 21 Sep 2023 12:28:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695324521; x=1695929321; darn=vger.kernel.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=iA2li7ELqa/hnFznycO86SuLFz051HXi1UIFyEU+SsY=; b=BGmAnpIi3iuDy812Osm+g+26341LogmDzQhgtW6SO6RxhNh2/Xxh9zdGfTP1dghyfu mwBgbXni0d0hUX2T+0307DGHcjWJjqjCHyQ6333ddP7sLjutHJ8eOWH0AU8ZqzyA5uwe 0tQCgIWsVbv8HjmWYojERkl+ck9leykdb9Cyg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695324521; x=1695929321; 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=iA2li7ELqa/hnFznycO86SuLFz051HXi1UIFyEU+SsY=; b=qGZZ1+je8XixjGWzzswGSmmkd4PM6L1scbdj1MgjTF2D1azUepE60o88jDEE+OSSzW dDHTlO0NjaDWSPlvLLsLZ7YZcA2+p+9jPDYT5xXUJe87Qoyyga5KbsbpskNQWgt49ie+ CVQVvD+WRefIIWg/0vwJJw+wEQYn1BBdWbvMTVPaY/aOODinlmfCZOS0S9mIL8zLv5eN eOevMoQ1KzxGosDpzXGTX5W9zMluRdtbXn8+lMG936sJ42TCW4BvW8gV5AUWsui9Dzca o0iIZu3naCOoCGekP16mqS/6to/AXhwO77LTN33Er/VPOtY2K4ASxQsj1JDUxS3BjCFz JKfw== X-Gm-Message-State: AOJu0YxIFHs9dAq5qeolah9ybydKsHz+sN9mmOBM99vI+OLPblN99Ofn c5fmDKSqeayZAJJyUeK9bmOJgA== X-Received: by 2002:a17:903:1205:b0:1c4:638:fff4 with SMTP id l5-20020a170903120500b001c40638fff4mr6441686plh.17.1695324521206; Thu, 21 Sep 2023 12:28:41 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 12:28:40 -0700 (PDT) From: Douglas Anderson <dianders@chromium.org> To: dri-devel@lists.freedesktop.org, Maxime Ripard <mripard@kernel.org> Cc: Douglas Anderson <dianders@chromium.org>, airlied@gmail.com, alim.akhtar@samsung.com, daniel@ffwll.ch, inki.dae@samsung.com, krzysztof.kozlowski@linaro.org, kyungmin.park@samsung.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, sw0312.kim@samsung.com Subject: [RFT PATCH v2 09/12] drm/exynos: Call drm_atomic_helper_shutdown() at shutdown/unbind time Date: Thu, 21 Sep 2023 12:26:52 -0700 Message-ID: <20230921122641.RFT.v2.9.Iea33274908b6b258955f45a8aaf6f5bba24ad6cd@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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 21 Sep 2023 12:49:30 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777699610787930076 X-GMAIL-MSGID: 1777699610787930076 |
Series |
drm: call drm_atomic_helper_shutdown() at the right times
|
|
Commit Message
Doug Anderson
Sept. 21, 2023, 7:26 p.m. UTC
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 <mripard@kernel.org> Reviewed-by: Maxime Ripard <mripard@kernel.org> Signed-off-by: Douglas Anderson <dianders@chromium.org> --- This commit is only compile-time tested. (no changes since v1) drivers/gpu/drm/exynos/exynos_drm_drv.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
Comments
On 21.09.2023 21:26, Douglas Anderson wrote: > 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 <mripard@kernel.org> > Reviewed-by: Maxime Ripard <mripard@kernel.org> > Signed-off-by: Douglas Anderson <dianders@chromium.org> Seems to be working fine on all my test Exynos-based boards with display. Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com> > --- > This commit is only compile-time tested. > > (no changes since v1) > > 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 8399256cb5c9..5380fb6c55ae 100644 > --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c > +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c > @@ -300,6 +300,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); > > @@ -313,6 +314,7 @@ static void exynos_drm_unbind(struct device *dev) > drm_dev_unregister(drm); > > drm_kms_helper_poll_fini(drm); > + drm_atomic_helper_shutdown(drm); > > component_unbind_all(drm->dev, drm); > drm_mode_config_cleanup(drm); > @@ -350,9 +352,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, Best regards
Thanks for testing. :) Acked-by : Inki Dae <inki.dae@samsung.com> 2023년 9월 22일 (금) 오후 3:00, Marek Szyprowski <m.szyprowski@samsung.com>님이 작성: > > > On 21.09.2023 21:26, Douglas Anderson wrote: > > 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 <mripard@kernel.org> > > Reviewed-by: Maxime Ripard <mripard@kernel.org> > > Signed-off-by: Douglas Anderson <dianders@chromium.org> > > Seems to be working fine on all my test Exynos-based boards with display. > > Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> > > Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com> > > > --- > > This commit is only compile-time tested. > > > > (no changes since v1) > > > > 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 8399256cb5c9..5380fb6c55ae 100644 > > --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c > > +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c > > @@ -300,6 +300,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); > > > > @@ -313,6 +314,7 @@ static void exynos_drm_unbind(struct device *dev) > > drm_dev_unregister(drm); > > > > drm_kms_helper_poll_fini(drm); > > + drm_atomic_helper_shutdown(drm); > > > > component_unbind_all(drm->dev, drm); > > drm_mode_config_cleanup(drm); > > @@ -350,9 +352,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, > > Best regards > -- > Marek Szyprowski, PhD > Samsung R&D Institute Poland >
Hi, On Thu, Oct 5, 2023 at 7:20 PM Inki Dae <daeinki@gmail.com> wrote: > > Thanks for testing. :) > > Acked-by : Inki Dae <inki.dae@samsung.com> Inki: does that mean you'd like this to go through drm-misc? I'm happy to do that, but there are no dependencies here so this could easily go through your tree. > 2023년 9월 22일 (금) 오후 3:00, Marek Szyprowski <m.szyprowski@samsung.com>님이 작성: > > > > > > On 21.09.2023 21:26, Douglas Anderson wrote: > > > 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 <mripard@kernel.org> > > > Reviewed-by: Maxime Ripard <mripard@kernel.org> > > > Signed-off-by: Douglas Anderson <dianders@chromium.org> > > > > Seems to be working fine on all my test Exynos-based boards with display. > > > > Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> > > > > Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com> > > > > > --- > > > This commit is only compile-time tested. > > > > > > (no changes since v1) > > > > > > 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 8399256cb5c9..5380fb6c55ae 100644 > > > --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c > > > +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c > > > @@ -300,6 +300,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); > > > > > > @@ -313,6 +314,7 @@ static void exynos_drm_unbind(struct device *dev) > > > drm_dev_unregister(drm); > > > > > > drm_kms_helper_poll_fini(drm); > > > + drm_atomic_helper_shutdown(drm); > > > > > > component_unbind_all(drm->dev, drm); > > > drm_mode_config_cleanup(drm); > > > @@ -350,9 +352,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, > > > > Best regards > > -- > > Marek Szyprowski, PhD > > Samsung R&D Institute Poland > >
Hi, 2023년 10월 6일 (금) 오후 10:51, Doug Anderson <dianders@chromium.org>님이 작성: > > Hi, > > On Thu, Oct 5, 2023 at 7:20 PM Inki Dae <daeinki@gmail.com> wrote: > > > > Thanks for testing. :) > > > > Acked-by : Inki Dae <inki.dae@samsung.com> > > Inki: does that mean you'd like this to go through drm-misc? I'm happy > to do that, but there are no dependencies here so this could easily go > through your tree. Ah, you are right. No dependency here. I will pick it up. Thanks, Inki Dae > > > > 2023년 9월 22일 (금) 오후 3:00, Marek Szyprowski <m.szyprowski@samsung.com>님이 작성: > > > > > > > > > On 21.09.2023 21:26, Douglas Anderson wrote: > > > > 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 <mripard@kernel.org> > > > > Reviewed-by: Maxime Ripard <mripard@kernel.org> > > > > Signed-off-by: Douglas Anderson <dianders@chromium.org> > > > > > > Seems to be working fine on all my test Exynos-based boards with display. > > > > > > Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> > > > > > > Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com> > > > > > > > --- > > > > This commit is only compile-time tested. > > > > > > > > (no changes since v1) > > > > > > > > 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 8399256cb5c9..5380fb6c55ae 100644 > > > > --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c > > > > +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c > > > > @@ -300,6 +300,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); > > > > > > > > @@ -313,6 +314,7 @@ static void exynos_drm_unbind(struct device *dev) > > > > drm_dev_unregister(drm); > > > > > > > > drm_kms_helper_poll_fini(drm); > > > > + drm_atomic_helper_shutdown(drm); > > > > > > > > component_unbind_all(drm->dev, drm); > > > > drm_mode_config_cleanup(drm); > > > > @@ -350,9 +352,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, > > > > > > Best regards > > > -- > > > Marek Szyprowski, PhD > > > Samsung R&D Institute Poland > > >
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index 8399256cb5c9..5380fb6c55ae 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c @@ -300,6 +300,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); @@ -313,6 +314,7 @@ static void exynos_drm_unbind(struct device *dev) drm_dev_unregister(drm); drm_kms_helper_poll_fini(drm); + drm_atomic_helper_shutdown(drm); component_unbind_all(drm->dev, drm); drm_mode_config_cleanup(drm); @@ -350,9 +352,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,