From patchwork Mon Nov 7 17:52:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 16609 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2201723wru; Mon, 7 Nov 2022 09:56:16 -0800 (PST) X-Google-Smtp-Source: AMsMyM5XEcuEm/1ZGM2/MaA2WxKjx7AVcFdR0ggSqqdmAzyZPShmjjbGhgHQPoVk+tdsjdBUdmDP X-Received: by 2002:a17:90b:b05:b0:212:f402:bd16 with SMTP id bf5-20020a17090b0b0500b00212f402bd16mr70715821pjb.163.1667843775841; Mon, 07 Nov 2022 09:56:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667843775; cv=none; d=google.com; s=arc-20160816; b=YDsRZefHDOetnqGVc6vqg6Ixx8MIwBsBLyo0w4rh5JQp1cMVDAjWSoGkElbUB4uNQK c97DwgJ86mqatUSz9EaSNsokDP07fq/83/Zxbv3rR2768AbK3dpiuCheJk8qEH8eZW9u SDNWLCfGR8Yq8Nxr6+KnuGhC/KwF1D+6SAap+s3DIsi9VQD9gBvSoDW3RvB4Xf8npulP 23TdD+ELDxCQGdd73cZs3V4de1rpjXcYGsWbf0VmP3w1UDt8Uc095aJA7q2p/IfJKK96 3Fqkruu/1XLYpL7tgR6e7V1+RmVoU1FLWJ4OBQpzRDvq04cSmymnJpt4ZJGeW7d1oUFZ 8EAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=S+yQFkjdP/jifUhuMI/LX0bFF+LF4Dh5aR0516qergg=; b=aH0A3Ru2TItZnEa+fTvRI+Z9ViR2gRsV1ajFYrM+QNT+nyywXan2vSyn0TGA49xXqC kkLhLASg5NYHwEUn0wuJ5Lwwg3OwsynjhYlbwb0HNCUfEO4WSGQnMQbHjzuY3XjAe1nH w4ilgNBk9+J+ZUxPyOAOk/7aC3x8CPctI3luGZ2MCT9jLbvDUJCFebuQ9BemIRSbCeCK Bwpn1II3JSVGd/krCbZBiu4xmKTZT1RQzUBmw+8YxUb4mDcpRGoAnjACz9dT7MhaOqwT SVgXp+sZwkwNcd6NF7sOrRMZPXa3iJycuHjNWhv3M8X8tNSad+052l0W/tSJquZnIF1m u8ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=jIW5SaZ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g13-20020a65580d000000b0046f580656c8si11757030pgr.351.2022.11.07.09.56.02; Mon, 07 Nov 2022 09:56:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=jIW5SaZ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232707AbiKGRzj (ORCPT + 99 others); Mon, 7 Nov 2022 12:55:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232377AbiKGRy0 (ORCPT ); Mon, 7 Nov 2022 12:54:26 -0500 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7E4F248F5 for ; Mon, 7 Nov 2022 09:53:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1667843590; 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=S+yQFkjdP/jifUhuMI/LX0bFF+LF4Dh5aR0516qergg=; b=jIW5SaZ4yHLJTfkFiKeDyZDbW7vGqUGKMhYBR7WPBlvLIjATO20mKsIJAikR0tcLgmxVwR JINbUfPpSgA6cl6x1qhoOFgMhgx9n3muxtGDTsf9TRPzcV0cUZjYrIe0faZfaCvlEHKZQl 6AadLDGpoXNEB/1GvFuYfP6NnW7hczY= From: Paul Cercueil To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Paul Cercueil , Rob Herring , Tomeu Vizoso , Steven Price , Alyssa Rosenzweig Subject: [PATCH 16/26] drm: panfrost: Remove #ifdef guards for PM related functions Date: Mon, 7 Nov 2022 17:52:46 +0000 Message-Id: <20221107175256.360839-6-paul@crapouillou.net> In-Reply-To: <20221107175256.360839-1-paul@crapouillou.net> References: <20221107175106.360578-1-paul@crapouillou.net> <20221107175256.360839-1-paul@crapouillou.net> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748860954769032604?= X-GMAIL-MSGID: =?utf-8?q?1748860954769032604?= Use the EXPORT_GPL_RUNTIME_DEV_PM_OPS() and pm_ptr() macros to handle the PM callbacks. These macros allow the PM functions to be automatically dropped by the compiler when CONFIG_PM is disabled, without having to use #ifdef guards. This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch. Signed-off-by: Paul Cercueil Reviewed-by: Steven Price --- Cc: Rob Herring Cc: Tomeu Vizoso Cc: Steven Price Cc: Alyssa Rosenzweig --- drivers/gpu/drm/panfrost/panfrost_device.c | 10 ++++++---- drivers/gpu/drm/panfrost/panfrost_device.h | 4 ++-- drivers/gpu/drm/panfrost/panfrost_drv.c | 7 +------ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c index ee612303f076..fa1a086a862b 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.c +++ b/drivers/gpu/drm/panfrost/panfrost_device.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include "panfrost_device.h" @@ -400,8 +401,7 @@ void panfrost_device_reset(struct panfrost_device *pfdev) panfrost_job_enable_interrupts(pfdev); } -#ifdef CONFIG_PM -int panfrost_device_resume(struct device *dev) +static int panfrost_device_resume(struct device *dev) { struct panfrost_device *pfdev = dev_get_drvdata(dev); @@ -411,7 +411,7 @@ int panfrost_device_resume(struct device *dev) return 0; } -int panfrost_device_suspend(struct device *dev) +static int panfrost_device_suspend(struct device *dev) { struct panfrost_device *pfdev = dev_get_drvdata(dev); @@ -423,4 +423,6 @@ int panfrost_device_suspend(struct device *dev) return 0; } -#endif + +EXPORT_GPL_RUNTIME_DEV_PM_OPS(panfrost_pm_ops, panfrost_device_suspend, + panfrost_device_resume, NULL); diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h index 8b25278f34c8..d9ba68cffb77 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.h +++ b/drivers/gpu/drm/panfrost/panfrost_device.h @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -172,8 +173,7 @@ int panfrost_device_init(struct panfrost_device *pfdev); void panfrost_device_fini(struct panfrost_device *pfdev); void panfrost_device_reset(struct panfrost_device *pfdev); -int panfrost_device_resume(struct device *dev); -int panfrost_device_suspend(struct device *dev); +extern const struct dev_pm_ops panfrost_pm_ops; enum drm_panfrost_exception_type { DRM_PANFROST_EXCEPTION_OK = 0x00, diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index 2fa5afe21288..fa619fe72086 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -676,17 +676,12 @@ static const struct of_device_id dt_match[] = { }; MODULE_DEVICE_TABLE(of, dt_match); -static const struct dev_pm_ops panfrost_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) - SET_RUNTIME_PM_OPS(panfrost_device_suspend, panfrost_device_resume, NULL) -}; - static struct platform_driver panfrost_driver = { .probe = panfrost_probe, .remove = panfrost_remove, .driver = { .name = "panfrost", - .pm = &panfrost_pm_ops, + .pm = pm_ptr(&panfrost_pm_ops), .of_match_table = dt_match, }, };