[RFC,28/29] clk: move the switch out of the loop in nvkm_cstate_valid

Submitted by Karol Herbst on Sept. 15, 2017, 5:11 p.m.

Details

Message ID 20170915171129.5009-29-karolherbst@gmail.com
State New
Headers show
Series "Current State of my clk patches" ( rev: 1 ) in Nouveau

Not browsing as part of any series.

Commit Message

Karol Herbst Sept. 15, 2017, 5:11 p.m.
Signed-off-by: Karol Herbst <karolherbst@gmail.com>
---
 drm/nouveau/nvkm/subdev/clk/base.c | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drm/nouveau/nvkm/subdev/clk/base.c b/drm/nouveau/nvkm/subdev/clk/base.c
index 2a51c078..994d32b9 100644
--- a/drm/nouveau/nvkm/subdev/clk/base.c
+++ b/drm/nouveau/nvkm/subdev/clk/base.c
@@ -83,28 +83,30 @@  nvkm_cstate_valid(struct nvkm_clk *clk, struct nvkm_cstate *cstate,
 	const struct nvkm_domain *domain = clk->domains;
 	struct nvkm_volt *volt = clk->subdev.device->volt;
 	int voltage;
+	u32 limit;
 
-	while (domain && domain->name != nv_clk_src_max) {
-		if (domain->flags & NVKM_CLK_DOM_FLAG_VPSTATE) {
-			u32 freq = cstate->domain[domain->name];
-			u32 limit;
-			switch (clk->boost_mode) {
-			case NVKM_CLK_BOOST_NONE:
-				limit = clk->base_limit.max_khz;
-				if (limit)
-					break;
-			case NVKM_CLK_BOOST_BIOS:
-				limit = clk->boost_limit.max_khz;
-				break;
-			default:
-				limit = 0;
-				break;
-			}
+	switch (clk->boost_mode) {
+	case NVKM_CLK_BOOST_NONE:
+		limit = clk->base_limit.max_khz;
+		if (limit)
+			break;
+	case NVKM_CLK_BOOST_BIOS:
+		limit = clk->boost_limit.max_khz;
+		break;
+	default:
+		limit = 0;
+		break;
+	}
 
+	if (limit) {
+		for (; domain && domain->name != nv_clk_src_max; domain++) {
+			u32 freq;
+			if (!(domain->flags & NVKM_CLK_DOM_FLAG_VPSTATE))
+				continue;
+			freq = cstate->domain[domain->name];
 			if (limit && freq > limit)
 				return false;
 		}
-		domain++;
 	}
 
 	if (!volt)