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: 13372944 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 6319BCA0FF9 for ; Fri, 1 Sep 2023 23:43:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jgxassF7qqkR3pnSDOHV99c9I/7Pg+emeupLs7bN2qI=; b=DTHs6J8tr800Df raPk5dBVTfDPrlHI0xmUcD4/Iv7tELrVP6wfaItFAynJD2sM2X5hAZnzNBfZlRB/ToSFhF8Q1ghY3 AavnrXeA3kTObbbze2vglJvsaIb9FY1iadnCwxAsx9tmnV7CsAmDxlMeKzNe5xZStdJ87Ix8xSh66 H8G4rwJW8EQS02Os2Fg1lzhwioXKuSEiot/1JG01LgebEL4+KcNDkXKooHJvbozJLVZpvxh4XmB0G nPFTtLfqX1LHUF0zUbbKqTbwfrlzy9A+77pbhAavYNvT6dHxQdCdfO9IVYl5MoaBDqP/G/1RboP68 3/PTWazBhlm4lY4IOXdQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qcDme-000Vod-11; Fri, 01 Sep 2023 23:42:36 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qcDmb-000VmY-0h for linux-arm-kernel@lists.infradead.org; Fri, 01 Sep 2023 23:42:34 +0000 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-68a3ced3ec6so2216828b3a.1 for ; Fri, 01 Sep 2023 16:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611750; x=1694216550; darn=lists.infradead.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=O20hFUcn4ycVb13QJ5udSRSftKP5iQyQ5Ah9h41vxPZXU4bC3WkQsane1xWyDxvETj jHo4M0kqoOS6Nu8Gd/xcUOqz9LjZZJWr0x4O51oa2XvuBWUNlSNMI2tEc+usmVSs+0il 4gmKmjO26XZ1oR25ynYBx6L8DdsNUPbD3Wbt8= 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=PC/DfEm+V1t2X/cl3z22LK2VIfocqMa25jDV0CRky11a9lkQj3aq4qA8i5r1HfKgxI Tib4V3xG9mIXg/0B7akaQ81b/+rSPGvfykY+7JSXzT93RSKNvamz7cvZuUFm4QAogxjl S4OCU4v66P6tcmwU8pdvI9pf1NRhj/81ZPhpciSwGU9R4n8I2pL1fOugelb0a1nUhNxK KPICnUGFAVZRTXd64pFugs9qf3i2NXLDskunwfXYpJYHmMVAaNOBYsCupbQ1nzzwTELa QbCKD3L+QAv1NVm4lt4JgsRF2Xub7sQzoXYZyoYw3saOnn5eMFVE8cv6jD/wMZzxy2+g dX6w== X-Gm-Message-State: AOJu0Yzgs+4KJO4ZwlNhZUy34Zl7h/XZ7K7+W34/y+pnuQEgtOldoDNU rXosZ0EEgZA6P85Bn4Mye2vDbw== X-Google-Smtp-Source: AGHT+IEo8+vhlzHuiA7kt4gie7hkc/892ETxj7IzgIvbEImTbdys6UWMlOfB4tKXF+g1dIUU86Genw== X-Received: by 2002:a05:6a00:139c:b0:68a:5449:7436 with SMTP id t28-20020a056a00139c00b0068a54497436mr4995293pfg.32.1693611750394; Fri, 01 Sep 2023 16:42:30 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8d94:1fc5:803c:41cc]) by smtp.gmail.com with ESMTPSA id o9-20020a639a09000000b0056c3a4a3ca5sm3326390pge.36.2023.09.01.16.42.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:42:28 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , Sascha Hauer , airlied@gmail.com, daniel@ffwll.ch, festevam@gmail.com, kernel@pengutronix.de, l.stach@pengutronix.de, laurentiu.palcu@oss.nxp.com, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, shawnguo@kernel.org Subject: [RFT PATCH 02/15] drm/imx/dcss: Call drm_atomic_helper_shutdown() at shutdown time Date: Fri, 1 Sep 2023 16:41:13 -0700 Message-ID: <20230901164111.RFT.2.I134336fce7eac5a63bdac46d57b0888858fc8081@changeid> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog In-Reply-To: <20230901234202.566951-1-dianders@chromium.org> References: <20230901234202.566951-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230901_164233_255088_37669D0C X-CRM114-Status: GOOD ( 17.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: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: 13372945 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 312EBCA0FF8 for ; Fri, 1 Sep 2023 23:43:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+3AgBUjJhP48xv0hRme3F2J4coh9BAAwuV/lwN9H0Zk=; b=cQ+ajC7a0YKCu4 4P30CIo6STJAO2HIqDNkS7nY0lXQK+kyVCkUFR/NWdiq8Y+xjJJhVKcvauN3+Fbmv21PzM3SIJHbX ibNPXoRMESAs0GvDxxCIt/UPnIJWuRwcUW+tzsPafgGXesBwE5jQlvNaUSw/L2CDTWBTQhPPkFI5A KjDoS/ZnsNIZoIGYIexcnEKikM0jOA0U0Xr61OVe6XCZF/chGo1sB4oT8xUXCKVqkNyjpNk+ZgRJz poZg/Wh6F57EmpcBDkUJKCqfnD3KCajP4ILPSj0ejf74EWcQFHwsiSPgb8uxY5yDa2QCHH0Q30dd7 d7v1H61ceC3baQR+2J6Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qcDml-000Vsf-1n; Fri, 01 Sep 2023 23:42:43 +0000 Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qcDmi-000Vpn-32 for linux-arm-kernel@lists.infradead.org; Fri, 01 Sep 2023 23:42:42 +0000 Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3a9b41ffe12so1707853b6e.3 for ; Fri, 01 Sep 2023 16:42:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611758; x=1694216558; darn=lists.infradead.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=JEEUbTxsfyb4ZZFNIRvigrE91xqcyKcWmlbIfBUGywkkSN5SVq/nw7NnnKI69gZNe4 jGDFP4/GRgVgGSDimEvSoOlCI2i0xehZjHRsYjtIDtaGIWUVdQDyKdQ+fGkRb4HkumpU 4AHRrcRMAUlU13WOosYwPX4KeAiOFA7dA5rz8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693611758; x=1694216558; 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=B6bIqEZxEPkrw6aIGSBCZupWmkB87PnG5Kl2GJjLc2VfgC1Wokr6uAhK946GpRlnaC 8A3EVkpT/bCspaxoq7w73JiP9NeVsoJvprVqsJNQQdnooI+EMZOTUwEwIPNDZ3pgzatk 8HWdW6MDgxJ4UY4N/LmCvXXg+74PlryctJF++Khs0YpvVZi0RdQnH7Qooknn2TuSZ8EY pkZhcEIDX8NyEbK5vpKnwHpmoDqUHfcXK1XD9fI2V7Fo0827BfiGNwfc+ds3MUrEeDsG XUyZZqFcr7bWWPGXCwhQGv2JMgURALBvM8oFIy0O9ew3yDwpZjyx1J9/aEgB11lY/Sz3 8dUg== X-Gm-Message-State: AOJu0Yw0IqPNTrzavL0qdiGtDE04sb5hKwMdQ75rNWFDyTDBGhRGJsKX UeRszF402PnXHrgxPapJ/NeOtA== X-Google-Smtp-Source: AGHT+IH161FDJO4p2lz9ilVRETKBQ5UyI7NChHl4VMZC9iScfWTxID2/lUEJl6hXY/byI5CWz2ElFA== X-Received: by 2002:a05:6808:28e:b0:3a7:a299:1201 with SMTP id z14-20020a056808028e00b003a7a2991201mr4034449oic.23.1693611755813; Fri, 01 Sep 2023 16:42:35 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8d94:1fc5:803c:41cc]) by smtp.gmail.com with ESMTPSA id o9-20020a639a09000000b0056c3a4a3ca5sm3326390pge.36.2023.09.01.16.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:42:35 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , airlied@gmail.com, angelogioacchino.delregno@collabora.com, chunkuang.hu@kernel.org, daniel@ffwll.ch, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com, p.zabel@pengutronix.de Subject: [RFT PATCH 05/15] drm/mediatek: Call drm_atomic_helper_shutdown() at shutdown time Date: Fri, 1 Sep 2023 16:41:16 -0700 Message-ID: <20230901164111.RFT.5.I2b014f90afc4729b6ecc7b5ddd1f6dedcea4625b@changeid> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog In-Reply-To: <20230901234202.566951-1-dianders@chromium.org> References: <20230901234202.566951-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230901_164240_972965_51C32BBB X-CRM114-Status: GOOD ( 20.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: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: 13372946 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 26022CA0FF6 for ; Fri, 1 Sep 2023 23:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uTiPRs/FcI2GkoKUXhEiBujyqoGprrtuZbkEogYfsAk=; b=wiSzjy6tNFep0t rav4fvMDaeZxMTnU81OB/RTV0WZRkxP9fojriKfx58enkZktuvIaOcj7rsjWxQ1RdY6Dn4nhTOaIK mkD6XdtIacAlGn39j5spwXrVFFOJXnHPQHBvYpLf8MArivxU4AP8Ag9iS6WEoifM7baJwP76VWkQ1 1I94IwECJQxAF0mPRpDAu25kEGql6kt93AFerJZ0nYiQ+71ap/j1KHaFmwzezy66Ji+roQ9wNBc6u jb++rWOd+uBl/2Y33OFbd9iR7Els0i26gcucVl8QVARqiKq1X9g7+vZiXzTpVR6UMLAR81REOe/t1 yDfbj4OKd77olHRYWvxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qcDmw-000Vz3-1R; Fri, 01 Sep 2023 23:42:54 +0000 Received: from mail-oo1-xc2c.google.com ([2607:f8b0:4864:20::c2c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qcDmt-000Vwt-1x for linux-arm-kernel@lists.infradead.org; Fri, 01 Sep 2023 23:42:52 +0000 Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-5735282d713so1489514eaf.2 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.infradead.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=YrFhT/8xFVu4dROkl2iK3pfAg0xh3dtLsmZL1EmtQb6KdlUfTRwyU5QYUnDKDAq0BX s6Cgwdxt3JGl5mJPym7OyXP4aX7h3ZQCF3SBzWVuF0Z5QMOCxghbyg3xHWchRU+82B0r a/eoTSpGyep1PQ64jnbi+NOD/M5/Ca70hUccE= 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=VPt2zOnOYEv433e221czu71z9L+GEA7ubE3FA786L7bA0dw3x/xjlU7HRyO8yowKE6 vcVBGwp0qGqnuvWMGXjlWuQ41YrBIGChAQtZH/m0auao+uiZhvipp+mLCaUqO9g5NiRi KyDtvnNCviaA5uW8ZzT/wd4ZXcVDaUb55gu67BjnJGHXxtF9u/XJiREn4LsWUVpfb3Ov Ej5K1xJdh+hvsdzUQFJ/DK4rXtwx69vbuI5nInRq9TiEzb6tE4mSkEvx5GDnEGVsSLk9 bG4tfBz4srMBtx3WJ3lRbEQ2XsQrHjWrPF1vyuwa6wZvpfXP2kQwNkM8wJxITfOXiSgJ HfRw== X-Gm-Message-State: AOJu0YzJCrR66Dbr2Jp5HMvoN+mzPi3yeY/z0navPXPnhILZC6bHuUtf LJMD4QKhmaaubh7Nx6oHgJitYQ== X-Google-Smtp-Source: AGHT+IEtno2sAZxUeLfldTVuC/n8wvbt8r9p0WUGoKpJ49IMbd/DsuhRqnZWTnQHfwEPIadZyumfcA== X-Received: by 2002:a05:6358:7e03:b0:127:f2fb:d103 with SMTP id o3-20020a0563587e0300b00127f2fbd103mr3928386rwm.16.1693611769417; Fri, 01 Sep 2023 16:42:49 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8d94:1fc5:803c:41cc]) by smtp.gmail.com with ESMTPSA id o9-20020a639a09000000b0056c3a4a3ca5sm3326390pge.36.2023.09.01.16.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:42:48 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , airlied@gmail.com, alim.akhtar@samsung.com, daniel@ffwll.ch, inki.dae@samsung.com, krzysztof.kozlowski@linaro.org, kyungmin.park@samsung.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, sw0312.kim@samsung.com Subject: [RFT PATCH 11/15] drm/exynos: Call drm_atomic_helper_shutdown() at shutdown/unbind time Date: Fri, 1 Sep 2023 16:41:22 -0700 Message-ID: <20230901164111.RFT.11.Iea33274908b6b258955f45a8aaf6f5bba24ad6cd@changeid> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog In-Reply-To: <20230901234202.566951-1-dianders@chromium.org> References: <20230901234202.566951-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230901_164251_640441_F4BF9CFF X-CRM114-Status: GOOD ( 21.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: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: 13372947 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 8D2F0CA0FF9 for ; Fri, 1 Sep 2023 23:43:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zdYMxsHTAJbRtZBlRNyULZwFN5VwJcM3F2jhj0ITYDU=; b=3rpOxzHbka6Re8 L2UuqYKmc6M0AZprMhFHRYAgW05VWkee988ZIe8oiOGfoXDXPwCsoBDhXBaqTmrauh0rV5jgYQQe3 5thqHFeN5L5zYmxllvXwDHXknQok21tUmfioJVp4750M/T18xzKiFndfQcm4vxcWqQFf6oUpUE4CB /Qatkyo/7NFKzDU9LSaKiFh3Xs084n8Rdlj86gyChx6rZxLOOo2zT46K3Afqe/inF9pB0JxBQURCx vsqKr2Fh4PNGKsX8DS8tWOh3XnOHV9X8aOS+tSfpYzlRPxRTYQVanxuCARdVy2WnNCkh+y8BaFx/C Xss1HZt86s9FzSyFQFiQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qcDmz-000W1G-0A; Fri, 01 Sep 2023 23:42:57 +0000 Received: from mail-il1-x12e.google.com ([2607:f8b0:4864:20::12e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qcDmw-000VyY-2g for linux-arm-kernel@lists.infradead.org; Fri, 01 Sep 2023 23:42:56 +0000 Received: by mail-il1-x12e.google.com with SMTP id e9e14a558f8ab-34bbc5eb310so8578485ab.2 for ; Fri, 01 Sep 2023 16:42:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1693611773; x=1694216573; darn=lists.infradead.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=HMclumGSGdmE8PZEq8tngJGozl70B1i0brYlySMxqWYw2TZ3p+owq6uTBURkPYTlgc u0Gj6PBd8pWcla6kzDYrLcsGlbXntH7jlEukh4eXRK9Qw4A12pU+hFl8F/MAaB6wDaYF kZikOKV5WXJrzFd7QXkXQEDbcq/D43qqZtjgU= 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=HBQx/WD6xcsuHX3oniXDGnOYQ1wrGf1tyTV+49Rud5qRa12oapLC4bpM7brGwaIJVW 3OJAMHwBjwcvkmeXuBkY/y+MFYfxYMn3SIMzB/EbJnwf5pOnZcDcWmUp/EHM7FHQ3KyR BfBZSKrofa7qpp47+jyzz/xGsd2AY6WOutaQqNHDhU5Ew6R4lM8JbAIqpIgHjOr/fknG vnMqsA4+U86xWzCSeaI1HAyg6MadabxTW89CdczpgwTRJ6Y4Ha4/hpW7wILiR2LGuhgT kyvN93Z0e7ReFmtOd5C7uspN4BAJyPXGCOcYMWrxq6PVHzCwWHiURIeXDadeD88DNqmI NoRA== X-Gm-Message-State: AOJu0YwzWlo3x83EeI+PstW5/BOeZigqWon2MQjXgLBONJg8rCdE0irm XO/UpF92KF2/AlmvTh3wH7kgcw== X-Google-Smtp-Source: AGHT+IFvdRCJwMr99Yb1JrwpTHYD/RaTUnsuipwnbiYPCDCcEBVC17WQxgviFC4gHISPtQjZ2Wly3g== X-Received: by 2002:a05:6e02:1a21:b0:348:fe3b:c8b with SMTP id g1-20020a056e021a2100b00348fe3b0c8bmr5295836ile.1.1693611773002; Fri, 01 Sep 2023 16:42:53 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8d94:1fc5:803c:41cc]) by smtp.gmail.com with ESMTPSA id o9-20020a639a09000000b0056c3a4a3ca5sm3326390pge.36.2023.09.01.16.42.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:42:52 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org, Maxime Ripard Cc: Douglas Anderson , Sascha Hauer , airlied@gmail.com, daniel@ffwll.ch, festevam@gmail.com, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, p.zabel@pengutronix.de, shawnguo@kernel.org Subject: [RFT PATCH 13/15] drm/imx/ipuv3: Call drm_atomic_helper_shutdown() at shutdown/unbind time Date: Fri, 1 Sep 2023 16:41:24 -0700 Message-ID: <20230901164111.RFT.13.I0a9940ff6f387d6acf4e71d8c7dbaff8c42e3aaa@changeid> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog In-Reply-To: <20230901234202.566951-1-dianders@chromium.org> References: <20230901234202.566951-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230901_164254_871165_75674B31 X-CRM114-Status: GOOD ( 21.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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,