From nobody Fri Sep 20 11:35:00 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8D74CA0FF8 for ; Fri, 1 Sep 2023 23:43:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351287AbjIAXnw (ORCPT ); Fri, 1 Sep 2023 19:43:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351274AbjIAXnp (ORCPT ); Fri, 1 Sep 2023 19:43:45 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63480E65 for ; Fri, 1 Sep 2023 16:43:06 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-68a42d06d02so2152956b3a.0 for ; Fri, 01 Sep 2023 16:43:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611747; x=1694216547; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BTyJ24tKFqLRbG9l9nWJNLGooQV8nSVkH6ez/jxbol4=; b=hkWS55RtaRYoC++pEQHfK9W4knfRv2Ux2Si/fSXi4BYjJzjTcFtb0A22nPosUZoHBT OzD44z2cyEIoXxfkpHIW5bok4R+AyvILSGnXsjX120WoKqxbjzoZ2IvUTkAg6ZJc5eo8 UzHvW9IbAEVCeZGpq9uHfil0keEhPn7zsS6lI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693611747; x=1694216547; 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=BTyJ24tKFqLRbG9l9nWJNLGooQV8nSVkH6ez/jxbol4=; b=dLfE0JsxNe16F55OJq3cG3bv9zbjNRqaKO+WRx1Ib10bGYSVPnxP15ND1de0SQ9bLz BbpCkScscWj9scKSrWe1VZRvyFGtNSp0ztWh4l4AHlrzRAqDevYoc9h1FZ1IioLhPiB+ iv+iesEfMlodhbaAXAVNGRPz2qIS3csyx0FEkVgpv164HSCOZSYkz5xqS7HuTAFNNU8h K9FrI8MmtFzPT4A5qvbByhrSzKSyT+RS2P7UQfkk+mjuJaBwIZ329EUMJjAH/3Ax0CI6 /bjd91m3OErD/2mhUa5cgPpH0TW07POOl6dFtMsRIw9VbqqfuZcI76ffQmbce/fwjjPg mjsw== X-Gm-Message-State: AOJu0YzZ5YZeQWmMIsDDsEyrKiC3YBjXDPGPiNZA8givIodrbiQz0ehA PhNBHZj6gGBu6A3WfEC3FZEu9Q== X-Google-Smtp-Source: AGHT+IEdOoLZSYVgu/HM3/52v8vTtHyToRKvwsbcU9nHFrr/BHqKpV2ahyit9WDnLfZWVQbJOzkyGg== X-Received: by 2002:a05:6a20:191:b0:149:73f9:332f with SMTP id 17-20020a056a20019100b0014973f9332fmr3881021pzy.61.1693611746996; Fri, 01 Sep 2023 16:42:26 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8d94:1fc5:803c:41cc]) by smtp.gmail.com with ESMTPSA id o9-20020a639a09000000b0056c3a4a3ca5sm3326390pge.36.2023.09.01.16.42.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:42:26 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , airlied@gmail.com, daniel@ffwll.ch, linux-kernel@vger.kernel.org, linux@armlinux.org.uk Subject: [RFT PATCH 01/15] drm/armada: Call drm_atomic_helper_shutdown() at shutdown time Date: Fri, 1 Sep 2023 16:41:12 -0700 Message-ID: <20230901164111.RFT.1.I3d5598bd73a59b5ded71430736c93f67dc5dea61@changeid> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog In-Reply-To: <20230901234202.566951-1-dianders@chromium.org> References: <20230901234202.566951-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 was fairly easy to update. The drm_device is stored in the drvdata so we just have to make sure the drvdata is NULL whenever the device is not bound. To make things simpler, drm_atomic_helper_shutdown() has been modified to consider a NULL drm_device as a noop in the patch ("drm/atomic-helper: drm_atomic_helper_shutdown(NULL) should be a noop"). Suggested-by: Maxime Ripard Signed-off-by: Douglas Anderson Reviewed-by: Maxime Ripard --- This commit is only compile-time tested. drivers/gpu/drm/armada/armada_drv.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/a= rmada_drv.c index e8d2fe955909..fa1c67598706 100644 --- a/drivers/gpu/drm/armada/armada_drv.c +++ b/drivers/gpu/drm/armada/armada_drv.c @@ -148,6 +148,7 @@ static int armada_drm_bind(struct device *dev) err_kms: drm_mode_config_cleanup(&priv->drm); drm_mm_takedown(&priv->linear); + dev_set_drvdata(dev, NULL); return ret; } =20 @@ -166,6 +167,7 @@ static void armada_drm_unbind(struct device *dev) =20 drm_mode_config_cleanup(&priv->drm); drm_mm_takedown(&priv->linear); + dev_set_drvdata(dev, NULL); } =20 static void armada_add_endpoints(struct device *dev, @@ -230,6 +232,11 @@ static int armada_drm_remove(struct platform_device *p= dev) return 0; } =20 +static void armada_drm_shutdown(struct platform_device *pdev) +{ + drm_atomic_helper_shutdown(platform_get_drvdata(pdev)); +} + static const struct platform_device_id armada_drm_platform_ids[] =3D { { .name =3D "armada-drm", @@ -243,6 +250,7 @@ MODULE_DEVICE_TABLE(platform, armada_drm_platform_ids); static struct platform_driver armada_drm_platform_driver =3D { .probe =3D armada_drm_probe, .remove =3D armada_drm_remove, + .shutdown =3D armada_drm_shutdown, .driver =3D { .name =3D "armada-drm", }, --=20 2.42.0.283.g2d96d420d3-goog From nobody Fri Sep 20 11:35:00 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DEBBCA0FF8 for ; Fri, 1 Sep 2023 23:43:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351296AbjIAXn4 (ORCPT ); Fri, 1 Sep 2023 19:43:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351282AbjIAXnu (ORCPT ); Fri, 1 Sep 2023 19:43:50 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79EFD173B for ; Fri, 1 Sep 2023 16:43:09 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-68c0d886ea0so2220674b3a.2 for ; Fri, 01 Sep 2023 16:43:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611750; x=1694216550; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=T/+h1ksZof8y/lEEP6nhkNB4pCHzfTPQtm4LO74Tft4=; b=FdlQbxAP3ThBYl+AFQkfMCHFM3nQtldNjMXTWnQAwiu7CXblffV6hymNckLBhsNTR6 aFwhE8YlZv/XVxNxqVab6MMnHgPKStBs9VsB6l3WUmCKK/hF4xan4duzM2qvAYukP+Uk dX6n8uDRZVh+g4BkRKQG5ybmlIULnv+G83Slw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693611750; x=1694216550; 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=T/+h1ksZof8y/lEEP6nhkNB4pCHzfTPQtm4LO74Tft4=; b=H+5SCy73w9IRoRAnFdwjX8YYsKswU6CesyuZW+Or7u8IngoFPkwGkREfifbJT/GHVu hR/gc9ShjUM3S2jPLtiZRRfE3FZnuur55eKnwBheQAnk1hNdCroRxa1OktnHkePK0HH8 62F8JhpUfMXztp4/j6HRGDedmYAC/zutem5B40ALgjEgB0zdoKGwSnFasAazc26b1GbS Z3wc+Z3uuEd2ytvqZHERT0ufOo3omrWeWpKU3oo8q+rWm6kjrZ2ahzwbOiwoxMwkIFnS fq9w4IsJrv8eV0tZ9M3nZhIvUpDVmYP/uKusZ64U+9j+4HckaaHRrfAHvFubHLArIkkZ p4aA== X-Gm-Message-State: AOJu0Yx98UIJHwGbtb6pdH/1i/ag+Ij+W6vbwvxAO9k8mKYFyENNqhKE nBTOmyXK0TGpJgaEnTruBVbOKg== X-Google-Smtp-Source: AGHT+IEo8+vhlzHuiA7kt4gie7hkc/892ETxj7IzgIvbEImTbdys6UWMlOfB4tKXF+g1dIUU86Genw== X-Received: by 2002:a05:6a00:139c:b0:68a:5449:7436 with SMTP id t28-20020a056a00139c00b0068a54497436mr4995293pfg.32.1693611750394; Fri, 01 Sep 2023 16:42:30 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8d94:1fc5:803c:41cc]) by smtp.gmail.com with ESMTPSA id o9-20020a639a09000000b0056c3a4a3ca5sm3326390pge.36.2023.09.01.16.42.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:42:28 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , Sascha Hauer , airlied@gmail.com, daniel@ffwll.ch, festevam@gmail.com, kernel@pengutronix.de, l.stach@pengutronix.de, laurentiu.palcu@oss.nxp.com, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, shawnguo@kernel.org Subject: [RFT PATCH 02/15] drm/imx/dcss: Call drm_atomic_helper_shutdown() at shutdown time Date: Fri, 1 Sep 2023 16:41:13 -0700 Message-ID: <20230901164111.RFT.2.I134336fce7eac5a63bdac46d57b0888858fc8081@changeid> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog In-Reply-To: <20230901234202.566951-1-dianders@chromium.org> References: <20230901234202.566951-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Maxime Ripard --- This commit is only compile-time tested. 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_devi= ce *pdev) return 0; } =20 +static void dcss_drv_platform_shutdown(struct platform_device *pdev) +{ + struct dcss_drv *mdrv =3D dev_get_drvdata(&pdev->dev); + + dcss_kms_shutdown(mdrv->kms); +} + static struct dcss_type_data dcss_types[] =3D { [DCSS_IMX8MQ] =3D { .name =3D "DCSS_IMX8MQ", @@ -114,6 +121,7 @@ MODULE_DEVICE_TABLE(of, dcss_of_match); static struct platform_driver dcss_platform_driver =3D { .probe =3D dcss_drv_platform_probe, .remove =3D dcss_drv_platform_remove, + .shutdown =3D dcss_drv_platform_shutdown, .driver =3D { .name =3D "imx-dcss", .of_match_table =3D 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 =3D NULL; } + +void dcss_kms_shutdown(struct dcss_kms_dev *kms) +{ + struct drm_device *drm =3D &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 { =20 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, --=20 2.42.0.283.g2d96d420d3-goog From nobody Fri Sep 20 11:35:00 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57DBECA0FF9 for ; Fri, 1 Sep 2023 23:43:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351218AbjIAXny (ORCPT ); Fri, 1 Sep 2023 19:43:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351285AbjIAXnu (ORCPT ); Fri, 1 Sep 2023 19:43:50 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58A8B10F4 for ; Fri, 1 Sep 2023 16:43:10 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-68bec3a9bdbso1892980b3a.3 for ; Fri, 01 Sep 2023 16:43:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611752; x=1694216552; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1xwlQKSbvtJNXAzlNyEq/ahWjOdZU7CV+KOcQ65YIkM=; b=aVlD5jjy/Qg218fKCYzNuYtJ33Gd8uiHcIPcyMsfpuzzK4rMBUaOWCF59uET3HCAUW ezPyXWAnvq6OdkvwHAcdZI7xkg1xTi4tNvsoSAjgH8Wb23NjT3MV0CJMGZwvF/QiTusQ SZDhlv9Dvtaq5qt5UNy2r24waWPqRX9HIt8a0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693611752; x=1694216552; 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=1xwlQKSbvtJNXAzlNyEq/ahWjOdZU7CV+KOcQ65YIkM=; b=OkrELHN/Kkj5Iu7w6L6PGZHqKaJlNlMg4CxHZBVFwI2yHD0SSkz987AEYAGf9/4WQ5 UVBe1MlIV6RF1gTM7C8SwcmFyalx5wTJhsNzp/IKcB2TlgJL3dd0Cw9yR1QXp4BVkvYg l/FGoowEOBt+FU5zP56sBgxI0LlqK3n51U+7MXghew8BwzEmlBc1jHrguBWiE0MphOXk C5kPD7I6mMbanD4BIPypyUgzaTbm0vzmknWfX3PYqrCjczSeDbjSB7mgmikLr5vgaorm MPbSGvSPlvLc4Ks4HupFKcrDA72eVS6Ad40btfiaxAFwQSfjYSjJrrSIk4TMofhL1n05 /7XA== X-Gm-Message-State: AOJu0YwbCpgW8K1Y9QEgfav/jd5ecfKHiN54G2GrnnbJPu0xDvd6JtSd Jis84n6EUMn1cWBkM9qds2OuSQ== X-Google-Smtp-Source: AGHT+IGfL6uqts2F3xQJXwlYG+LNTYjXpiNnutEBct9PU2CYaFs2opMUSGjfnS0VF4YFDV8NxqnnXA== X-Received: by 2002:a05:6a00:2d99:b0:68c:431e:6490 with SMTP id fb25-20020a056a002d9900b0068c431e6490mr4989342pfb.1.1693611751966; Fri, 01 Sep 2023 16:42:31 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8d94:1fc5:803c:41cc]) by smtp.gmail.com with ESMTPSA id o9-20020a639a09000000b0056c3a4a3ca5sm3326390pge.36.2023.09.01.16.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:42:31 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , airlied@gmail.com, daniel@ffwll.ch, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, paul@crapouillou.net Subject: [RFT PATCH 03/15] drm/ingenic: Call drm_atomic_helper_shutdown() at shutdown time Date: Fri, 1 Sep 2023 16:41:14 -0700 Message-ID: <20230901164111.RFT.3.Iea742f06d8bec41598aa40378fc625fbd7e8a3d6@changeid> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog In-Reply-To: <20230901234202.566951-1-dianders@chromium.org> References: <20230901234202.566951-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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. Since this driver uses the component model and shutdown happens at the base driver, we communicate whether we have to call drm_atomic_helper_shutdown() by seeing if drvdata is non-NULL. Suggested-by: Maxime Ripard Signed-off-by: Douglas Anderson Acked-by: Paul Cercueil Reviewed-by: Maxime Ripard --- This commit is only compile-time tested. NOTE: this patch touches a lot more than other similar patches since the bind() function is long and we want to make sure that we unset the drvdata if bind() fails. While making this patch, I noticed that the bind() function of this driver is using "devm" and thus assumes it doesn't need to do much explicit error handling. That's actually 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 drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 66 +++++++++++++++-------- 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c b/drivers/gpu/drm/in= genic/ingenic-drm-drv.c index 8dbd4847d3a6..51995a0cd568 100644 --- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c +++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c @@ -1130,7 +1130,7 @@ static int ingenic_drm_bind(struct device *dev, bool = has_components) =20 ret =3D drmm_mode_config_init(drm); if (ret) - return ret; + goto err_drvdata; =20 drm->mode_config.min_width =3D 0; drm->mode_config.min_height =3D 0; @@ -1142,7 +1142,8 @@ static int ingenic_drm_bind(struct device *dev, bool = has_components) base =3D devm_platform_get_and_ioremap_resource(pdev, 0, &res); if (IS_ERR(base)) { dev_err(dev, "Failed to get memory resource\n"); - return PTR_ERR(base); + ret =3D PTR_ERR(base); + goto err_drvdata; } =20 regmap_config =3D ingenic_drm_regmap_config; @@ -1151,33 +1152,40 @@ static int ingenic_drm_bind(struct device *dev, boo= l has_components) ®map_config); if (IS_ERR(priv->map)) { dev_err(dev, "Failed to create regmap\n"); - return PTR_ERR(priv->map); + ret =3D PTR_ERR(priv->map); + goto err_drvdata; } =20 irq =3D platform_get_irq(pdev, 0); - if (irq < 0) - return irq; + if (irq < 0) { + ret =3D irq; + goto err_drvdata; + } =20 if (soc_info->needs_dev_clk) { priv->lcd_clk =3D devm_clk_get(dev, "lcd"); if (IS_ERR(priv->lcd_clk)) { dev_err(dev, "Failed to get lcd clock\n"); - return PTR_ERR(priv->lcd_clk); + ret =3D PTR_ERR(priv->lcd_clk); + goto err_drvdata; } } =20 priv->pix_clk =3D devm_clk_get(dev, "lcd_pclk"); if (IS_ERR(priv->pix_clk)) { dev_err(dev, "Failed to get pixel clock\n"); - return PTR_ERR(priv->pix_clk); + ret =3D PTR_ERR(priv->pix_clk); + goto err_drvdata; } =20 priv->dma_hwdescs =3D dmam_alloc_coherent(dev, sizeof(*priv->dma_hwdescs), &priv->dma_hwdescs_phys, GFP_KERNEL); - if (!priv->dma_hwdescs) - return -ENOMEM; + if (!priv->dma_hwdescs) { + ret =3D -ENOMEM; + goto err_drvdata; + } =20 /* Configure DMA hwdesc for foreground0 plane */ ingenic_drm_configure_hwdesc_plane(priv, 0); @@ -1199,7 +1207,7 @@ static int ingenic_drm_bind(struct device *dev, bool = has_components) NULL, DRM_PLANE_TYPE_PRIMARY, NULL); if (ret) { dev_err(dev, "Failed to register plane: %i\n", ret); - return ret; + goto err_drvdata; } =20 if (soc_info->map_noncoherent) @@ -1211,7 +1219,7 @@ static int ingenic_drm_bind(struct device *dev, bool = has_components) NULL, &ingenic_drm_crtc_funcs, NULL); if (ret) { dev_err(dev, "Failed to init CRTC: %i\n", ret); - return ret; + goto err_drvdata; } =20 drm_crtc_enable_color_mgmt(&priv->crtc, 0, false, @@ -1230,7 +1238,7 @@ static int ingenic_drm_bind(struct device *dev, bool = has_components) if (ret) { dev_err(dev, "Failed to register overlay plane: %i\n", ret); - return ret; + goto err_drvdata; } =20 if (soc_info->map_noncoherent) @@ -1241,17 +1249,18 @@ static int ingenic_drm_bind(struct device *dev, boo= l has_components) if (ret) { if (ret !=3D -EPROBE_DEFER) dev_err(dev, "Failed to bind components: %i\n", ret); - return ret; + goto err_drvdata; } =20 ret =3D devm_add_action_or_reset(dev, ingenic_drm_unbind_all, priv); if (ret) - return ret; + goto err_drvdata; =20 priv->ipu_plane =3D drm_plane_from_index(drm, 2); if (!priv->ipu_plane) { dev_err(dev, "Failed to retrieve IPU plane\n"); - return -EINVAL; + ret =3D -EINVAL; + goto err_drvdata; } } } @@ -1263,7 +1272,7 @@ static int ingenic_drm_bind(struct device *dev, bool = has_components) break; /* we're done */ if (ret !=3D -EPROBE_DEFER) dev_err(dev, "Failed to get bridge handle\n"); - return ret; + goto err_drvdata; } =20 if (panel) @@ -1275,7 +1284,7 @@ static int ingenic_drm_bind(struct device *dev, bool = has_components) if (IS_ERR(ib)) { ret =3D PTR_ERR(ib); dev_err(dev, "Failed to init encoder: %d\n", ret); - return ret; + goto err_drvdata; } =20 encoder =3D &ib->encoder; @@ -1290,13 +1299,14 @@ static int ingenic_drm_bind(struct device *dev, boo= l has_components) DRM_BRIDGE_ATTACH_NO_CONNECTOR); if (ret) { dev_err(dev, "Unable to attach bridge\n"); - return ret; + goto err_drvdata; } =20 connector =3D drm_bridge_connector_init(drm, encoder); if (IS_ERR(connector)) { dev_err(dev, "Unable to init connector\n"); - return PTR_ERR(connector); + ret =3D PTR_ERR(connector); + goto err_drvdata; } =20 drm_connector_attach_encoder(connector, encoder); @@ -1313,13 +1323,13 @@ static int ingenic_drm_bind(struct device *dev, boo= l has_components) ret =3D devm_request_irq(dev, irq, ingenic_drm_irq_handler, 0, drm->drive= r->name, drm); if (ret) { dev_err(dev, "Unable to install IRQ handler\n"); - return ret; + goto err_drvdata; } =20 ret =3D drm_vblank_init(drm, 1); if (ret) { dev_err(dev, "Failed calling drm_vblank_init()\n"); - return ret; + goto err_drvdata; } =20 drm_mode_config_reset(drm); @@ -1327,7 +1337,7 @@ static int ingenic_drm_bind(struct device *dev, bool = has_components) ret =3D clk_prepare_enable(priv->pix_clk); if (ret) { dev_err(dev, "Unable to start pixel clock\n"); - return ret; + goto err_drvdata; } =20 if (priv->lcd_clk) { @@ -1402,6 +1412,8 @@ static int ingenic_drm_bind(struct device *dev, bool = has_components) clk_disable_unprepare(priv->lcd_clk); err_pixclk_disable: clk_disable_unprepare(priv->pix_clk); +err_drvdata: + platform_set_drvdata(pdev, NULL); return ret; } =20 @@ -1422,6 +1434,7 @@ static void ingenic_drm_unbind(struct device *dev) =20 drm_dev_unregister(&priv->drm); drm_atomic_helper_shutdown(&priv->drm); + dev_set_drvdata(dev, NULL); } =20 static const struct component_master_ops ingenic_master_ops =3D { @@ -1461,6 +1474,14 @@ static int ingenic_drm_remove(struct platform_device= *pdev) return 0; } =20 +static void ingenic_drm_shutdown(struct platform_device *pdev) +{ + struct ingenic_drm *priv =3D platform_get_drvdata(pdev); + + if (priv) + drm_atomic_helper_shutdown(&priv->drm); +} + static int ingenic_drm_suspend(struct device *dev) { struct ingenic_drm *priv =3D dev_get_drvdata(dev); @@ -1612,6 +1633,7 @@ static struct platform_driver ingenic_drm_driver =3D { }, .probe =3D ingenic_drm_probe, .remove =3D ingenic_drm_remove, + .shutdown =3D ingenic_drm_shutdown, }; =20 static int ingenic_drm_init(void) --=20 2.42.0.283.g2d96d420d3-goog From nobody Fri Sep 20 11:35:00 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF62ECA0FF6 for ; Fri, 1 Sep 2023 23:43:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236764AbjIAXn6 (ORCPT ); Fri, 1 Sep 2023 19:43:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351291AbjIAXnw (ORCPT ); Fri, 1 Sep 2023 19:43:52 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE53E1704 for ; Fri, 1 Sep 2023 16:43:11 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-68becf931d0so2105912b3a.3 for ; Fri, 01 Sep 2023 16:43:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611754; x=1694216554; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Cc544bXmls05RiqEx12Xvv3H5cbPiv1GFPSua0tXsTc=; b=YXss6mMzpdVvjXsykrn+LndV+HjfcsmnWCzCgkl1+vpTTshlChiwvUPRgOkWmk6R/Z /D/B4thnbxmEk9680HgW6u9N3rw4gaTr12XvR8wzXwnUoU9rHtHoyNjCdVBq+vTr8Wp0 OPuOBdD3Q9XHyuZMkow/SiqekkAVh2G2on3dg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693611754; x=1694216554; 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=Cc544bXmls05RiqEx12Xvv3H5cbPiv1GFPSua0tXsTc=; b=jnFkiGBsFNSGFFLz7AJNjaCuPyhdmiUniOjdtm3hO/hWyiVg+E9Oz732Tr1agCC1Ko r3iT8/jg99280ULBPN5xUSyGE9lPHcIstqSuaht/y1WRpoPEFdG6Y1n+Vp6KVLrxrb/e /UZvTapJZKt3aFAzRdNTT8mgRDVhS/jOjWxvpRSEcZ2aORi2ieFQvvVmtMXC1vua+RoU CyyKHjIY3J3jgCfLCJ7OVT34SyTsSXz8ob5tbF10GExxMghIpCdEWbcIovxXNxreko0b nQOEhPYbOGMwo+KAIvV2tIvY8PAf/fKI/LLA2LEfkgIHQ4Lri6lDf+CZgBH+dyS5CimC zeHQ== X-Gm-Message-State: AOJu0Yw4b+EDQ5gRxobBsD1QTKY59vcu/7kTKntUP58SiJT2A8yIpjF6 HbGXjJuOgeakwDQvoBlfO/e4MQ== X-Google-Smtp-Source: AGHT+IGAoNt4CxHEBkp++4gMl/OPzz+Yhylo+U5CTknKu4gd+KmH9VfQD9fB/cKCtbNNcv6lJ8N/6g== X-Received: by 2002:a05:6a20:7da0:b0:126:9081:2156 with SMTP id v32-20020a056a207da000b0012690812156mr5068857pzj.4.1693611754018; Fri, 01 Sep 2023 16:42:34 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8d94:1fc5:803c:41cc]) by smtp.gmail.com with ESMTPSA id o9-20020a639a09000000b0056c3a4a3ca5sm3326390pge.36.2023.09.01.16.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:42:33 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , airlied@gmail.com, anitha.chrisanthus@intel.com, daniel@ffwll.ch, edmund.j.dea@intel.com, linux-kernel@vger.kernel.org Subject: [RFT PATCH 04/15] drm/kmb: Call drm_atomic_helper_shutdown() at shutdown time Date: Fri, 1 Sep 2023 16:41:15 -0700 Message-ID: <20230901164111.RFT.4.I20cb02bafa7c2368e4bd579df0716eb62a3a21bf@changeid> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog In-Reply-To: <20230901234202.566951-1-dianders@chromium.org> References: <20230901234202.566951-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Maxime Ripard --- This commit is only compile-time tested. 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; } =20 +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 =3D get_device(&pdev->dev); @@ -622,6 +627,7 @@ static SIMPLE_DEV_PM_OPS(kmb_pm_ops, kmb_pm_suspend, km= b_pm_resume); static struct platform_driver kmb_platform_driver =3D { .probe =3D kmb_probe, .remove =3D kmb_remove, + .shutdown =3D kmb_shutdown, .driver =3D { .name =3D "kmb-drm", .pm =3D &kmb_pm_ops, --=20 2.42.0.283.g2d96d420d3-goog From nobody Fri Sep 20 11:35:00 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEC43CA0FF9 for ; Fri, 1 Sep 2023 23:43:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351311AbjIAXoB (ORCPT ); Fri, 1 Sep 2023 19:44:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351295AbjIAXnw (ORCPT ); Fri, 1 Sep 2023 19:43:52 -0400 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A536610D2 for ; Fri, 1 Sep 2023 16:43:13 -0700 (PDT) Received: by mail-oi1-x22d.google.com with SMTP id 5614622812f47-3a7aedc57ffso1704374b6e.2 for ; Fri, 01 Sep 2023 16:43:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611756; x=1694216556; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Vomcb5R4YlkPi6yAEBTRSlkjqsgpX/8uar7hs/ep3QM=; b=A7fmUeitqUvMSMxFr2TLY4xst8WEqKgsQ+7/zrV+uQ5GbVRHdeb1Vfk7sl0Bv72LSf LTCLKLWsgmayPd2Cgsvrz9XVP2Gd7i4e50LO4J8Fj2LLzzCzdYju5CfaySBQwipS4taX DUCBF8y+V9eXROX/bvFSB3Wxx7xY2UNnOzPE0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693611756; x=1694216556; 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=Vomcb5R4YlkPi6yAEBTRSlkjqsgpX/8uar7hs/ep3QM=; b=WqvYFspznmpOJhQOSxuQxd9NBtv8QH5WdFPP+Peq8l+1gf8qCpvt5SpE6MWbIu3ma1 9f6qaJT5mOQc636qnMk2nrFhSFODp1CmsufYkrJ/IPsj3I4zviqG0kjorM8tJ5WY0S11 uDvWnK2TPKzf/rSsit2vt27KTKX0sDQ8kHDpbikUjW+HobiJQSp2qwUKrPnjMvBWDcm9 eSmrORcf24BMOijWsJk3cx715+tzMZTEhJiAYrdxQJzJHUYDc5lfgqP1m63S0EH7lAXJ 4n/xg3FsFvuJNFSixA6tXTclkYl9R7eKRQhuAm1cGxp23OPWwiMeu5hqnpHguDJHKhDB +GCg== X-Gm-Message-State: AOJu0Yz79peNy+YWNQ/57hof8sQ6ZKVfAzBVj61BtJ56w6Ehr0aW2gq+ 7hnUZwGpt+2trDtzoHA5yegj6AmnSLaqFawtRu9mdxNz X-Google-Smtp-Source: AGHT+IH161FDJO4p2lz9ilVRETKBQ5UyI7NChHl4VMZC9iScfWTxID2/lUEJl6hXY/byI5CWz2ElFA== X-Received: by 2002:a05:6808:28e:b0:3a7:a299:1201 with SMTP id z14-20020a056808028e00b003a7a2991201mr4034449oic.23.1693611755813; Fri, 01 Sep 2023 16:42:35 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8d94:1fc5:803c:41cc]) by smtp.gmail.com with ESMTPSA id o9-20020a639a09000000b0056c3a4a3ca5sm3326390pge.36.2023.09.01.16.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:42:35 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , airlied@gmail.com, angelogioacchino.delregno@collabora.com, chunkuang.hu@kernel.org, daniel@ffwll.ch, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com, p.zabel@pengutronix.de Subject: [RFT PATCH 05/15] drm/mediatek: Call drm_atomic_helper_shutdown() at shutdown time Date: Fri, 1 Sep 2023 16:41:16 -0700 Message-ID: <20230901164111.RFT.5.I2b014f90afc4729b6ecc7b5ddd1f6dedcea4625b@changeid> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog In-Reply-To: <20230901234202.566951-1-dianders@chromium.org> References: <20230901234202.566951-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Douglas Anderson Reviewed-by: Fei Shao Reviewed-by: Maxime Ripard Tested-by: Fei Shao --- This commit is only compile-time tested. 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/media= tek/mtk_drm_drv.c index 961715dd5b11..8b1c9c992ca8 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c @@ -921,6 +921,14 @@ static int mtk_drm_remove(struct platform_device *pdev) return 0; } =20 +static void mtk_drm_shutdown(struct platform_device *pdev) +{ + struct mtk_drm_private *private =3D 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 =3D dev_get_drvdata(dev); @@ -952,6 +960,7 @@ static const struct dev_pm_ops mtk_drm_pm_ops =3D { static struct platform_driver mtk_drm_platform_driver =3D { .probe =3D mtk_drm_probe, .remove =3D mtk_drm_remove, + .shutdown =3D mtk_drm_shutdown, .driver =3D { .name =3D "mediatek-drm", .pm =3D &mtk_drm_pm_ops, --=20 2.42.0.283.g2d96d420d3-goog From nobody Fri Sep 20 11:35:00 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58E88CA0FF8 for ; Fri, 1 Sep 2023 23:44:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351326AbjIAXoG (ORCPT ); Fri, 1 Sep 2023 19:44:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351285AbjIAXnz (ORCPT ); Fri, 1 Sep 2023 19:43:55 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54BC41703 for ; Fri, 1 Sep 2023 16:43:17 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-68a3082c771so340959b3a.0 for ; Fri, 01 Sep 2023 16:43:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611759; x=1694216559; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vRgeQgzVDXmV3JVrPP8xBMX8Swv3+BcS7jAR8idQ+gY=; b=bcjq8jVo0Ijsz3DQFoySHvk5wqEdGVzN/pmgkQfESizm33hNnGl7+hmTCqy85FWuwU qguSP63ORXIla+/osCVP6bDCqrw7MobNWwldkRX4mlEw2ZTRUqQPmy8Bm1KtePVvxEWu Ni3/jMGgOCccZdZkZvFkjOMYKuQFoYZmVzcDM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693611759; x=1694216559; 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=vRgeQgzVDXmV3JVrPP8xBMX8Swv3+BcS7jAR8idQ+gY=; b=b3WyTchnL2oGO9vRx4ap2uCvA+8GSc43uYCJtV+1HNNynRZfA3LQXXjNCm6RqCz/pV AalghPY8TTYZ1HLNowK6f80emo/0dG9jw7z/aR+/vI8dkL7vKNy+WVw7YoWwJZGF4Fvl 5K+FBu2ljI2LYYqDAoNwa9ksAmD3xO5aaog8O3zlRRDczDxgoYVEfEz912mindND7d2L y00bokQKxCZldKBqlNeBkTvsTqN+h4bc4mexXXrXYabxBLKelJ1nNqHNLx3x0sbPTL0s P81cqbTeBhgry4FMw85WUrLcWgG4xtX0crk/cPMiRXZOuflNT7ru5tVPHlCXvzjQxjaP m1PA== X-Gm-Message-State: AOJu0YwGVo+x8teMc45Lg9z1fPkp0c/O/kx1UhEzYvMxtJ/Zg/pTeErh PQtg8u6z5inUYbhOmkZj3azeloXiRPfKVxCzQ1AsVsXz X-Google-Smtp-Source: AGHT+IGtmbAKHGuLHO3p7Yzikip33D41k/UMdvLiEDSJbNafsboBSz7i0yyxWsOXwhZuzfQmGxSWqA== X-Received: by 2002:a05:6a00:4c8f:b0:68c:59cb:2dd9 with SMTP id eb15-20020a056a004c8f00b0068c59cb2dd9mr5216448pfb.1.1693611759266; Fri, 01 Sep 2023 16:42:39 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8d94:1fc5:803c:41cc]) by smtp.gmail.com with ESMTPSA id o9-20020a639a09000000b0056c3a4a3ca5sm3326390pge.36.2023.09.01.16.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:42:38 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , airlied@gmail.com, bskeggs@redhat.com, daniel@ffwll.ch, kherbst@redhat.com, linux-kernel@vger.kernel.org, lyude@redhat.com, nouveau@lists.freedesktop.org Subject: [RFT PATCH 06/15] drm/nouveau: Call drm_atomic_helper_shutdown() or equiv at shutdown time Date: Fri, 1 Sep 2023 16:41:17 -0700 Message-ID: <20230901164111.RFT.6.Ie7588ec6e0f93e8bc700e76b265ad1a7ad6b15ad@changeid> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog In-Reply-To: <20230901234202.566951-1-dianders@chromium.org> References: <20230901234202.566951-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Douglas Anderson Reviewed-by: Maxime Ripard --- 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. 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/no= uveau/nouveau_display.c index 99977e5fe716..04b3a3c0b5a5 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 susp= end, bool runtime) disp->fini(dev, runtime, suspend); } =20 +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/no= uveau/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 runtim= e); void nouveau_display_hpd_resume(struct drm_device *dev); void nouveau_display_fini(struct drm_device *dev, bool suspend, bool runti= me); +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/nouvea= u/nouveau_drm.c index 4396f501b16a..d8e8160cdf35 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); } =20 +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) { @@ -1343,6 +1355,7 @@ nouveau_drm_pci_driver =3D { .id_table =3D nouveau_drm_pci_table, .probe =3D nouveau_drm_probe, .remove =3D nouveau_drm_remove, + .shutdown =3D nouveau_drm_shutdown, .driver.pm =3D &nouveau_pm_ops, }; =20 diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouvea= u/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); =20 #define NV_PRINTK(l,c,f,a...) do { = \ struct nouveau_cli *_cli =3D (c); \ diff --git a/drivers/gpu/drm/nouveau/nouveau_platform.c b/drivers/gpu/drm/n= ouveau/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_devic= e *pdev) return 0; } =20 +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 =3D { .iommu_bit =3D 34, @@ -94,4 +99,5 @@ struct platform_driver nouveau_platform_driver =3D { }, .probe =3D nouveau_platform_probe, .remove =3D nouveau_platform_remove, + .shutdown =3D nouveau_platform_shutdown, }; --=20 2.42.0.283.g2d96d420d3-goog From nobody Fri Sep 20 11:35:00 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5B67CA0FF9 for ; Fri, 1 Sep 2023 23:44:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351320AbjIAXoE (ORCPT ); Fri, 1 Sep 2023 19:44:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351298AbjIAXn5 (ORCPT ); Fri, 1 Sep 2023 19:43:57 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E768110F3 for ; Fri, 1 Sep 2023 16:43:18 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-68bedc0c268so2192315b3a.0 for ; Fri, 01 Sep 2023 16:43:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611761; x=1694216561; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZQWyzi0Qz9s7AgC5vmSBsF4S5izX7bpWF4dQoTwwlFk=; b=jhUQa6qXTunywrIOeBZdxAC0cZcKoiae62syhjWvn2iIBqYXWYMtrPCoHaxnZuRClA zc1aeCY9/w3g+jG9YcaRJ8LBOIE29AIrQqzq7yMDRQOwbvxy+TClLjkC7V0PmbL6/kFY 7XhjT1BndeQjl5wx4XxG7YQ35+SubywsTRd8g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693611761; x=1694216561; 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=ZQWyzi0Qz9s7AgC5vmSBsF4S5izX7bpWF4dQoTwwlFk=; b=gb4AHL/PWA98BaTJO50txam/WEKFPKgOAGMnpNuZY6agkNH4lhtP9kWK5gjxD/WoxG JBSnL7SWZpLeEfRAxkyM+WZ0mMSWMRJLK8smSHaoNLvuKuRCfGiLc6888gsSR3S6fBSl GwdF4HbYS3M0pLCGWvAJ6ESdntUBIl45FlTKDpuaIfMZmN0XQ9DmBEJ0/aAwm9X4r1Mr /qyHc0EIlWscei2OAPiNTP5fcdJb70v4RjdiCEgqD88+lijrI8sdv0F/kRMExkqMQeD6 eRKsgDMZgsfv+HIkOuWVY3J4lqIA0izh4ZM4WVMHLcETL4G6F4YV6xrK59DiQv2wfEMD /RBA== X-Gm-Message-State: AOJu0YxOi2Rbhcu8MYmI5XPJENt3U6i0PB4eY97BTdOYubGyTejCaIwK 3UhdCF4SnJxWVTEsv4v6BY0yAg== X-Google-Smtp-Source: AGHT+IF5BMwzbAVcMICDe8gM+PDdxCL3nr7AkrZf9oUjU4217SZ+nxlT0MJiiAfrSttf6dGmLwxm3Q== X-Received: by 2002:a05:6a20:9144:b0:135:110c:c6de with SMTP id x4-20020a056a20914400b00135110cc6demr5402182pzc.6.1693611761326; Fri, 01 Sep 2023 16:42:41 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8d94:1fc5:803c:41cc]) by smtp.gmail.com with ESMTPSA id o9-20020a639a09000000b0056c3a4a3ca5sm3326390pge.36.2023.09.01.16.42.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:42:40 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , airlied@gmail.com, daniel@ffwll.ch, jonathanh@nvidia.com, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, mperttunen@nvidia.com, thierry.reding@gmail.com Subject: [RFT PATCH 07/15] drm/tegra: Call drm_atomic_helper_shutdown() at shutdown time Date: Fri, 1 Sep 2023 16:41:18 -0700 Message-ID: <20230901164111.RFT.7.Ifb4450979b62976fd5a98847dade2e5b377d47c8@changeid> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog In-Reply-To: <20230901234202.566951-1-dianders@chromium.org> References: <20230901234202.566951-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Maxime Ripard --- This commit is only compile-time tested. 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 *d= ev) return 0; } =20 +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 =3D { }, .probe =3D host1x_drm_probe, .remove =3D host1x_drm_remove, + .shutdown =3D host1x_drm_shutdown, .subdevs =3D host1x_drm_subdevs, }; =20 --=20 2.42.0.283.g2d96d420d3-goog From nobody Fri Sep 20 11:35:00 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB197CA0FF8 for ; Fri, 1 Sep 2023 23:44:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351341AbjIAXoI (ORCPT ); Fri, 1 Sep 2023 19:44:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351277AbjIAXn7 (ORCPT ); Fri, 1 Sep 2023 19:43:59 -0400 Received: from mail-oo1-xc2f.google.com (mail-oo1-xc2f.google.com [IPv6:2607:f8b0:4864:20::c2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 513C41991 for ; Fri, 1 Sep 2023 16:43:23 -0700 (PDT) Received: by mail-oo1-xc2f.google.com with SMTP id 006d021491bc7-5735282d713so1489469eaf.2 for ; Fri, 01 Sep 2023 16:43:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611763; x=1694216563; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e4TY+mfn1StbQRy79Smag9rvt1YGLeZB0A1g4xD0EoY=; b=L0wEXyKYEB/0OrpRhb6aZ3Y6qlbzCX9Tvh0R632JS86KqJ+gvBqFEZaxYw2YqPG+kU daasImSVboWjZQacBJBKfA8jRpFzuGQNSIvHYcTy6I2phEKirrYaInK6wZD7ocWjzle3 1S6WM1H08S0hX7x713avyr6623kVVyonqeuE0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693611763; x=1694216563; 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=e4TY+mfn1StbQRy79Smag9rvt1YGLeZB0A1g4xD0EoY=; b=Ar4BfNccFOszE4LrnH2bKoJzfoMX91oMyFJJTxsVZOL0k04NOIO+WUI0yGVRNYX+mF Lb0nJaW4GaUL7MWMm9SNW1VN99Y/nDp3qmuqHjODiCGDyNg07jZqnBpthySzccBRjvN9 6dQaiAfX89+uDJvHoChElC5G8HjJqjqblomAq5lDAwY+xgstw+DK66Cc34mrzkz2O3u0 5Y7/BkWpiw15u90lwv+Od+5ilGI2nODE/On2YzlE7HIygqpIQWBPrLc8iqsbD79VlxkH Qc41O1HwW0WWABwQ22u1mt2jmp+bzfZvkTfjbHbYRwfNeD4KqmqeejZklO7VlX7kZdy9 vq1Q== X-Gm-Message-State: AOJu0YwuWy70qubZGAGv/n9jfgxQc+WGuTPCLPWdxh4qPwRxc/wth6Qt kBk2SOWYwummo+PI6luxHPj3AQ== X-Google-Smtp-Source: AGHT+IF7UPzkkGzgqVZz1o/USebNUQJU5okEoq2BB0eQhVhRuIETriXPYYu2vmslkxHSUlAV+cQf2A== X-Received: by 2002:a05:6358:6f92:b0:134:e603:116e with SMTP id s18-20020a0563586f9200b00134e603116emr4089163rwn.6.1693611762893; Fri, 01 Sep 2023 16:42:42 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8d94:1fc5:803c:41cc]) by smtp.gmail.com with ESMTPSA id o9-20020a639a09000000b0056c3a4a3ca5sm3326390pge.36.2023.09.01.16.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:42:42 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , abrodkin@synopsys.com, airlied@gmail.com, daniel@ffwll.ch, linux-kernel@vger.kernel.org Subject: [RFT PATCH 08/15] drm/arcpgu: Call drm_atomic_helper_shutdown() at shutdown time Date: Fri, 1 Sep 2023 16:41:19 -0700 Message-ID: <20230901164111.RFT.8.I8a0a246fea222059881d01a8fff2adcf7ef3d7a4@changeid> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog In-Reply-To: <20230901234202.566951-1-dianders@chromium.org> References: <20230901234202.566951-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Maxime Ripard --- This commit is only compile-time tested. 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; } =20 +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[] =3D { {.compatible =3D "snps,arcpgu"}, {} @@ -424,6 +429,7 @@ MODULE_DEVICE_TABLE(of, arcpgu_of_table); static struct platform_driver arcpgu_platform_driver =3D { .probe =3D arcpgu_probe, .remove =3D arcpgu_remove, + .shutdown =3D arcpgu_shutdown, .driver =3D { .name =3D "arcpgu", .of_match_table =3D arcpgu_of_table, --=20 2.42.0.283.g2d96d420d3-goog From nobody Fri Sep 20 11:35:00 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E881CA0FF6 for ; Fri, 1 Sep 2023 23:44:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351343AbjIAXoK (ORCPT ); Fri, 1 Sep 2023 19:44:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351300AbjIAXn7 (ORCPT ); Fri, 1 Sep 2023 19:43:59 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 012171705 for ; Fri, 1 Sep 2023 16:43:23 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-68a42d06d02so2153070b3a.0 for ; Fri, 01 Sep 2023 16:43:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611765; x=1694216565; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=B1wNSnWkGtYsqmdJ7SiIP0G54S9pY24k7p5P1n8MG+s=; b=LRVbvyJLIf2G4Y1E4c9uUZDwHa6Lv59cz/pI/FIodexSSlLcPDdZr/X+85OGrBDOMb kbKhrHQ2EAkr14QjJzXpSIMaD4IAy0g0IJQgk5Ivrrtj7rrckRHKUtbTgQDpsooMQ8E2 zdzl24htGHoenngLd5pjgD1rcTwJ3AAZebdVg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693611765; x=1694216565; 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=B1wNSnWkGtYsqmdJ7SiIP0G54S9pY24k7p5P1n8MG+s=; b=gu6enYLvKYfWY0paG7jHGjWTLy3gKmfmAUC1Y1cr8DncpBqTKUSOyWb+oHOiWCsnrG I+5TsKaT/jvfzZkkx+tJVcGS7MbcEbfF3XrCT8Y8W39KRnEA1C+1R2Ky+Uxk6MvpGGM6 zqZRwSxpBF7Eo6z6R19/qpss0x6dSD8+uomFRPRCh7FItLqUwl+z2giRNbEAmWoH+Jr1 4tpUErRJDVT1VwT7KivdRxM4Til/1yOxojfJH/y1zBd4wdYyO0oIvwACjRoHB+8Aq1X2 7wjTcJfFb9AY5WEEF49bzjCxZWB7VdutMcUFguOvFA2y5f0CCuJVt4/TDsXAprVxi6+L ihxA== X-Gm-Message-State: AOJu0YwcVI1/AqSMWaIsgS6i2cIUC1vLeCEro5YY0M36JwaU5fQ/ifs9 EEm4Ea7CU3xeHXSGzJlBPnbmPQ== X-Google-Smtp-Source: AGHT+IEkl683gWaaIdVyv+hHmYbbrgZJNsGzwDeq5vblOp769UBG3JrWsk8J+Ps9xjU1Cfx4ftFMxQ== X-Received: by 2002:a05:6a00:2484:b0:68b:e7d4:2564 with SMTP id c4-20020a056a00248400b0068be7d42564mr4944901pfv.24.1693611765024; Fri, 01 Sep 2023 16:42:45 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8d94:1fc5:803c:41cc]) by smtp.gmail.com with ESMTPSA id o9-20020a639a09000000b0056c3a4a3ca5sm3326390pge.36.2023.09.01.16.42.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:42:44 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , Bokun.Zhang@amd.com, Hawking.Zhang@amd.com, James.Zhu@amd.com, Victor.Zhao@amd.com, Xinhui.Pan@amd.com, YiPeng.Chai@amd.com, airlied@gmail.com, alexander.deucher@amd.com, amd-gfx@lists.freedesktop.org, christian.koenig@amd.com, daniel@ffwll.ch, le.ma@amd.com, lijo.lazar@amd.com, linux-kernel@vger.kernel.org, maarten.lankhorst@linux.intel.com, mario.limonciello@amd.com, mdaenzer@redhat.com, shiwu.zhang@amd.com, srinivasan.shanmugam@amd.com, tzimmermann@suse.de Subject: [RFT PATCH 09/15] drm/amdgpu: Call drm_atomic_helper_shutdown() at shutdown time Date: Fri, 1 Sep 2023 16:41:20 -0700 Message-ID: <20230901164111.RFT.9.I27914059cc822b52db9bf72b4013b525b60e06fd@changeid> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog In-Reply-To: <20230901234202.566951-1-dianders@chromium.org> References: <20230901234202.566951-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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! 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/amdg= pu/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(s= truct 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); =20 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/a= md/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 *ade= v) =20 } =20 +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 =3D pci_get_drvdata(pdev); struct amdgpu_device *adev =3D drm_to_adev(dev); =20 + amdgpu_device_shutdown_hw(adev); + if (amdgpu_ras_intr_triggered()) return; =20 --=20 2.42.0.283.g2d96d420d3-goog From nobody Fri Sep 20 11:35:00 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97250CA0FF9 for ; Fri, 1 Sep 2023 23:44:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351360AbjIAXoN (ORCPT ); Fri, 1 Sep 2023 19:44:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351278AbjIAXoC (ORCPT ); Fri, 1 Sep 2023 19:44:02 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E60F6170A for ; Fri, 1 Sep 2023 16:43:26 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-68bedc0c268so2192385b3a.0 for ; Fri, 01 Sep 2023 16:43:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611767; x=1694216567; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=84GRgyYKdpTNARq0AeOvL2Otr8e52pcbhFdnubGKvgE=; b=GMEOdQfTBQielRTVFsB9Q8nNCGjgUsI2cc4mVTPT4ZzD7rKwi8SaChhlomKP9oZHPz 11niVblCod0vRIwGRYqGc73UAcXT4rzp+QHYguoTGhpTweQoJ2ICQK0vDzACqJqJyt08 skjLoZmi8pdTL96vROt4L+w1SvvKRPLyXVaL4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693611767; x=1694216567; 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=84GRgyYKdpTNARq0AeOvL2Otr8e52pcbhFdnubGKvgE=; b=euKPEjzKcuEdX6iLGcUZEuX6R+quZ6iEE/hnDFN0jmv8SgE1gz/IqJZ82IKd6q6NcJ 8kXffczOhkeZ4UYtubZc7A2oaoPx3JprlRDsZ1jRjFst18MplvK/OlpXyrgQJjiE38RT S1yZctnvLpOkLKHe3iszszSU2hpN0oJWWGhxczwRGbBFvU1HN8QVYmv/FOmhyKTUxwk1 7J6zqgNij47O4bXl84FwHvGe1SzTDAMlJhHwu404LZRSGb/4z21PCFBmAR7w3PisVGSo AkAF8PbIiS69uUR6RnEy7U9Gd+QEi05ghP0RMyPDo8z8REc4eJwtC7LeB1lvjs8EGr2+ kaWQ== X-Gm-Message-State: AOJu0YxyUmBXI+Z53iV3wDh/HYd/If8jqqFdCxAexCBYIYFY0kLnroX0 fufa6V5xOOpg99E26P43w5a+EQ== X-Google-Smtp-Source: AGHT+IHMnRRZU1AoK52w/ETGomJDYboa0sUaaYzUFQVRras778aL93jg/RTp1bID3QpRqIrdbXtX8Q== X-Received: by 2002:a05:6a20:54a7:b0:127:72c3:6427 with SMTP id i39-20020a056a2054a700b0012772c36427mr5163175pzk.2.1693611767663; Fri, 01 Sep 2023 16:42:47 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8d94:1fc5:803c:41cc]) by smtp.gmail.com with ESMTPSA id o9-20020a639a09000000b0056c3a4a3ca5sm3326390pge.36.2023.09.01.16.42.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:42:46 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , Baolin Wang , airlied@gmail.com, daniel@ffwll.ch, linux-kernel@vger.kernel.org, liviu.dudau@arm.com, orsonzhai@gmail.com, rfoss@kernel.org, robh@kernel.org, sam@ravnborg.org, steven.price@arm.com, tzimmermann@suse.de, zhang.lyra@gmail.com Subject: [RFT PATCH 10/15] drm/sprd: Call drm_atomic_helper_shutdown() at remove time Date: Fri, 1 Sep 2023 16:41:21 -0700 Message-ID: <20230901164111.RFT.10.I7a2dd349cb52bae53280d0a49e22cc27b923274b@changeid> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog In-Reply-To: <20230901234202.566951-1-dianders@chromium.org> References: <20230901234202.566951-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Douglas Anderson Reviewed-by: Maxime Ripard --- 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 actually 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 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_dr= m.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; } =20 @@ -122,10 +123,11 @@ static void sprd_drm_unbind(struct device *dev) struct drm_device *drm =3D dev_get_drvdata(dev); =20 drm_dev_unregister(drm); - drm_kms_helper_poll_fini(drm); + drm_atomic_helper_shutdown(drm); =20 component_unbind_all(drm->dev, drm); + dev_set_drvdata(dev, NULL); } =20 static const struct component_master_ops drm_component_ops =3D { --=20 2.42.0.283.g2d96d420d3-goog From nobody Fri Sep 20 11:35:00 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 029AACA0FF9 for ; Fri, 1 Sep 2023 23:44:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351374AbjIAXoQ (ORCPT ); Fri, 1 Sep 2023 19:44:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351322AbjIAXoE (ORCPT ); Fri, 1 Sep 2023 19:44:04 -0400 Received: from mail-oo1-xc2b.google.com (mail-oo1-xc2b.google.com [IPv6:2607:f8b0:4864:20::c2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72A7C1713 for ; Fri, 1 Sep 2023 16:43:28 -0700 (PDT) Received: by mail-oo1-xc2b.google.com with SMTP id 006d021491bc7-571194584e2so1490700eaf.3 for ; Fri, 01 Sep 2023 16:43:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611769; x=1694216569; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+uOG7orqF4actDsz25kkoaGcb+oSREvVrWkgMBMJJLo=; b=SRrtO74To+xOSsfEnrnrc/0pZK86OkB8mybSOAdCR3tzNO9KrEFhAfMaT522/JHv5K l8mwVKK6C73d7B6DSQMO9Xm5HFNEf69yWff7Dns3A2RzkzpDgEfS082QYwg5QRSMFvgZ SwUkKSeTZmsBFlluUIGhC7xbxEQH55xj5o764= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693611769; x=1694216569; 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=+uOG7orqF4actDsz25kkoaGcb+oSREvVrWkgMBMJJLo=; b=iCpQZb42+NvWSd3PmUs/jZMTfk4K7KaL5T25CNDt6YZOjpcdKNHvBoNvy7sKRUZ6O4 ZYjo8wpadYFuugxeqqv5Bk2RhEAvlgRYSIWpo4r+GoVr2uusMZpLSub/Of5qS7dlCuv0 bj2LXSOCJlbPnxhgeLDGnAUfnLuZz/kTQy86qbz0r7nJ7nV87tt9cLrMibvxDb/PL0dy izuHxU7u4BBAgYKVMBu+T97xL9s/xLyHUVdVcI+Xxi3ln6DJqHjm4ljxkeHqY8gmU2Dm j/N14PxcvX1Ie+ussp/ALzLYY/ALNwPTh3Z+bcOIwXHV8IQVMLmcPE3BpVMWYz4LyIbH dpTA== X-Gm-Message-State: AOJu0YzkJdK1C1quywm8L0WeyUZLHroz+OqaWYvpUnu6Q8zLW0QVwMAE TcAokJ4hBY6NJ7GoQiaiGZrYwA== X-Google-Smtp-Source: AGHT+IEtno2sAZxUeLfldTVuC/n8wvbt8r9p0WUGoKpJ49IMbd/DsuhRqnZWTnQHfwEPIadZyumfcA== X-Received: by 2002:a05:6358:7e03:b0:127:f2fb:d103 with SMTP id o3-20020a0563587e0300b00127f2fbd103mr3928386rwm.16.1693611769417; Fri, 01 Sep 2023 16:42:49 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8d94:1fc5:803c:41cc]) by smtp.gmail.com with ESMTPSA id o9-20020a639a09000000b0056c3a4a3ca5sm3326390pge.36.2023.09.01.16.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:42:48 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , airlied@gmail.com, alim.akhtar@samsung.com, daniel@ffwll.ch, inki.dae@samsung.com, krzysztof.kozlowski@linaro.org, kyungmin.park@samsung.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, sw0312.kim@samsung.com Subject: [RFT PATCH 11/15] drm/exynos: Call drm_atomic_helper_shutdown() at shutdown/unbind time Date: Fri, 1 Sep 2023 16:41:22 -0700 Message-ID: <20230901164111.RFT.11.Iea33274908b6b258955f45a8aaf6f5bba24ad6cd@changeid> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog In-Reply-To: <20230901234202.566951-1-dianders@chromium.org> References: <20230901234202.566951-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Douglas Anderson Reviewed-by: Maxime Ripard --- This commit is only compile-time tested. 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/exyn= os/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); =20 @@ -313,6 +314,7 @@ static void exynos_drm_unbind(struct device *dev) drm_dev_unregister(drm); =20 drm_kms_helper_poll_fini(drm); + drm_atomic_helper_shutdown(drm); =20 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; } =20 +static void exynos_drm_platform_shutdown(struct platform_device *pdev) +{ + struct drm_device *drm =3D platform_get_drvdata(pdev); + + if (drm) + drm_atomic_helper_shutdown(drm); +} + static struct platform_driver exynos_drm_platform_driver =3D { .probe =3D exynos_drm_platform_probe, .remove =3D exynos_drm_platform_remove, + .shutdown =3D exynos_drm_platform_shutdown, .driver =3D { .name =3D "exynos-drm", .pm =3D &exynos_drm_pm_ops, --=20 2.42.0.283.g2d96d420d3-goog From nobody Fri Sep 20 11:35:00 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D058ACA0FF6 for ; Fri, 1 Sep 2023 23:44:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351316AbjIAXoR (ORCPT ); Fri, 1 Sep 2023 19:44:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351323AbjIAXoE (ORCPT ); Fri, 1 Sep 2023 19:44:04 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF236E7F for ; Fri, 1 Sep 2023 16:43:28 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-68bed286169so2171143b3a.1 for ; Fri, 01 Sep 2023 16:43:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611771; x=1694216571; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hHay3IZ79gwyzzJIvA/KLviDPDyXcoAjtR8WZOwFgDw=; b=foiReDb///9mnd8lo5Cl6NNugH0l8Zdbx8BVAFGnPJ4FeVekCSn4vcbQ8QT3jPCh16 36jt98myaLITcV27VVzTHbJrHG7ZEZTyral6DRmnNBx7Fc2DPB1CXt0Zw9oLt2myAQRL uqor6l37nFSAPEfTZdf+Rnw0wW+dP2SIFIO30= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693611771; x=1694216571; 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=hHay3IZ79gwyzzJIvA/KLviDPDyXcoAjtR8WZOwFgDw=; b=OSInPlicBipG7ElDWWqa7bmtwrkr4iairurC6dE1DynFssbEwM9kRRlXVlLtG67U5Q czcXnLNWWnKRPgA7PJ1ky6WGN9Dsn90fGXmpbv3UKBt4KbbM2NpE8kLxn+oSakh79FtK qkmAAuhS6l5gRR/vz4GEQiiYtfQysbFAw5usgNZxxhnb6ATN2fNeU//zqDJea+amscbb 1FMEyutcyjJTyTD8ZIc1e2z1XHQaWTmTVGV8JiGhCWET14MGUG6DvXU+ol3uSAZS48Vf VU2QZwV/xLQZmCNVE0bHqWCbJ5Sr3QsYDIM1Kj4xeZDY+iRsdy9ziAtdc6KtVLzw1hjq qs5w== X-Gm-Message-State: AOJu0YwBB4kBAskmpIzT9vQ4m5xI/9nxG0/IicW+WPWzmfknnKofxx6y iLYpswroNP5tw1+NXWn2d/S91w== X-Google-Smtp-Source: AGHT+IHY7t2zN6rtVOOQuBIslh6uo5hZExLEtoUk+kZCKL2mIpIBCiF+lomwnDGZdtLEJFAPIrODXQ== X-Received: by 2002:a05:6a20:2cf:b0:14d:382c:f354 with SMTP id 15-20020a056a2002cf00b0014d382cf354mr3916743pzb.36.1693611770966; Fri, 01 Sep 2023 16:42:50 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8d94:1fc5:803c:41cc]) by smtp.gmail.com with ESMTPSA id o9-20020a639a09000000b0056c3a4a3ca5sm3326390pge.36.2023.09.01.16.42.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:42:50 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , airlied@gmail.com, daniel@ffwll.ch, linux-kernel@vger.kernel.org, patrik.r.jakobsson@gmail.com Subject: [RFT PATCH 12/15] drm/gma500: Call drm_helper_force_disable_all() at shutdown/remove time Date: Fri, 1 Sep 2023 16:41:23 -0700 Message-ID: <20230901164111.RFT.12.I1be622999c3b23f28f077fc75bb0319396a216e9@changeid> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog In-Reply-To: <20230901234202.566951-1-dianders@chromium.org> References: <20230901234202.566951-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Douglas Anderson Reviewed-by: Maxime Ripard --- This commit is only compile-time tested. 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 =20 #include +#include #include #include #include @@ -485,6 +486,12 @@ static void psb_pci_remove(struct pci_dev *pdev) struct drm_device *dev =3D pci_get_drvdata(pdev); =20 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)); } =20 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 =3D { .id_table =3D pciidlist, .probe =3D psb_pci_probe, .remove =3D psb_pci_remove, + .shutdown =3D psb_pci_shutdown, .driver.pm =3D &psb_pm_ops, }; =20 --=20 2.42.0.283.g2d96d420d3-goog From nobody Fri Sep 20 11:35:00 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 971ECCA0FFB for ; Fri, 1 Sep 2023 23:44:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351380AbjIAXoT (ORCPT ); Fri, 1 Sep 2023 19:44:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351331AbjIAXoH (ORCPT ); Fri, 1 Sep 2023 19:44:07 -0400 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D927C1710 for ; Fri, 1 Sep 2023 16:43:31 -0700 (PDT) Received: by mail-il1-x12c.google.com with SMTP id e9e14a558f8ab-34df502d238so8638525ab.0 for ; Fri, 01 Sep 2023 16:43:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611773; x=1694216573; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pzZMfYrc4MS7Ddrskta252Gk/vbJZVRLTsLEIZtE5Vw=; b=FN5js8Si5UfNhghP9yH/+SW5UzMm8bitbD1a4lDJppllxdRKO8GAmxnc7HpCMK25O1 7ltQ2vY056qt4ru2BRxicNzxJq4AQX0SXZELXgL6RfyqBx+t/zT6I2X8wykNX8LhzTTT KwD4MLzAgaj5J7FnsR1OlERDj/rNH+4BcGIx8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693611773; x=1694216573; 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=pzZMfYrc4MS7Ddrskta252Gk/vbJZVRLTsLEIZtE5Vw=; b=P3zVNp/DlHFwh3HlNIzyUPTfTdUrSm0aZ/4zXrlFFdLWKcJ1LC1O8KC+BV+GyS81aS XRW0y0mIhMr0CF6rusLrszdV++ACRjxKPEhgixUgq4OtrpbQj5yi+jLZAGxQo8n17Bp+ +fL8Fi2AX98nSVI1v4lRaW++eQxmm8mNa9WFxLQ0cKwoQ7JYvh3ip5Axjqsg1/E1EQ0p HrPOjSFixlU59iBVJcURGKlLzJqtvOlk4bBRID16b88nSIvWgRRNZAadz33dZLPIYsv5 +U1/JOo7REp5TaoPoVrD/Xu6SogGPTrYYdN4LFKIJ9HaY/WKwZ/8LagqOAdwIbFSkQJy WS6g== X-Gm-Message-State: AOJu0YyWpKu3+5CotGmXCnbTC+ulmWIikNSydbKTBfbXtrpoVgJh/ZqD EbmWrm9rRyzn6FekE6LdXKqX2w== X-Google-Smtp-Source: AGHT+IFvdRCJwMr99Yb1JrwpTHYD/RaTUnsuipwnbiYPCDCcEBVC17WQxgviFC4gHISPtQjZ2Wly3g== X-Received: by 2002:a05:6e02:1a21:b0:348:fe3b:c8b with SMTP id g1-20020a056e021a2100b00348fe3b0c8bmr5295836ile.1.1693611773002; Fri, 01 Sep 2023 16:42:53 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8d94:1fc5:803c:41cc]) by smtp.gmail.com with ESMTPSA id o9-20020a639a09000000b0056c3a4a3ca5sm3326390pge.36.2023.09.01.16.42.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:42:52 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , Sascha Hauer , airlied@gmail.com, daniel@ffwll.ch, festevam@gmail.com, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, p.zabel@pengutronix.de, shawnguo@kernel.org Subject: [RFT PATCH 13/15] drm/imx/ipuv3: Call drm_atomic_helper_shutdown() at shutdown/unbind time Date: Fri, 1 Sep 2023 16:41:24 -0700 Message-ID: <20230901164111.RFT.13.I0a9940ff6f387d6acf4e71d8c7dbaff8c42e3aaa@changeid> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog In-Reply-To: <20230901234202.566951-1-dianders@chromium.org> References: <20230901234202.566951-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Douglas Anderson Reviewed-by: Maxime Ripard Tested-by: Philipp Zabel --- This commit is only compile-time tested. drivers/gpu/drm/imx/ipuv3/imx-drm-core.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/gpu/drm/imx/ipuv3/imx-drm-core.c b/drivers/gpu/drm/imx= /ipuv3/imx-drm-core.c index 4a866ac60fff..4c8bc49758a7 100644 --- a/drivers/gpu/drm/imx/ipuv3/imx-drm-core.c +++ b/drivers/gpu/drm/imx/ipuv3/imx-drm-core.c @@ -257,6 +257,7 @@ static int imx_drm_bind(struct device *dev) drm_kms_helper_poll_fini(drm); component_unbind_all(drm->dev, drm); err_kms: + dev_set_drvdata(dev, NULL); drm_dev_put(drm); =20 return ret; @@ -269,6 +270,7 @@ static void imx_drm_unbind(struct device *dev) drm_dev_unregister(drm); =20 drm_kms_helper_poll_fini(drm); + drm_atomic_helper_shutdown(drm); =20 component_unbind_all(drm->dev, drm); =20 @@ -298,6 +300,14 @@ static int imx_drm_platform_remove(struct platform_dev= ice *pdev) return 0; } =20 +static void imx_drm_platform_shutdown(struct platform_device *pdev) +{ + struct drm_device *drm =3D platform_get_drvdata(pdev); + + if (drm) + drm_atomic_helper_shutdown(platform_get_drvdata(pdev)); +} + #ifdef CONFIG_PM_SLEEP static int imx_drm_suspend(struct device *dev) { @@ -325,6 +335,7 @@ MODULE_DEVICE_TABLE(of, imx_drm_dt_ids); static struct platform_driver imx_drm_pdrv =3D { .probe =3D imx_drm_platform_probe, .remove =3D imx_drm_platform_remove, + .shutdown =3D imx_drm_platform_shutdown, .driver =3D { .name =3D "imx-drm", .pm =3D &imx_drm_pm_ops, --=20 2.42.0.283.g2d96d420d3-goog From nobody Fri Sep 20 11:35:00 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62242CA0FF8 for ; Fri, 1 Sep 2023 23:44:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351384AbjIAXoV (ORCPT ); Fri, 1 Sep 2023 19:44:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351333AbjIAXoH (ORCPT ); Fri, 1 Sep 2023 19:44:07 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0D0C1717 for ; Fri, 1 Sep 2023 16:43:33 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3a751d2e6ecso1715923b6e.0 for ; Fri, 01 Sep 2023 16:43:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611775; x=1694216575; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KKiMaJ+cEDZwLLCxXqIHb+OBndFjgPpn6nuXSf4hrW0=; b=Zw5/VdPLcVL4HDNW6p2TU8oTJNw2tLikGcVSVi1SiBG3kuQ9zzprA3WkeGmYfP1rrV pOcfnse1mVsUygznmYDm/RnGo7BRq2sU4tFy15zP/l496u1DVBUjB1GjEuGdn4V3Ovxi MA0AV8ohMiXdbLZ/4YyGfSBERHUBBVdHhVB08= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693611775; x=1694216575; 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=KKiMaJ+cEDZwLLCxXqIHb+OBndFjgPpn6nuXSf4hrW0=; b=ZeWu61zeElsVfuwbFZ3BpcIVByZl74tBGF6SetlLPr/V5kC3M6JXPf9J/bX+bSUOkn luMXv20xdMuJ5d8zUd3C1VbXHnZbSx0bMadJuPzm9FvYEUsvrKsyIBn9h3w6pW0KXDx4 NjSyYzUsKNaV6qNwau05OFzQeyurSoCXWRG8/IK62qqF6qXI5vlFSgYK5zLYfoHt0yqc z4IqYfnh9j0eqUyBzv9ZAyo2hVovOwP5jN5UQ8FWFJwHHrRh7bb2R3V3sUAuNR2evF6g LvRzkZk/hOWS8Vu+4HMnfyxDiPJORDqiVKtfvVs1WTrldxBzzt1wAeLZLFCOdm9E+OzA tM1w== X-Gm-Message-State: AOJu0YwSW+DysYgXuG7iQHP4hyNFqvjlPJvTmtqQuGZqmpdo3UiNHJV7 Zp5c7fVM23WN2DOkrGGx59FKBQ== X-Google-Smtp-Source: AGHT+IH3N6oAfydomdv+c+JnkApo3hK8ntxo9o07pRRK+2oRgBVZbVsjJxP7itMUHip6V7XJUK2i9g== X-Received: by 2002:a54:458e:0:b0:3a8:847e:c5b7 with SMTP id z14-20020a54458e000000b003a8847ec5b7mr4071404oib.31.1693611775021; Fri, 01 Sep 2023 16:42:55 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8d94:1fc5:803c:41cc]) by smtp.gmail.com with ESMTPSA id o9-20020a639a09000000b0056c3a4a3ca5sm3326390pge.36.2023.09.01.16.42.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:42:54 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , Xinhui.Pan@amd.com, airlied@gmail.com, alexander.deucher@amd.com, amd-gfx@lists.freedesktop.org, christian.koenig@amd.com, daniel@ffwll.ch, linux-kernel@vger.kernel.org Subject: [RFT PATCH 14/15] drm/radeon: Call drm_helper_force_disable_all() at shutdown/remove time Date: Fri, 1 Sep 2023 16:41:25 -0700 Message-ID: <20230901164111.RFT.14.I022cfc2dcd30e77d4f7005a2d912dd7ab76c0338@changeid> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog In-Reply-To: <20230901234202.566951-1-dianders@chromium.org> References: <20230901234202.566951-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Douglas Anderson Reviewed-by: Maxime Ripard --- 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. 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/r= adeon_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 =20 #include +#include #include #include #include @@ -357,7 +358,9 @@ radeon_pci_remove(struct pci_dev *pdev) { struct drm_device *dev =3D pci_get_drvdata(pdev); =20 - drm_put_dev(dev); + drm_dev_unregister(dev); + drm_helper_force_disable_all(dev); + drm_dev_put(dev); } =20 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)); =20 #if defined(CONFIG_PPC64) || defined(CONFIG_MACH_LOONGSON64) /* --=20 2.42.0.283.g2d96d420d3-goog From nobody Fri Sep 20 11:35:00 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28EE5CA0FF6 for ; Fri, 1 Sep 2023 23:44:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351386AbjIAXoY (ORCPT ); Fri, 1 Sep 2023 19:44:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351338AbjIAXoH (ORCPT ); Fri, 1 Sep 2023 19:44:07 -0400 Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB3A91719 for ; Fri, 1 Sep 2023 16:43:34 -0700 (PDT) Received: by mail-oi1-x235.google.com with SMTP id 5614622812f47-3aa14d8641cso271442b6e.3 for ; Fri, 01 Sep 2023 16:43:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611777; x=1694216577; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IdM+lGT73cjSOBSP8IlsC1l9xDfQI2J1yvb0n4/3ZvY=; b=WrfUkV6fBZa/HNDQ+C+jGvmAdKnM10L7WP0qDDbOx2EdlehV0DJFZhhRU3HT+3pnzP scfXOaqUoKqJTTMBps7t9Sf62aaET+vtqAGk5Z4AZMm9hhmu8Enj5O9F/5R+iAr0tSO5 wRyZ9miECUr7NapzzC/bqty/Clm8YAKw5kQ8U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693611777; x=1694216577; 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=IdM+lGT73cjSOBSP8IlsC1l9xDfQI2J1yvb0n4/3ZvY=; b=AGbvU5n0L6/4nIdlCUFvTspMvMhdh9UOXgObdkqdF7Z04r6r53lSm9Lqh5c/XSpeh5 EYdK8a2ZN4FgLgfbsts8WQo4X6xWbX0hyZyAQm10UT4GYXNhT6IVu7FTrit+KfBkUgAq MrF9cNYquMkDnqMoDvCeuQsshVgoMG0MdxvVXqapGVnno0Xbguw+OPL52E210Db3lIum SNAygKxDn/HtYWUYGX4F4h6aiJJmbjq8scooizwNKrmOfwF3AmA6e5kCR+5FOab+YfXJ bxq6yDNr9UokTa8LCb9Q2uW45ViC5MWEDWoraFf9EUW754mghNqsgTnEHMUWHbZj8U6Q LtIg== X-Gm-Message-State: AOJu0Yww8jkndnLEenAtrod8AuQsotkDpxY1lLPsRJUXAsHOAop0JQFv GNmGjBHNJfB0XjIF27PT0bm2ew== X-Google-Smtp-Source: AGHT+IFcdBjJJQwlyQ5ZEP5yP3QLZHGZAWqiXZ/QhDSapWZmB7jAL9+asxO5XakvnmAO3TBkPL5opA== X-Received: by 2002:a05:6808:919:b0:3a7:46d2:5203 with SMTP id w25-20020a056808091900b003a746d25203mr4110653oih.51.1693611776821; Fri, 01 Sep 2023 16:42:56 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8d94:1fc5:803c:41cc]) by smtp.gmail.com with ESMTPSA id o9-20020a639a09000000b0056c3a4a3ca5sm3326390pge.36.2023.09.01.16.42.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:42:56 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , airlied@gmail.com, biju.das.jz@bp.renesas.com, daniel@ffwll.ch, geert+renesas@glider.be, kieran.bingham+renesas@ideasonboard.com, laurent.pinchart@ideasonboard.com, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, paul@crapouillou.net, tzimmermann@suse.de Subject: [RFT PATCH 15/15] drm/renesas/shmobile: Call drm_helper_force_disable_all() at shutdown/remove time Date: Fri, 1 Sep 2023 16:41:26 -0700 Message-ID: <20230901164111.RFT.15.Iaf638a1d4c8b3c307a6192efabb4cbb06b195f15@changeid> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog In-Reply-To: <20230901234202.566951-1-dianders@chromium.org> References: <20230901234202.566951-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Douglas Anderson --- This commit is only compile-time tested. 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 30493ce87419..d6dd46c925c5 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 =20 +#include #include #include #include @@ -179,12 +180,20 @@ static int shmob_drm_remove(struct platform_device *p= dev) =20 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); =20 return 0; } =20 +static void shmob_drm_shutdown(struct platform_device *pdev) +{ + struct shmob_drm_device *sdev =3D 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 =3D pdev->dev.platform_data; @@ -289,6 +298,7 @@ static int shmob_drm_probe(struct platform_device *pdev) static struct platform_driver shmob_drm_platform_driver =3D { .probe =3D shmob_drm_probe, .remove =3D shmob_drm_remove, + .shutdown =3D shmob_drm_shutdown, .driver =3D { .name =3D "shmob-drm", .pm =3D pm_sleep_ptr(&shmob_drm_pm_ops), --=20 2.42.0.283.g2d96d420d3-goog