Skip to contentSkip to conversation

drm/nv50/pm: signedness bug in nv50_pm_clocks_pre()

PATCH In review Dan Carpenter 2 participants 4 messages Jan 4, 2012 – Jan 10, 2012

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/nv50/pm: signedness bug in nv50_pm_clocks_pre()

calc_mclk() returns zero on success and negative on failure but clk is a u32.

drivers/gpu/drm/nouveau/nv50_pm.c +1 -1
index 0393721..3508de9 100644
@@ -540,7 +540,7 @@ nv50_pm_clocks_pre(struct drm_device *dev, struct nouveau_pm_level *perflvl)
 	info->mclk_hwsq.len = 0;
 	if (perflvl->memory) {
 		clk = calc_mclk(dev, perflvl->memory, &info->mclk_hwsq);
-		if (clk < 0) {
+		if ((int)clk < 0) {
 			ret = clk;
 			goto error;
 		}
#1 lore raw
Quoted 10 lines · Dan Carpenter

calc_mclk() returns zero on success and negative on failure but clk is a u32.

drivers/gpu/drm/nouveau/nv50_pm.c +0 -0
index 0393721..3508de9 100644

drivers/gpu/drm/nouveau/nv50_pm.c nv50_pm_clocks_pre(struct drm_device *dev, struct nouveau_pm_level *perflvl) · line 546

Quoted 8 lines
drivers/gpu/drm/nouveau/nv50_pm.c +1 -1
@@ -540,7 +540,7 @@ nv50_pm_clocks_pre(struct drm_device *dev, struct nouveau_pm_level *perflvl)
  	info->mclk_hwsq.len = 0;
  	if (perflvl->memory) {
  		clk = calc_mclk(dev, perflvl->memory,&info->mclk_hwsq);
-		if (clk<  0) {
+		if ((int)clk<  0) {
  			ret = clk;
  			goto error;
  		}

Well spotted Dan!

Sorry for the late answer, was busy reworking this file for safe reclocking.

I have a slightly different fix for that. Please tell me if It suits you:
https://gitorious.org/linux-nouveau-pm/linux-nouveau-pm/commit/c1b80360ezd1aa7dd780ac383aae9437c66ef3b89
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 21 lines · Martin Peres
Quoted 10 lines · Dan Carpenter

calc_mclk() returns zero on success and negative on failure but clk is a u32.

drivers/gpu/drm/nouveau/nv50_pm.c +0 -0
index 0393721..3508de9 100644

drivers/gpu/drm/nouveau/nv50_pm.c nv50_pm_clocks_pre(struct drm_device *dev, struct nouveau_pm_level *perflvl) · line 546

Quoted 8 lines
drivers/gpu/drm/nouveau/nv50_pm.c +1 -1
@@ -540,7 +540,7 @@ nv50_pm_clocks_pre(struct drm_device *dev, struct nouveau_pm_level *perflvl)
 	info->mclk_hwsq.len = 0;
 	if (perflvl->memory) {
 		clk = calc_mclk(dev, perflvl->memory,&info->mclk_hwsq);
-		if (clk<  0) {
+		if ((int)clk<  0) {
 			ret = clk;
 			goto error;
 		}

Well spotted Dan!

Quoted 4 lines

Sorry for the late answer, was busy reworking this file for safe reclocking.

I have a slightly different fix for that. Please tell me if It suits
you: https://gitorious.org/linux-nouveau-pm/linux-nouveau-pm/commit/c1b80360ezd1aa7dd780ac383aae9437c66ef3b89

That link redirects to
https://gitorious.org/linux-nouveau-pm/linux-nouveau-pm/commits/master
and it doesn't show the patch.

But I wasn't a huge fan of adding the cast very much either so I'm sure your patch is good.

regards,
dan carpenter

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
Quoted 30 lines · Dan Carpenter
Quoted 21 lines · Martin Peres
Quoted 10 lines · Dan Carpenter

calc_mclk() returns zero on success and negative on failure but clk is a u32.

drivers/gpu/drm/nouveau/nv50_pm.c +0 -0
index 0393721..3508de9 100644

drivers/gpu/drm/nouveau/nv50_pm.c nv50_pm_clocks_pre(struct drm_device *dev, struct nouveau_pm_level *perflvl) · line 546

Quoted 8 lines
drivers/gpu/drm/nouveau/nv50_pm.c +1 -1
@@ -540,7 +540,7 @@ nv50_pm_clocks_pre(struct drm_device *dev, struct nouveau_pm_level *perflvl)
  	info->mclk_hwsq.len = 0;
  	if (perflvl->memory) {
  		clk = calc_mclk(dev, perflvl->memory,&info->mclk_hwsq);
-		if (clk<   0) {
+		if ((int)clk<   0) {
  			ret = clk;
  			goto error;
  		}

Well spotted Dan!

Quoted 4 lines

Sorry for the late answer, was busy reworking this file for safe reclocking.

I have a slightly different fix for that. Please tell me if It suits
you: https://gitorious.org/linux-nouveau-pm/linux-nouveau-pm/commit/c1b80360ezd1aa7dd780ac383aae9437c66ef3b89

That link redirects to
https://gitorious.org/linux-nouveau-pm/linux-nouveau-pm/commits/master
and it doesn't show the patch.

Quoted 5 lines

But I wasn't a huge fan of adding the cast very much either so I'm sure your patch is good.

regards,
dan carpenter

Sorry, here is the patch attached.

From c1b80360ed1aa7dd780ac383aae9437c66ef3b89 Mon Sep 17 00:00:00 2001
From: Dan Carpenter <[email protected]>
Date: Wed, 4 Jan 2012 10:20:47 +0300
Subject: [PATCH 5/7] drm/nv50/pm: signedness bug in nv50_pm_clocks_pre()

calc_mclk() returns zero on success and negative on failure but clk is a u32.

v2: Martin Peres:
- clk should be an int, not a u32

---
 drivers/gpu/drm/nouveau/nv50_pm.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nv50_pm.c +2 -2
index 983b432..4be2e20 100644
@@ -659,11 +659,11 @@ nv50_pm_clocks_pre(struct drm_device *dev, struct nouveau_pm_level *perflvl)
 	struct nv50_pm_state *info;
 	struct hwsq_ucode *hwsq;
 	struct pll_lims pll;
-	int ret = -EINVAL;
+	int clk, ret = -EINVAL;
 	int N, M, P1, P2;
 	u32 mast = nv_rd32(dev, 0x00c040);
 	u32 divs = read_div(dev);
-	u32 ctrl, clk, out;
+	u32 ctrl, out;
 
 	if (dev_priv->chipset == 0xaa ||
 	    dev_priv->chipset == 0xac)
Signature · 1 line
1.7.8.1