From patchwork Wed Jun 12 22:23:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13695623 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 73BDBC27C53 for ; Wed, 12 Jun 2024 22:24:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 332A710E930; Wed, 12 Jun 2024 22:24:50 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="fzaSwGOG"; dkim-atps=neutral Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by gabe.freedesktop.org (Postfix) with ESMTPS id D356E10E92C for ; Wed, 12 Jun 2024 22:24:46 +0000 (UTC) Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2c3050f4c50so268347a91.0 for ; Wed, 12 Jun 2024 15:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718231085; x=1718835885; darn=lists.freedesktop.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=eoxHQFAxTEKhFcdkzLVS9yQebfe3JVmywDzGyzZKvTc=; b=fzaSwGOGlkozl+Ld+4V9RyVoCs4QZvhYEB6lC0KPbRND4CUPW8627crr5aw0QzvzvO ohrDlYqKXDXwTTeiIC07K8jP6OP/mULkyYp2j5KYq0JDjvmPI1WGB09DnMzliQO5pSFj M/QZ6/osePnKf8NiRMiz1GyWUsgjTrRJu5MAo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718231085; x=1718835885; 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=eoxHQFAxTEKhFcdkzLVS9yQebfe3JVmywDzGyzZKvTc=; b=cD8o19BSWaj8osIqP3UZ3xEzEayDZkXmbgtTbpV4AGDbGFEq6T2Yxeesp04baUYevx hfs0YG5F5iVymk6b3aNDdimOKFlll5lA1gqDDbF264MwQgUiFnGtrutBQ7XA+CF9JKbW 5Ig6P30N8M6Xua39SWoxv1D2zxMOGOU2y1Ch7oNDdfXuPnc1e2Ak9NXeDrMl3IxNdj2b jytKLsnPQT+kc+fhjikIiX+htPPJ2R7J7YiS1ylV9zqVXWzoovR8fEvUGgkBwd74YOMW fAdBOwqXbkXt1k8IpMzsHnR5gn7klV4l/LXcvBV07V1vz0yn/2szV7IAkQoV5AjQz0E6 bTzA== X-Gm-Message-State: AOJu0Yx+n10uhH7rTSuT3l7UDfqBEcfEppzOdJIxG3pUDPHf1l/CeE3f t0k7VUL05XCrbVNE6StQwcWeyjko4LH2TojmjKyytaBD5ev7ZACa7CI3ozqLbyvbxrnRXbgweEs = X-Google-Smtp-Source: AGHT+IGoKR+i8ngPgUDnHIH0M19hh39IIq/3uUrBXIU2bl3u/ZzKf7epk3yumtBMdDz0FOKiHNHMNA== X-Received: by 2002:a17:90b:17ce:b0:2c4:aa69:c4bc with SMTP id 98e67ed59e1d1-2c4aa69c57bmr2820224a91.19.1718231085222; Wed, 12 Jun 2024 15:24:45 -0700 (PDT) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:2816:6a42:9074:18cc]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f6f30acda9sm87914105ad.198.2024.06.12.15.24.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 15:24:43 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , Anitha Chrisanthus , Daniel Vetter , David Airlie , Edmund Dea , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/8] drm/kmb: Call drm_atomic_helper_shutdown() at shutdown time Date: Wed, 12 Jun 2024 15:23:41 -0700 Message-ID: <20240612152336.v2.1.I20cb02bafa7c2368e4bd579df0716eb62a3a21bf@changeid> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog In-Reply-To: <20240612222435.3188234-1-dianders@chromium.org> References: <20240612222435.3188234-1-dianders@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. 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/kmb/kmb_drv.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/kmb/kmb_drv.c b/drivers/gpu/drm/kmb/kmb_drv.c index 169b83987ce2..73d82b4d33e7 100644 --- a/drivers/gpu/drm/kmb/kmb_drv.c +++ b/drivers/gpu/drm/kmb/kmb_drv.c @@ -475,6 +475,11 @@ static void kmb_remove(struct platform_device *pdev) drm_atomic_helper_shutdown(drm); } +static void kmb_shutdown(struct platform_device *pdev) +{ + drm_atomic_helper_shutdown(platform_get_drvdata(pdev)); +} + static int kmb_probe(struct platform_device *pdev) { struct device *dev = get_device(&pdev->dev); @@ -621,6 +626,7 @@ static SIMPLE_DEV_PM_OPS(kmb_pm_ops, kmb_pm_suspend, kmb_pm_resume); static struct platform_driver kmb_platform_driver = { .probe = kmb_probe, .remove_new = kmb_remove, + .shutdown = kmb_shutdown, .driver = { .name = "kmb-drm", .pm = &kmb_pm_ops, From patchwork Wed Jun 12 22:23:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13695624 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 9B998C27C53 for ; Wed, 12 Jun 2024 22:24:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3BA4510E92D; Wed, 12 Jun 2024 22:24:56 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="efq4N2OJ"; dkim-atps=neutral Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by gabe.freedesktop.org (Postfix) with ESMTPS id 68EF410E931 for ; Wed, 12 Jun 2024 22:24:50 +0000 (UTC) Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1f7274a453bso3599395ad.2 for ; Wed, 12 Jun 2024 15:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718231088; x=1718835888; darn=lists.freedesktop.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=aR6S2QVtzFM/jxymlLuEpObYuJIES6ks6qhmMWCUZhU=; b=efq4N2OJeqXbR9yADwA5WKDs8oMAajqVjFopRZb+nA2RTz/USJyZXC70CeagpVwIrn RwcXb/EX+yDY8wa9nhrfODhjqmtlKiNKCQyYn0JheHrd4CTyUxDtzEh3E70RukoR+Fxb Pt+lRxrhzC16DCeK7Rdqmcc5G5viaTP7Vqg7g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718231088; x=1718835888; 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=aR6S2QVtzFM/jxymlLuEpObYuJIES6ks6qhmMWCUZhU=; b=HNouVjkEyxqKC0/08wJoT6i4PE5OtvXOtmf1p5VBr3R1tmOTOeo3wYt0ZW97Bg5mIi INZdEDuvd+DPkRQoQ60E+msOD771abZGyE82sRde101p2BudL7qS7LGFPqKeH/kn1OjP x7A5Xe5xLNHNwxveJBIOgJR0x/96SJNXeAzqCZCL7oiap5xBqkvmBELrUPvMWDZGT56n CgRxOljwIbSat31/j63Ivz2NayyJoDueobpwPWGquSqD2IaHCCgd+OBKgTYKqRmkGjbu Xm2khhqmZp2mBjzQAGMtbxLcCMf4H+rhJc1z7JwbrQUboEMO425j1JUa62olE91x+NU1 UMow== X-Gm-Message-State: AOJu0Yy29FQKnQmFLqz66Kx8a11lQ27XUJGIjwUNmoTaHnFF31902w4S tw3O9ZNVk3Bq+q7Q9Jk2IEneJtMicm0UUwrITqaF0OXY8BxB7ocH4Qlqbw7P+Ry8jVWuxLxxX+Q = X-Google-Smtp-Source: AGHT+IHKCE/3t+anxzcGR/vWhd2u/e5A1hvjZyotl4hoC22LuX9W+2G5IFPLfxJ6lZv8cQy/absvjg== X-Received: by 2002:a17:902:e844:b0:1f6:225e:67a1 with SMTP id d9443c01a7336-1f83b70eaa3mr34942835ad.56.1718231088645; Wed, 12 Jun 2024 15:24:48 -0700 (PDT) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:2816:6a42:9074:18cc]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f6f30acda9sm87914105ad.198.2024.06.12.15.24.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 15:24:47 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , Daniel Vetter , Danilo Krummrich , David Airlie , Karol Herbst , Lyude Paul , linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org Subject: [PATCH v2 2/8] drm/nouveau: Call drm_atomic_helper_shutdown() or equiv at shutdown time Date: Wed, 12 Jun 2024 15:23:42 -0700 Message-ID: <20240612152336.v2.2.Ie7588ec6e0f93e8bc700e76b265ad1a7ad6b15ad@changeid> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog In-Reply-To: <20240612222435.3188234-1-dianders@chromium.org> References: <20240612222435.3188234-1-dianders@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Based on grepping through the source code this driver appears to be missing a call to drm_atomic_helper_shutdown() (or drm_helper_force_disable_all() if not using atomic) 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. Suggested-by: Maxime Ripard Reviewed-by: Maxime Ripard Signed-off-by: Douglas Anderson --- This commit is only compile-time tested. I made my best guess about how to fit this into the existing code. If someone wishes a different style, please yell. (no changes since v1) drivers/gpu/drm/nouveau/nouveau_display.c | 9 +++++++++ drivers/gpu/drm/nouveau/nouveau_display.h | 1 + drivers/gpu/drm/nouveau/nouveau_drm.c | 13 +++++++++++++ drivers/gpu/drm/nouveau/nouveau_drv.h | 1 + drivers/gpu/drm/nouveau/nouveau_platform.c | 6 ++++++ 5 files changed, 30 insertions(+) diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c index d4725a968827..15da55c382f1 100644 --- a/drivers/gpu/drm/nouveau/nouveau_display.c +++ b/drivers/gpu/drm/nouveau/nouveau_display.c @@ -645,6 +645,15 @@ nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime) disp->fini(dev, runtime, suspend); } +void +nouveau_display_shutdown(struct drm_device *dev) +{ + if (drm_drv_uses_atomic_modeset(dev)) + drm_atomic_helper_shutdown(dev); + else + drm_helper_force_disable_all(dev); +} + static void nouveau_display_create_properties(struct drm_device *dev) { diff --git a/drivers/gpu/drm/nouveau/nouveau_display.h b/drivers/gpu/drm/nouveau/nouveau_display.h index 2ab2ddb1eadf..9df62e833cda 100644 --- a/drivers/gpu/drm/nouveau/nouveau_display.h +++ b/drivers/gpu/drm/nouveau/nouveau_display.h @@ -47,6 +47,7 @@ void nouveau_display_destroy(struct drm_device *dev); int nouveau_display_init(struct drm_device *dev, bool resume, bool runtime); void nouveau_display_hpd_resume(struct drm_device *dev); void nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime); +void nouveau_display_shutdown(struct drm_device *dev); int nouveau_display_suspend(struct drm_device *dev, bool runtime); void nouveau_display_resume(struct drm_device *dev, bool runtime); int nouveau_display_vblank_enable(struct drm_crtc *crtc); diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index a947e1d5f309..b41154c9b9cc 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -894,6 +894,18 @@ nouveau_drm_remove(struct pci_dev *pdev) pci_disable_device(pdev); } +void +nouveau_drm_device_shutdown(struct drm_device *dev) +{ + nouveau_display_shutdown(dev); +} + +static void +nouveau_drm_shutdown(struct pci_dev *pdev) +{ + nouveau_drm_device_shutdown(pci_get_drvdata(pdev)); +} + static int nouveau_do_suspend(struct drm_device *dev, bool runtime) { @@ -1361,6 +1373,7 @@ nouveau_drm_pci_driver = { .id_table = nouveau_drm_pci_table, .probe = nouveau_drm_probe, .remove = nouveau_drm_remove, + .shutdown = nouveau_drm_shutdown, .driver.pm = &nouveau_pm_ops, }; diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index 25fca98a20bc..78a91686006b 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -327,6 +327,7 @@ struct drm_device * nouveau_platform_device_create(const struct nvkm_device_tegra_func *, struct platform_device *, struct nvkm_device **); void nouveau_drm_device_remove(struct drm_device *dev); +void nouveau_drm_device_shutdown(struct drm_device *dev); #define NV_PRINTK(l,c,f,a...) do { \ struct nouveau_cli *_cli = (c); \ diff --git a/drivers/gpu/drm/nouveau/nouveau_platform.c b/drivers/gpu/drm/nouveau/nouveau_platform.c index bf2dc7567ea4..511f3a0c6ee9 100644 --- a/drivers/gpu/drm/nouveau/nouveau_platform.c +++ b/drivers/gpu/drm/nouveau/nouveau_platform.c @@ -49,6 +49,11 @@ static void nouveau_platform_remove(struct platform_device *pdev) nouveau_drm_device_remove(dev); } +static void nouveau_platform_shutdown(struct platform_device *pdev) +{ + nouveau_drm_device_shutdown(platform_get_drvdata(pdev)); +} + #if IS_ENABLED(CONFIG_OF) static const struct nvkm_device_tegra_func gk20a_platform_data = { .iommu_bit = 34, @@ -93,4 +98,5 @@ struct platform_driver nouveau_platform_driver = { }, .probe = nouveau_platform_probe, .remove_new = nouveau_platform_remove, + .shutdown = nouveau_platform_shutdown, }; From patchwork Wed Jun 12 22:23:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13695627 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 4B30CC27C53 for ; Wed, 12 Jun 2024 22:25:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 129F210E935; Wed, 12 Jun 2024 22:25:09 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ocwlUoYB"; dkim-atps=neutral Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1916910E92D for ; Wed, 12 Jun 2024 22:24:53 +0000 (UTC) Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1f44b594deeso3822095ad.2 for ; Wed, 12 Jun 2024 15:24:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718231092; x=1718835892; darn=lists.freedesktop.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=zpmQn9g7cRN67S7SSaIwDQvRoODph3OOMStNp4IKliA=; b=ocwlUoYB6WdUqlX7qyvq1Im0h8Z3wYQ07vg5CuHn/NQ0AfHE6/1rcwcIJbtahWjJzH mHmKJYz71slINXbJU8XDvVjBZ5989PR4IzIBi3NmziqCxb2xzlJ04fw2r0PHkvzdlvdo kpanVBXA3A3lIzX7A3w4lEbsO98iSWNO3EZIw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718231092; x=1718835892; 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=zpmQn9g7cRN67S7SSaIwDQvRoODph3OOMStNp4IKliA=; b=lqc32YCAPZK5udWk32dd9+9148sgeF1i163DWlSv+lHL8HXMP9/0axmPEgBedlsIdd /qkF1+z7zuo6tJVXJU52eSXvTTCYBKc87O7DpLAFEhOpf4jiJDaMwE5NTBLqTZ4uylFY MLni17fPfSeFQmV5YhIvxUM64Kgz+zk9+iqvb4fOolt2yfteglxGCy+MQvaXql/Sbj9Y 7RSIowctUMMwOwZURXx2Zn6SXxDlJdy98jzWJw0S9emu1iN+M1jfUH6EncKJglz4IDJo Jhg5l2O6f++Lu2Ca6cHbq24qR8nD77x6+mWoutB2HQayuKblm4dS/GDtES524Cwi2sbj iZEw== X-Gm-Message-State: AOJu0YxmuFzIaKq+3HwR6nTKx+eMc9M94PfNOnuKVS38JaZ7e5Xh8ejM F1UdzpOwBXUpbZ40jt6xpLcHUIuO5fj4RXmolaa6fwl3cVTlvgc4jvEoOuqn9Omnj/5NDkgSwAU = X-Google-Smtp-Source: AGHT+IEw5ujOqNAyOIoLP8KuspnMOnAtd7Hh5dDQKTX8TBm9/CzqJoj2TsY6aejmqFawCaR9pN4o7w== X-Received: by 2002:a17:902:e750:b0:1f7:2a95:f2f8 with SMTP id d9443c01a7336-1f83b55e32cmr41999395ad.14.1718231091823; Wed, 12 Jun 2024 15:24:51 -0700 (PDT) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:2816:6a42:9074:18cc]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f6f30acda9sm87914105ad.198.2024.06.12.15.24.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 15:24:51 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , Daniel Vetter , David Airlie , Jonathan Hunter , Mikko Perttunen , Thierry Reding , linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH v2 3/8] drm/tegra: Call drm_atomic_helper_shutdown() at shutdown time Date: Wed, 12 Jun 2024 15:23:43 -0700 Message-ID: <20240612152336.v2.3.Ifb4450979b62976fd5a98847dade2e5b377d47c8@changeid> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog In-Reply-To: <20240612222435.3188234-1-dianders@chromium.org> References: <20240612222435.3188234-1-dianders@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. Suggested-by: Maxime Ripard Reviewed-by: Maxime Ripard Signed-off-by: Douglas Anderson Acked-by: Thierry Reding --- This commit is only compile-time tested. (no changes since v1) drivers/gpu/drm/tegra/drm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 03d1c76aec2d..d9f0728c3afd 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -1330,6 +1330,11 @@ static int host1x_drm_remove(struct host1x_device *dev) return 0; } +static void host1x_drm_shutdown(struct host1x_device *dev) +{ + drm_atomic_helper_shutdown(dev_get_drvdata(&dev->dev)); +} + #ifdef CONFIG_PM_SLEEP static int host1x_drm_suspend(struct device *dev) { @@ -1398,6 +1403,7 @@ static struct host1x_driver host1x_drm_driver = { }, .probe = host1x_drm_probe, .remove = host1x_drm_remove, + .shutdown = host1x_drm_shutdown, .subdevs = host1x_drm_subdevs, }; From patchwork Wed Jun 12 22:23: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: 13695625 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 39C17C27C77 for ; Wed, 12 Jun 2024 22:25:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6CF1E10E932; Wed, 12 Jun 2024 22:25:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ByBo8gxy"; dkim-atps=neutral Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9968710E932 for ; Wed, 12 Jun 2024 22:24:54 +0000 (UTC) Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-6e9f52e99c2so269642a12.1 for ; Wed, 12 Jun 2024 15:24:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718231093; x=1718835893; darn=lists.freedesktop.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=cG9YsnvV0dqFs63XW3w7FcDwXhGHgBYJnS7/vNMDsUI=; b=ByBo8gxyw7cbIrmx/A4eVeXJe3Se74vbY7a0Pr2YGvblMSTr/wyrQNsfRK06vzSFZ8 rQ/gmlO8iFE3GNVDoMxga87f0dEMAkHceFPrm9f73e9WeauispjlRqRvQ1jJBHvWuO44 kLljK/Smp61Uwc4bNw8vCYfA3VRLLXbqxY4Vc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718231093; x=1718835893; 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=cG9YsnvV0dqFs63XW3w7FcDwXhGHgBYJnS7/vNMDsUI=; b=e9MUur7tf8o/MDWJljJqudoXmGTb9KHUdwhdTvisnCjHc+h0E4iOMfRfFscW68DNi8 l+8eQeNKT0Eb8ELVaEBWSVctwyyNjDtDjWDm2hmIJJoMd7MvRo5x/SoK86xyWTrFIMVm p2NiX7XIv4zBdLv8+RRYZVuMhgXZd3G4BeP6BwNajamxhd7jlGhNWvc3uqRaWGCTARt+ 4SuXndsn9wRQ9YnMF+pu3NIKZLcbYqaBhF7YrE/EovV+mteW0WNTlVmj7FSMOP/u8Gfg jbijf3r7UPJV8zbimtchaE441xKe3kCYow9EUAC0hAaRPNLffoqGlG63Uvp07mznZBUG c7bA== X-Gm-Message-State: AOJu0Yzm7o/iQccG8fo2n939EIbKTfh5WuFSJHekA9ua0vAxeGgJgnHX ggEEa2kVLszfDm2+EmIU9bJ7tUhVSWweLXdBjZkGJDNeQ1fTH2hqCsHm5mnNy4z/uIWqOFt7TH8 = X-Google-Smtp-Source: AGHT+IGI/wCAa9iSAbUyULm8uaZzcZmzyBGn6eSxHSxLyKPWYAONixriz1scQsX3eltdmrQaRYhqHw== X-Received: by 2002:a17:903:1cd:b0:1f7:234b:4f28 with SMTP id d9443c01a7336-1f83b60954cmr37501915ad.25.1718231093331; Wed, 12 Jun 2024 15:24:53 -0700 (PDT) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:2816:6a42:9074:18cc]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f6f30acda9sm87914105ad.198.2024.06.12.15.24.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 15:24:52 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , Alexey Brodkin , Daniel Vetter , David Airlie , Maarten Lankhorst , Thomas Zimmermann , linux-kernel@vger.kernel.org Subject: [PATCH v2 4/8] drm/arcpgu: Call drm_atomic_helper_shutdown() at shutdown time Date: Wed, 12 Jun 2024 15:23:44 -0700 Message-ID: <20240612152336.v2.4.I8a0a246fea222059881d01a8fff2adcf7ef3d7a4@changeid> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog In-Reply-To: <20240612222435.3188234-1-dianders@chromium.org> References: <20240612222435.3188234-1-dianders@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. 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/tiny/arcpgu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c index 4f8f3172379e..85b21f5aac55 100644 --- a/drivers/gpu/drm/tiny/arcpgu.c +++ b/drivers/gpu/drm/tiny/arcpgu.c @@ -412,6 +412,11 @@ static void arcpgu_remove(struct platform_device *pdev) arcpgu_unload(drm); } +static void arcpgu_shutdown(struct platform_device *pdev) +{ + drm_atomic_helper_shutdown(platform_get_drvdata(pdev)); +} + static const struct of_device_id arcpgu_of_table[] = { {.compatible = "snps,arcpgu"}, {} @@ -422,6 +427,7 @@ MODULE_DEVICE_TABLE(of, arcpgu_of_table); static struct platform_driver arcpgu_platform_driver = { .probe = arcpgu_probe, .remove_new = arcpgu_remove, + .shutdown = arcpgu_shutdown, .driver = { .name = "arcpgu", .of_match_table = arcpgu_of_table, From patchwork Wed Jun 12 22:23:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13695626 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 13FBFC27C53 for ; Wed, 12 Jun 2024 22:25:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EBDAE10E933; Wed, 12 Jun 2024 22:25:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ZBVFP8xZ"; dkim-atps=neutral Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by gabe.freedesktop.org (Postfix) with ESMTPS id 34C4D10E931 for ; Wed, 12 Jun 2024 22:24:57 +0000 (UTC) Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1f717b3f2d8so10880495ad.1 for ; Wed, 12 Jun 2024 15:24:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718231095; x=1718835895; darn=lists.freedesktop.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=moW+vuchPBzwhuLa9D90CyqT2Qzy5nveIbqumh1IepQ=; b=ZBVFP8xZZ8bHnyRl4zP5ISh8MHTyv6qmVG16b/1dsqLLS6Sd4n8gx311h945zMYt+z y7DPTgTVAAjfOGo9LzsoW8U0NYp0a3agzq9s3vKUjt5mIA9QrWr8POzFcQnPzBHQM84V U6j+joS4dOSSSOzI3bIf88pWYfo+E/t9vMNBc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718231095; x=1718835895; 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=moW+vuchPBzwhuLa9D90CyqT2Qzy5nveIbqumh1IepQ=; b=BXyWL/1Ay8tXKP/kv5ayCaecClDidKWSq59EU2fg1k8jzE4M7ZujUOChgfX6s8LxzP 12Fp9L4JgDmi35GRtKt1j5OLqEPBOc3isnInmHkf4MwhHWz3jK+aNs1SgcwFcTmW+fB1 waIPhTLcpk0I2dU4tyL06XmG1/yKzqT8p9hINOmijIUNZN31TYW7eJ4xv+L3P8Qm9f58 XIffMvaEwKFx+YKAHMya/Kdme3didevianJHcC346AIloe+uMWI7cRucIsBOZ6JwJiER nWbTa0vU5HPYlBNSsxKCT+wGVuDgQ/mBmO0Xv6TPaQt21YpuwGpmni+v0AJWVZo1yxPL PG2w== X-Gm-Message-State: AOJu0YwgSZZN+gS49XyJ6m6xbf4Sd3XnCcbCVpPCagIVAtFxUA/ghzw/ jBMsqdcugyrGcBLHmOVtbUvrTg6OFRQ+562PTaSRuLfVOmvJ2Ohfmj9pHpZOX3JZN4k0jQvMYBM = X-Google-Smtp-Source: AGHT+IHBAtSsNRsCiipiSSmdPtxdIvkO4DzXuXDcDLjyV0KBNSghL6hedDrLySr08oXr7dCUGUp9XA== X-Received: by 2002:a17:902:fc46:b0:1f2:fee2:82ed with SMTP id d9443c01a7336-1f84e425a39mr11905935ad.30.1718231095482; Wed, 12 Jun 2024 15:24:55 -0700 (PDT) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:2816:6a42:9074:18cc]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f6f30acda9sm87914105ad.198.2024.06.12.15.24.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 15:24:54 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , Baolin Wang , Chunyan Zhang , Daniel Vetter , David Airlie , Kieran Bingham , Maarten Lankhorst , Orson Zhai , Rob Herring , Sam Ravnborg , Steven Price , Thomas Zimmermann , linux-kernel@vger.kernel.org Subject: [PATCH v2 5/8] drm/sprd: Call drm_atomic_helper_shutdown() at remove time Date: Wed, 12 Jun 2024 15:23:45 -0700 Message-ID: <20240612152336.v2.5.I7a2dd349cb52bae53280d0a49e22cc27b923274b@changeid> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog In-Reply-To: <20240612222435.3188234-1-dianders@chromium.org> References: <20240612222435.3188234-1-dianders@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Based on grepping through the source code, this driver appears to be missing a call to drm_atomic_helper_shutdown() at remove time. Let's add it. The fact that we should call drm_atomic_helper_shutdown() in the case of OS driver remove comes straight out of the kernel doc "driver instance overview" in drm_drv.c. While at it, let's also fix it so that if the driver's bind fails or if a driver gets unbound that the drvdata gets set to NULL. This will make sure we can't get confused during a later shutdown(). Suggested-by: Maxime Ripard Reviewed-by: Maxime Ripard Signed-off-by: Douglas Anderson --- This commit is only compile-time tested. While making this patch, I noticed that the bind() function of this driver is using "devm". That's probably a bug. As per kernel docs [1] "the lifetime of the aggregate driver does not align with any of the underlying struct device instances. Therefore devm cannot be used and all resources acquired or allocated in this callback must be explicitly released in the unbind callback". Fixing that is outside the scope of this commit. [1] https://docs.kernel.org/driver-api/component.html (no changes since v1) drivers/gpu/drm/sprd/sprd_drm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sprd/sprd_drm.c b/drivers/gpu/drm/sprd/sprd_drm.c index a74cd0caf645..d4453430dd1f 100644 --- a/drivers/gpu/drm/sprd/sprd_drm.c +++ b/drivers/gpu/drm/sprd/sprd_drm.c @@ -114,6 +114,7 @@ static int sprd_drm_bind(struct device *dev) drm_kms_helper_poll_fini(drm); err_unbind_all: component_unbind_all(drm->dev, drm); + platform_set_drvdata(pdev, NULL); return ret; } @@ -122,10 +123,11 @@ static void sprd_drm_unbind(struct device *dev) struct drm_device *drm = dev_get_drvdata(dev); drm_dev_unregister(drm); - drm_kms_helper_poll_fini(drm); + drm_atomic_helper_shutdown(drm); component_unbind_all(drm->dev, drm); + dev_set_drvdata(dev, NULL); } static const struct component_master_ops drm_component_ops = { From patchwork Wed Jun 12 22:23:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13695628 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 08941C27C77 for ; Wed, 12 Jun 2024 22:25:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E3B3E10E934; Wed, 12 Jun 2024 22:25:35 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="LBOxyrOC"; dkim-atps=neutral Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by gabe.freedesktop.org (Postfix) with ESMTPS id D443810E933 for ; Wed, 12 Jun 2024 22:24:58 +0000 (UTC) Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-6eab07ae82bso270609a12.3 for ; Wed, 12 Jun 2024 15:24:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718231098; x=1718835898; darn=lists.freedesktop.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=eCLxsF8rhWGGZr+97E/MrTNjYe+fnMrZ7mNGuOaWySo=; b=LBOxyrOChXWKWl2WidOI0fx+sXFaXiL1ZYn108zAObifZMZmejAMLVixqxM1l8rJAA UL6gf/uomRAoVJnkbR58DJHlFnl23t3Ouk2oIF7K1gybcOGJPAq/RlD4YOznRCYBTgJ3 iyUwiKhMHSSvRBqRAn1tl1V4bWRy0/m49rfSA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718231098; x=1718835898; 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=eCLxsF8rhWGGZr+97E/MrTNjYe+fnMrZ7mNGuOaWySo=; b=AFCOP0Wwq91+aYvKrCuTXpPuh329GFpR6zI5tvdRnO4M6K4Cr+cSbNovCuZRiAXEHY EVfmh9hT53mM93Urygw0z6kCelEwbEsv8lq7Wy/lMdGZDMNYe64eTyRHRrMrcCB3JuvG fAX890aBK4yR7PKLYOTSxNO4C/Ks1HOKMaxVga4dwpfSBx+8tYIjYVX32AYUGENAd/QN t7r69DbvA/VujKr0zL9XW/pRGDqQWXoGWB0mGzKCPu7+884wBJnfg3Vd12ii2VaG+OUf A7Nils0V6VlIt3CvRmNPDeF6ROFoDYF/LPiMkTlV3oiYBESacAiDQY5up5QVhxIUiIIz JHlA== X-Gm-Message-State: AOJu0Yxv4ZWOloH1yfOHoDckqBkJtS3yp8aGxAMFUI0WNNEZqZPVWLL9 FpIMXhcYopONw2Qx2ruN8iLrwCSaZafFVaICdHXIza9RNREyI+RNCuObK0nJ8Mm42MRESyjg1IE = X-Google-Smtp-Source: AGHT+IFXmBDxj4j5xao5roMZtZUT3z8AsYTNgifgJ+RUUK1gO4l9UAxZFVxYo9uWh5aBe2pfsNj1Pg== X-Received: by 2002:a17:903:2307:b0:1f7:1ca3:d0d3 with SMTP id d9443c01a7336-1f83b565d56mr34307215ad.4.1718231097634; Wed, 12 Jun 2024 15:24:57 -0700 (PDT) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:2816:6a42:9074:18cc]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f6f30acda9sm87914105ad.198.2024.06.12.15.24.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 15:24:56 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , Daniel Vetter , David Airlie , Maarten Lankhorst , Patrik Jakobsson , Thomas Zimmermann , linux-kernel@vger.kernel.org Subject: [PATCH v2 6/8] drm/gma500: Call drm_helper_force_disable_all() at shutdown/remove time Date: Wed, 12 Jun 2024 15:23:46 -0700 Message-ID: <20240612152336.v2.6.I1be622999c3b23f28f077fc75bb0319396a216e9@changeid> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog In-Reply-To: <20240612222435.3188234-1-dianders@chromium.org> References: <20240612222435.3188234-1-dianders@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Based on grepping through the source code, this driver appears to be missing a call to drm_atomic_helper_shutdown(), or in this case the non-atomic equivalent drm_helper_force_disable_all(), at system shutdown time and at driver remove time. This is important because drm_helper_force_disable_all() will cause panels to get disabled cleanly which may be important for their power sequencing. Future changes will remove any custom powering off in individual panel drivers so the DRM drivers need to start getting this right. The fact that we should call drm_atomic_helper_shutdown(), or in this case the non-atomic equivalent drm_helper_force_disable_all(), in the case of OS shutdown/restart comes straight out of the kernel doc "driver instance overview" in drm_drv.c. 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/gma500/psb_drv.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c index 8b64f61ffaf9..a5a399bbe8f5 100644 --- a/drivers/gpu/drm/gma500/psb_drv.c +++ b/drivers/gpu/drm/gma500/psb_drv.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -485,6 +486,12 @@ static void psb_pci_remove(struct pci_dev *pdev) struct drm_device *dev = pci_get_drvdata(pdev); drm_dev_unregister(dev); + drm_helper_force_disable_all(dev); +} + +static void psb_pci_shutdown(struct pci_dev *pdev) +{ + drm_helper_force_disable_all(pci_get_drvdata(pdev)); } static DEFINE_RUNTIME_DEV_PM_OPS(psb_pm_ops, gma_power_suspend, gma_power_resume, NULL); @@ -521,6 +528,7 @@ static struct pci_driver psb_pci_driver = { .id_table = pciidlist, .probe = psb_pci_probe, .remove = psb_pci_remove, + .shutdown = psb_pci_shutdown, .driver.pm = &psb_pm_ops, }; From patchwork Wed Jun 12 22:28:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13695632 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 DBF3AC27C75 for ; Wed, 12 Jun 2024 22:28:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D80D710E937; Wed, 12 Jun 2024 22:28:44 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="CL1Sdwc7"; dkim-atps=neutral Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by gabe.freedesktop.org (Postfix) with ESMTPS id 14BDA10E937 for ; Wed, 12 Jun 2024 22:28:42 +0000 (UTC) Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1f7028196f2so3372735ad.2 for ; Wed, 12 Jun 2024 15:28:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718231322; x=1718836122; darn=lists.freedesktop.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=L/jWWU1pq804c3ou2ews3riGNTGElQFQ1wAS5cHqZxA=; b=CL1Sdwc7x4iD/dvwaI/nUYtWyd5Sek3vn6LCVQ84wzWJXrgKpC47jEvoNgjAcqJoA2 xAHjnyMc+zeDzoPn2sWaJanppASjpRkvjdLhGSLwIbJWk+UsPPozmenE5YlV74/sx0hh 1UnqiL1b0KNcvmso3Gt/V3W8/zGoWwjBbyUkQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718231322; x=1718836122; 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=L/jWWU1pq804c3ou2ews3riGNTGElQFQ1wAS5cHqZxA=; b=FJ1WkOnouyS0gulTGrEDdwXeA6xwT3boWbvbJtJlUwSYlTDMK/2SbSahJqoIosYLhT teN6G8WAMj666ymq4OvwXJs+qS3fX5zcU3+AsazodDsGbnDsh/XBu5/ErvOqHofHxUtT q+mPuJNrDaEqkYggZBETIc8yhq+BIwsC+4WtmoKj30RYbMgbLzyyfKRC6TkeodShr1DW 59s6s0dGLCVVERSQtWIp/D14RA6iX3Grxjtsysp+3eR05E/SkpqoKTwrBUOqimHg34X/ UMpThb1FbT0SbAgBpDE8w5a7i/7YgEBIn6xSz+ilNLWWRHjyq77KrIZZMVBkNwdEmAMF mzZQ== X-Gm-Message-State: AOJu0YzlqaDOf0/Qj7lZvqBW90vKzSs4s8CTU5LfFUT5Fnnj3uh+KQW+ /Vj8grmAD+qZ8tSgEMESH1kFIWVlO4L9ujdYnvjpDEZYcdutBwRs8udzXJ9zxla28fKvfP/oGvM = X-Google-Smtp-Source: AGHT+IF/TlcvLXIfZfu54yCkggfRcKPb4J9ZvGiYz9EXPf3MwPKKQhOCuUiLPrDC9MOJJ/dvVbiIOQ== X-Received: by 2002:a17:903:234a:b0:1f7:187f:cb5b with SMTP id d9443c01a7336-1f83b7f5871mr39623195ad.64.1718231321795; Wed, 12 Jun 2024 15:28:41 -0700 (PDT) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:2816:6a42:9074:18cc]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f6f336d172sm87788575ad.247.2024.06.12.15.28.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 15:28:41 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xinhui Pan , Daniel Vetter , David Airlie , amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 7/8] drm/radeon: Call drm_helper_force_disable_all() at shutdown/remove time Date: Wed, 12 Jun 2024 15:28:03 -0700 Message-ID: <20240612152752.v2.7.I022cfc2dcd30e77d4f7005a2d912dd7ab76c0338@changeid> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog In-Reply-To: <20240612222435.3188234-1-dianders@chromium.org> References: <20240612222435.3188234-1-dianders@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Based on grepping through the source code, this driver appears to be missing a call to drm_atomic_helper_shutdown(), or in this case the non-atomic equivalent drm_helper_force_disable_all(), at system shutdown time and at driver remove time. This is important because drm_helper_force_disable_all() will cause panels to get disabled cleanly which may be important for their power sequencing. Future changes will remove any custom powering off in individual panel drivers so the DRM drivers need to start getting this right. The fact that we should call drm_atomic_helper_shutdown(), or in this case the non-atomic equivalent drm_helper_force_disable_all(), in the case of OS shutdown/restart comes straight out of the kernel doc "driver instance overview" in drm_drv.c. NOTE: in order to get things inserted in the right place, I had to replace the old/deprecated drm_put_dev() function with the equivalent new calls. Suggested-by: Maxime Ripard Reviewed-by: Maxime Ripard Cc: Alex Deucher Cc: Christian König Cc: Xinhui Pan Signed-off-by: Douglas Anderson --- I honestly have no idea if I got this patch right. The shutdown() function already had some special case logic for PPC, Loongson, and VMs and I don't 100% for sure know how this interacts with those. Everything here is just compile tested. (no changes since v1) drivers/gpu/drm/radeon/radeon_drv.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index 7bf08164140e..9ea7f163a731 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c @@ -38,6 +38,7 @@ #include #include +#include #include #include #include @@ -330,7 +331,9 @@ radeon_pci_remove(struct pci_dev *pdev) { struct drm_device *dev = pci_get_drvdata(pdev); - drm_put_dev(dev); + drm_dev_unregister(dev); + drm_helper_force_disable_all(dev); + drm_dev_put(dev); } static void @@ -341,6 +344,8 @@ radeon_pci_shutdown(struct pci_dev *pdev) */ if (radeon_device_is_virtual()) radeon_pci_remove(pdev); + else + drm_helper_force_disable_all(pci_get_drvdata(pdev)); #if defined(CONFIG_PPC64) || defined(CONFIG_MACH_LOONGSON64) /* From patchwork Wed Jun 12 22:28:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13695633 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 B081AC27C75 for ; Wed, 12 Jun 2024 22:28:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B419110E938; Wed, 12 Jun 2024 22:28:51 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="EQx5pIkx"; dkim-atps=neutral Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9DD5310E939 for ; Wed, 12 Jun 2024 22:28:48 +0000 (UTC) Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-2c2e31d319eso248256a91.1 for ; Wed, 12 Jun 2024 15:28:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718231327; x=1718836127; darn=lists.freedesktop.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=GlLfBbnX9FblBpW76gVStblANR7z9T1g0t5a6w4/nbU=; b=EQx5pIkxaXnqtqd014VLlG8nY4grJ4Spq51gJ5tWUY+pSXDgHHZi2V395ArAC07g0J f4+qQhfSeY/dR0PjGoKatta5IGTQyoegPeYEboOEjaWSGQs6Kg85Oxe8vM8A8UJV5XxM WEFw3zTEuRu115iqA9u4hHu+GBMWko6jKgntk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718231327; x=1718836127; 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=GlLfBbnX9FblBpW76gVStblANR7z9T1g0t5a6w4/nbU=; b=TOuKxBlC7Ui0vQh4OzNUDDMlU93pOzkS5xWpsnGUNVC1NbrZMS1rEwR6S6wvDGehon lksouMWvI7xr0JnHAtYL4oDIwq8/eTrif8H2a5EWYap780JN9gsFh6FmWWAZhRUL58CI D9yPKFfc8LKAWf0QWr5SA0gQgTrc2R0iFHrUisYtGr5UAa3txJ/42Z/nOoZkMLhbUIqk a1g5waqzlnlT1xf1kf9i8TeeM9Leli1fyMZh3LmK1g0QMsp2npw/j1zttFs63DblbBmw XrAnCeobmqQOEhVIqHXTrJmMp3S1o+/P+xND6uqLQsGtRyOH1XL5F8t514NwadMtqGTy g+Yw== X-Gm-Message-State: AOJu0YycNyVjv6mSR0uHkNhUEJBF77XNEtTFirlpuUXinZ4jhnGAFKc7 EzBdfKp9bKMkrXL8CJxjS1+HHZiEYceKythRF2yENsryVOuuloebW2hYq6vEtBQv7sEm+xF5sj8 = X-Google-Smtp-Source: AGHT+IHPZkmR/uiNsfI6yDfoiz6DjupPzvyE09FKeunOtYBdIdMpSm5jxkYUgJB/lptf93zhOTJSfQ== X-Received: by 2002:a17:90b:4ad2:b0:2c4:ab32:b723 with SMTP id 98e67ed59e1d1-2c4ab32b8c3mr2926957a91.29.1718231327185; Wed, 12 Jun 2024 15:28:47 -0700 (PDT) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:2816:6a42:9074:18cc]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f6f336d172sm87788575ad.247.2024.06.12.15.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 15:28:46 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xinhui Pan , =?utf-8?q?Andr=C3=A9_Almeida?= , Aurabindo Pillai , Candice Li , Daniel Vetter , David Airlie , Hamza Mahfooz , Hawking Zhang , Le Ma , Lijo Lazar , Ma Jun , Mario Limonciello , Shashank Sharma , Srinivasan Shanmugam , Thomas Zimmermann , Victor Lu , amd-gfx@lists.freedesktop.org, chenxuebing , linux-kernel@vger.kernel.org Subject: [PATCH v2 8/8] drm/amdgpu: Call drm_atomic_helper_shutdown() at shutdown time Date: Wed, 12 Jun 2024 15:28:04 -0700 Message-ID: <20240612152752.v2.8.I27914059cc822b52db9bf72b4013b525b60e06fd@changeid> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog In-Reply-To: <20240612222435.3188234-1-dianders@chromium.org> References: <20240612222435.3188234-1-dianders@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. Suggested-by: Maxime Ripard Cc: Alex Deucher Cc: Christian König Cc: Xinhui Pan Signed-off-by: Douglas Anderson --- This commit is only compile-time tested. ...and further, I'd say that this patch is more of a plea for help than a patch I think is actually right. I'm _fairly_ certain that drm/amdgpu needs this call at shutdown time but the logic is a bit hard for me to follow. I'd appreciate if anyone who actually knows what this should look like could illuminate me, or perhaps even just post a patch themselves! (no changes since v1) drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 ++ 3 files changed, 13 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index f87d53e183c3..c202a1d5ff5f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -1197,6 +1197,7 @@ static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_device *bdev) int amdgpu_device_init(struct amdgpu_device *adev, uint32_t flags); void amdgpu_device_fini_hw(struct amdgpu_device *adev); +void amdgpu_device_shutdown_hw(struct amdgpu_device *adev); void amdgpu_device_fini_sw(struct amdgpu_device *adev); int amdgpu_gpu_wait_for_idle(struct amdgpu_device *adev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 861ccff78af9..a8c4b8412e04 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -4531,6 +4531,16 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev) } +void amdgpu_device_shutdown_hw(struct amdgpu_device *adev) +{ + if (adev->mode_info.mode_config_initialized) { + if (!drm_drv_uses_atomic_modeset(adev_to_drm(adev))) + drm_helper_force_disable_all(adev_to_drm(adev)); + else + drm_atomic_helper_shutdown(adev_to_drm(adev)); + } +} + void amdgpu_device_fini_sw(struct amdgpu_device *adev) { int idx; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index ea14f1c8f430..b34bf9259d5c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -2409,6 +2409,8 @@ amdgpu_pci_shutdown(struct pci_dev *pdev) struct drm_device *dev = pci_get_drvdata(pdev); struct amdgpu_device *adev = drm_to_adev(dev); + amdgpu_device_shutdown_hw(adev); + if (amdgpu_ras_intr_triggered()) return;