Skip to contentSkip to conversation

drm/udl: Fix unaligned memory access in udl_render_hline

PATCH Applied Jonathan Neuschäfer 2 participants 3 messages Apr 7, 2017 – Apr 11, 2017

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

PATCH 1/1 drm/udl: Fix unaligned memory access in udl_render_hline

On SPARC, the udl driver filled my kernel log with these messages:

[186668.910612] Kernel unaligned access at TPC[76609c] udl_render_hline+0x13c/0x3a0

Use put_unaligned_be16 to avoid them. On x86 this results in the same code, but on SPARC the compiler emits two single-byte stores.

---
 drivers/gpu/drm/udl/udl_transfer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/udl/udl_transfer.c +2 -1
index 917dcb978c2c..0c87b1ac6b68 100644
@@ -14,6 +14,7 @@
 #include <linux/slab.h>
 #include <linux/fb.h>
 #include <linux/prefetch.h>
+#include <asm/unaligned.h>
 
 #include <drm/drmP.h>
 #include "udl_drv.h"
@@ -163,7 +164,7 @@ static void udl_compress_hline16(
 			const u8 *const start = pixel;
 			const uint16_t repeating_pixel_val16 = pixel_val16;
 
-			*(uint16_t *)cmd = cpu_to_be16(pixel_val16);
+			put_unaligned_be16(pixel_val16, cmd);
 
 			cmd += 2;
 			pixel += bpp;
Signature · 1 line
2.11.0
Applied
#1 lore raw
Quoted 7 lines · Jonathan Neuschäfer

On SPARC, the udl driver filled my kernel log with these messages:

[186668.910612] Kernel unaligned access at TPC[76609c] udl_render_hline+0x13c/0x3a0

Use put_unaligned_be16 to avoid them. On x86 this results in the same code, but on SPARC the compiler emits two single-byte stores.

Pushed to drm-misc-fixes with Dave's IRC Ack.

Thanks,

Sean

Quoted 28 lines
---
 drivers/gpu/drm/udl/udl_transfer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/udl/udl_transfer.c +2 -1
index 917dcb978c2c..0c87b1ac6b68 100644
@@ -14,6 +14,7 @@
 #include <linux/slab.h>
 #include <linux/fb.h>
 #include <linux/prefetch.h>
+#include <asm/unaligned.h>
 
 #include <drm/drmP.h>
 #include "udl_drv.h"
@@ -163,7 +164,7 @@ static void udl_compress_hline16(
 			const u8 *const start = pixel;
 			const uint16_t repeating_pixel_val16 = pixel_val16;
 
-			*(uint16_t *)cmd = cpu_to_be16(pixel_val16);
+			put_unaligned_be16(pixel_val16, cmd);
 
 			cmd += 2;
 			pixel += bpp;
Signature · 1 line
2.11.0
Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
Quoted 9 lines · Sean Paul
Quoted 7 lines · Jonathan Neuschäfer

On SPARC, the udl driver filled my kernel log with these messages:

[186668.910612] Kernel unaligned access at TPC[76609c] udl_render_hline+0x13c/0x3a0

Use put_unaligned_be16 to avoid them. On x86 this results in the same code, but on SPARC the compiler emits two single-byte stores.

Quoted 5 lines

Pushed to drm-misc-fixes with Dave's IRC Ack.

Thanks,

Sean

Thanks as well :-)

Jonathan