Skip to contentSkip to conversation

ttm: Fix a potential comparison of structs.

PATCH New Thomas Hellstrom 2 participants 4 messages Jul 31, 2009 – Aug 2, 2009

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

PATCH 1/1 ttm: Fix a potential comparison of structs.

On some architectures the comparison may cause a compilation failure.

---
 drivers/gpu/drm/ttm/ttm_bo_util.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_util.c +2 -2
index ce2e6f3..ee9a281 100644
@@ -150,7 +150,7 @@ static int ttm_copy_io_ttm_page(struct ttm_tt *ttm, void *src,
 #ifdef CONFIG_X86
 	dst = kmap_atomic_prot(d, KM_USER0, prot);
 #else
-	if (prot != PAGE_KERNEL)
+	if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL))
 		dst = vmap(&d, 1, 0, prot);
 	else
 		dst = kmap(d);
@@ -163,7 +163,7 @@ static int ttm_copy_io_ttm_page(struct ttm_tt *ttm, void *src,
 #ifdef CONFIG_X86
 	kunmap_atomic(dst, KM_USER0);
 #else
-	if (prot != PAGE_KERNEL)
+	if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL))
 		vunmap(dst);
 	else
 		kunmap(d);
Signature · 1 line
1.6.1.3
#1 lore raw

PATCH 1/1 ttm: Fix a potential comparison of structs.

Quoted 1 line

From 5e2851952729b287a82efa002b28a2095404d44d Mon Sep 17 00:00:00 2001

From: Thomas Hellstrom <[email protected]>
Date: Fri, 31 Jul 2009 10:47:51 +0200
Subject: [PATCH] ttm: Fix a potential comparison of structs.

On some architectures the comparison may cause a compilation failure.

Original partial fix Signed-off-by: Thomas Hellstrom <[email protected]>

---

Thomas, you forgot two more of these :-) Here's a patch that actually compiles on x86_64.

 drivers/gpu/drm/ttm/ttm_bo_util.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_util.c +4 -4
index f4e2eba..999fbe7 100644
@@ -151,7 +151,7 @@ static int ttm_copy_io_ttm_page(struct ttm_tt *ttm, void *src,
 #ifdef CONFIG_X86
 	dst = kmap_atomic_prot(d, KM_USER0, prot);
 #else
-	if (prot != PAGE_KERNEL)
+	if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL))
 		dst = vmap(&d, 1, 0, prot);
 	else
 		dst = kmap(d);
@@ -164,7 +164,7 @@ static int ttm_copy_io_ttm_page(struct ttm_tt *ttm, void *src,
 #ifdef CONFIG_X86
 	kunmap_atomic(dst, KM_USER0);
 #else
-	if (prot != PAGE_KERNEL)
+	if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL))
 		vunmap(dst);
 	else
 		kunmap(d);
@@ -187,7 +187,7 @@ static int ttm_copy_ttm_io_page(struct ttm_tt *ttm, void *dst,
 #ifdef CONFIG_X86
 	src = kmap_atomic_prot(s, KM_USER0, prot);
 #else
-	if (prot != PAGE_KERNEL)
+	if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL))
 		src = vmap(&s, 1, 0, prot);
 	else
 		src = kmap(s);
@@ -200,7 +200,7 @@ static int ttm_copy_ttm_io_page(struct ttm_tt *ttm, void *dst,
 #ifdef CONFIG_X86
 	kunmap_atomic(src, KM_USER0);
 #else
-	if (prot != PAGE_KERNEL)
+	if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL))
 		vunmap(src);
 	else
 		kunmap(s);
Signature · 1 line
1.6.3.3
#2 lore raw

Pekka Paalanen skrev:

Quoted 7 lines

From 5e2851952729b287a82efa002b28a2095404d44d Mon Sep 17 00:00:00 2001
From: Thomas Hellstrom <[email protected]>
Date: Fri, 31 Jul 2009 10:47:51 +0200
Subject: [PATCH] ttm: Fix a potential comparison of structs.

On some architectures the comparison may cause a compilation failure.

Quoted 8 lines

Original partial fix Signed-off-by: Thomas Hellstrom <[email protected]>

---

Thomas, you forgot two more of these :-)
Here's a patch that actually compiles on x86_64.

Pekka,
Thanks for fixing this! (Just for clarity, i assume you mean that the non-x86 part now compiles on x86?)

Dave, is there a chance to have this in 2.6.31? Compilation errors are bad, although probably nobody has been hitting this yet..

/Thomas

Quoted 44 lines
 drivers/gpu/drm/ttm/ttm_bo_util.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_util.c +4 -4
index f4e2eba..999fbe7 100644
@@ -151,7 +151,7 @@ static int ttm_copy_io_ttm_page(struct ttm_tt *ttm, void *src,
 #ifdef CONFIG_X86
 	dst = kmap_atomic_prot(d, KM_USER0, prot);
 #else
-	if (prot != PAGE_KERNEL)
+	if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL))
 		dst = vmap(&d, 1, 0, prot);
 	else
 		dst = kmap(d);
@@ -164,7 +164,7 @@ static int ttm_copy_io_ttm_page(struct ttm_tt *ttm, void *src,
 #ifdef CONFIG_X86
 	kunmap_atomic(dst, KM_USER0);
 #else
-	if (prot != PAGE_KERNEL)
+	if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL))
 		vunmap(dst);
 	else
 		kunmap(d);
@@ -187,7 +187,7 @@ static int ttm_copy_ttm_io_page(struct ttm_tt *ttm, void *dst,
 #ifdef CONFIG_X86
 	src = kmap_atomic_prot(s, KM_USER0, prot);
 #else
-	if (prot != PAGE_KERNEL)
+	if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL))
 		src = vmap(&s, 1, 0, prot);
 	else
 		src = kmap(s);
@@ -200,7 +200,7 @@ static int ttm_copy_ttm_io_page(struct ttm_tt *ttm, void *dst,
 #ifdef CONFIG_X86
 	kunmap_atomic(src, KM_USER0);
 #else
-	if (prot != PAGE_KERNEL)
+	if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL))
 		vunmap(src);
 	else
 		kunmap(s);
#3 lore raw
Quoted 13 lines · On Sun, 02 Aug 2009 20:12:18 +0200 Thomas Hellström <[email protected]>…

Pekka Paalanen skrev:

Quoted 12 lines

From 5e2851952729b287a82efa002b28a2095404d44d Mon Sep 17 00:00:00 2001
From: Thomas Hellstrom <[email protected]>
Date: Fri, 31 Jul 2009 10:47:51 +0200
Subject: [PATCH] ttm: Fix a potential comparison of structs.

On some architectures the comparison may cause a compilation failure.

Original partial fix Signed-off-by: Thomas Hellstrom <[email protected]>

---

Quoted 7 lines
Quoted 3 lines

Thomas, you forgot two more of these :-)
Here's a patch that actually compiles on x86_64.

Pekka,
Thanks for fixing this! (Just for clarity, i assume you mean that the non-x86 part now compiles on x86?)

Ah yes, that's what I mean. I changed the #ifdefs for my compat fix in
http://cgit.freedesktop.org/nouveau/linux-2.6/log/?h=master-compat
and tried compiling it the both ways.

Quoted 2 lines

Dave, is there a chance to have this in 2.6.31? Compilation errors are bad, although probably nobody has been hitting this yet..

Well, Nouveau master-compat users would have hit it, but I added your fix, too. Users with x86_32 highmem kernels already hit the kmap_atomic_prot not exported bug while building the latest DRM, TTM and Nouveau bits against distro kernels.

So yeah, no-one anyone (else) would care about ;-)

Thanks.

Quoted 46 lines

/Thomas

Quoted 43 lines
 drivers/gpu/drm/ttm/ttm_bo_util.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_util.c +4 -4
index f4e2eba..999fbe7 100644
@@ -151,7 +151,7 @@ static int ttm_copy_io_ttm_page(struct ttm_tt *ttm, void *src,
 #ifdef CONFIG_X86
 	dst = kmap_atomic_prot(d, KM_USER0, prot);
 #else
-	if (prot != PAGE_KERNEL)
+	if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL))
 		dst = vmap(&d, 1, 0, prot);
 	else
 		dst = kmap(d);
@@ -164,7 +164,7 @@ static int ttm_copy_io_ttm_page(struct ttm_tt *ttm, void *src,
 #ifdef CONFIG_X86
 	kunmap_atomic(dst, KM_USER0);
 #else
-	if (prot != PAGE_KERNEL)
+	if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL))
 		vunmap(dst);
 	else
 		kunmap(d);
@@ -187,7 +187,7 @@ static int ttm_copy_ttm_io_page(struct ttm_tt *ttm, void *dst,
 #ifdef CONFIG_X86
 	src = kmap_atomic_prot(s, KM_USER0, prot);
 #else
-	if (prot != PAGE_KERNEL)
+	if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL))
 		src = vmap(&s, 1, 0, prot);
 	else
 		src = kmap(s);
@@ -200,7 +200,7 @@ static int ttm_copy_ttm_io_page(struct ttm_tt *ttm, void *dst,
 #ifdef CONFIG_X86
 	kunmap_atomic(src, KM_USER0);
 #else
-	if (prot != PAGE_KERNEL)
+	if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL))
 		vunmap(src);
 	else
 		kunmap(s);
Signature · 2 lines
Pekka Paalanen
http://www.iki.fi/pq/