From patchwork Fri Sep 1 23:41:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13372927 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 21239CA0FF8 for ; Fri, 1 Sep 2023 23:42:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3D4D110E80A; Fri, 1 Sep 2023 23:42:31 +0000 (UTC) Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by gabe.freedesktop.org (Postfix) with ESMTPS id D9B1510E7FC for ; Fri, 1 Sep 2023 23:42:27 +0000 (UTC) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-68bed8de5b9so2141167b3a.3 for ; Fri, 01 Sep 2023 16:42:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611747; x=1694216547; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BTyJ24tKFqLRbG9l9nWJNLGooQV8nSVkH6ez/jxbol4=; b=Qtt9S98Krg44gbPHSH3gHusLnvHS1tnTjdu/LtQkixlOWGhL+NDN2qkn0lbZYlNrna brhKAud6XtvstJ8R1+BahiNXmqKyHi+EBTCKWx8txzZdKMTqDO3XtoGiZnueNyb14DHY ebKwEujkD5EgxYvvqvIbm8TOCsE7oX6SNjF8g= 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=mHJCvt+7hLhpP7H7oHP+kWK9qB7ztt9Qsp/e6AtjYM+x6iiIMcAuosAE/1KdLOckcA rzTRp9Nu2hQ6xnlAFI5o7rZz0ubs56S+BNgieq9KvC3nq5wNkitAsrHpNWNnQokLtXCW 53u+C4fYYQILdfKauaMsgh6GJucD/AYVRqGxLUHCSIMEomh7ByFt4L8xCiD2JLZ+pLWl 19pX7xmfNsuaegIEkiNjgFyugfKQHhthVO0VXQmxEg0qQfAQwOpAyiZfmFxPnl3BOs86 GIiWpQO/VzlcoXTwSLVblM4lvyEEikVyEp+diimhPdpaTufIxKpq53uNTC2ssIkkg38H n0SQ== X-Gm-Message-State: AOJu0Yxua22Ec/lf1utxmzBx5WNVNe7oH+j92Q8CsbtkNkMqflGwvqBL wvusx7nIp5HUxERY8GlMz1fLFcHXKczDG3UclakbrHCA 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux@armlinux.org.uk, Douglas Anderson , linux-kernel@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Based on grepping through the source code this driver appears to be missing a call to drm_atomic_helper_shutdown() at system shutdown time. Among other things, this means that if a panel is in use that it won't be cleanly powered off at system shutdown time. The fact that we should call drm_atomic_helper_shutdown() in the case of OS shutdown/restart comes straight out of the kernel doc "driver instance overview" in drm_drv.c. 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/armada_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; } @@ -166,6 +167,7 @@ static void armada_drm_unbind(struct device *dev) drm_mode_config_cleanup(&priv->drm); drm_mm_takedown(&priv->linear); + dev_set_drvdata(dev, NULL); } static void armada_add_endpoints(struct device *dev, @@ -230,6 +232,11 @@ static int armada_drm_remove(struct platform_device *pdev) return 0; } +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[] = { { .name = "armada-drm", @@ -243,6 +250,7 @@ MODULE_DEVICE_TABLE(platform, armada_drm_platform_ids); static struct platform_driver armada_drm_platform_driver = { .probe = armada_drm_probe, .remove = armada_drm_remove, + .shutdown = armada_drm_shutdown, .driver = { .name = "armada-drm", }, From patchwork Fri Sep 1 23:41:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13372928 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4E6E1CA0FF9 for ; Fri, 1 Sep 2023 23:42:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8683210E7F4; Fri, 1 Sep 2023 23:42:34 +0000 (UTC) Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8850510E80D for ; Fri, 1 Sep 2023 23:42:31 +0000 (UTC) Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-68a3ced3ec6so2216838b3a.1 for ; Fri, 01 Sep 2023 16:42:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611750; x=1694216550; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=T/+h1ksZof8y/lEEP6nhkNB4pCHzfTPQtm4LO74Tft4=; b=S2jl1jKoQU213s8T6A12rmEdEwcMyGNngqWlKFGv9FBtQAhzV7t0Ov5RMt2QICACA6 rEjxJ3dahCRADqafXmpK1vSQx3XWOUwGQjQEv8t8VK3I07y1Xs1sXQY3My0lEDY8dYZq MDPOuyFdqbSdCeiPXkcmTC3WQ7OOoIV+UFs94= 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=QB7Y2U63g2thHV/pA36ZlFVtqCQ9NdgqX/tM58Q68bmQoyOldB4fr85Ghq1McyAPPS tCj0jdCALG1JwOYwsPhn0TbLIo6fBWYscnelM+RhBv7tcjACzbfBduTts3JFt2P0C6Ev dp9TTxy5fRTZwy3B37GYCvKo2xhfK23uMviIkZNhsn0vagZbRb9mg0hCWxLk89wcMRcv deyfi3qgHLn4LwGrD7DkzfgKTlN0mfbL9NmZiUuPc/n0cSkwcEnPlO77dlB19g5AmTWH APcH+qOaGdMc3X00B0pETma04DzguRQBrx66xGubdWkOhiAfPmLcGDSj1ZcP3MPLCs+9 o13w== X-Gm-Message-State: AOJu0YxL8RpQ1II/kVV5p4MuezG/qDKZuLjSHdec+AR4gr235DgqH9OO 9uT6SgW1qyrZAhG6lj4vGpcHJNZebUgttNKIr3dprRpV 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sascha Hauer , Douglas Anderson , linux-kernel@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, laurentiu.palcu@oss.nxp.com, shawnguo@kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Based on grepping through the source code this driver appears to be missing a call to drm_atomic_helper_shutdown() at system shutdown time. Among other things, this means that if a panel is in use that it won't be cleanly powered off at system shutdown time. The fact that we should call drm_atomic_helper_shutdown() in the case of OS shutdown/restart comes straight out of the kernel doc "driver instance overview" in drm_drv.c. Suggested-by: Maxime Ripard 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_device *pdev) return 0; } +static void dcss_drv_platform_shutdown(struct platform_device *pdev) +{ + struct dcss_drv *mdrv = dev_get_drvdata(&pdev->dev); + + dcss_kms_shutdown(mdrv->kms); +} + static struct dcss_type_data dcss_types[] = { [DCSS_IMX8MQ] = { .name = "DCSS_IMX8MQ", @@ -114,6 +121,7 @@ MODULE_DEVICE_TABLE(of, dcss_of_match); static struct platform_driver dcss_platform_driver = { .probe = dcss_drv_platform_probe, .remove = dcss_drv_platform_remove, + .shutdown = dcss_drv_platform_shutdown, .driver = { .name = "imx-dcss", .of_match_table = dcss_of_match, diff --git a/drivers/gpu/drm/imx/dcss/dcss-kms.c b/drivers/gpu/drm/imx/dcss/dcss-kms.c index 896de946f8df..d0ea4e97cded 100644 --- a/drivers/gpu/drm/imx/dcss/dcss-kms.c +++ b/drivers/gpu/drm/imx/dcss/dcss-kms.c @@ -172,3 +172,10 @@ void dcss_kms_detach(struct dcss_kms_dev *kms) dcss_crtc_deinit(&kms->crtc, drm); drm->dev_private = NULL; } + +void dcss_kms_shutdown(struct dcss_kms_dev *kms) +{ + struct drm_device *drm = &kms->base; + + drm_atomic_helper_shutdown(drm); +} diff --git a/drivers/gpu/drm/imx/dcss/dcss-kms.h b/drivers/gpu/drm/imx/dcss/dcss-kms.h index dfe5dd99eea3..62521c1fd6d2 100644 --- a/drivers/gpu/drm/imx/dcss/dcss-kms.h +++ b/drivers/gpu/drm/imx/dcss/dcss-kms.h @@ -34,6 +34,7 @@ struct dcss_kms_dev { struct dcss_kms_dev *dcss_kms_attach(struct dcss_dev *dcss); void dcss_kms_detach(struct dcss_kms_dev *kms); +void dcss_kms_shutdown(struct dcss_kms_dev *kms); int dcss_crtc_init(struct dcss_crtc *crtc, struct drm_device *drm); void dcss_crtc_deinit(struct dcss_crtc *crtc, struct drm_device *drm); struct dcss_plane *dcss_plane_init(struct drm_device *drm, From patchwork Fri Sep 1 23:41:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13372929 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D5E15CA0FF6 for ; Fri, 1 Sep 2023 23:42:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0706110E80D; Fri, 1 Sep 2023 23:42:36 +0000 (UTC) Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1CD9010E7F4 for ; Fri, 1 Sep 2023 23:42:33 +0000 (UTC) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-68a4bcf8a97so1906406b3a.1 for ; Fri, 01 Sep 2023 16:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611752; x=1694216552; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1xwlQKSbvtJNXAzlNyEq/ahWjOdZU7CV+KOcQ65YIkM=; b=Q8MH49mbnVMgjphqdMU+2GRMS8W05FsTKdC5ab1uYF5SnpEfDk71/rkUMBUfLkpe70 RXGg/xikiz8TlQLEyFHd3lpdPTASfl+OceSfEqIFVOnRR9F0Qs+ZGPis74qWH/v7oJAO XxY4Ow8JPXYc/a7ODHdyKJdVogA4OH508yoqk= 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=U96luXEKBireNqbTIEqvsFJm2LXsWN5OvE2fOeD+rY0+lBP9Mv3Xqi6zqw71i11DXP Cko1iuSSXwuYNspB0lccuotasNDbn4OqXkxqu3RdRM/K8lDkSRY0lwGtKi5RAiLbW6Qi vjKOBXAdnvzDa8DgMII/Fv6urCV39GqA3x+8m0G35B5dypuXDtT5lAz6LW3cm9nacKQV oN4bT31wjTx9Kbcu7gdViukWTGsRCxJbFPQVaOyu3d/B+PhqdGh0Pj89yQinlrrnxvqr zcD7+IImRQYWY3fx+Mftmq/yHh/lByLtD3gg3zcFLdGckYFJHYSdZD0ACRhxgXtRUoaq vZrg== X-Gm-Message-State: AOJu0YyooMWyYQ11iU+r231JOoIl/I3CoWG3lwTL0/wv+FO3n/EsWTPJ uAWtAXkw5vF0NpSNra1dky2UVvJ67wF8EPaNokkX9snO 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Douglas Anderson , paul@crapouillou.net Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Based on grepping through the source code this driver appears to be missing a call to drm_atomic_helper_shutdown() at system shutdown time. Among other things, this means that if a panel is in use that it won't be cleanly powered off at system shutdown time. The fact that we should call drm_atomic_helper_shutdown() in the case of OS shutdown/restart comes straight out of the kernel doc "driver instance overview" in drm_drv.c. 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 Reviewed-by: Maxime Ripard Acked-by: Paul Cercueil --- 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/ingenic/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) ret = drmm_mode_config_init(drm); if (ret) - return ret; + goto err_drvdata; drm->mode_config.min_width = 0; drm->mode_config.min_height = 0; @@ -1142,7 +1142,8 @@ static int ingenic_drm_bind(struct device *dev, bool has_components) base = 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 = PTR_ERR(base); + goto err_drvdata; } regmap_config = ingenic_drm_regmap_config; @@ -1151,33 +1152,40 @@ static int ingenic_drm_bind(struct device *dev, bool has_components) ®map_config); if (IS_ERR(priv->map)) { dev_err(dev, "Failed to create regmap\n"); - return PTR_ERR(priv->map); + ret = PTR_ERR(priv->map); + goto err_drvdata; } irq = platform_get_irq(pdev, 0); - if (irq < 0) - return irq; + if (irq < 0) { + ret = irq; + goto err_drvdata; + } if (soc_info->needs_dev_clk) { priv->lcd_clk = 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 = PTR_ERR(priv->lcd_clk); + goto err_drvdata; } } priv->pix_clk = 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 = PTR_ERR(priv->pix_clk); + goto err_drvdata; } priv->dma_hwdescs = 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 = -ENOMEM; + goto err_drvdata; + } /* 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; } 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; } 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; } if (soc_info->map_noncoherent) @@ -1241,17 +1249,18 @@ static int ingenic_drm_bind(struct device *dev, bool has_components) if (ret) { if (ret != -EPROBE_DEFER) dev_err(dev, "Failed to bind components: %i\n", ret); - return ret; + goto err_drvdata; } ret = devm_add_action_or_reset(dev, ingenic_drm_unbind_all, priv); if (ret) - return ret; + goto err_drvdata; priv->ipu_plane = drm_plane_from_index(drm, 2); if (!priv->ipu_plane) { dev_err(dev, "Failed to retrieve IPU plane\n"); - return -EINVAL; + ret = -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 != -EPROBE_DEFER) dev_err(dev, "Failed to get bridge handle\n"); - return ret; + goto err_drvdata; } if (panel) @@ -1275,7 +1284,7 @@ static int ingenic_drm_bind(struct device *dev, bool has_components) if (IS_ERR(ib)) { ret = PTR_ERR(ib); dev_err(dev, "Failed to init encoder: %d\n", ret); - return ret; + goto err_drvdata; } encoder = &ib->encoder; @@ -1290,13 +1299,14 @@ static int ingenic_drm_bind(struct device *dev, bool has_components) DRM_BRIDGE_ATTACH_NO_CONNECTOR); if (ret) { dev_err(dev, "Unable to attach bridge\n"); - return ret; + goto err_drvdata; } connector = drm_bridge_connector_init(drm, encoder); if (IS_ERR(connector)) { dev_err(dev, "Unable to init connector\n"); - return PTR_ERR(connector); + ret = PTR_ERR(connector); + goto err_drvdata; } drm_connector_attach_encoder(connector, encoder); @@ -1313,13 +1323,13 @@ static int ingenic_drm_bind(struct device *dev, bool has_components) ret = devm_request_irq(dev, irq, ingenic_drm_irq_handler, 0, drm->driver->name, drm); if (ret) { dev_err(dev, "Unable to install IRQ handler\n"); - return ret; + goto err_drvdata; } ret = drm_vblank_init(drm, 1); if (ret) { dev_err(dev, "Failed calling drm_vblank_init()\n"); - return ret; + goto err_drvdata; } drm_mode_config_reset(drm); @@ -1327,7 +1337,7 @@ static int ingenic_drm_bind(struct device *dev, bool has_components) ret = clk_prepare_enable(priv->pix_clk); if (ret) { dev_err(dev, "Unable to start pixel clock\n"); - return ret; + goto err_drvdata; } 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; } @@ -1422,6 +1434,7 @@ static void ingenic_drm_unbind(struct device *dev) drm_dev_unregister(&priv->drm); drm_atomic_helper_shutdown(&priv->drm); + dev_set_drvdata(dev, NULL); } static const struct component_master_ops ingenic_master_ops = { @@ -1461,6 +1474,14 @@ static int ingenic_drm_remove(struct platform_device *pdev) return 0; } +static void ingenic_drm_shutdown(struct platform_device *pdev) +{ + struct ingenic_drm *priv = platform_get_drvdata(pdev); + + if (priv) + drm_atomic_helper_shutdown(&priv->drm); +} + static int ingenic_drm_suspend(struct device *dev) { struct ingenic_drm *priv = dev_get_drvdata(dev); @@ -1612,6 +1633,7 @@ static struct platform_driver ingenic_drm_driver = { }, .probe = ingenic_drm_probe, .remove = ingenic_drm_remove, + .shutdown = ingenic_drm_shutdown, }; static int ingenic_drm_init(void) From patchwork Fri Sep 1 23:41:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13372930 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E84F1CA0FF8 for ; Fri, 1 Sep 2023 23:42:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2BC9C10E80E; Fri, 1 Sep 2023 23:42:37 +0000 (UTC) Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by gabe.freedesktop.org (Postfix) with ESMTPS id F140410E80D for ; Fri, 1 Sep 2023 23:42:34 +0000 (UTC) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-68a6f6a66e1so2105433b3a.2 for ; Fri, 01 Sep 2023 16:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611754; x=1694216554; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Cc544bXmls05RiqEx12Xvv3H5cbPiv1GFPSua0tXsTc=; b=DKW9Dpp5k8bQjCDXcSs8EcQS2KIOq5lRTRy+xqvQr0YEf1idm50sUo30tuMRnRS/9g 0lj1WPh1Rwzuy7CIjxtXPGtMyaphHqlxIUtyDe75j5TXsIbgsMzv8ptG9jxRHx6tr7PN yvwI1aWWOGTdsmQWvUqzxxMAJHENrNSTiDV/w= 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=kMFDjBxwWdKhKnQNPgpSMqsbkQXcRvWNmDvaeTcT1a9kBD1IMoAxB1xvJm1XE6jDn5 Qo96i7qbOrA2BAgBjaRKMKDU8Jjh6n8zMt/Ey9x7A4qAfkqxZgai6qhfRmQiTXcKbIy5 Rp1VCnlO5ftOvyD/CakC8QkvQZcYJQTwFNRm9qj7twjvX8WneHUaIo03j5RI4aIT3+MF 9MeQSg32Ob+Rn2ygCJjnj5AQFeL9HBY9/mCZdtK3RDkzghAxIJZbNmqlpVw1EiFt+pQY BPwPhcFhYWpL4l44y2pmspHIGJG7R3iJbqCsAobgR/dTUeo22dsMEIumqmjVMc0i0H3K Ohvw== X-Gm-Message-State: AOJu0Ywn+jmZXsSBgru/w5KtoXRSZRVP+NbgYwIKFqzYLyx4sUc7Um+n 0WKJc9+Seov6Q1CP8mfNe/IPsdPDJ56aHOsXAx6ZJqB6 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: edmund.j.dea@intel.com, Douglas Anderson , linux-kernel@vger.kernel.org, anitha.chrisanthus@intel.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Based on grepping through the source code this driver appears to be missing a call to drm_atomic_helper_shutdown() at system shutdown time. Among other things, this means that if a panel is in use that it won't be cleanly powered off at system shutdown time. The fact that we should call drm_atomic_helper_shutdown() in the case of OS shutdown/restart comes straight out of the kernel doc "driver instance overview" in drm_drv.c. Suggested-by: Maxime Ripard 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; } +static void kmb_shutdown(struct platform_device *pdev) +{ + drm_atomic_helper_shutdown(platform_get_drvdata(pdev)); +} + static int kmb_probe(struct platform_device *pdev) { struct device *dev = get_device(&pdev->dev); @@ -622,6 +627,7 @@ static SIMPLE_DEV_PM_OPS(kmb_pm_ops, kmb_pm_suspend, kmb_pm_resume); static struct platform_driver kmb_platform_driver = { .probe = kmb_probe, .remove = kmb_remove, + .shutdown = kmb_shutdown, .driver = { .name = "kmb-drm", .pm = &kmb_pm_ops, From patchwork Fri Sep 1 23:41:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13372931 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7870CCA0FF8 for ; Fri, 1 Sep 2023 23:42:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BF8F710E81C; Fri, 1 Sep 2023 23:42:39 +0000 (UTC) Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8F33610E819 for ; Fri, 1 Sep 2023 23:42:37 +0000 (UTC) Received: by mail-oi1-x22a.google.com with SMTP id 5614622812f47-3a7aedc57ffso1704384b6e.2 for ; Fri, 01 Sep 2023 16:42:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611756; x=1694216556; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Vomcb5R4YlkPi6yAEBTRSlkjqsgpX/8uar7hs/ep3QM=; b=mDz9IOv+b06KHrBmsYrjcszffq3UkqKl6OAYb0LY5auelRo4BP4QrfZkCSBty5PRJI bKKxgNMl/ex/AlkIHPTPe2/3hccdGVDRuYuyXAz6326LGzf0hC9MqEbAOhuYJVYVjyIy rPBsA2oKHfT1R78xmN7bjPZtkl0Qrs5U0ZFjM= 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=lxtirFTOZ7TVeBKvO0xC2ypdedvcjYAkzi1FYb6icneSsfixFgo4vUDSlYLnX2DBPv u41N9snprZT4PzHI7OwhbI728UlWf9LHozolwYOVClHFqfk+lAKv5ferJYoFZ/bt1FYQ NC8ddWirQ0JUEHQKhmtUO4B1E3rixISexpIOD+X5VCss5P7LWWLywLG8fGUA/7hzR+ei qwBqMmlk3QbQ3XUtOpw6qNdGet4w9g5iG0H4lG3vi9/9FBx73qcTy3rM57TtlYE9S/B8 od5NmstE9ZACWc2/7EoSZSlj06Vce0+z2JmEi91hhBs20zlf42H6euBRivLBdK+5d1wZ Z00g== X-Gm-Message-State: AOJu0YzdIJr6GDcMEb0UMvSCmS3zGM6ATYyWuzrUAyYrz6bvtvHJQgF+ bdEhhgqY8KeXPLzpW/DKw4w35Gbx/UOJ99r8Kr1psiKi 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: chunkuang.hu@kernel.org, Douglas Anderson , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com, linux-arm-kernel@lists.infradead.org, angelogioacchino.delregno@collabora.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Based on grepping through the source code this driver appears to be missing a call to drm_atomic_helper_shutdown() at system shutdown time. Among other things, this means that if a panel is in use that it won't be cleanly powered off at system shutdown time. The fact that we should call drm_atomic_helper_shutdown() in the case of OS shutdown/restart comes straight out of the kernel doc "driver instance overview" in drm_drv.c. This driver users the component model and shutdown happens in the base driver. The "drvdata" for this driver will always be valid if shutdown() is called and we know that if the "drm" pointer in our private data is non-NULL then we need to call drm_atomic_helper_shutdown(). Technically with a previous patch, ("drm/atomic-helper: drm_atomic_helper_shutdown(NULL) should be a noop"), we don't actually need to check to see if our "drm" pointer is NULL before calling drm_atomic_helper_shutdown(). We'll leave the "if" test in, though, so that this patch can land without any dependencies. It could potentially be removed later. Suggested-by: Maxime Ripard Signed-off-by: Douglas Anderson Reviewed-by: Maxime Ripard Reviewed-by: Fei Shao 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/mediatek/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; } +static void mtk_drm_shutdown(struct platform_device *pdev) +{ + struct mtk_drm_private *private = platform_get_drvdata(pdev); + + if (private->drm) + drm_atomic_helper_shutdown(private->drm); +} + static int mtk_drm_sys_prepare(struct device *dev) { struct mtk_drm_private *private = dev_get_drvdata(dev); @@ -952,6 +960,7 @@ static const struct dev_pm_ops mtk_drm_pm_ops = { static struct platform_driver mtk_drm_platform_driver = { .probe = mtk_drm_probe, .remove = mtk_drm_remove, + .shutdown = mtk_drm_shutdown, .driver = { .name = "mediatek-drm", .pm = &mtk_drm_pm_ops, From patchwork Fri Sep 1 23:41:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13372933 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5911FCA0FFA for ; Fri, 1 Sep 2023 23:42:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8F3EB10E82C; Fri, 1 Sep 2023 23:42:42 +0000 (UTC) Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 30F8310E819 for ; Fri, 1 Sep 2023 23:42:40 +0000 (UTC) Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-68c3b9f8333so330449b3a.1 for ; Fri, 01 Sep 2023 16:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611759; x=1694216559; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vRgeQgzVDXmV3JVrPP8xBMX8Swv3+BcS7jAR8idQ+gY=; b=irkOT8+GSjAcIBYW/JY1mowugLlzEsxK/24cvLRWVJ+PprcB2/l/qcHb5SXeqnQKcb xosZ9qosIF9qZ4i2uEiL25XApsn4eGYYMjjkkvBsMURZ7Xs4mKSrRjL9v25PPCAWMv1g G9qDnJuvLOBv8Bj+QIEyxs7kO07v9SuSGIyig= 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=YjL8ATkMu0WumfZ1Gp8XcIfwmbTcI4tEvlJPGtKFIil+v7iDeaM0KVK+rD3JYQqBvR 94ToPhyyW6220bKFyVsZlWH5azIlrZ5Cpx6Bz2KuXnuot2yLLSEDckqwcgTdwIjnKu22 z8OjXxlINR1K7/Tyr3eGHa2BK02xiVhx7UJSrzUhAXfITS9Tai/Fw6oonDx4k4G4+w9S B1U50gJ9f2LGMxxCOE61RUoQf8uZFOI1HaSTnqiDnQpruV8YO00QHFlJxbpGrESyrpUM NZOt1R4NQSwKrutApRysthg5//wIquNwbZ3UMoQ2pGsuZkDzD/Er1hSR7+edTUSsvUD7 bYGA== X-Gm-Message-State: AOJu0Yxj/+jdo61qryNpReUdaKNkrX1KcgvCbNuOtM6rTLMMQ8ceYa3h RhlFqEKryaW2yacwLBkKsosEupI/+pkbx/nizLtzReqv 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kherbst@redhat.com, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, Douglas Anderson , bskeggs@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Based on grepping through the source code this driver appears to be missing a call to drm_atomic_helper_shutdown() (or drm_helper_force_disable_all() if not using atomic) at system shutdown time. Among other things, this means that if a panel is in use that it won't be cleanly powered off at system shutdown time. The fact that we should call drm_atomic_helper_shutdown() in the case of OS shutdown/restart comes straight out of the kernel doc "driver instance overview" in drm_drv.c. Suggested-by: Maxime Ripard 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/nouveau/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 suspend, bool runtime) disp->fini(dev, runtime, suspend); } +void +nouveau_display_shutdown(struct drm_device *dev) +{ + if (drm_drv_uses_atomic_modeset(dev)) + drm_atomic_helper_shutdown(dev); + else + drm_helper_force_disable_all(dev); +} + static void nouveau_display_create_properties(struct drm_device *dev) { diff --git a/drivers/gpu/drm/nouveau/nouveau_display.h b/drivers/gpu/drm/nouveau/nouveau_display.h index 2ab2ddb1eadf..9df62e833cda 100644 --- a/drivers/gpu/drm/nouveau/nouveau_display.h +++ b/drivers/gpu/drm/nouveau/nouveau_display.h @@ -47,6 +47,7 @@ void nouveau_display_destroy(struct drm_device *dev); int nouveau_display_init(struct drm_device *dev, bool resume, bool runtime); void nouveau_display_hpd_resume(struct drm_device *dev); void nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime); +void nouveau_display_shutdown(struct drm_device *dev); int nouveau_display_suspend(struct drm_device *dev, bool runtime); void nouveau_display_resume(struct drm_device *dev, bool runtime); int nouveau_display_vblank_enable(struct drm_crtc *crtc); diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 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); } +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 = { .id_table = nouveau_drm_pci_table, .probe = nouveau_drm_probe, .remove = nouveau_drm_remove, + .shutdown = nouveau_drm_shutdown, .driver.pm = &nouveau_pm_ops, }; diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index 3666a7403e47..aa936cabb6cf 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -327,6 +327,7 @@ struct drm_device * nouveau_platform_device_create(const struct nvkm_device_tegra_func *, struct platform_device *, struct nvkm_device **); void nouveau_drm_device_remove(struct drm_device *dev); +void nouveau_drm_device_shutdown(struct drm_device *dev); #define NV_PRINTK(l,c,f,a...) do { \ struct nouveau_cli *_cli = (c); \ diff --git a/drivers/gpu/drm/nouveau/nouveau_platform.c b/drivers/gpu/drm/nouveau/nouveau_platform.c index 23cd43a7fd19..b2e82a96411c 100644 --- a/drivers/gpu/drm/nouveau/nouveau_platform.c +++ b/drivers/gpu/drm/nouveau/nouveau_platform.c @@ -50,6 +50,11 @@ static int nouveau_platform_remove(struct platform_device *pdev) return 0; } +static void nouveau_platform_shutdown(struct platform_device *pdev) +{ + nouveau_drm_device_shutdown(platform_get_drvdata(pdev)); +} + #if IS_ENABLED(CONFIG_OF) static const struct nvkm_device_tegra_func gk20a_platform_data = { .iommu_bit = 34, @@ -94,4 +99,5 @@ struct platform_driver nouveau_platform_driver = { }, .probe = nouveau_platform_probe, .remove = nouveau_platform_remove, + .shutdown = nouveau_platform_shutdown, }; From patchwork Fri Sep 1 23:41:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13372932 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7D708CA0FF8 for ; Fri, 1 Sep 2023 23:42:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A20F710E827; Fri, 1 Sep 2023 23:42:43 +0000 (UTC) Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6EF1410E827 for ; Fri, 1 Sep 2023 23:42:42 +0000 (UTC) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-68c576d35feso2161350b3a.2 for ; Fri, 01 Sep 2023 16:42:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611761; x=1694216561; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZQWyzi0Qz9s7AgC5vmSBsF4S5izX7bpWF4dQoTwwlFk=; b=AUyrjEs6TDzOEUOlzoige4WYt6Iy+oboVRvzEprSvTyzu+275E8gxrHbw/vuHqDihI nhO4SJ1RctODFQLud9rjIj9UZK8cLvAmF4fefTv+haFgRWec+ss5l425jP1Hu4uSBHSo R1GQkLebU6VCKkt+Gtwv7wL/60jxr95BhB7GI= 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=Z5Cl4zNt29pg+3+5HuX+28GGhaGlXGcqqb3E112VDsZv+JqRJ4AoMsimjoNtAzjw+J TMPfyNpRDtXPIx29+XSzxsXyUkhMCe2Uc0IdCEZoXMRQCw3c8Zks7V05xB07G2olv56f 2Pe5yW3lUVBCLOAnIqkoxatpp2bNH/6eeSd6VPYmmdkEFpPjxVFLCOfbbeWMFcHH9Vft QDlAlgDl500XR0a02iIxREnPyQap/1255XxgaM84YUvJFkWXyr2N91yq44kG36e/Cw2Y QlJi0XYne6wURyKa1LzuAlp7+LrFS51fbPo3Da2D/yLiMjQiJRCjRLl+WaV4JQoebdQq hB/g== X-Gm-Message-State: AOJu0YxlnHY9AQtLsSKqdnr+LFjwQoUarVULuo/MZGf/pZvBTy9qe6z8 r+buk3RCdpQudlS438GqBbD1+GI+E22KTXd+b3Km/U2Y 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mperttunen@nvidia.com, linux-kernel@vger.kernel.org, Douglas Anderson , thierry.reding@gmail.com, linux-tegra@vger.kernel.org, jonathanh@nvidia.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Based on grepping through the source code this driver appears to be missing a call to drm_atomic_helper_shutdown() at system shutdown time. Among other things, this means that if a panel is in use that it won't be cleanly powered off at system shutdown time. The fact that we should call drm_atomic_helper_shutdown() in the case of OS shutdown/restart comes straight out of the kernel doc "driver instance overview" in drm_drv.c. Suggested-by: Maxime Ripard 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 *dev) return 0; } +static void host1x_drm_shutdown(struct host1x_device *dev) +{ + drm_atomic_helper_shutdown(dev_get_drvdata(&dev->dev)); +} + #ifdef CONFIG_PM_SLEEP static int host1x_drm_suspend(struct device *dev) { @@ -1380,6 +1385,7 @@ static struct host1x_driver host1x_drm_driver = { }, .probe = host1x_drm_probe, .remove = host1x_drm_remove, + .shutdown = host1x_drm_shutdown, .subdevs = host1x_drm_subdevs, }; From patchwork Fri Sep 1 23:41:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13372934 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D576CA0FF9 for ; Fri, 1 Sep 2023 23:42:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7BF4310E835; Fri, 1 Sep 2023 23:42:45 +0000 (UTC) Received: from mail-oo1-xc34.google.com (mail-oo1-xc34.google.com [IPv6:2607:f8b0:4864:20::c34]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5305A10E829 for ; Fri, 1 Sep 2023 23:42:44 +0000 (UTC) Received: by mail-oo1-xc34.google.com with SMTP id 006d021491bc7-57325fcd970so1502926eaf.1 for ; Fri, 01 Sep 2023 16:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611763; x=1694216563; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e4TY+mfn1StbQRy79Smag9rvt1YGLeZB0A1g4xD0EoY=; b=USQwV9Y9e4Qabw7ce3QkwlRz/7ZZzIzVz/2YALRZ6qY7q/wJhuboxrNu2u/ODFpZE+ 3vhRZLpEyBtIapWv8MWaQsJxfyk5CE0VP3JGpB710QjWImCZyEx7vkZ9odg/NiOeT2wz rCIpaOw4wfPSEww73d6Av/OsB4y8sllxElwfc= 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=DHRxvQHhWXahoy1BbLM8OUfrRzBT28wJRDYdG4+GxK2CZAcl7Ne8rEFnT9+byR7r4G S1FnQzb5WA4YChzS/RNgarum2LQEAboXDQusTubKEVA7GE9fSHPSMvChmNbBtDE4v88G C/vNpOPQLmaPowiDxTuUZScc4pQCOjgTjsd5BIR+vzK0zMqcBJVbo0ogWL16hgDkz5Wn 4Q2gDWLmJAdE1Ard4MfDDEI/rKgi1ifabKGNo+TL5O3X1ZG7za+p2dP6+DbA3dIV68i+ l3vA28M5fqqMXN/zn6Dw7f1ZvTBnbd8N4qSQILpwI0ogSdR+fTCksACxJ3HVhkqLsGiJ WcMw== X-Gm-Message-State: AOJu0YzQLa7FT82OG1o4l8dpwJ7uzw92O/HS2Jon8FI9OKJ9O0uHwtQE 81uemyWLpGMlsKZnkL5YHrEZBrk3NnFB8CTkq7VF3CDS 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: abrodkin@synopsys.com, Douglas Anderson , linux-kernel@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Based on grepping through the source code this driver appears to be missing a call to drm_atomic_helper_shutdown() at system shutdown time. Among other things, this means that if a panel is in use that it won't be cleanly powered off at system shutdown time. The fact that we should call drm_atomic_helper_shutdown() in the case of OS shutdown/restart comes straight out of the kernel doc "driver instance overview" in drm_drv.c. Suggested-by: Maxime Ripard 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; } +static void arcpgu_shutdown(struct platform_device *pdev) +{ + drm_atomic_helper_shutdown(platform_get_drvdata(pdev)); +} + static const struct of_device_id arcpgu_of_table[] = { {.compatible = "snps,arcpgu"}, {} @@ -424,6 +429,7 @@ MODULE_DEVICE_TABLE(of, arcpgu_of_table); static struct platform_driver arcpgu_platform_driver = { .probe = arcpgu_probe, .remove = arcpgu_remove, + .shutdown = arcpgu_shutdown, .driver = { .name = "arcpgu", .of_match_table = arcpgu_of_table, From patchwork Fri Sep 1 23:41:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13372935 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 52348CA0FFA for ; Fri, 1 Sep 2023 23:42:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A2E0510E837; Fri, 1 Sep 2023 23:42:47 +0000 (UTC) Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1AD2B10E829 for ; Fri, 1 Sep 2023 23:42:46 +0000 (UTC) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-68bed8de5b9so2141293b3a.3 for ; Fri, 01 Sep 2023 16:42:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611765; x=1694216565; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=B1wNSnWkGtYsqmdJ7SiIP0G54S9pY24k7p5P1n8MG+s=; b=KKzdHHoFNINtk2MLAp4UQnTC94LILh1zsoYG4JYt9qfkj3k4yym/rT0GRm35cY3klU rPZRCmSN/vZ/JaEdk+shVXC7tp8TfKM1lriLFvvAl2MXI0wUbEB5hHrrhVvGFlL0FhPV 0idB9yJv9kQ/X/F42r0zDyVdJm8R21LveEdZY= 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=ENveufi0MCltRs4i0R2HglOeEVcfNu0CFC4NQRTuWupusjCCceQE4fVlcMMYsYZl3W +49tI/gG0oRfs+Wn4fYrabWzYsJelXdx7MkZbKpjiszfu8p5a8wmLUIY3wHp9yYqnCS4 QqiIS/C0dm40ArmfR6QQCM01thSr5lq4R/Zuaa4AvLPNZe8BsEzb8IUdRlMnYjHfyvZR SsyFqHrAv4OcJXly6sViSFKgrA9MjD8XXOXvpuwZHNLeQ7OH3zneE3+1sB2HkCzkZsPQ a32Cfh27fZLHlUu+WPJWD4IWlzVW3zYMMFxypv86CyIf3rOlSwow3sNt+dG4jd8M9+jC aJpg== X-Gm-Message-State: AOJu0YzXiEPH4TaoccZToVN4EN5lVX9/wkrcjo+ETipBZ4yETRT362n/ 4mkHKd2Pzj8fzcSSsVqAAo3jM6leH17/YBlMHsgNELwW 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Victor.Zhao@amd.com, srinivasan.shanmugam@amd.com, tzimmermann@suse.de, Bokun.Zhang@amd.com, Xinhui.Pan@amd.com, Douglas Anderson , amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, lijo.lazar@amd.com, le.ma@amd.com, mdaenzer@redhat.com, YiPeng.Chai@amd.com, mario.limonciello@amd.com, alexander.deucher@amd.com, shiwu.zhang@amd.com, James.Zhu@amd.com, christian.koenig@amd.com, Hawking.Zhang@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Based on grepping through the source code this driver appears to be missing a call to drm_atomic_helper_shutdown() at system shutdown time. Among other things, this means that if a panel is in use that it won't be cleanly powered off at system shutdown time. The fact that we should call drm_atomic_helper_shutdown() in the case of OS shutdown/restart comes straight out of the kernel doc "driver instance overview" in drm_drv.c. Suggested-by: Maxime Ripard Signed-off-by: Douglas Anderson --- This commit is only compile-time tested. ...and further, I'd say that this patch is more of a plea for help than a patch I think is actually right. I'm _fairly_ certain that drm/amdgpu needs this call at shutdown time but the logic is a bit hard for me to follow. I'd appreciate if anyone who actually knows what this should look like could illuminate me, or perhaps even just post a patch themselves! drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 ++ 3 files changed, 13 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 8f2255b3a38a..cfcff0b37466 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -1104,6 +1104,7 @@ static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_device *bdev) int amdgpu_device_init(struct amdgpu_device *adev, uint32_t flags); void amdgpu_device_fini_hw(struct amdgpu_device *adev); +void amdgpu_device_shutdown_hw(struct amdgpu_device *adev); void amdgpu_device_fini_sw(struct amdgpu_device *adev); int amdgpu_gpu_wait_for_idle(struct amdgpu_device *adev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index a2cdde0ca0a7..fa5925c2092d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -4247,6 +4247,16 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev) } +void amdgpu_device_shutdown_hw(struct amdgpu_device *adev) +{ + if (adev->mode_info.mode_config_initialized) { + if (!drm_drv_uses_atomic_modeset(adev_to_drm(adev))) + drm_helper_force_disable_all(adev_to_drm(adev)); + else + drm_atomic_helper_shutdown(adev_to_drm(adev)); + } +} + void amdgpu_device_fini_sw(struct amdgpu_device *adev) { int idx; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index e90f730eb715..3a7cbff111d1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -2333,6 +2333,8 @@ amdgpu_pci_shutdown(struct pci_dev *pdev) struct drm_device *dev = pci_get_drvdata(pdev); struct amdgpu_device *adev = drm_to_adev(dev); + amdgpu_device_shutdown_hw(adev); + if (amdgpu_ras_intr_triggered()) return; From patchwork Fri Sep 1 23:41:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13372936 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 43123CA0FF6 for ; Fri, 1 Sep 2023 23:42:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BBB1510E838; Fri, 1 Sep 2023 23:42:51 +0000 (UTC) Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9CF1310E838 for ; Fri, 1 Sep 2023 23:42:48 +0000 (UTC) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-68bedc0c268so2192389b3a.0 for ; Fri, 01 Sep 2023 16:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611767; x=1694216567; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=84GRgyYKdpTNARq0AeOvL2Otr8e52pcbhFdnubGKvgE=; b=JmUOq+4yh4WQ1c60CA1DJYAP6SQMYBTW4I5EE4pt/2I6oXzN22157l2NwKJmWAs4Sq abGTQiDISMIO8pCZA8CICbPxs7RsEVHDr06dwT2noBPzkKyXoa9ucrmcJKfV9Mix+4nq YdQgOUwQG9aLaH+x19xwqz+U94xNGh1Lj0S20= 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=d7zEHQLLYQfs5DE2FBkK4WnMtq7X76InRC2SA9kiwjll46FAIJg67dEDuYnry9L7zl bcnX24pmgBXXZrYGO5lzqed0NqL0Q2ehcx8Ytzq9IXMvW6McBiVEAG7jV9O6lLYXNloU eY61q5gl9jpcD0DMrRHKLqr5nVu4zO8M5mx7tuid1vnKFmeEMrCrn+FP5ioTH9ave+OW y2VHN8IGtA1eoCMwgmnshwBLbEj+HZE+/PH9r5IGpIMW8HJiZAqfOH/iXg/02Kis33J4 q50EFOcAF984p19qO7BNeoXA+RXxIVhIER3yDAFS9786nVrlnBMSNjwSE/PkBaN7Tsgg mc/g== X-Gm-Message-State: AOJu0YyBmrPFxJJ6+OAcE8192QuUQsoycSwcNXb7GEHhRmDDcn8unPCQ 8E/6CQHLm0T2AL4s3fDTTaCQfzNyEjQsG1ISn83RXIXH 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: rfoss@kernel.org, Baolin Wang , tzimmermann@suse.de, sam@ravnborg.org, liviu.dudau@arm.com, Douglas Anderson , linux-kernel@vger.kernel.org, zhang.lyra@gmail.com, orsonzhai@gmail.com, steven.price@arm.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Based on grepping through the source code, this driver appears to be missing a call to drm_atomic_helper_shutdown() at remove time. Let's add it. The fact that we should call drm_atomic_helper_shutdown() in the case of OS driver remove comes straight out of the kernel doc "driver instance overview" in drm_drv.c. While at it, let's also fix it so that if the driver's bind fails or if a driver gets unbound that the drvdata gets set to NULL. This will make sure we can't get confused during a later shutdown(). Suggested-by: Maxime Ripard 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_drm.c index 0aa39156f2fa..86a175116140 100644 --- a/drivers/gpu/drm/sprd/sprd_drm.c +++ b/drivers/gpu/drm/sprd/sprd_drm.c @@ -114,6 +114,7 @@ static int sprd_drm_bind(struct device *dev) drm_kms_helper_poll_fini(drm); err_unbind_all: component_unbind_all(drm->dev, drm); + platform_set_drvdata(pdev, NULL); return ret; } @@ -122,10 +123,11 @@ static void sprd_drm_unbind(struct device *dev) struct drm_device *drm = dev_get_drvdata(dev); drm_dev_unregister(drm); - drm_kms_helper_poll_fini(drm); + drm_atomic_helper_shutdown(drm); component_unbind_all(drm->dev, drm); + dev_set_drvdata(dev, NULL); } static const struct component_master_ops drm_component_ops = { From patchwork Fri Sep 1 23:41:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13372937 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A781ACA0FF8 for ; Fri, 1 Sep 2023 23:42:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ED51310E839; Fri, 1 Sep 2023 23:42:53 +0000 (UTC) Received: from mail-oo1-xc29.google.com (mail-oo1-xc29.google.com [IPv6:2607:f8b0:4864:20::c29]) by gabe.freedesktop.org (Postfix) with ESMTPS id 04E0810E838 for ; Fri, 1 Sep 2023 23:42:50 +0000 (UTC) Received: by mail-oo1-xc29.google.com with SMTP id 006d021491bc7-5733d431209so1506288eaf.0 for ; Fri, 01 Sep 2023 16:42:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611769; x=1694216569; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+uOG7orqF4actDsz25kkoaGcb+oSREvVrWkgMBMJJLo=; b=D5CV0B0Mo/BpErlWx0TwiKC/tX37o3N9VATZnnvAmVtxxvLOU2MC4G9xKQms8aChx9 e5BPS0/zoStWApBSngoHUu4zF+Sd/R87eChQtO2PzZO2AH8Tr3iyJY8gO3vkq+FnRCHD 6Yu6/P7zRh2u1FIQbzCe+uGmDrfZdsfUgL8R8= 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=Q/3wOdqvcUUAvoIC8X6QVVMjUabYka0CL7uma25eWEYSqeWAcjRTM8B8uCgS+4yLNa QdP3fPSiPvM6Y++XtiG2d3wFoCMMXG7E2aTJ8j1PxDOzN2Rn9IDrY6rckyoM+BoxkoSe eBXrgR37263sUeZBnPd3ErDyy37YppyoFmnbsc86LaKqwX0pMfHNDvOYG8BxKe4lanD2 Q3vXHXuFke9nqmEZxj6WPl2HarUx8JmFSZHSHvFd6nmSRb8ML4Yuui+bzk6su8wFMPmO 3yGSXO5GDLJRjBb9ell1YLRxzNXXdG4tjgF78CZ2oP5zDjv05V3bMXqXsre6KTCbdZ5A rQIw== X-Gm-Message-State: AOJu0YwB8SsjU4ZN4NMXpUECg6EsBI2+UpPmIwL/ocZuUc+rHaO1HyjB s35i2lYJvJ0RFEsKia7ZVmBh50VOOWBaCwi3SCS03rtr 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-samsung-soc@vger.kernel.org, alim.akhtar@samsung.com, sw0312.kim@samsung.com, Douglas Anderson , linux-kernel@vger.kernel.org, krzysztof.kozlowski@linaro.org, kyungmin.park@samsung.com, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Based on grepping through the source code this driver appears to be missing a call to drm_atomic_helper_shutdown() at system shutdown time and at driver unbind time. Among other things, this means that if a panel is in use that it won't be cleanly powered off at system shutdown time. The fact that we should call drm_atomic_helper_shutdown() in the case of OS shutdown/restart and at driver remove (or unbind) time comes straight out of the kernel doc "driver instance overview" in drm_drv.c. A few notes about this fix: - When adding drm_atomic_helper_shutdown() to the unbind path, I added it after drm_kms_helper_poll_fini() since that's when other drivers seemed to have it. - Technically with a previous patch, ("drm/atomic-helper: drm_atomic_helper_shutdown(NULL) should be a noop"), we don't actually need to check to see if our "drm" pointer is NULL before calling drm_atomic_helper_shutdown(). We'll leave the "if" test in, though, so that this patch can land without any dependencies. It could potentially be removed later. - This patch also makes sure to set the drvdata to NULL in the case of bind errors to make sure that shutdown can't access freed data. Suggested-by: Maxime Ripard 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/exynos/exynos_drm_drv.c index 8399256cb5c9..5380fb6c55ae 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c @@ -300,6 +300,7 @@ static int exynos_drm_bind(struct device *dev) drm_mode_config_cleanup(drm); exynos_drm_cleanup_dma(drm); kfree(private); + dev_set_drvdata(dev, NULL); err_free_drm: drm_dev_put(drm); @@ -313,6 +314,7 @@ static void exynos_drm_unbind(struct device *dev) drm_dev_unregister(drm); drm_kms_helper_poll_fini(drm); + drm_atomic_helper_shutdown(drm); component_unbind_all(drm->dev, drm); drm_mode_config_cleanup(drm); @@ -350,9 +352,18 @@ static int exynos_drm_platform_remove(struct platform_device *pdev) return 0; } +static void exynos_drm_platform_shutdown(struct platform_device *pdev) +{ + struct drm_device *drm = platform_get_drvdata(pdev); + + if (drm) + drm_atomic_helper_shutdown(drm); +} + static struct platform_driver exynos_drm_platform_driver = { .probe = exynos_drm_platform_probe, .remove = exynos_drm_platform_remove, + .shutdown = exynos_drm_platform_shutdown, .driver = { .name = "exynos-drm", .pm = &exynos_drm_pm_ops, From patchwork Fri Sep 1 23:41:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13372938 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0FFA8CA0FF6 for ; Fri, 1 Sep 2023 23:42:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 38AFE10E83B; Fri, 1 Sep 2023 23:42:54 +0000 (UTC) Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0F8A810E839 for ; Fri, 1 Sep 2023 23:42:52 +0000 (UTC) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-68a440a8a20so2165969b3a.3 for ; Fri, 01 Sep 2023 16:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611771; x=1694216571; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hHay3IZ79gwyzzJIvA/KLviDPDyXcoAjtR8WZOwFgDw=; b=JqNxfGfGIg9p/Ioaix3E1fCYp7u9wuAdBIBGvQ90GS1kMVdK9SHlPrCOjl7OCNBPbV Cs1sLH0cpWUfQBctHkMRDNGoWd5r/XN85VT00VV7z3CeRUasUobVscMX8liHJdlalbNS 8VvT08+nsn3MoITpo02O6o0UClgZGsVfB9jYI= 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=aQQN/Dt6TrCpwnRoMrIwDOHds9gL6FFr5TO3PuvHWzcvqi3TlK5Plcgq8jzblEqy0Z wZTY7ILMwCztpeNTtkQ1ckL+6ZcW2Zwl/vmdCAIrG6ZbTRwJbPMIC3QxUSFZN8K2khZ2 0geVZKftkaP0wJ9BDqIMk/6O6QXMgV+0SqHvP5T8Ht4Ea0QKXviLxVm3KOrR+Zeu49Xp PEbuL89mQhhEQOm8Tjr8nE5cKSKRwkBgwp3Yy6PnA0SOwtwjjGKJdtaYs/C8FsM9hg2D g2mvzBf6TwyoS6iTli8Iyke/E3uvGaYcGWt7FR5HHQJ3P6NlyWLAC4o418n++dj1qXxD G1Eg== X-Gm-Message-State: AOJu0YwT7++ZX8Tq5lnBWs4u9goOEkzNmjDCXXxodVHa9PGPdfhFxvhH MWtS+RsMSE83ETYO+oa+CA/y9CVl75YYZ30l8Z1DoYx1 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Douglas Anderson , linux-kernel@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Based on grepping through the source code, this driver appears to be missing a call to drm_atomic_helper_shutdown(), or in this case the non-atomic equivalent drm_helper_force_disable_all(), at system shutdown time and at driver remove time. This is important because drm_helper_force_disable_all() will cause panels to get disabled cleanly which may be important for their power sequencing. Future changes will remove any custom powering off in individual panel drivers so the DRM drivers need to start getting this right. The fact that we should call drm_atomic_helper_shutdown(), or in this case the non-atomic equivalent drm_helper_force_disable_all(), in the case of OS shutdown/restart comes straight out of the kernel doc "driver instance overview" in drm_drv.c. Suggested-by: Maxime Ripard 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 #include +#include #include #include #include @@ -485,6 +486,12 @@ static void psb_pci_remove(struct pci_dev *pdev) struct drm_device *dev = pci_get_drvdata(pdev); drm_dev_unregister(dev); + drm_helper_force_disable_all(dev); +} + +static void psb_pci_shutdown(struct pci_dev *pdev) +{ + drm_helper_force_disable_all(pci_get_drvdata(pdev)); } static DEFINE_RUNTIME_DEV_PM_OPS(psb_pm_ops, gma_power_suspend, gma_power_resume, NULL); @@ -521,6 +528,7 @@ static struct pci_driver psb_pci_driver = { .id_table = pciidlist, .probe = psb_pci_probe, .remove = psb_pci_remove, + .shutdown = psb_pci_shutdown, .driver.pm = &psb_pm_ops, }; From patchwork Fri Sep 1 23:41:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13372939 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DCD8ACA0FF9 for ; Fri, 1 Sep 2023 23:42:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 05C6C10E83C; Fri, 1 Sep 2023 23:42:56 +0000 (UTC) Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by gabe.freedesktop.org (Postfix) with ESMTPS id 784A810E83C for ; Fri, 1 Sep 2023 23:42:54 +0000 (UTC) Received: by mail-il1-x12f.google.com with SMTP id e9e14a558f8ab-34e12396f6fso4575125ab.1 for ; Fri, 01 Sep 2023 16:42:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611773; x=1694216573; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pzZMfYrc4MS7Ddrskta252Gk/vbJZVRLTsLEIZtE5Vw=; b=GJd7eER/L7IAJXH04mokh23kTh4307Yzhb7gNUDZw6KCgaV1hXvNfif8FARlQ9CEvE 14Mi/gUQCJoLgP703UCe4fk4K5l9rP0ipxqUyneIVGRO9sRdgqSa8rtOvBwC2098F52u yexIT9nFrPac4ByNRO5pS9JQs+f3IovOndVh4= 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=Zl9TNocWAmIo9jlh7xjIW5ZL1Lbbuf8Pb59Rzi8KYLtyT6WvrDqqDgtCNzqdGpBShB mdmivgSRSfi7Cw/sDje4AGGvFjaBC74xqWw90sK3OP81q+ouus72CQY1C4q4YzzvOT/z FGE/Lh4e1mGBxtLXnP/b4bnRpBNrGFC8eso2NlHdoElXEu/y3rKeKtjVikJxGers6UUw Mt5AtCDvrhsAcQ5XpMgJUsjUlWPjT/zWpeHlWxFZeOJLpOrHD9pRBsm7J9YLgXSqa9uZ tKnloujUuiQGsS8g/ByIZfsyJJUibXp8DCbcdP3dhu6ZBAHdUOONwEWI06Aqcl8/uCVP 4vTQ== X-Gm-Message-State: AOJu0Yz+El9gzu3PavmRxDDw+JFrWOA69qtJaKO1rErZm6a9fpndt1n7 wdw8+HqQy/6ww7W6hp/jZ1ciBHEsdk3sIRg+ZRtitqwu 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sascha Hauer , Douglas Anderson , shawnguo@kernel.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Based on grepping through the source code this driver appears to be missing a call to drm_atomic_helper_shutdown() at system shutdown time and at driver unbind time. Among other things, this means that if a panel is in use that it won't be cleanly powered off at system shutdown time. The fact that we should call drm_atomic_helper_shutdown() in the case of OS shutdown/restart and at driver remove (or unbind) time comes straight out of the kernel doc "driver instance overview" in drm_drv.c. A few notes about this fix: - When adding drm_atomic_helper_shutdown() to the unbind path, I added it after drm_kms_helper_poll_fini() since that's when other drivers seemed to have it. - Technically with a previous patch, ("drm/atomic-helper: drm_atomic_helper_shutdown(NULL) should be a noop"), we don't actually need to check to see if our "drm" pointer is NULL before calling drm_atomic_helper_shutdown(). We'll leave the "if" test in, though, so that this patch can land without any dependencies. It could potentially be removed later. - This patch also makes sure to set the drvdata to NULL in the case of bind errors to make sure that shutdown can't access freed data. Suggested-by: Maxime Ripard 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); return ret; @@ -269,6 +270,7 @@ static void imx_drm_unbind(struct device *dev) drm_dev_unregister(drm); drm_kms_helper_poll_fini(drm); + drm_atomic_helper_shutdown(drm); component_unbind_all(drm->dev, drm); @@ -298,6 +300,14 @@ static int imx_drm_platform_remove(struct platform_device *pdev) return 0; } +static void imx_drm_platform_shutdown(struct platform_device *pdev) +{ + struct drm_device *drm = 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 = { .probe = imx_drm_platform_probe, .remove = imx_drm_platform_remove, + .shutdown = imx_drm_platform_shutdown, .driver = { .name = "imx-drm", .pm = &imx_drm_pm_ops, From patchwork Fri Sep 1 23:41:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13372940 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4FA72CA0FF8 for ; Fri, 1 Sep 2023 23:42:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8D12210E83F; Fri, 1 Sep 2023 23:42:58 +0000 (UTC) Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4B96710E83D for ; Fri, 1 Sep 2023 23:42:56 +0000 (UTC) Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3aa1443858eso353915b6e.3 for ; Fri, 01 Sep 2023 16:42:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611775; x=1694216575; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KKiMaJ+cEDZwLLCxXqIHb+OBndFjgPpn6nuXSf4hrW0=; b=lNykkiFAhlsmA8jPi2qSxaIuI76WYWJznmYKJCi1VY6KjszVosPVYePP0GERA264SR jr8ZkRg5DtM8kqd+WFIInSKVmX5nFNNA0g0FpA7Cqtf5l69IWPbQR6xMF3Aq9gvZzABZ WXczy/FTRVi9FFhkrxrKAnpCzVsPxjK1ceRNc= 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=U4nLbnl4PB2PrfVbgMeKptcvsPZjFP5hnOB9t9KmXA5wN1BZ6EehrTqFUqFO7Wil3Y i/rh424tPf7lSJ2Tofdfgr1BmePjIFYor+KEuPM4tixPgaBNquvgnKXesvwZaPL4SJd7 007qs+q+b6dJGMz3FAcsi8eibM67xfuEDJbj845U7Jtk7R/vYluz+fVLGHr03BVIUxGF DecCaZkLIs0bvzQO/hmlTKUI0Y0gXnEJHdVI1MG7BDAcbWI+4LszAMnc+C83KdnY8R5h 2M+gXPD6vJAnt2P+tDSmfwr6lrSNo3v5srZgP0Jke37nHfxl5gCycW/r6uJtSkjZOLWo khsw== X-Gm-Message-State: AOJu0Yy+L2FSh3ewf0KrKjzRB48VB+M+y7uGELskW0+e17ZlPwx/AgJ3 CdV4vdtvbgPvfDzgFXusXUu8kkasI1rG/mmnVeK6Ddjr 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Xinhui.Pan@amd.com, Douglas Anderson , amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, alexander.deucher@amd.com, christian.koenig@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Based on grepping through the source code, this driver appears to be missing a call to drm_atomic_helper_shutdown(), or in this case the non-atomic equivalent drm_helper_force_disable_all(), at system shutdown time and at driver remove time. This is important because drm_helper_force_disable_all() will cause panels to get disabled cleanly which may be important for their power sequencing. Future changes will remove any custom powering off in individual panel drivers so the DRM drivers need to start getting this right. The fact that we should call drm_atomic_helper_shutdown(), or in this case the non-atomic equivalent drm_helper_force_disable_all(), in the case of OS shutdown/restart comes straight out of the kernel doc "driver instance overview" in drm_drv.c. NOTE: in order to get things inserted in the right place, I had to replace the old/deprecated drm_put_dev() function with the equivalent new calls. Suggested-by: Maxime Ripard 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/radeon_drv.c index 39cdede460b5..67995ea24852 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c @@ -38,6 +38,7 @@ #include #include +#include #include #include #include @@ -357,7 +358,9 @@ radeon_pci_remove(struct pci_dev *pdev) { struct drm_device *dev = pci_get_drvdata(pdev); - drm_put_dev(dev); + drm_dev_unregister(dev); + drm_helper_force_disable_all(dev); + drm_dev_put(dev); } static void @@ -368,6 +371,8 @@ radeon_pci_shutdown(struct pci_dev *pdev) */ if (radeon_device_is_virtual()) radeon_pci_remove(pdev); + else + drm_helper_force_disable_all(pci_get_drvdata(pdev)); #if defined(CONFIG_PPC64) || defined(CONFIG_MACH_LOONGSON64) /* From patchwork Fri Sep 1 23:41:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13372941 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B1F02CA0FFA for ; Fri, 1 Sep 2023 23:43:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E0DF410E840; Fri, 1 Sep 2023 23:43:00 +0000 (UTC) Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1CEBD10E83F for ; Fri, 1 Sep 2023 23:42:58 +0000 (UTC) Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3a8614fe8c4so1603446b6e.1 for ; Fri, 01 Sep 2023 16:42:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611777; x=1694216577; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IdM+lGT73cjSOBSP8IlsC1l9xDfQI2J1yvb0n4/3ZvY=; b=bd/48yII4/iHlNgmq7YYVcix0dLpIO7UhlkkMh2BIWqidhEmvICMtFcmL7wuM/ab3b IXNUarvhYl6fAgnbOlrzySYCUfgOLSE9LZ8MkSOeyA/lYDT7riK3qbIqz8uMqAFolKpC 7JlrdxAPGMRyHlpt6i9vHsW9NjDMSEgKYNydc= 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=MpW9R/9SNdu4MKk0KcSQ4CXhva9jBo5KAI2bxPEvM0kKzjw6dbnjizhxOFM/AYZYW7 4xlbe+z/8dXKZyP23Lv6iQS7kz2tFemsq5Td6T7V1KjCch7gSZfuEUE9F8n2azd3RYXW Ov4h0/V8LTXW3g1I6133+iI1go374UvYyDBglBHNVl4i7z2d9bgvEDUT0xT4XmvwmnEh gOaYOp/lM5d6ygTSZJCvqC1Nqbxq5MaoT1lCnmT2Bt8RrrnpsoT+Re5Xze/Y1xEUD9Zl Mn2CMUSD2dfS+WC4ISsoGsyZWwEigjhkRnvPzqPHCRqzHnKCrhixJ1qqFqvXJ0vM7zy3 rFLA== X-Gm-Message-State: AOJu0YyddyHQvSz+MpThELGkkPR+HRKBhf6QpqcEGIE/kV/PPYvHgbTQ 7UDN5PM+YFtelLwgYJGLD0z5YtL908D4GvyyABbf2tb3 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: paul@crapouillou.net, tzimmermann@suse.de, geert+renesas@glider.be, Douglas Anderson , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, kieran.bingham+renesas@ideasonboard.com, laurent.pinchart@ideasonboard.com, biju.das.jz@bp.renesas.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Based on grepping through the source code, this driver appears to be missing a call to drm_atomic_helper_shutdown(), or in this case the non-atomic equivalent drm_helper_force_disable_all(), at system shutdown time and at driver remove time. This is important because drm_helper_force_disable_all() will cause panels to get disabled cleanly which may be important for their power sequencing. Future changes will remove any custom powering off in individual panel drivers so the DRM drivers need to start getting this right. The fact that we should call drm_atomic_helper_shutdown(), or in this case the non-atomic equivalent drm_helper_force_disable_all(), in the case of OS shutdown/restart comes straight out of the kernel doc "driver instance overview" in drm_drv.c. Suggested-by: Maxime Ripard 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 +#include #include #include #include @@ -179,12 +180,20 @@ static int shmob_drm_remove(struct platform_device *pdev) drm_dev_unregister(ddev); drm_kms_helper_poll_fini(ddev); + drm_helper_force_disable_all(ddev); free_irq(sdev->irq, ddev); drm_dev_put(ddev); return 0; } +static void shmob_drm_shutdown(struct platform_device *pdev) +{ + struct shmob_drm_device *sdev = platform_get_drvdata(pdev); + + drm_helper_force_disable_all(sdev->ddev); +} + static int shmob_drm_probe(struct platform_device *pdev) { struct shmob_drm_platform_data *pdata = pdev->dev.platform_data; @@ -289,6 +298,7 @@ static int shmob_drm_probe(struct platform_device *pdev) static struct platform_driver shmob_drm_platform_driver = { .probe = shmob_drm_probe, .remove = shmob_drm_remove, + .shutdown = shmob_drm_shutdown, .driver = { .name = "shmob-drm", .pm = pm_sleep_ptr(&shmob_drm_pm_ops),