Re: [PATCH v2] drm/radeon/dpm: simplifying low state adjustment's logic for NI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 26, 2013 at 1:13 AM, Alexandre Demers
<alexandre.f.demers@xxxxxxxxx> wrote:
> While working on a dpm bug (https://bugs.freedesktop.org/show_bug.cgi?id=69723), I stumbled upon a couple of lines in NI dpm where we were reading and setting back the same values for no obvious reason. Simplified the logic.
>

This patch creates some unused variable warnings.  While fixing them
up, I found the logic could be further cleaned up.  See attached.

Alex

> Signed-off-by: Alexandre Demers <alexandre.f.demers@xxxxxxxxx>
> ---
>  drivers/gpu/drm/radeon/ni_dpm.c | 17 ++++-------------
>  1 file changed, 4 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/ni_dpm.c b/drivers/gpu/drm/radeon/ni_dpm.c
> index f263390..2a10bbe 100644
> --- a/drivers/gpu/drm/radeon/ni_dpm.c
> +++ b/drivers/gpu/drm/radeon/ni_dpm.c
> @@ -841,21 +841,12 @@ static void ni_apply_state_adjust_rules(struct radeon_device *rdev,
>
>         if (disable_mclk_switching) {
>                 mclk  = ps->performance_levels[ps->performance_level_count - 1].mclk;
> -               sclk = ps->performance_levels[0].sclk;
> -               vddc = ps->performance_levels[0].vddc;
>                 vddci = ps->performance_levels[ps->performance_level_count - 1].vddci;
> -       } else {
> -               sclk = ps->performance_levels[0].sclk;
> -               mclk = ps->performance_levels[0].mclk;
> -               vddc = ps->performance_levels[0].vddc;
> -               vddci = ps->performance_levels[0].vddci;
> -       }
>
> -       /* adjusted low state */
> -       ps->performance_levels[0].sclk = sclk;
> -       ps->performance_levels[0].mclk = mclk;
> -       ps->performance_levels[0].vddc = vddc;
> -       ps->performance_levels[0].vddci = vddci;
> +               /* adjusted low state */
> +               ps->performance_levels[0].mclk = mclk;
> +               ps->performance_levels[0].vddci = vddci;
> +       }
>
>         btc_skip_blacklist_clocks(rdev, max_limits->sclk, max_limits->mclk,
>                                   &ps->performance_levels[0].sclk,
> --
> 1.8.4
>
From 4b72ca961a5d6e8ea657acfaeeb3e9a9557f059d Mon Sep 17 00:00:00 2001
From: Alex Deucher <alexander.deucher@xxxxxxx>
Date: Tue, 26 Nov 2013 10:16:31 -0500
Subject: [PATCH] drm/radeon/dpm: simply state adjust logic for NI

This is based on a similar patch from Alexandre Demers.
While fixing up some warnings with that patch I saw some
additional cleanups that could be applied.  This patch
simplifies the logic for patching the power state.

Signed-off-by: Alex Deucher <alexander.deucher@xxxxxxx>
Cc: Alexandre Demers <alexandre.f.demers@xxxxxxxxx>
---
 drivers/gpu/drm/radeon/ni_dpm.c | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/radeon/ni_dpm.c b/drivers/gpu/drm/radeon/ni_dpm.c
index cdc0030..49c4d48 100644
--- a/drivers/gpu/drm/radeon/ni_dpm.c
+++ b/drivers/gpu/drm/radeon/ni_dpm.c
@@ -785,8 +785,8 @@ static void ni_apply_state_adjust_rules(struct radeon_device *rdev,
 	struct ni_ps *ps = ni_get_ps(rps);
 	struct radeon_clock_and_voltage_limits *max_limits;
 	bool disable_mclk_switching;
-	u32 mclk, sclk;
-	u16 vddc, vddci;
+	u32 mclk;
+	u16 vddci;
 	u32 max_sclk_vddc, max_mclk_vddci, max_mclk_vddc;
 	int i;
 
@@ -839,24 +839,14 @@ static void ni_apply_state_adjust_rules(struct radeon_device *rdev,
 
 	/* XXX validate the min clocks required for display */
 
+	/* adjust low state */
 	if (disable_mclk_switching) {
-		mclk  = ps->performance_levels[ps->performance_level_count - 1].mclk;
-		sclk = ps->performance_levels[0].sclk;
-		vddc = ps->performance_levels[0].vddc;
-		vddci = ps->performance_levels[ps->performance_level_count - 1].vddci;
-	} else {
-		sclk = ps->performance_levels[0].sclk;
-		mclk = ps->performance_levels[0].mclk;
-		vddc = ps->performance_levels[0].vddc;
-		vddci = ps->performance_levels[0].vddci;
+		ps->performance_levels[0].mclk =
+			ps->performance_levels[ps->performance_level_count - 1].mclk;
+		ps->performance_levels[0].vddci =
+			ps->performance_levels[ps->performance_level_count - 1].vddci;
 	}
 
-	/* adjusted low state */
-	ps->performance_levels[0].sclk = sclk;
-	ps->performance_levels[0].mclk = mclk;
-	ps->performance_levels[0].vddc = vddc;
-	ps->performance_levels[0].vddci = vddci;
-
 	btc_skip_blacklist_clocks(rdev, max_limits->sclk, max_limits->mclk,
 				  &ps->performance_levels[0].sclk,
 				  &ps->performance_levels[0].mclk);
@@ -868,11 +858,15 @@ static void ni_apply_state_adjust_rules(struct radeon_device *rdev,
 			ps->performance_levels[i].vddc = ps->performance_levels[i - 1].vddc;
 	}
 
+	/* adjust remaining states */
 	if (disable_mclk_switching) {
 		mclk = ps->performance_levels[0].mclk;
+		vddci = ps->performance_levels[0].vddci;
 		for (i = 1; i < ps->performance_level_count; i++) {
 			if (mclk < ps->performance_levels[i].mclk)
 				mclk = ps->performance_levels[i].mclk;
+			if (vddci < ps->performance_levels[i].vddci)
+				vddci = ps->performance_levels[i].vddci;
 		}
 		for (i = 0; i < ps->performance_level_count; i++) {
 			ps->performance_levels[i].mclk = mclk;
-- 
1.8.3.1

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel

[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux