From patchwork Mon Nov 7 17:50:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 13034969 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 33397C43219 for ; Mon, 7 Nov 2022 17:51:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2F8AD10E86D; Mon, 7 Nov 2022 17:51:28 +0000 (UTC) Received: from aposti.net (aposti.net [89.234.176.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 71E4C10E86D for ; Mon, 7 Nov 2022 17:51:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1667843472; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z+IpH1Q1dYPVKyLaxilWX5S98yicXsHBkC9S23qvx10=; b=0tiKwTfjj4UhOpeAevLbvl402I7D2NMWgngf1Q/iHCa1FNymftekv38ReVkSCMcp2rxzwa IM3Zhe0MlmSK6UO4Xyh3Udg2YJvZeIfJF5lhtnGRf4QYf992QMXJNQTJXwNc2UzExMP9wJ a7UjBsnLWx/CAYHgDcoX6uCq4V8Gpp4= From: Paul Cercueil To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Subject: [PATCH 01/26] drm: modeset-helper: Export dev_pm_ops for simple drivers Date: Mon, 7 Nov 2022 17:50:41 +0000 Message-Id: <20221107175106.360578-2-paul@crapouillou.net> In-Reply-To: <20221107175106.360578-1-paul@crapouillou.net> References: <20221107175106.360578-1-paul@crapouillou.net> 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 Cercueil , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Export a dev_pm_ops meant to be used with simple drivers, which have their struct drm_device registered as their struct device's drvdata, and only call drm_mode_config_pm_{suspend,resume}. The symbol is conditionally exported if IS_ENABLED(CONFIG_PM_SLEEP), and therefore it should always be referenced using the pm_sleep_ptr() macro. Signed-off-by: Paul Cercueil --- drivers/gpu/drm/drm_modeset_helper.c | 32 ++++++++++++++++++++++++++++ include/drm/drm_modeset_helper.h | 4 ++++ 2 files changed, 36 insertions(+) diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c index f858dfedf2cf..0bc9f9228a60 100644 --- a/drivers/gpu/drm/drm_modeset_helper.c +++ b/drivers/gpu/drm/drm_modeset_helper.c @@ -20,6 +20,9 @@ * OF THIS SOFTWARE. */ +#include +#include + #include #include #include @@ -244,3 +247,32 @@ int drm_mode_config_helper_resume(struct drm_device *dev) return ret; } EXPORT_SYMBOL(drm_mode_config_helper_resume); + +static int drm_mode_config_pm_suspend(struct device *dev) +{ + struct drm_device *drm = dev_get_drvdata(dev); + + return drm_mode_config_helper_suspend(drm); +} + +static int drm_mode_config_pm_resume(struct device *dev) +{ + struct drm_device *drm = dev_get_drvdata(dev); + + return drm_mode_config_helper_resume(drm); +} + +/** + * drm_mode_config_pm_ops - Exported dev_pm_ops helper for simple drivers + * + * This dev_pm_ops can be used for simple drivers that would otherwise only call + * drm_mode_config_helper_suspend / drm_mode_config_helper_resume in their PM + * callbacks. It is only valid if the driver's drm_device has been registered as + * the struct device's drvdata. + * + * The exported symbol must always be used with the pm_sleep_ptr() macro, like + * this: + * .pm = pm_sleep_ptr(&drm_mode_config_pm_ops), + */ +EXPORT_SIMPLE_DEV_PM_OPS(drm_mode_config_pm_ops, + drm_mode_config_pm_suspend, drm_mode_config_pm_resume); diff --git a/include/drm/drm_modeset_helper.h b/include/drm/drm_modeset_helper.h index 995fd981cab0..85f29637e9c1 100644 --- a/include/drm/drm_modeset_helper.h +++ b/include/drm/drm_modeset_helper.h @@ -23,6 +23,8 @@ #ifndef __DRM_KMS_HELPER_H__ #define __DRM_KMS_HELPER_H__ +#include + struct drm_crtc; struct drm_crtc_funcs; struct drm_device; @@ -41,4 +43,6 @@ int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, int drm_mode_config_helper_suspend(struct drm_device *dev); int drm_mode_config_helper_resume(struct drm_device *dev); +extern const struct dev_pm_ops drm_mode_config_pm_ops; + #endif From patchwork Mon Nov 7 17:50:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 13034970 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 B0DF4C4332F for ; Mon, 7 Nov 2022 17:51:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4D93C10E86E; Mon, 7 Nov 2022 17:51:33 +0000 (UTC) Received: from aposti.net (aposti.net [89.234.176.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6564A10E86D for ; Mon, 7 Nov 2022 17:51:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1667843473; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EDRHgJeXjD/Lfgp6cHobjOELEmX34fviCtkXalmd8+c=; b=f0JM/l8sjONQLMbeKaV/13rSiNUmMjvk1GSAMsTvoHb8ClwnThUWo7yB/bPzQpKMojrQtX Gh+xqUDRaNWRqQcrKl8qKs/IwLSiuWGYy+8WGZDAG8aG6KtfazclijdWmWPoJ0kmCQY5n5 I6QP0f4xD6v2Df9PkdLUssmfIjwqs2U= From: Paul Cercueil To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Subject: [PATCH 02/26] drm: bochs: Use the dev_pm_ops provided by modeset helper Date: Mon, 7 Nov 2022 17:50:42 +0000 Message-Id: <20221107175106.360578-3-paul@crapouillou.net> In-Reply-To: <20221107175106.360578-1-paul@crapouillou.net> References: <20221107175106.360578-1-paul@crapouillou.net> MIME-Version: 1.0 X-Spam: Yes 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 Cercueil , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Gerd Hoffmann Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use the drm_mode_config_pm_ops structure exported by drm_modeset_helper.c, which provides the exact same PM callbacks. Signed-off-by: Paul Cercueil --- Cc: Gerd Hoffmann Cc: virtualization@lists.linux-foundation.org --- drivers/gpu/drm/tiny/bochs.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c index 04682f831544..26e9cba89f68 100644 --- a/drivers/gpu/drm/tiny/bochs.c +++ b/drivers/gpu/drm/tiny/bochs.c @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -610,30 +611,6 @@ static const struct drm_driver bochs_driver = { DRM_GEM_VRAM_DRIVER, }; -/* ---------------------------------------------------------------------- */ -/* pm interface */ - -#ifdef CONFIG_PM_SLEEP -static int bochs_pm_suspend(struct device *dev) -{ - struct drm_device *drm_dev = dev_get_drvdata(dev); - - return drm_mode_config_helper_suspend(drm_dev); -} - -static int bochs_pm_resume(struct device *dev) -{ - struct drm_device *drm_dev = dev_get_drvdata(dev); - - return drm_mode_config_helper_resume(drm_dev); -} -#endif - -static const struct dev_pm_ops bochs_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(bochs_pm_suspend, - bochs_pm_resume) -}; - /* ---------------------------------------------------------------------- */ /* pci interface */ @@ -721,7 +698,7 @@ static struct pci_driver bochs_pci_driver = { .id_table = bochs_pci_tbl, .probe = bochs_pci_probe, .remove = bochs_pci_remove, - .driver.pm = &bochs_pm_ops, + .driver.pm = pm_sleep_ptr(&drm_mode_config_pm_ops), }; /* ---------------------------------------------------------------------- */ From patchwork Mon Nov 7 17:50:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 13034971 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 7A647C4332F for ; Mon, 7 Nov 2022 17:51:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1A54210E874; Mon, 7 Nov 2022 17:51:41 +0000 (UTC) Received: from aposti.net (aposti.net [89.234.176.197]) by gabe.freedesktop.org (Postfix) with ESMTPS id B6B8D10E879 for ; Mon, 7 Nov 2022 17:51:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1667843474; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z0IvuxOw+z5I1Jelwxg7JYk5e8a4KTZtu0lWisuvsAA=; b=xno/RlzPPkwiCU8bqZQTuoUebofUxgdKbbJ3ikbUar9R21y2dFcY8v7URWtBk4yx2rW02I B/7hMKxtjPc7pYtPpHqP9a4KEwcRFeouwDajgB7tQ37tIvXv57VU4dMwTY7diOceMuMIDA WY3U+xUXIo4G32BxIK89jr4B6hjSpvU= From: Paul Cercueil To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Subject: [PATCH 03/26] drm: imx: Use the dev_pm_ops provided by modeset helper Date: Mon, 7 Nov 2022 17:50:43 +0000 Message-Id: <20221107175106.360578-4-paul@crapouillou.net> In-Reply-To: <20221107175106.360578-1-paul@crapouillou.net> References: <20221107175106.360578-1-paul@crapouillou.net> MIME-Version: 1.0 X-Spam: Yes 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: Pengutronix Kernel Team , Sascha Hauer , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Paul Cercueil , NXP Linux Team , Shawn Guo , linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use the drm_mode_config_pm_ops structure exported by drm_modeset_helper.c, which provides the exact same PM callbacks. Signed-off-by: Paul Cercueil --- Cc: Philipp Zabel Cc: Shawn Guo Cc: Sascha Hauer Cc: Pengutronix Kernel Team Cc: Fabio Estevam Cc: NXP Linux Team Cc: linux-arm-kernel@lists.infradead.org --- drivers/gpu/drm/imx/imx-drm-core.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c index 8dd8b0f912af..4cbd15c2c8ea 100644 --- a/drivers/gpu/drm/imx/imx-drm-core.c +++ b/drivers/gpu/drm/imx/imx-drm-core.c @@ -10,6 +10,7 @@ #include #include #include +#include #include