Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2445795rdb; Thu, 21 Sep 2023 21:02:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFw3Co0cA1OtjuwNr2143oCC1+/EcuCbYodmZQiWPJJCvNSylMgMVA3KndWSQAr9QalZsVM X-Received: by 2002:a17:90b:11cd:b0:26d:416a:d9d0 with SMTP id gv13-20020a17090b11cd00b0026d416ad9d0mr7092908pjb.21.1695355347753; Thu, 21 Sep 2023 21:02:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695355347; cv=none; d=google.com; s=arc-20160816; b=b7OWXo0EygqKh//X59GX0KkXBLbTU4rRbQCa//P484BsGq/OvCboCnbRoNLKTiAmRk /IVRYoOi6fOeHFyCf58vp9zCMrAAKKAU5Nr46TuMPnAXyaFLIoOLKve/vi8Vsajj9ubF WTnRz11Qv5y8+3kHm0/elDAr0ypKK+QdqDDzS/Bwn8PXOIkMfuPAiELpzAU3CBdS0E9Q Kl0/PBmuN0u+LBkpMlMDpp0Y6L8w12cpJt8b6JXIb8+cz5uNdCXzzn8Qf/Sv70gurxEA 8VV5Ye0U844F7wxB+p15PIvf6efFP58ujTYkCGa3mNBKa/BVTconTWlbqZGmJjZoGoO8 tjjQ== 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 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id lx8-20020a17090b4b0800b0026b49c1aa50si5913478pjb.111.2023.09.21.21.02.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 21:02:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; 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 2620:137:e000::3:1 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 EC53E83328EE; Thu, 21 Sep 2023 12:49:17 -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 S231143AbjIUTtL (ORCPT + 99 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 ); 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 ; Thu, 21 Sep 2023 12:28:41 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1c465d59719so11303875ad.1 for ; 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 To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , 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: 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:18 -0700 (PDT) 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 --- 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, -- 2.42.0.515.g380fc7ccd1-goog