From patchwork Thu Sep 21 19:26:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13394378 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 C9256E7D0A6 for ; Thu, 21 Sep 2023 19:28:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D994B10E5F3; Thu, 21 Sep 2023 19:28:22 +0000 (UTC) Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by gabe.freedesktop.org (Postfix) with ESMTPS id F269610E5EF for ; Thu, 21 Sep 2023 19:28:17 +0000 (UTC) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1c46b30a1ceso11386835ad.3 for ; Thu, 21 Sep 2023 12:28:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695324497; x=1695929297; 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=NI6y381yNrtia6QcCIC7z4DDn4lzJBG1Oz9c+agvn3E=; b=Ee0HTb1RsY1m4W/L4lJN5wV5Mi01d8HR4oRNkwHwOR73sJrLyet5HyQxI6w5dz1BLQ Ro2SJwbrSZ0DIJhpy0ExYmhzqmCHRsXp8q6hfWHIyOmvv7SF6+Z0Un4bGWJAUtYFBp6a hFGriRtaK26LLNg2UTDtQmHHIprCckBVYtqro= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695324497; x=1695929297; 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=NI6y381yNrtia6QcCIC7z4DDn4lzJBG1Oz9c+agvn3E=; b=SuYPz3cdf/F0255jYxTPaaTndoxg9wMJNgBmuVVecGmtsCBF6fZ5JieThD3J0Q0lJ1 OdBooA1LQNCbjEU7+C7iLOz+V9pBHLf4dV3FsRMXsA0oC6Ghbak58WTO4yx5rwu6VeAq DRplxsGbzQjmG+ZoepPsfwF6wGGOtKZ2CWhGVsnmAiKYjHzx4L90hd9Esm4vUhAUp1rg 3JocxiSv9XDPkqLdpRVXfgVDGO1f+mflzjFsL8Asr/wOhaNJOBGBMVGD43tHl5y5lsWZ x+AMm23r2DcxJjlQdaj8j2Jv8gTIiZGIe0jfGqYQ200gYX/LDN787SFIo8v70MXK11yQ 1L5g== X-Gm-Message-State: AOJu0YwIQRWAB4LXZuVzdCWyf0hJwe6Q1KdBKnIyfvBVlADq1A7J1h8r HEZeZJvdTwqhpEn3kOiWUrKtkfl/o5/Mu1+Tu/wQuu1U X-Google-Smtp-Source: AGHT+IEwO0wT0IFYtUWxf8dEr+TXDKdYpZSldG17COiUXE+UPVFkQVI7f6AGosPMSTOkM8sO3JyqHw== X-Received: by 2002:a17:902:ab17:b0:1c4:4efc:90a6 with SMTP id ik23-20020a170902ab1700b001c44efc90a6mr6250166plb.38.1695324496702; Thu, 21 Sep 2023 12:28:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 12:28:15 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Subject: [RFT PATCH v2 01/12] drm/imx/dcss: Call drm_atomic_helper_shutdown() at shutdown time Date: Thu, 21 Sep 2023 12:26:44 -0700 Message-ID: <20230921122641.RFT.v2.1.I134336fce7eac5a63bdac46d57b0888858fc8081@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-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: , Cc: Sascha Hauer , Douglas Anderson , linux-kernel@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, laurentiu.palcu@oss.nxp.com, shawnguo@kernel.org, linux-arm-kernel@lists.infradead.org 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 Tested-by: Laurentiu Palcu Reviewed-by: Laurentiu Palcu --- This commit is only compile-time tested. (no changes since v1) drivers/gpu/drm/imx/dcss/dcss-drv.c | 8 ++++++++ drivers/gpu/drm/imx/dcss/dcss-kms.c | 7 +++++++ drivers/gpu/drm/imx/dcss/dcss-kms.h | 1 + 3 files changed, 16 insertions(+) diff --git a/drivers/gpu/drm/imx/dcss/dcss-drv.c b/drivers/gpu/drm/imx/dcss/dcss-drv.c index c68b0d93ae9e..b61cec0cc79d 100644 --- a/drivers/gpu/drm/imx/dcss/dcss-drv.c +++ b/drivers/gpu/drm/imx/dcss/dcss-drv.c @@ -92,6 +92,13 @@ static int dcss_drv_platform_remove(struct platform_device *pdev) return 0; } +static void dcss_drv_platform_shutdown(struct platform_device *pdev) +{ + struct dcss_drv *mdrv = dev_get_drvdata(&pdev->dev); + + dcss_kms_shutdown(mdrv->kms); +} + static struct dcss_type_data dcss_types[] = { [DCSS_IMX8MQ] = { .name = "DCSS_IMX8MQ", @@ -114,6 +121,7 @@ MODULE_DEVICE_TABLE(of, dcss_of_match); static struct platform_driver dcss_platform_driver = { .probe = dcss_drv_platform_probe, .remove = dcss_drv_platform_remove, + .shutdown = dcss_drv_platform_shutdown, .driver = { .name = "imx-dcss", .of_match_table = dcss_of_match, diff --git a/drivers/gpu/drm/imx/dcss/dcss-kms.c b/drivers/gpu/drm/imx/dcss/dcss-kms.c index 896de946f8df..d0ea4e97cded 100644 --- a/drivers/gpu/drm/imx/dcss/dcss-kms.c +++ b/drivers/gpu/drm/imx/dcss/dcss-kms.c @@ -172,3 +172,10 @@ void dcss_kms_detach(struct dcss_kms_dev *kms) dcss_crtc_deinit(&kms->crtc, drm); drm->dev_private = NULL; } + +void dcss_kms_shutdown(struct dcss_kms_dev *kms) +{ + struct drm_device *drm = &kms->base; + + drm_atomic_helper_shutdown(drm); +} diff --git a/drivers/gpu/drm/imx/dcss/dcss-kms.h b/drivers/gpu/drm/imx/dcss/dcss-kms.h index dfe5dd99eea3..62521c1fd6d2 100644 --- a/drivers/gpu/drm/imx/dcss/dcss-kms.h +++ b/drivers/gpu/drm/imx/dcss/dcss-kms.h @@ -34,6 +34,7 @@ struct dcss_kms_dev { struct dcss_kms_dev *dcss_kms_attach(struct dcss_dev *dcss); void dcss_kms_detach(struct dcss_kms_dev *kms); +void dcss_kms_shutdown(struct dcss_kms_dev *kms); int dcss_crtc_init(struct dcss_crtc *crtc, struct drm_device *drm); void dcss_crtc_deinit(struct dcss_crtc *crtc, struct drm_device *drm); struct dcss_plane *dcss_plane_init(struct drm_device *drm, From patchwork Thu Sep 21 19:26:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13394379 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 41356E7D0A7 for ; Thu, 21 Sep 2023 19:28:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DBE7B10E5F0; Thu, 21 Sep 2023 19:28:26 +0000 (UTC) Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by gabe.freedesktop.org (Postfix) with ESMTPS id ECBC110E5F3 for ; Thu, 21 Sep 2023 19:28:21 +0000 (UTC) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1bf6ea270b2so11209995ad.0 for ; Thu, 21 Sep 2023 12:28:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695324500; x=1695929300; 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=hhxODKU/1KHUMb12P9tKCTdkzqsk+8BNlEjNG+/jd3Y=; b=EWohkUNdUOCnAEBo3vWGpbWQ7/o4zLYvSaC+5vwuql7qE5jhtUqzrnrszdsaKxkwYa 6m/dbXIe7L/7/Csg9r4QI3dV2++o/fjgoMArIUb7YPnviX78bUCCd3cadT2f5O/5jwU2 LJhkuajAiqdQLRWILftqCnzPdGMq2R/M/xoJ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695324500; x=1695929300; 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=hhxODKU/1KHUMb12P9tKCTdkzqsk+8BNlEjNG+/jd3Y=; b=F4EyA4DfjOBfh0JCNAhszDdfoRC4cHhHqZKTLH5O8U4C05A7RvZne/riK3On52b9/j iuNbc2bXVUT5BtObuj2aQXN0RzcxHaDR0wjZ055suA54gL+A/w/UxIfidJvbeBCxkJs7 7WmyDOvPPMpcB4YZY8b2q/tOBBjH2ptm05i0n9xIffGbjHYckvDvBsaZ118o5O43b9Sw vFQ1GF1dmeO+F//trikLSFENH5Geue52+tqqGPe6kmrNHpZQXn37scOL4BFZV2gJmMfw v3Js5phGBujOCOW/2VNd7XboiFvdRkURbq07L6dC4VWyWiUSwJUquftYArBw1psMa9hT 9bvw== X-Gm-Message-State: AOJu0YzIdlNvKBEW0VVHy4lsFKzmibTaWtGoy+NOI0azYX5V+IOQrZK8 P2L0ytYfr0h8o5ENl4DsAtVHABVbBq/REjWVOQ7/SNjg X-Google-Smtp-Source: AGHT+IHUQlNIbJeLrvAj7jWESgKPAFex7wB5VnwlWGMQsi3fiVSh6nFpJjIAzbg6QtOMH1SG8wCkdQ== X-Received: by 2002:a17:902:6ac8:b0:1bb:1523:b311 with SMTP id i8-20020a1709026ac800b001bb1523b311mr5075598plt.41.1695324500459; Thu, 21 Sep 2023 12:28:20 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 12:28:19 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Subject: [RFT PATCH v2 02/12] drm/kmb: Call drm_atomic_helper_shutdown() at shutdown time Date: Thu, 21 Sep 2023 12:26:45 -0700 Message-ID: <20230921122641.RFT.v2.2.I20cb02bafa7c2368e4bd579df0716eb62a3a21bf@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-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: , Cc: edmund.j.dea@intel.com, Douglas Anderson , linux-kernel@vger.kernel.org, anitha.chrisanthus@intel.com 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 24035b53441c..af9bd34fefc0 100644 --- a/drivers/gpu/drm/kmb/kmb_drv.c +++ b/drivers/gpu/drm/kmb/kmb_drv.c @@ -476,6 +476,11 @@ static int kmb_remove(struct platform_device *pdev) return 0; } +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); @@ -622,6 +627,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 = kmb_remove, + .shutdown = kmb_shutdown, .driver = { .name = "kmb-drm", .pm = &kmb_pm_ops, 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: 13394381 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 A9690E7D0A8 for ; Thu, 21 Sep 2023 19:28:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C4C1710E5F6; Thu, 21 Sep 2023 19:28:29 +0000 (UTC) Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2BF0C10E5F0 for ; Thu, 21 Sep 2023 19:28:25 +0000 (UTC) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c44c0f9138so11042705ad.2 for ; Thu, 21 Sep 2023 12:28:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695324503; x=1695929303; 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=qhFda07Eo+JhAQAACXr7n7to50ItTosGgo10Du+RGvo=; b=Sd3LS6zmQwgBdodFIU2oAG6h4c/v2Fvipe2O1CS7oJ+h3eiWnoAOBE3BB8r8CKpy/L N25USdgaR8sYJewdxQKY0TV4rxJ/+Reyi0G6i6c5UCG2RgorfnACAl+T4upUzFhJmbm4 oXIc4z7Ut1vnR9qxZUpfqREvHN3utC84E9CEM= 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=pKs/ugWsULOWq9Zb5ZTe/j5A52DXcyL1heol0W683iwEF/YyXuIcQn2+sVa7HnEdPz 0mEYgYEOhfTLXuOcYXnM6Kw2wsj/nXxrnoGXT3hJQzzIs30TsKQ5pEFbojtQ5H6ok5bp tofQ6AdTbUGUzRZQGmF8XHvjjaiB4H4mbae1d6p1Eu1zQbnj20SiMQVfVE9kj/mNnn4K f2MAzFaTOC2Ir9dbPkpVGZJkGzXLaRCoPUxH2C6V7J2SKzKFfadvh5Fw5GnO70AF4ilI yYs9tfFT46wjfGC2/G0IJ6rwMQ9ULBvSmZEumM6jWJW2nzP79OqgEl9G9NcoZtPwi6Zf kDIQ== X-Gm-Message-State: AOJu0Yxvku5VHAe9XUyuVtIeg9zNE7OzvL4FE6doHKr5DGrM7dZMxS3c 9sPm7R7L+VRsJAEAvBdQ/XVA6ahk3ftTdPJkOXk/qzJu 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 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-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: , Cc: chunkuang.hu@kernel.org, Fei Shao , Douglas Anderson , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com, linux-arm-kernel@lists.infradead.org, angelogioacchino.delregno@collabora.com 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. 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, From patchwork Thu Sep 21 19:26:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13394380 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 C424AE7D0A6 for ; Thu, 21 Sep 2023 19:28:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D35F310E5F7; Thu, 21 Sep 2023 19:28:29 +0000 (UTC) Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 239E110E5F6 for ; Thu, 21 Sep 2023 19:28:28 +0000 (UTC) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-690bc3f82a7so1285094b3a.0 for ; Thu, 21 Sep 2023 12:28:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695324506; x=1695929306; 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=XHA8WV61h1sCTUoopvu6jUmhZo1/0sc2wBZa91YnlqI=; b=FiaARAKeySvDrEEDMpN9tDIaZSRTKBTUxEcLENrZUYG2Uuh80yWYVRZgyq+1uAvIql EHcjAplEfmc8n04TzJASaqasPY3fGfAg431GEAxCBBjZakPaXmTO/HZ+2HcZgFL1+uug KpY1Kd0F4vyrdkJ+GUiodNei4pM/2QATXrM/U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695324506; x=1695929306; 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=XHA8WV61h1sCTUoopvu6jUmhZo1/0sc2wBZa91YnlqI=; b=T+rEOlHAqK9PhXb6j+ERazyIfy5L024rjpw7uNEw/fFM+j9RWpzTwI6RtauZpeHj1t 7e9o2lwptfR3dLEokCuuO1nH+reIDm0FG3O3wvNghDoGbQp7ukSTyJcgpaUcfAm9NJ1v 2Ma3eARqC1xR3qmq8EDGMRAJbI5K6oseD8XVQk9Nh3CJZGGSpw6Np16dYa+ZZvTCVUGk +rlfqI88F6E5FpgksJdk+7hyrSZhdYrZsgp8D4dh5us2F48VGzXYQ1DOliibgNNfMEGz pwvFWrMTh3U+G3NX2LQ2H+k5xkUYD0XLDgKgJGm1xp5AUJCfM53kWdXlUC5HtwG8VwxT mlQQ== X-Gm-Message-State: AOJu0YzwO//WvgjakmwFKQdw3zNm7tDsq+teVkCNUGf/5GXKlaEYqFNf MeHk6grqgMrooQnZl8Qx21Hi/7koHgq3NAa3iznekgSW X-Google-Smtp-Source: AGHT+IHqTEJgRF5kJ5LaOV5RP1ReQKOtcWcO7Dx6XuYKQwxO/AtAnwFW/vbvFSlG1XFJXQbmien+fA== X-Received: by 2002:a05:6a20:3ca8:b0:15c:e0bf:40ec with SMTP id b40-20020a056a203ca800b0015ce0bf40ecmr5940561pzj.17.1695324506566; Thu, 21 Sep 2023 12:28:26 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 12:28:24 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Subject: [RFT PATCH v2 04/12] drm/nouveau: Call drm_atomic_helper_shutdown() or equiv at shutdown time Date: Thu, 21 Sep 2023 12:26:47 -0700 Message-ID: <20230921122641.RFT.v2.4.Ie7588ec6e0f93e8bc700e76b265ad1a7ad6b15ad@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-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: , Cc: kherbst@redhat.com, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, Douglas Anderson , bskeggs@redhat.com 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 Reviewed-by: Lyude Paul Tested-by: Lyude Paul --- 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 d8c92521226d..05c3688ccb76 100644 --- a/drivers/gpu/drm/nouveau/nouveau_display.c +++ b/drivers/gpu/drm/nouveau/nouveau_display.c @@ -642,6 +642,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 50589f982d1a..8ecfd66b7aab 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -879,6 +879,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) { @@ -1346,6 +1358,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 3666a7403e47..aa936cabb6cf 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 23cd43a7fd19..b2e82a96411c 100644 --- a/drivers/gpu/drm/nouveau/nouveau_platform.c +++ b/drivers/gpu/drm/nouveau/nouveau_platform.c @@ -50,6 +50,11 @@ static int nouveau_platform_remove(struct platform_device *pdev) return 0; } +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, @@ -94,4 +99,5 @@ struct platform_driver nouveau_platform_driver = { }, .probe = nouveau_platform_probe, .remove = nouveau_platform_remove, + .shutdown = nouveau_platform_shutdown, }; From patchwork Thu Sep 21 19:26:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13394382 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 1544EE7D0A9 for ; Thu, 21 Sep 2023 19:28:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 43CB110E5F1; Thu, 21 Sep 2023 19:28:38 +0000 (UTC) Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6B9C210E5F9 for ; Thu, 21 Sep 2023 19:28:31 +0000 (UTC) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-690bc3f82a7so1285151b3a.0 for ; Thu, 21 Sep 2023 12:28:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695324510; x=1695929310; 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=EjE+v7+9YV8M91Wchnv2I6StT/F66BSqTQ0jlAjsGeo=; b=PxPtm23I2KXI8mTNMWlE8PxOyOl5b343WNWZQ/98T4tFTI1dlljrcs4cSNfFXCRabw 16GCijb01FNsPu5PcLbB7ke1VdBJGqJZuarz2sR+UarDZl24IEGYOzYWDzAoOzSJz6qx Q4nrMCu8HTxFHLfxuB8JFnxV/zD1C+0dmuQoE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695324510; x=1695929310; 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=EjE+v7+9YV8M91Wchnv2I6StT/F66BSqTQ0jlAjsGeo=; b=ba0MGP6NBmYHJxjTTdJ9B2U02bRw2IBv6giBrGicPqax+B5q7/17quMUns6bkK7otp 6ijv92J0HUPD01LJTFB8kRa+ZtaJgLECPcJvLeKBatRYeKDE9O3ahnFUFHvrIrWfsTBJ TMwjfLZxNZ61s29wxJO14bu4mbp7UVkchHWDoNVe+8gmgushk3mhPE/HLhfslU0s/o4U r8lRqIaVngZFQJ+kBodLvF/hPS0xKDm9LKNQe54ajtsZnZXDHqHqElkhDVljIzeWYjDO UsK5VMva31I9xF0W8WUD0HrqJ+Atw01LlqIml22SuYavg0SQLVb9N0A0kZZdgn+ihMz+ 4seQ== X-Gm-Message-State: AOJu0YxppHZgBmsHzSnsK4qGGW9DLAPG4AWdS3t9lN/dalBPLTZaf6FK wR6uGc5qEIHJdgSN/MlJkkmH7k7WG9ydjWIcuyoE6Kwj X-Google-Smtp-Source: AGHT+IE+we6oLujL1MkhnRpx7DOVM1KJZ/SsmSrAejYsuJZcNIFP8yRibQZNs1+sdIdQDwROK48mpw== X-Received: by 2002:a05:6a20:840d:b0:154:6480:83b4 with SMTP id c13-20020a056a20840d00b00154648083b4mr7513077pzd.14.1695324509805; Thu, 21 Sep 2023 12:28:29 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 12:28:28 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Subject: [RFT PATCH v2 05/12] drm/tegra: Call drm_atomic_helper_shutdown() at shutdown time Date: Thu, 21 Sep 2023 12:26:48 -0700 Message-ID: <20230921122641.RFT.v2.5.Ifb4450979b62976fd5a98847dade2e5b377d47c8@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-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: , Cc: mperttunen@nvidia.com, linux-kernel@vger.kernel.org, Douglas Anderson , thierry.reding@gmail.com, linux-tegra@vger.kernel.org, jonathanh@nvidia.com 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/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 ff36171c8fb7..ce2d4153f7bd 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -1312,6 +1312,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) { @@ -1380,6 +1385,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 Thu Sep 21 19:26:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13394383 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 AA686E7D0A2 for ; Thu, 21 Sep 2023 19:28:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7449110E5F9; Thu, 21 Sep 2023 19:28:38 +0000 (UTC) Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by gabe.freedesktop.org (Postfix) with ESMTPS id D7ABA10E5F9 for ; Thu, 21 Sep 2023 19:28:33 +0000 (UTC) Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-517ab9a4a13so947920a12.1 for ; Thu, 21 Sep 2023 12:28:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695324512; x=1695929312; 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=cZtAYqJWE7JpdsZxb5rfWkU3kZ2lTrkKomU0ysGX5d0=; b=Bz5WsbUmerrwH62CmE9A3H5TynFU43dnEPTvRNO0H50pXApql2LQvwrNok8BkGcVpR oMyVfkY8bBAws1HeFNgxGwuiCk1sPGdN9htgc6zR5DXURc46E1+GgprkNAM8mTiJ34fQ 40JmX78hDY4hKHrEoU73Kz3ZnO9FbYEnBTuSs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695324512; x=1695929312; 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=cZtAYqJWE7JpdsZxb5rfWkU3kZ2lTrkKomU0ysGX5d0=; b=gkjS4+jbt30o/+QkrThMU2pVFVEeTL8rli0EvCr+zX75awVO+WhLKLLqOLE5I4jOpU JD1/d3EyR4Higw5E+KxK7VMIYCtYFlYa8mTfLeA7nFytY8xbv7Ksq5gQUpMnxS3n9Ck2 JS9smZS0sJW1JSDScvBVEK3oRdIL97HXT24uydMe5tqd33Mlm01lQeMEriYWbSa4Y+Rn h+ioFcvo8m47WRH80NKX1HzzbL+s66wCgSu1dRr71wuigIH7QLaPijFVqJiQWn8IHuKa BrRl/eIFqfbTCmmYlJsjOus0J2phhjDmQKGX7TgK0fHbiolpUHNSsrcEnZl1q2iF7AFp wh8Q== X-Gm-Message-State: AOJu0YwX/LbEqg2xW+Tq51GSTqheH+T0UCf+PoXmNWZxzYeb5WA+btCB PhGgqGJxTf919S5H0mKmZiyLNxgoJgDB+ck8ws5UIGzW X-Google-Smtp-Source: AGHT+IFLfEFOKyhwKb3FZnAY6hGcxUNsWis48sb0QkS+Rc27anChCNA3mxZflSD413ezokJ4zowvTw== X-Received: by 2002:a05:6a20:7f93:b0:152:6b63:f1e5 with SMTP id d19-20020a056a207f9300b001526b63f1e5mr8883328pzj.38.1695324512344; Thu, 21 Sep 2023 12:28:32 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 12:28:30 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Subject: [RFT PATCH v2 06/12] drm/arcpgu: Call drm_atomic_helper_shutdown() at shutdown time Date: Thu, 21 Sep 2023 12:26:49 -0700 Message-ID: <20230921122641.RFT.v2.6.I8a0a246fea222059881d01a8fff2adcf7ef3d7a4@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-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: , Cc: abrodkin@synopsys.com, Douglas Anderson , linux-kernel@vger.kernel.org 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 e5b10e41554a..c1e851c982e4 100644 --- a/drivers/gpu/drm/tiny/arcpgu.c +++ b/drivers/gpu/drm/tiny/arcpgu.c @@ -414,6 +414,11 @@ static int arcpgu_remove(struct platform_device *pdev) return 0; } +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"}, {} @@ -424,6 +429,7 @@ MODULE_DEVICE_TABLE(of, arcpgu_of_table); static struct platform_driver arcpgu_platform_driver = { .probe = arcpgu_probe, .remove = arcpgu_remove, + .shutdown = arcpgu_shutdown, .driver = { .name = "arcpgu", .of_match_table = arcpgu_of_table, From patchwork Thu Sep 21 19:26:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13394385 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 B519EE7D0A7 for ; Thu, 21 Sep 2023 19:28:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8985910E5FB; Thu, 21 Sep 2023 19:28:47 +0000 (UTC) Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0EA0910E5F9 for ; Thu, 21 Sep 2023 19:28:37 +0000 (UTC) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1c364fb8a4cso12168835ad.1 for ; Thu, 21 Sep 2023 12:28:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695324515; x=1695929315; 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=yIB9Su1U7bIPFr+7ANN/OcavTAqWwcBq0GS4I1/bwSs=; b=l2BIvCiTSlEeYV3AHCWuG1EjJtQ1Tq5QFsmA3+WnxpRaDsLpSyXGzP99/Px3S/RYJi OvzoY4Gl3kOSm/S7jqJLV4cexx3bDlUbgwNqqP2KNNRVI+/KwqZfMTDYiR8dwe7sbWVw dXaK1YcV25iuN1inqY9GzbFqqORYTKFO66QoA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695324515; x=1695929315; 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=yIB9Su1U7bIPFr+7ANN/OcavTAqWwcBq0GS4I1/bwSs=; b=rFHqH1IkSB9Ww1j3pbODFKn+71AvmflBcyd32YtM+fnLHBPrxbY9NC0ZBRE3QyaakI xxdh4h9bYO+eF72PAdv5S5IxDkQ/CBpa9/wkqG1d0/qQB/pV96ZqyphESi+RuCSOcB9t z7uIT0iQaDw9Mr9R4ACWyByy6urzvTaKxY1mREQztkG77DBkkgUAT2E/BPwU3I/r3VsX WvE23OrnKi7lt44D01d4/KLTnPsQ14w/Hogg0Mqkl9RKFCDCbDs0epoA4mBZYKjXdJcf sUYwrjbS3fuf/o6W9eYQgEZqOTCX80+QkK0pwaqYEKqvtNQHbs80qg+rBJSFoI76r02J cPWQ== X-Gm-Message-State: AOJu0YxNtLj7ItGVkIT+GObYszcQayDTkY9y6cWtJ0ZbqnJSNOGMAlxF KXgCC2o8WCc8F1Yda9+bUz2Mjol40TYgIBt6kokIM9vY X-Google-Smtp-Source: AGHT+IG6gT2BLC16ToMT+YRTSkTdSEdEW0H2PnMiZoFRHOn+2vS6h4Vr0OhvW/jKYuQ4kfyd3+axAQ== X-Received: by 2002:a17:902:bb83:b0:1c2:82e:32de with SMTP id m3-20020a170902bb8300b001c2082e32demr5155768pls.0.1695324515416; Thu, 21 Sep 2023 12:28:35 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 12:28:34 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Subject: [RFT PATCH v2 07/12] drm/amdgpu: Call drm_atomic_helper_shutdown() at shutdown time Date: Thu, 21 Sep 2023 12:26:50 -0700 Message-ID: <20230921122641.RFT.v2.7.I27914059cc822b52db9bf72b4013b525b60e06fd@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-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: , Cc: Victor.Zhao@amd.com, linux-kernel@vger.kernel.org, mdaenzer@redhat.com, mario.limonciello@amd.com, amd-gfx@lists.freedesktop.org, lijo.lazar@amd.com, srinivasan.shanmugam@amd.com, Bokun.Zhang@amd.com, shiwu.zhang@amd.com, le.ma@amd.com, James.Zhu@amd.com, felix.kuehling@amd.com, Xinhui.Pan@amd.com, Douglas Anderson , tzimmermann@suse.de, alexander.deucher@amd.com, christian.koenig@amd.com, Hawking.Zhang@amd.com 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 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 8f2255b3a38a..cfcff0b37466 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -1104,6 +1104,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 a2cdde0ca0a7..fa5925c2092d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -4247,6 +4247,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 e90f730eb715..3a7cbff111d1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -2333,6 +2333,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; From patchwork Thu Sep 21 19:26:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13394384 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 1668AE7D0A8 for ; Thu, 21 Sep 2023 19:28:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 54F5B10E5FE; Thu, 21 Sep 2023 19:28:48 +0000 (UTC) Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6BD8610E5FB for ; Thu, 21 Sep 2023 19:28:40 +0000 (UTC) Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-578d0d94986so937956a12.2 for ; Thu, 21 Sep 2023 12:28:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695324519; x=1695929319; 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=pLjLrmqx+liQMxms0HfuoarLoIvQ77Y5EZxHJFXGDMo=; b=ifiEcVYMaj/3OKh3nYyc1Ja61p89ozZ+gh44KwYfGj0fi6U/gi6zHyVl2qkfBteM8z sbPHFoTJ49T01UTyfDN1VLkGgXdRTKHBY92tNqqld8lWt6Bnd52szgb6HinH3p1eAA+z j3Te0dsOvw1kCa91baIutbWucOJ1YfEVtL8tk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695324519; x=1695929319; 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=pLjLrmqx+liQMxms0HfuoarLoIvQ77Y5EZxHJFXGDMo=; b=jN63v/FffSDy1mtwFRM4/gA5z6YjPxStV0aVx+7dny8Lewit5jXqEon+llFflux3p+ g65O3iaKldot/uS+M7uvrBYCHKwFX+ne7JuBkWg7dhPJdGtSfbU3+vjr29m3+1bE5pIa sOjSzk97CjxE+pkly0/9jlTlj7vDUrUo1nyr2nOOeEyva64AguX8PTZtbHzS8wH7Ym2q WgVwCpXtRBCuOxQaTjCQRpdgaIyniFI9TyabShrpgajGRcMrSdN5+JiU7LcezdIktg9l LpIEOBKJHffNcv61tAUhPB/jrLShK6y9beCyfpDO5dij4tLrPYTZm+5e6Zg/jAOc/mtd Nbgw== X-Gm-Message-State: AOJu0Yw338dxyoBm5HMfL9+mR5uX3wUdPxTcqFs3mNhThGWUDd55+ubV FN9Gtjzw+ppv9/O1+LF6dzszbsu+PPEjP2FJvQhHfwAj X-Google-Smtp-Source: AGHT+IEoRL+LQQb5QJ020x/RBTSHvfniX1vz+zMVAHt3qEaz0AKEABZX30JR3ZV4ZtsBNVQhvE+uKA== X-Received: by 2002:a05:6a20:324c:b0:148:6063:3273 with SMTP id hm12-20020a056a20324c00b0014860633273mr5419552pzc.29.1695324518923; Thu, 21 Sep 2023 12:28:38 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 12:28:37 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Subject: [RFT PATCH v2 08/12] drm/sprd: Call drm_atomic_helper_shutdown() at remove time Date: Thu, 21 Sep 2023 12:26:51 -0700 Message-ID: <20230921122641.RFT.v2.8.I7a2dd349cb52bae53280d0a49e22cc27b923274b@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-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: , Cc: Baolin Wang , tzimmermann@suse.de, sam@ravnborg.org, Douglas Anderson , linux-kernel@vger.kernel.org, kieran.bingham+renesas@ideasonboard.com, zhang.lyra@gmail.com, orsonzhai@gmail.com, steven.price@arm.com 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. (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 0aa39156f2fa..86a175116140 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 Thu Sep 21 19:26:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13394387 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 A6134E7D0A6 for ; Thu, 21 Sep 2023 19:28:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E05FF10E5FF; Thu, 21 Sep 2023 19:28:55 +0000 (UTC) Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4117E10E5FB for ; Thu, 21 Sep 2023 19:28:42 +0000 (UTC) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1c0ecb9a075so11227875ad.2 for ; Thu, 21 Sep 2023 12:28:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695324521; x=1695929321; 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=iA2li7ELqa/hnFznycO86SuLFz051HXi1UIFyEU+SsY=; b=Lc29iVe+2y7h3ODTW3MChqgAI/Pnj9IkWZFZXAbG/huQ1B854wD18rvOL67JxvhM66 0hxC37ibtZeC2Qp0c57YwYXwScoUf4Z6ImSw5mOoheuGxqXInniJ634VyrOno5rcNv+0 kuktwpbUI7Vl1aKmvDyjbezKDZtVO/kW4Zdfc= 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=LbbGazbPKAAGe/lUnZJV8YQufSexfn0pHt8EqILkl3VvIW5mVpp8u/pZiNU4FMjxZ0 hiN0+S4hhq6urhYKFVKHV2D6vAKPUCllZgY6UaLsJAfq5e0tiuUn0YqDmJQcVmFU4L6v exk0YCwhDb5GUdDUeTHdkl07PHasDeDcOX8Ai/edjQlbtKvJAmS6LuBcXQu608VmSX/f h/eN17UslXgAUoKyCfpy1DADNXg6ZCdESyxkiq7Syy0OpIbpkmLt9BQvKaG7+Cgf0fwC P9fj4J7cmxeZlhc8EHKwsO21s9QqNVTyUPTDeuCNlFoKcsB+JWasJOkxEfKZ6ZZjaSF8 Vafg== X-Gm-Message-State: AOJu0Yz5xa7VnngNZRhwieqi8Q9akH/FKZDMaBame590kbyeQrpOJLpB KsaGprAJ7zMxRXVy6CO+KEnjiztXcnq46ZTJLzJ0DXfX X-Google-Smtp-Source: AGHT+IGqiH8+93CjsgTzwhYDRPl823KLkGG4+0EgU7Nds+tbBUgFbUmFj98SJgfl8Opc5kzECLW4aw== 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 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 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: , Cc: linux-samsung-soc@vger.kernel.org, alim.akhtar@samsung.com, sw0312.kim@samsung.com, Douglas Anderson , linux-kernel@vger.kernel.org, krzysztof.kozlowski@linaro.org, kyungmin.park@samsung.com, linux-arm-kernel@lists.infradead.org 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 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 Tested-by: Marek Szyprowski Reviewed-by: Marek Szyprowski --- 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, From patchwork Thu Sep 21 19:26:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13394388 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 73607E7D0A6 for ; Thu, 21 Sep 2023 19:29:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ADE8F10E601; Thu, 21 Sep 2023 19:29:02 +0000 (UTC) Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4511C10E5FB for ; Thu, 21 Sep 2023 19:28:45 +0000 (UTC) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1bf55a81eeaso11223815ad.0 for ; Thu, 21 Sep 2023 12:28:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695324524; x=1695929324; 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=SjE9g39gnCCj7j/VSb42AYR6J5acTdAldxrB9mluCQs=; b=UG++Og2T9y9WiyVf4dlnIO6nv0Ojv6OBNJiyLj2csAflhRwCEukdZhnrxFn6RYhiYi eFlH+RzFyDbLq1ikk1HOXBZCBg6JTtRYg0jEaTSniq3mocvipgkVbNmvG/m71UFPAzPA kJ6oFnX4+mTLOamWUvS54xau/1ke6p4ghTPyU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695324524; x=1695929324; 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=SjE9g39gnCCj7j/VSb42AYR6J5acTdAldxrB9mluCQs=; b=KKQ8Gk0ndrxP2/DvJ/oqgC33crFksVhDuEGn8byuppoqTNKc7ABU+6kLeyRD0uTdZr jhWgmxE57ytxJo5mr0oz9rE9X/vg8aAARzRuW4JboHeDhQapOkDf23Q729ZmI0ErB24Q znelgFQ/ixon+yTXC5HhJ0gbvSf0tqiR2weGa2r2KSpa3vFGGMoZ2da55bvEwAiaWG6g EvBkoEtKLiL4favgXJoAHazuQfT7nhyR+Bq4iA/Brf3MVQQ5POjSLcciJs6kSNt98yX6 NRGQO+Cmyzgvj/J+pRJFThjaw2wqaJl6Ih9LhkZZhMJ7DGttSlecTV1xA++Ie4K8+StQ lOTw== X-Gm-Message-State: AOJu0YwkqO7MKoV5ZTEJ/NPyN1FtmRE+3/WUd4omUqlwgzeJ+QiojqHt AGmHJFVLflPIg/7IfYx3x6tLyLRhHw3ArELA/xwVpOlV X-Google-Smtp-Source: AGHT+IGaL8Xuy7USK74rcVfJD2FYDrURYbnbnv1NxMU2yTzdabxZ6fmTke9TgpsR322JBCoPZAOITQ== X-Received: by 2002:a17:902:d491:b0:1c3:8230:30d8 with SMTP id c17-20020a170902d49100b001c3823030d8mr7671409plg.38.1695324524060; Thu, 21 Sep 2023 12:28:44 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 12:28:42 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Subject: [RFT PATCH v2 10/12] drm/gma500: Call drm_helper_force_disable_all() at shutdown/remove time Date: Thu, 21 Sep 2023 12:26:53 -0700 Message-ID: <20230921122641.RFT.v2.10.I1be622999c3b23f28f077fc75bb0319396a216e9@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-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: , Cc: Douglas Anderson , linux-kernel@vger.kernel.org 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 Thu Sep 21 19:26:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13394386 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 4F286E7D0A2 for ; Thu, 21 Sep 2023 19:28:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9B3A010E5FA; Thu, 21 Sep 2023 19:28:54 +0000 (UTC) Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by gabe.freedesktop.org (Postfix) with ESMTPS id A15EB10E5FE for ; Thu, 21 Sep 2023 19:28:47 +0000 (UTC) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1c328b53aeaso11710205ad.2 for ; Thu, 21 Sep 2023 12:28:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695324526; x=1695929326; 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=vNE7U3MRFdvHzy3AatqQxrB+Rii45BA8np0vc2lW0nQ=; b=TwNBy3PHbyw/XT5wPpPP7CoWwJWOeUiTVuVk3S4L3JEmhXShC9pw8O2f2pzWwTvwNN Idc6hdW463V1aqoxxM5dUFfhtsNE5BIE3BEypTtVKMIzzrV4P0Pgtg4W3Levwq18okZC KUoE4L7HIDIzUb0acTDETL/XhkJoAgxDUspz0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695324526; x=1695929326; 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=vNE7U3MRFdvHzy3AatqQxrB+Rii45BA8np0vc2lW0nQ=; b=JKQoaCz4Z0nAa94+OcFf8rgA/Y6HuOl2NLoxUgbIIwO5gac2c31gEuw6jk4ffWunPE KLKQ99qgQg3ulyvKS/uUSE0Klubpe+mnuqJuxRpGwAXQ300lEmHi4/IJusWyW6lANCYY yH7ULXNfp4kprgLOdzmmAdcbhh7aPh9c83b0L51M99NETRNy79R4COxN7X2r1qCHyna4 c1nw9PJwvWZ9XKcsk2dI3Invvt1jUAJi8comjDkdl54/3pku2HBmlDkndYZ6Lz3qqgJO X7vH/qYXADZJxOTlC+FGOSwn/ORYA1jEBaV06hs4Bn7OKIlff2GGWHO65nI9qbX7NLZN 2HVQ== X-Gm-Message-State: AOJu0YxE23AFDJ+hxmQIhKpb4WNEeLpezutxqs5rvXtymx8ADyEfSQ9H /kDcbzlF18b/6+R1GImy9FH5JjvZV1Bw+mcm+fxS9RUB X-Google-Smtp-Source: AGHT+IFvUfNdgD3M025ie0SSfztu5G0EGA1WZyW9KYEx3xmH/xP1cMH0WFKYaDRfvGODLOGFhzZm+g== X-Received: by 2002:a17:902:7fce:b0:1bf:27a2:b52b with SMTP id t14-20020a1709027fce00b001bf27a2b52bmr5978389plb.58.1695324526019; Thu, 21 Sep 2023 12:28:46 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 12:28:45 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Subject: [RFT PATCH v2 11/12] drm/radeon: Call drm_helper_force_disable_all() at shutdown/remove time Date: Thu, 21 Sep 2023 12:26:54 -0700 Message-ID: <20230921122641.RFT.v2.11.I022cfc2dcd30e77d4f7005a2d912dd7ab76c0338@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-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: , Cc: Xinhui.Pan@amd.com, Douglas Anderson , amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, alexander.deucher@amd.com, christian.koenig@amd.com 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 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 39cdede460b5..67995ea24852 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 @@ -357,7 +358,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 @@ -368,6 +371,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 Thu Sep 21 19:26:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13394389 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 55DEBE7D0A2 for ; Thu, 21 Sep 2023 19:29:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0F4D110E602; Thu, 21 Sep 2023 19:29:03 +0000 (UTC) Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1CE7F10E5FF for ; Thu, 21 Sep 2023 19:28:50 +0000 (UTC) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1c4586b12feso11087745ad.2 for ; Thu, 21 Sep 2023 12:28:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695324529; x=1695929329; 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=6yWq/C0tGEFLQw6PZcuzFNMM1hDy2t48whBia8F49Jg=; b=AoIiSue3XWZTYqbaDx+xgbyTpQkTu/QPaBojtZ+UGpjBxx9muDoKy2THCzitzxAl8S 77YyPm+hAtXoQt1OgGSQchdghNvHgsbYXMSINIt46R1XjOGW5QZQ6T2jFS2TpQGIrS/b MbOpQ2V1VtismH/4IHHuSkWDzlPfr68BA/O1U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695324529; x=1695929329; 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=6yWq/C0tGEFLQw6PZcuzFNMM1hDy2t48whBia8F49Jg=; b=N1RCaZVWi/+o5vDMwqGu9yjSJ2RJBEjHTJhXgPBU2xRbyDONFRFp6bWn8uRFqImkEG tn1AIg09epOekpGtJ3UHEGdaP+wTrBM924RxXNx1HXb1C3ym8ikMYezwrziANRCLq4G1 7IAZ7+2dzA1qGnxCpV8eIjjJbX9V5yW/Y7PssWYbBFWKho6mSQeE3ZoVmIZEKsaRUGb5 S+PdL+hRFR7TenokQ09zCgNR8vBhYqf3LPwWy5EBZXpjyLdlZdzLYVXo0Mj7Ca9j0CHg SiyfTcbbtQMN3lfPjHnc0dmHEKvEKGj13Dkze7EDnkyli/XXPdaYWCKeufnGHh2mVeB6 YHzA== X-Gm-Message-State: AOJu0Yy8m1NAaI5EBxAy1mD5JOv2/8iQDKuJ6lo9SiHyFo8faVeejENY +LhAs/yPLiYS5aIg1cpEZyA3bpcjx7vLRRU/Ogp13IVs X-Google-Smtp-Source: AGHT+IG2w0WDLRZHyuJ2LAJ89ZhWzmeDvnFDIDFpOKHgPfnwnQMLnbx8TB6Jh7P+yKBv1bgwE5yOVg== X-Received: by 2002:a17:902:c409:b0:1c4:4a4d:cda with SMTP id k9-20020a170902c40900b001c44a4d0cdamr7404355plk.15.1695324528913; Thu, 21 Sep 2023 12:28:48 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 12:28:47 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Subject: [RFT PATCH v2 12/12] drm/renesas/shmobile: Call drm_helper_force_disable_all() at shutdown/remove time Date: Thu, 21 Sep 2023 12:26:55 -0700 Message-ID: <20230921122641.RFT.v2.12.Iaf638a1d4c8b3c307a6192efabb4cbb06b195f15@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-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: , Cc: paul@crapouillou.net, tzimmermann@suse.de, Geert Uytterhoeven , sam@ravnborg.org, Douglas Anderson , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, kieran.bingham+renesas@ideasonboard.com, laurent.pinchart@ideasonboard.com, biju.das.jz@bp.renesas.com 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 Cc: Geert Uytterhoeven Signed-off-by: Douglas Anderson --- This commit is only compile-time tested. As Geert pointed out in response to v1 [1], this patch conflicts with the patches doing atomic conversion [2]. Since those patches don't appear to be landed yet, I'm simply reposting v1. If those patches land, I'm more than happy to re-post this one. I'm also more than happy if someone wants to incorporate these changes into a different patch. [1] https://lore.kernel.org/r/CAMuHMdWOB7d-KE3F7aeZvVimNuy_U30uk=PND7=tWmPzCd7_eg@mail.gmail.com [2] https://lore.kernel.org/dri-devel/fd7a6702490bd431f314d6591551bb39e77e3304.1692178020.git.geert+renesas@glider.be/ Changes in v2: - Rebased and resolved conflicts. drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c index e5db4e0095ba..8c4c9d17a79e 100644 --- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c +++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -179,10 +180,18 @@ static void shmob_drm_remove(struct platform_device *pdev) drm_dev_unregister(ddev); drm_kms_helper_poll_fini(ddev); + drm_helper_force_disable_all(ddev); free_irq(sdev->irq, ddev); drm_dev_put(ddev); } +static void shmob_drm_shutdown(struct platform_device *pdev) +{ + struct shmob_drm_device *sdev = platform_get_drvdata(pdev); + + drm_helper_force_disable_all(sdev->ddev); +} + static int shmob_drm_probe(struct platform_device *pdev) { struct shmob_drm_platform_data *pdata = pdev->dev.platform_data; @@ -287,6 +296,7 @@ static int shmob_drm_probe(struct platform_device *pdev) static struct platform_driver shmob_drm_platform_driver = { .probe = shmob_drm_probe, .remove_new = shmob_drm_remove, + .shutdown = shmob_drm_shutdown, .driver = { .name = "shmob-drm", .pm = pm_sleep_ptr(&shmob_drm_pm_ops),