Skip to contentSkip to conversation

drm/vmwgfx: Avoid compiler warning

PATCH In review Thierry Reding 2 participants 2 messages Jun 3, 2016

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

PATCH 1/1 drm/vmwgfx: Avoid compiler warning

From: Thierry Reding <[email protected]>

While the current code is correct and the compiler's DCE pass should remove either of the branches depending on the width of DMA addresses, the compiler still has to compile the code first.

On configurations with 32-bit DMA addresses, right-shifting the address by 32 causes GCC to output a build warning. Work around this by using a preprocessor conditional instead.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c +5 -5
index 67cebb23c940..577faca0fe9d 100644
@@ -291,12 +291,12 @@ void vmw_cmdbuf_header_free(struct vmw_cmdbuf_header *header)
 static int vmw_cmdbuf_header_submit(struct vmw_cmdbuf_header *header)
 {
 	struct vmw_cmdbuf_man *man = header->man;
-	u32 val;
+#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
+	u32 val = header->handle >> 32;
+#else
+	u32 val = 0;
+#endif
 
-	if (sizeof(header->handle) > 4)
-		val = (header->handle >> 32);
-	else
-		val = 0;
 	vmw_write(man->dev_priv, SVGA_REG_COMMAND_HIGH, val);
 
 	val = (header->handle & 0xFFFFFFFFULL);
Signature · 6 lines
2.8.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw

Looks good to me. Thanks!

Quoted 40 lines · Thierry Reding

From: Thierry Reding <[email protected]>

While the current code is correct and the compiler's DCE pass should remove either of the branches depending on the width of DMA addresses, the compiler still has to compile the code first.

On configurations with 32-bit DMA addresses, right-shifting the address by 32 causes GCC to output a build warning. Work around this by using a preprocessor conditional instead.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c +5 -5
index 67cebb23c940..577faca0fe9d 100644
@@ -291,12 +291,12 @@ void vmw_cmdbuf_header_free(struct vmw_cmdbuf_header *header)
 static int vmw_cmdbuf_header_submit(struct vmw_cmdbuf_header *header)
 {
 	struct vmw_cmdbuf_man *man = header->man;
-	u32 val;
+#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
+	u32 val = header->handle >> 32;
+#else
+	u32 val = 0;
+#endif
 
-	if (sizeof(header->handle) > 4)
-		val = (header->handle >> 32);
-	else
-		val = 0;
 	vmw_write(man->dev_priv, SVGA_REG_COMMAND_HIGH, val);
 
 	val = (header->handle & 0xFFFFFFFFULL);
Signature · 1 line
2.8.3

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