Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2228416rwb; Mon, 7 Nov 2022 10:40:08 -0800 (PST) X-Google-Smtp-Source: AMsMyM49d33eoORVG+VA4eEsqHIiQvV0F2ibY3VhAE+K/fCs+ZjVhfbvY1TZ6dgVQQWhgnAcVf/N X-Received: by 2002:a17:90a:6f83:b0:213:9e97:d5e1 with SMTP id e3-20020a17090a6f8300b002139e97d5e1mr54356148pjk.149.1667846408358; Mon, 07 Nov 2022 10:40:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667846408; cv=none; d=google.com; s=arc-20160816; b=v/q0RWI0mIQ4Jqk/Iq/XIJuEsiumt2Sm5/180oH5Wt1cDJKXV0WYcDCbDTycnQHyco z45qIEmvI8b5BHUoFD6CorpkSnC9WVc+6tpOT/qw4oodouG/ddy9kyO9EqECaoHShcpg Pip5R5tlnK4mX5usDrqEpZOshwnZxePl4uHfkK8Sg57cdtwdUA+4gaB3rz/cgZKsSiqx J54HxY5HSGd/L5YcemdORdrfZBWg/mk8OtVW5XSfZdkuPpks9WWGP93JIzf9Wav9hymF N6uHE+3rnFjdua1UMsu52li7ByIeI8KOFNBAV99D8f5H5yDYQBcahwEr6gEIhcIZd7IU KEcw== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=J3vWPRpVuoxLy/Fz2CONVNZS/smE4Qc26elDfqJ4Xvo=; b=lE9DibrbXlW19clBBRV4u63CmdMe31A8QkRjxWJj9HZUqsz5OT4Cp1BpPcS8qtYijr 7y++O+ybt5KPzbrunoMIZCn5+wWRBZZXa6/wXqHbumBB8qcxIQ4BlDUZ8rv4pXtxmJqQ gMbdi1TtKNwYs7jVXChhAZpXRx0npu1qDW6phwHJuwS7mX21h3DosDp9oxw9RN8OkY0g siunjPRjEA3Q63eGhOt5OB5UKGMZL7Bs310tOjWYvvdNSGI0p9XYA+Fx/YQ/ThC/M57A CBQ5M2Xwc36L5IiyiAQb+PqAy/h+jYR8har3bVtZDUAe3swhc2pwntVzJxfUwsNvUdJ6 DpaA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a62-20020a636641000000b004402f48dee0si11523264pgc.629.2022.11.07.10.39.56; Mon, 07 Nov 2022 10:40:08 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233073AbiKGSKm (ORCPT + 92 others); Mon, 7 Nov 2022 13:10:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232540AbiKGSKX (ORCPT ); Mon, 7 Nov 2022 13:10:23 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91191108E for ; Mon, 7 Nov 2022 10:07:54 -0800 (PST) Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=[IPv6:::1]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1os6X0-0005Ct-6o; Mon, 07 Nov 2022 19:07:34 +0100 Message-ID: Subject: Re: [PATCH 12/26] drm: etnaviv: Remove #ifdef guards for PM related functions From: Lucas Stach To: Paul Cercueil , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Russell King , Christian Gmeiner , etnaviv@lists.freedesktop.org Date: Mon, 07 Nov 2022 19:07:32 +0100 In-Reply-To: <20221107175256.360839-2-paul@crapouillou.net> References: <20221107175106.360578-1-paul@crapouillou.net> <20221107175256.360839-1-paul@crapouillou.net> <20221107175256.360839-2-paul@crapouillou.net> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.4 (3.40.4-1.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,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 Am Montag, dem 07.11.2022 um 17:52 +0000 schrieb Paul Cercueil: > Use the RUNTIME_PM_OPS() and pm_ptr() macros to handle the > .runtime_suspend/.runtime_resume callbacks. > > These macros allow the suspend and resume 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. > > Some #ifdef CONFIG_PM guards were protecting simple statements, and were > also converted to "if (IS_ENABLED(CONFIG_PM))". > Reasoning and the change itself look good. > Note that this driver should probably use the > DEFINE_RUNTIME_DEV_PM_OPS() macro instead, which will provide > .suspend/.resume callbacks, pointing to pm_runtime_force_suspend() and > pm_runtime_force_resume() respectively; unless those callbacks really > aren't needed. This however isn't true, specifically this driver can _not_ use pm_runtime_force_suspend, as the GPU can't be forced into suspend by calling the rpm callback. A real suspend implementation would first need to make sure the GPU finished working on the current queued jobs, only then it would be able to power it down via the rpm suspend callback. Regards, Lucas > > Signed-off-by: Paul Cercueil > --- > Cc: Lucas Stach > Cc: Russell King > Cc: Christian Gmeiner > Cc: etnaviv@lists.freedesktop.org > --- > drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 30 +++++++++++---------------- > 1 file changed, 12 insertions(+), 18 deletions(-) > > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c > index 37018bc55810..e9a5444ec1c7 100644 > --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c > +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c > @@ -1605,7 +1605,6 @@ static int etnaviv_gpu_hw_suspend(struct etnaviv_gpu *gpu) > return etnaviv_gpu_clk_disable(gpu); > } > > -#ifdef CONFIG_PM > static int etnaviv_gpu_hw_resume(struct etnaviv_gpu *gpu) > { > int ret; > @@ -1621,7 +1620,6 @@ static int etnaviv_gpu_hw_resume(struct etnaviv_gpu *gpu) > > return 0; > } > -#endif > > static int > etnaviv_gpu_cooling_get_max_state(struct thermal_cooling_device *cdev, > @@ -1689,11 +1687,10 @@ static int etnaviv_gpu_bind(struct device *dev, struct device *master, > if (ret) > goto out_workqueue; > > -#ifdef CONFIG_PM > - ret = pm_runtime_get_sync(gpu->dev); > -#else > - ret = etnaviv_gpu_clk_enable(gpu); > -#endif > + if (IS_ENABLED(CONFIG_PM)) > + ret = pm_runtime_get_sync(gpu->dev); > + else > + ret = etnaviv_gpu_clk_enable(gpu); > if (ret < 0) > goto out_sched; > > @@ -1737,12 +1734,12 @@ static void etnaviv_gpu_unbind(struct device *dev, struct device *master, > > etnaviv_sched_fini(gpu); > > -#ifdef CONFIG_PM > - pm_runtime_get_sync(gpu->dev); > - pm_runtime_put_sync_suspend(gpu->dev); > -#else > - etnaviv_gpu_hw_suspend(gpu); > -#endif > + if (IS_ENABLED(CONFIG_PM)) { > + pm_runtime_get_sync(gpu->dev); > + pm_runtime_put_sync_suspend(gpu->dev); > + } else { > + etnaviv_gpu_hw_suspend(gpu); > + } > > if (gpu->mmu_context) > etnaviv_iommu_context_put(gpu->mmu_context); > @@ -1856,7 +1853,6 @@ static int etnaviv_gpu_platform_remove(struct platform_device *pdev) > return 0; > } > > -#ifdef CONFIG_PM > static int etnaviv_gpu_rpm_suspend(struct device *dev) > { > struct etnaviv_gpu *gpu = dev_get_drvdata(dev); > @@ -1899,18 +1895,16 @@ static int etnaviv_gpu_rpm_resume(struct device *dev) > > return 0; > } > -#endif > > static const struct dev_pm_ops etnaviv_gpu_pm_ops = { > - SET_RUNTIME_PM_OPS(etnaviv_gpu_rpm_suspend, etnaviv_gpu_rpm_resume, > - NULL) > + RUNTIME_PM_OPS(etnaviv_gpu_rpm_suspend, etnaviv_gpu_rpm_resume, NULL) > }; > > struct platform_driver etnaviv_gpu_driver = { > .driver = { > .name = "etnaviv-gpu", > .owner = THIS_MODULE, > - .pm = &etnaviv_gpu_pm_ops, > + .pm = pm_ptr(&etnaviv_gpu_pm_ops), > .of_match_table = etnaviv_gpu_match, > }, > .probe = etnaviv_gpu_platform_probe,