From patchwork Mon Apr 13 17:33:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= X-Patchwork-Id: 11486897 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6DB7B14B4 for ; Tue, 14 Apr 2020 07:07:01 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 4C34B206E9 for ; Tue, 14 Apr 2020 07:07:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N4jNigDm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C34B206E9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 84D606E471; Tue, 14 Apr 2020 07:06:49 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3A73889CF8 for ; Mon, 13 Apr 2020 17:33:47 +0000 (UTC) Received: by mail-wm1-x333.google.com with SMTP id z6so10799962wml.2 for ; Mon, 13 Apr 2020 10:33:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/+Q3sQHWHz/4UUWb+fTY+Lp+S0KWob6RkIjERN3PrL0=; b=N4jNigDmVKSbuGJIYErgx2wKkgof51DDTFYeJrbPeiBoXHbVSgm1rvyddooJwQ9/F7 dBKI4oGUrbpftuKwatusTGfwjFk9ZMDVM8mmcyvVGZZ+oknZ6o5isIBIXgMH/FwLyzIw UiMu0w0GxAf3NaFN6o4WKc+XH6Hwn3pYIc8SHDrinUGFbMtAOeX1FcynrjpjzZcLZxbV fSEl+EmvEwWkGHwBv13UwsrlXU53gllxB1D4d1cQpHLbppZOsu5MIVVdvUaQNXeRmthF 4kl7jdSgOss7MRRe5PJMbqi6UBW2A04Dm5wjyUambqsaaar2P3usG2vYH4Z/C6ktLgxo nWgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/+Q3sQHWHz/4UUWb+fTY+Lp+S0KWob6RkIjERN3PrL0=; b=HT0kKwjf7WzI5OqcslFMwU4+b/lxOU1U/lREByKGmsPw8l1xkDgWHDE832QNJZKfkC p0ysBQ5h0+D8Sw7cf8NH2Lusig0+K+gV0D0hvjQlzYApb/6LRa7V+UCTjlOiwMh9hBey DbHU+XjFfw6L85dTuGu+aubKKPX9RyPvij+q/GBizUqmLwvaDncHCVuPxedW4VocCaWy NggYD86DaQYKnVzsKdIlZjUSmfxguoz8bEsgz70lpZ/X48FRv2wJeGZXrsDp5o2tZeQC Co91x8GXaJFLtBeIvdUYP6PqK1xS30Go1Plu/xRiCCpHgim7ktvJTTySeVwuMkZaOWi3 z0wQ== X-Gm-Message-State: AGi0PublF9SH8CxovzkQcU/96Ze06DC6BrUp71nXXNKEqBqG6qu498NB fowyK8uwcEW1k4t4Etbws2c= X-Google-Smtp-Source: APiQypIzdPLyjmPzkX2e19Qkf1kNYWx+TJed6CleG8uZX09mZoberRJIHXFRzVApcauMNo3V2XOI0g== X-Received: by 2002:a1c:6:: with SMTP id 6mr11592040wma.12.1586799225707; Mon, 13 Apr 2020 10:33:45 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:1f1:d0f0::42f0:c285]) by smtp.gmail.com with ESMTPSA id v7sm17025219wmg.3.2020.04.13.10.33.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 10:33:44 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= To: Rob Herring , Tomeu Vizoso , Steven Price , Alyssa Rosenzweig , Viresh Kumar , Nishanth Menon , Stephen Boyd Subject: [PATCH v2 1/2] drm/panfrost: missing remove opp table in case of failure Date: Mon, 13 Apr 2020 19:33:37 +0200 Message-Id: <20200413173338.8294-1-peron.clem@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 14 Apr 2020 07:06:18 +0000 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: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In case of failure we need to remove OPP table. Use Linux classic error handling with goto usage. Reviewed-by: Steven Price Signed-off-by: Clément Péron --- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c index 413987038fbf..62541f4edd81 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c @@ -90,8 +90,11 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) cur_freq = clk_get_rate(pfdev->clock); opp = devfreq_recommended_opp(dev, &cur_freq, 0); - if (IS_ERR(opp)) - return PTR_ERR(opp); + if (IS_ERR(opp)) { + DRM_DEV_ERROR(dev, "Failed to set recommended OPP\n"); + ret = PTR_ERR(opp); + goto err_opp; + } panfrost_devfreq_profile.initial_freq = cur_freq; dev_pm_opp_put(opp); @@ -100,8 +103,8 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL); if (IS_ERR(devfreq)) { DRM_DEV_ERROR(dev, "Couldn't initialize GPU devfreq\n"); - dev_pm_opp_of_remove_table(dev); - return PTR_ERR(devfreq); + ret = PTR_ERR(devfreq); + goto err_opp; } pfdev->devfreq.devfreq = devfreq; @@ -112,6 +115,11 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) pfdev->devfreq.cooling = cooling; return 0; + +err_opp: + dev_pm_opp_of_remove_table(dev); + + return ret; } void panfrost_devfreq_fini(struct panfrost_device *pfdev) From patchwork Mon Apr 13 17:33:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= X-Patchwork-Id: 11486893 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7BB8A13B2 for ; Tue, 14 Apr 2020 07:06:55 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 5A7AA206E9 for ; Tue, 14 Apr 2020 07:06:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="joPKK1pt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5A7AA206E9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5DBED6E47A; Tue, 14 Apr 2020 07:06:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by gabe.freedesktop.org (Postfix) with ESMTPS id 45A6289CF8 for ; Mon, 13 Apr 2020 17:33:48 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id d77so10017048wmd.3 for ; Mon, 13 Apr 2020 10:33:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8aUMUy/wOX/7K0dS1U3BUrwSzoWMPHBW5fhBQA8MxGM=; b=joPKK1pt9Q1roRgAEHNzrtbiAO9UqKMcrjasUBKJbXFLK0l7M9MR8SUoEGycMZVJKI SUfGpJSvMsvbuer6EW9fqrR+A7GY/I27Yr11B+kbcPgNXAW9E7u/C+d6MTT65VycrIz+ oO4Iwdj5DoyWNBIWMEfnRE7u5asYx4o9fvK7rPy1wGSrAbctgmG14b14+LHjBBrS1/JM Wc1LN3roDxpiS9yIHx0e6eD86QcKwav7/wQS7FNUw3SdDcF1RpSl1EJ/4gE70PgoOdBN ah9yH7s35tO+J0JHouUz0/ahj9yZTAP6U39eVALf3/DyDBgyzHgKYyD+MrontQ+fjRCx TUmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8aUMUy/wOX/7K0dS1U3BUrwSzoWMPHBW5fhBQA8MxGM=; b=S0Q8puX/8A0QfW8bCVXOGOwzvq4viSxHPIR/6lxoy+RpkPUdQCsyhYpgmPdl4D9xJj 8YMsqxZCTEGeET0fFbBBNZ/Z6rKRSB9W6HCSBMS/5JbNchdV3nkqSJSfPJ+mqiVEmPTb mcqRS8RKTcaTzQKW7laHeOmIAx1Q8VUqpbob1cpOqGoF0FVCTF6M2sGx1OHh5GMJd9dK WO0kFy/Zaj+q11Lwn7Nbg+C1Y7rrEQKQ9c/oMqCPqL/Ptc+HdVch+wwUN4cIx8jHDxaR J0oOIk/omMfuyL5eivJCe4LmnG7ufLzPA3fMA9vV4JkEjvNAvpxfzCc8V+KiV/mVtm8b zCAw== X-Gm-Message-State: AGi0Pubb+nFG5ZJ+v0YE2v/OGg8ajPql8khh05skUXPgW66fQMRSG7Ms CdL1CsWQQcJTLmXWjctcaZgBj4BqX6Q= X-Google-Smtp-Source: APiQypLfNEB9bAOtFdIH8RmANnwshXM6x6H3qFZOwYXkmx+YDtINIiwe6Qu3boNCWaiCCL285aMJYA== X-Received: by 2002:a05:600c:214b:: with SMTP id v11mr20754687wml.151.1586799226743; Mon, 13 Apr 2020 10:33:46 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:1f1:d0f0::42f0:c285]) by smtp.gmail.com with ESMTPSA id v7sm17025219wmg.3.2020.04.13.10.33.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 10:33:46 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= To: Rob Herring , Tomeu Vizoso , Steven Price , Alyssa Rosenzweig , Viresh Kumar , Nishanth Menon , Stephen Boyd Subject: [PATCH v2 2/2] drm/panfrost: add devfreq regulator support Date: Mon, 13 Apr 2020 19:33:38 +0200 Message-Id: <20200413173338.8294-2-peron.clem@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200413173338.8294-1-peron.clem@gmail.com> References: <20200413173338.8294-1-peron.clem@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 14 Apr 2020 07:06:18 +0000 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: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" OPP table can defined both frequency and voltage. Register mali regulators to OPP driver. Signed-off-by: Clément Péron --- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 34 ++++++++++++++++++--- drivers/gpu/drm/panfrost/panfrost_device.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c index 62541f4edd81..54a109bbdc18 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c @@ -78,12 +78,26 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) struct device *dev = &pfdev->pdev->dev; struct devfreq *devfreq; struct thermal_cooling_device *cooling; + struct opp_table *opp_table; + + /* Regulator is optional */ + opp_table = dev_pm_opp_set_regulators(dev, pfdev->comp->supply_names, + pfdev->comp->num_supplies); + if (IS_ERR(opp_table)) { + ret = PTR_ERR(opp_table); + if (ret != -ENODEV) { + DRM_DEV_ERROR(dev, "Failed to set regulator: %d\n", ret); + return ret; + } + } + pfdev->devfreq.opp_table = opp_table; ret = dev_pm_opp_of_add_table(dev); - if (ret == -ENODEV) /* Optional, continue without devfreq */ - return 0; - else if (ret) - return ret; + if (ret) { + if (ret == -ENODEV) /* Optional, continue without devfreq */ + ret = 0; + goto err_opp_reg; + } panfrost_devfreq_reset(pfdev); @@ -119,6 +133,12 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) err_opp: dev_pm_opp_of_remove_table(dev); +err_opp_reg: + if (pfdev->devfreq.opp_table) { + dev_pm_opp_put_regulators(pfdev->devfreq.opp_table); + pfdev->devfreq.opp_table = NULL; + } + return ret; } @@ -126,7 +146,13 @@ void panfrost_devfreq_fini(struct panfrost_device *pfdev) { if (pfdev->devfreq.cooling) devfreq_cooling_unregister(pfdev->devfreq.cooling); + dev_pm_opp_of_remove_table(&pfdev->pdev->dev); + + if (pfdev->devfreq.opp_table) { + dev_pm_opp_put_regulators(pfdev->devfreq.opp_table); + pfdev->devfreq.opp_table = NULL; + } } void panfrost_devfreq_resume(struct panfrost_device *pfdev) diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h index c30c719a8059..c11d19430c0f 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.h +++ b/drivers/gpu/drm/panfrost/panfrost_device.h @@ -110,6 +110,7 @@ struct panfrost_device { struct { struct devfreq *devfreq; struct thermal_cooling_device *cooling; + struct opp_table *opp_table; ktime_t busy_time; ktime_t idle_time; ktime_t time_last_update;