Skip to contentSkip to conversation

drm/nouveau/bios: fix a bit shift error introduced by 457e77b

PATCH In review Sergei Antonov 2 participants 4 messages Apr 15, 2014 – Apr 20, 2014 3 messages not in the archive

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

PATCH 1/1 drm/nouveau/bios: fix a bit shift error introduced by 457e77b

Commit 457e77b26428ab4a24998eecfb99f27fa4195397 added two checks applied to a value received from nv_rd32(bios, 0x619f04). But after this new piece of code is executed, the addr local variable does not hold the same value it used to hold before the commit. Here is what is was assigned in the original code:

	(u64)(nv_rd32(bios, 0x619f04) & 0xffffff00) << 8
in the committed code it ends up with this value:
	(u64)(nv_rd32(bios, 0x619f04) >> 8) << 8

These expressions are obviously not equivalent.

My Nvidia video card does not show anything on the display when I boot a kernel containing this commit.

The patch fixes the code so that the new checks are still done, but the side effect of an incorrect addr value is gone.

Cc Ben Skeggs <[email protected]>
Cc Dave Airlie <[email protected]>
Cc Andrew Morton <akpm-de/[email protected]>
---
 drivers/gpu/drm/nouveau/core/subdev/bios/base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/core/subdev/bios/base.c +1 -1
index e9df94f..291adb6 100644
@@ -109,7 +109,7 @@ nouveau_bios_shadow_pramin(struct nouveau_bios *bios)
 			return;
 		}
 
-		addr = (u64)(addr >> 8) << 8;
+		addr = (u64)(addr & 0xffffff00) << 8;
 		if (!addr) {
 			addr  = (u64)nv_rd32(bios, 0x001700) << 16;
 			addr += 0xf0000;
Signature · 1 line
1.9.0

A message that is not in the archive (sent off-list or not yet received): 1397596717-6862-1-git-send-email-saproj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw
Quoted 28 lines · Sergei Antonov

Commit 457e77b26428ab4a24998eecfb99f27fa4195397 added two checks applied to a value received from nv_rd32(bios, 0x619f04). But after this new piece of code is executed, the addr local variable does not hold the same value it used to hold before the commit. Here is what is was assigned in the original code:

        (u64)(nv_rd32(bios, 0x619f04) & 0xffffff00) << 8
in the committed code it ends up with this value:
        (u64)(nv_rd32(bios, 0x619f04) >> 8) << 8

These expressions are obviously not equivalent.

My Nvidia video card does not show anything on the display when I boot a kernel containing this commit.

The patch fixes the code so that the new checks are still done, but the side effect of an incorrect addr value is gone.

Cc Ben Skeggs <[email protected]>
Cc Dave Airlie <[email protected]>
Cc Andrew Morton <akpm-de/[email protected]>
---
 drivers/gpu/drm/nouveau/core/subdev/bios/base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/core/subdev/bios/base.c +0 -0
index e9df94f..291adb6 100644

drivers/gpu/drm/nouveau/core/subdev/bios/base.c nouveau_bios_shadow_pramin(struct nouveau_bios *bios) · line 112

Quoted 5 lines
drivers/gpu/drm/nouveau/core/subdev/bios/base.c +1 -1
@@ -109,7 +109,7 @@ nouveau_bios_shadow_pramin(struct nouveau_bios *bios)
                        return;
                }
 
-               addr = (u64)(addr >> 8) << 8;
+               addr = (u64)(addr & 0xffffff00) << 8;

I just noticed that "(u64)" is redundant here. Can it be removed in the patch without resubmitting, Andrew?

Quoted 6 lines
drivers/gpu/drm/nouveau/core/subdev/bios/base.c +0 -1
                if (!addr) {
                        addr  = (u64)nv_rd32(bios, 0x001700) << 16;
                        addr += 0xf0000;
--

1.9.0

A message that is not in the archive (sent off-list or not yet received): CABikg9yL9y49ws5yJq9R0LV7++ysgPD0wwAeoNd3g8Tm34ysHg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#4 lore raw
Quoted 10 lines · Sergei Antonov
Quoted 9 lines · Sergei Antonov

Commit 457e77b26428ab4a24998eecfb99f27fa4195397 added two checks applied to a value received from nv_rd32(bios, 0x619f04). But after this new piece of code is executed, the addr local variable does not hold the same value it used to hold before the commit. Here is what is was assigned in the original code:

        (u64)(nv_rd32(bios, 0x619f04) & 0xffffff00) << 8
in the committed code it ends up with this value:
        (u64)(nv_rd32(bios, 0x619f04) >> 8) << 8

These expressions are obviously not equivalent.

Quoted 6 lines
Quoted 6 lines

My Nvidia video card does not show anything on the display when I boot a kernel containing this commit.

The patch fixes the code so that the new checks are still done, but the side effect of an incorrect addr value is gone.

Hi Sergei

A similar patch [1] has been sent a few days prior to yours, and I'm assuming it will be queued/merged shortly. Just letting you know.

Cheers
-Emil

[1] http://lists.freedesktop.org/archives/dri-devel/2014-April/057318.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 19 lines · Emil Velikov
Quoted 10 lines · Sergei Antonov
Quoted 9 lines · Sergei Antonov

Commit 457e77b26428ab4a24998eecfb99f27fa4195397 added two checks applied to a value received from nv_rd32(bios, 0x619f04). But after this new piece of code is executed, the addr local variable does not hold the same value it used to hold before the commit. Here is what is was assigned in the original code:

        (u64)(nv_rd32(bios, 0x619f04) & 0xffffff00) << 8
in the committed code it ends up with this value:
        (u64)(nv_rd32(bios, 0x619f04) >> 8) << 8

These expressions are obviously not equivalent.

Quoted 6 lines
Quoted 6 lines

My Nvidia video card does not show anything on the display when I boot a kernel containing this commit.

The patch fixes the code so that the new checks are still done, but the side effect of an incorrect addr value is gone.

Hi Sergei

Quoted 7 lines

A similar patch [1] has been sent a few days prior to yours, and I'm assuming it will be queued/merged shortly. Just letting you know.

Cheers
-Emil

[1] http://lists.freedesktop.org/archives/dri-devel/2014-April/057318.html

Thanks! I didn't know about this patch. Sorry for accidentally creating a race condition.
My patch has been merged today (included in "drm fixes" from Dave Airlie).