[Nouveau] Fix unaligned accesses for SPARC

Patrick Baggett baggett.patrick at gmail.com
Tue Mar 12 20:18:41 PDT 2013


The nouveau driver makes a number of unaligned accesses via the ROM16(),
ROM32() and ROM64() macros which fault on SPARC (but would be transparently
handled by x86 hardware). Making use of get_unaligned() macro fixes the
problem for me.

diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.h
b/drivers/gpu/drm/nouveau/nouveau_bios.h
index 7ccd28f..92031f6 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bios.h
+++ b/drivers/gpu/drm/nouveau/nouveau_bios.h
@@ -26,6 +26,8 @@

 #include "nvreg.h"

+#include <asm/unaligned.h>
+
 #define DCB_MAX_NUM_ENTRIES 16
 #define DCB_MAX_NUM_I2C_ENTRIES 16
 #define DCB_MAX_NUM_GPIO_ENTRIES 32
@@ -33,10 +35,10 @@

 #define DCB_LOC_ON_CHIP 0

-#define ROM16(x) le16_to_cpu(*(u16 *)&(x))
-#define ROM32(x) le32_to_cpu(*(u32 *)&(x))
+#define ROM16(x) le16_to_cpu(get_unaligned((u16 *)&(x)))
+#define ROM32(x) le32_to_cpu(get_unaligned((u32 *)&(x)))
 #define ROM48(x) ({ u8 *p = &(x); (u64)ROM16(p[4]) << 32 | ROM32(p[0]); })
-#define ROM64(x) le64_to_cpu(*(u64 *)&(x))
+#define ROM64(x) le64_to_cpu(get_unaligned((u64 *)&(x)))
 #define ROMPTR(d,x) ({            \
        struct nouveau_drm *drm = nouveau_drm((d)); \
        ROM16(x) ? &drm->vbios.data[ROM16(x)] : NULL; \
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/nouveau/attachments/20130312/da6bf1dd/attachment-0001.html>


More information about the Nouveau mailing list