From b93e6c3026f4189918b6a4d82a66100263ee8349 Mon Sep 17 00:00:00 2001 From: Jernej Skrabec Date: Sun, 12 Apr 2020 12:47:45 +0200 Subject: [PATCH] Allwinner: H6: Fix panfrost devfreq voltage adjustments --- .../17-Add-GPU-operating-points-for-H6.patch | 236 ++++++++++++++++-- 1 file changed, 214 insertions(+), 22 deletions(-) diff --git a/projects/Allwinner/devices/H6/patches/linux/17-Add-GPU-operating-points-for-H6.patch b/projects/Allwinner/devices/H6/patches/linux/17-Add-GPU-operating-points-for-H6.patch index 5dbe3bf060..7e7c8a3549 100644 --- a/projects/Allwinner/devices/H6/patches/linux/17-Add-GPU-operating-points-for-H6.patch +++ b/projects/Allwinner/devices/H6/patches/linux/17-Add-GPU-operating-points-for-H6.patch @@ -1,23 +1,23 @@ -From patchwork Wed May 29 15:32:55 2019 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 8bit -Subject: arm64: dts: allwinner: Add GPU operating points for H6 -X-Patchwork-Submitter: Tomeu Vizoso -X-Patchwork-Id: 165375 -Message-Id: <20190529153255.40038-1-tomeu.vizoso@collabora.com> -To: linux-kernel@vger.kernel.org -Cc: Tomeu Vizoso , =?utf-8?b?Q2zDqW1lbnQgUMOp?= - =?utf-8?q?ron?= , - Maxime Ripard , Chen-Yu Tsai , - Rob Herring , Mark Rutland , - linux-arm-kernel@lists.infradead.org (moderated list:ARM/Allwinner - sunXi SoC support), devicetree@vger.kernel.org (open list:OPEN - FIRMWARE AND FLATTENED DEVICE TREE BINDINGS) -Date: Wed, 29 May 2019 17:32:55 +0200 -From: Tomeu Vizoso -List-Id: - +From patchwork Wed May 29 15:32:55 2019 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Subject: arm64: dts: allwinner: Add GPU operating points for H6 +X-Patchwork-Submitter: Tomeu Vizoso +X-Patchwork-Id: 165375 +Message-Id: <20190529153255.40038-1-tomeu.vizoso@collabora.com> +To: linux-kernel@vger.kernel.org +Cc: Tomeu Vizoso , =?utf-8?b?Q2zDqW1lbnQgUMOp?= + =?utf-8?q?ron?= , + Maxime Ripard , Chen-Yu Tsai , + Rob Herring , Mark Rutland , + linux-arm-kernel@lists.infradead.org (moderated list:ARM/Allwinner + sunXi SoC support), devicetree@vger.kernel.org (open list:OPEN + FIRMWARE AND FLATTENED DEVICE TREE BINDINGS) +Date: Wed, 29 May 2019 17:32:55 +0200 +From: Tomeu Vizoso +List-Id: + The GPU driver needs them to change the clock frequency and regulator voltage depending on the load. @@ -37,8 +37,8 @@ Tomeu 1 file changed, 66 insertions(+) -- -2.20.1 - +2.20.1 + diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi index 6aad06095c40..decf7b56e2df 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi @@ -123,3 +123,195 @@ index 6aad06095c40..decf7b56e2df 100644 status = "disabled"; }; +From: =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= +To: Rob Herring , + Tomeu Vizoso , + Steven Price , + Alyssa Rosenzweig , + Viresh Kumar , Nishanth Menon , + Stephen Boyd +Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, + =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= +Subject: [PATCH 1/2] drm/panfrost: missing remove opp table in case of failure +Date: Sat, 11 Apr 2020 22:06:31 +0200 +Message-Id: <20200411200632.4045-1-peron.clem@gmail.com> +X-Mailer: git-send-email 2.20.1 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Sender: linux-kernel-owner@vger.kernel.org +Precedence: bulk +List-ID: +X-Mailing-List: linux-kernel@vger.kernel.org +Archived-At: +List-Archive: +List-Post: + +In case of failure we need to remove OPP table. + +Use Linux classic error handling with goto usage. + +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) +-- +2.20.1 + + +From: =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= +To: Rob Herring , + Tomeu Vizoso , + Steven Price , + Alyssa Rosenzweig , + Viresh Kumar , Nishanth Menon , + Stephen Boyd +Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, + =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= +Subject: [PATCH 2/2] drm/panfrost: add devfreq regulator support +Date: Sat, 11 Apr 2020 22:06:32 +0200 +Message-Id: <20200411200632.4045-2-peron.clem@gmail.com> +X-Mailer: git-send-email 2.20.1 +In-Reply-To: <20200411200632.4045-1-peron.clem@gmail.com> +References: <20200411200632.4045-1-peron.clem@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +Sender: linux-kernel-owner@vger.kernel.org +Precedence: bulk +List-ID: +X-Mailing-List: linux-kernel@vger.kernel.org +Archived-At: +List-Archive: +List-Post: + +OPP table can defined both frequency and voltage. + +Register the mali regulator if it exist. + +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..2dc8e2355358 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; ++ const char *mali = "mali"; ++ struct opp_table *opp_table = NULL; ++ ++ /* Regulator is optional */ ++ opp_table = dev_pm_opp_set_regulators(dev, &mali, 1); ++ 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 06713811b92c..f6b0c779dfe5 100644 +--- a/drivers/gpu/drm/panfrost/panfrost_device.h ++++ b/drivers/gpu/drm/panfrost/panfrost_device.h +@@ -86,6 +86,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; +-- +2.20.1 + +