From patchwork Mon May 13 17:55:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 10941439 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 23851924 for ; Mon, 13 May 2019 17:56:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EC2B277D9 for ; Mon, 13 May 2019 17:56:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02B08283C3; Mon, 13 May 2019 17:56:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 885AF277D9 for ; Mon, 13 May 2019 17:56:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0E6CD6E7C2; Mon, 13 May 2019 17:56:12 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1EC3A6E7C2 for ; Mon, 13 May 2019 17:56:10 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id A3468283B06 From: Ezequiel Garcia To: Rob Herring , Tomeu Vizoso , David Airlie , Daniel Vetter Subject: [PATCH] drm/panfrost: Make devfreq truly optional Date: Mon, 13 May 2019 14:55:54 -0300 Message-Id: <20190513175554.31804-1-ezequiel@collabora.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel@collabora.com, Ezequiel Garcia , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently, there is some logic to make devfreq optional, but it fails to cover some cases such as !CONFIG_PM_DEVFREQ. Moreover, depending on return codes is not resilient to change, so let's take a different approach, introducing proper stubs and only conditionally compiling the devfreq support. Signed-off-by: Ezequiel Garcia --- drivers/gpu/drm/panfrost/Makefile | 3 ++- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 13 ++----------- drivers/gpu/drm/panfrost/panfrost_devfreq.h | 19 +++++++++++++++++-- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/panfrost/Makefile b/drivers/gpu/drm/panfrost/Makefile index 6de72d13c58f..8b690672f9d9 100644 --- a/drivers/gpu/drm/panfrost/Makefile +++ b/drivers/gpu/drm/panfrost/Makefile @@ -3,10 +3,11 @@ panfrost-y := \ panfrost_drv.o \ panfrost_device.o \ - panfrost_devfreq.o \ panfrost_gem.o \ panfrost_gpu.o \ panfrost_job.o \ panfrost_mmu.o +panfrost-$(CONFIG_PM_DEVFREQ) += panfrost_devfreq.o + obj-$(CONFIG_DRM_PANFROST) += panfrost.o diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c index 238bd1d89d43..29fcffdf2d57 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c @@ -140,8 +140,8 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) return 0; ret = dev_pm_opp_of_add_table(&pfdev->pdev->dev); - if (ret == -ENODEV) /* Optional, continue without devfreq */ - return 0; + if (ret) + return ret; panfrost_devfreq_reset(pfdev); @@ -170,9 +170,6 @@ void panfrost_devfreq_resume(struct panfrost_device *pfdev) { int i; - if (!pfdev->devfreq.devfreq) - return; - panfrost_devfreq_reset(pfdev); for (i = 0; i < NUM_JOB_SLOTS; i++) pfdev->devfreq.slot[i].busy = false; @@ -182,9 +179,6 @@ void panfrost_devfreq_resume(struct panfrost_device *pfdev) void panfrost_devfreq_suspend(struct panfrost_device *pfdev) { - if (!pfdev->devfreq.devfreq) - return; - devfreq_suspend_device(pfdev->devfreq.devfreq); } @@ -194,9 +188,6 @@ static void panfrost_devfreq_update_utilization(struct panfrost_device *pfdev, i ktime_t now; ktime_t last; - if (!pfdev->devfreq.devfreq) - return; - now = ktime_get(); last = pfdev->devfreq.slot[slot].time_last_update; diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.h b/drivers/gpu/drm/panfrost/panfrost_devfreq.h index eb999531ed90..76b56a8de6e3 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.h +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.h @@ -4,11 +4,26 @@ #ifndef __PANFROST_DEVFREQ_H__ #define __PANFROST_DEVFREQ_H__ +#if defined(CONFIG_PM_DEVFREQ) int panfrost_devfreq_init(struct panfrost_device *pfdev); - void panfrost_devfreq_resume(struct panfrost_device *pfdev); void panfrost_devfreq_suspend(struct panfrost_device *pfdev); - void panfrost_devfreq_record_transition(struct panfrost_device *pfdev, int slot); +#else +static inline int panfrost_devfreq_init(struct panfrost_device *pfdev) +{ + return 0; +} + +static inline void panfrost_devfreq_resume(struct panfrost_device *pfdev) +{} + +static inline void panfrost_devfreq_suspend(struct panfrost_device *pfdev) +{} + +static inline void +panfrost_devfreq_record_transition(struct panfrost_device *pfdev, int slot) +{} +#endif #endif /* __PANFROST_DEVFREQ_H__ */