Skip to contentSkip to conversation

drm/radeon/kms/atom: use get_unaligned() for ctx->ps

PATCH In review Matt Turner 2 participants 5 messages Feb 11, 2010 – Feb 14, 2010

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

PATCH 1/1 drm/radeon/kms/atom: use get_unaligned() for ctx->ps

Noticed on a DEC Alpha.

Start up into console mode caused 15 unaligned accesses, and starting X caused another 48.

CC Jerome Glisse <[email protected]>
CC Alex Deucher <[email protected]>
CC Dave Airlie <[email protected]>
---
 drivers/gpu/drm/radeon/atom.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/gpu/drm/radeon/atom.c +4 -1
index bd0c843..c1d3c24 100644
@@ -24,6 +24,7 @@
 
 #include <linux/module.h>
 #include <linux/sched.h>
+#include <asm/unaligned.h>
 
 #define ATOM_DEBUG
 
@@ -212,7 +213,9 @@ static uint32_t atom_get_src_int(atom_exec_context *ctx, uint8_t attr,
 	case ATOM_ARG_PS:
 		idx = U8(*ptr);
 		(*ptr)++;
-		val = le32_to_cpu(ctx->ps[idx]);
+		/* get_unaligned avoids unaligned accesses from atombios tables
+		 * 21, 24, 42. */
+		val = le32_to_cpu(get_unaligned((u32 *)&ctx->ps[idx]));
 		if (print)
 			DEBUG("PS[0x%02X,0x%04X]", idx, val);
 		break;
Signature · 8 lines
1.6.5.3


------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
--
#1 lore raw

Updated patch to use get_unaligned_le32, as suggested by Dave.

Quoted 30 lines · Matt Turner

Noticed on a DEC Alpha.

Start up into console mode caused 15 unaligned accesses, and starting X caused another 48.

CC Jerome Glisse <[email protected]>
CC Alex Deucher <[email protected]>
CC Dave Airlie <[email protected]>

---
 drivers/gpu/drm/radeon/atom.c |    5 ++++-

 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/gpu/drm/radeon/atom.c +1 -0
index bd0c843..c1d3c24 100644
@@ -24,6 +24,7 @@
 
  #include <linux/module.h>
  #include <linux/sched.h>
+#include <asm/unaligned.h>
 
  #define ATOM_DEBUG
 
@@ -212,7 +213,9 @@ static uint32_t atom_get_src_int(atom_exec_context *ctx, uint8_t attr,

       case ATOM_ARG_PS:
               idx = U8(*ptr);
               (*ptr)++;
-               val = le32_to_cpu(ctx->ps[idx]);

Quoted 10 lines

+               /* get_unaligned avoids unaligned accesses from atombios tables
+                * 21, 24, 42. */
+               val = le32_to_cpu(get_unaligned((u32 *)&ctx->ps[idx])); if (print)
                       DEBUG("PS[0x%02X,0x%04X]", idx, val); break;
--
1.6.5.3

From 89ccfb52e4ac0f6ab481bd6f3a75b67435f99212 Mon Sep 17 00:00:00 2001
From: Matt Turner <[email protected]>
Date: Wed, 10 Feb 2010 23:22:27 -0500
Subject: [PATCH] drm/radeon/kms/atom: use get_unaligned_le32() for ctx->ps

Noticed on a DEC Alpha.

Start up into console mode caused 15 unaligned accesses, and starting X caused another 48.

CC Jerome Glisse <[email protected]>
CC Alex Deucher <[email protected]>
CC Dave Airlie <[email protected]>
---
 drivers/gpu/drm/radeon/atom.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/gpu/drm/radeon/atom.c +4 -1
index bd0c843..ee4da4d 100644
@@ -24,6 +24,7 @@
 
 #include <linux/module.h>
 #include <linux/sched.h>
+#include <asm/unaligned.h>
 
 #define ATOM_DEBUG
 
@@ -212,7 +213,9 @@ static uint32_t atom_get_src_int(atom_exec_context *ctx, uint8_t attr,
 	case ATOM_ARG_PS:
 		idx = U8(*ptr);
 		(*ptr)++;
-		val = le32_to_cpu(ctx->ps[idx]);
+		/* get_unaligned_le32 avoids unaligned accesses from atombios
+		 * tables 21, 24, 42. */
+		val = get_unaligned_le32((u32 *)&ctx->ps[idx]);
 		if (print)
 			DEBUG("PS[0x%02X,0x%04X]", idx, val);
 		break;
Signature · 1 line
1.6.5.3

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev

--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel

#2 lore raw
Quoted 28 lines · Matt Turner

Updated patch to use get_unaligned_le32, as suggested by Dave.

Quoted 25 lines · Matt Turner

Noticed on a DEC Alpha.

Start up into console mode caused 15 unaligned accesses, and starting X caused another 48.

CC Jerome Glisse <[email protected]>
CC Alex Deucher <[email protected]>
CC Dave Airlie <[email protected]>

---
 drivers/gpu/drm/radeon/atom.c |    5 ++++-

 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/gpu/drm/radeon/atom.c +1 -0
index bd0c843..c1d3c24 100644
@@ -24,6 +24,7 @@
 
  #include <linux/module.h>
  #include <linux/sched.h>
+#include <asm/unaligned.h>
 
  #define ATOM_DEBUG
 
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/radeon/atom.c +0 -0
@@ -212,7 +213,9 @@ static uint32_t atom_get_src_int(atom_exec_context *ctx, uint8_t attr,

       case ATOM_ARG_PS:
               idx = U8(*ptr);
               (*ptr)++;
-               val = le32_to_cpu(ctx->ps[idx]);
+               /* get_unaligned avoids unaligned accesses from atombios tables
+                * 21, 24, 42. */

Not a big deal, but you might want to mention that this is needed for alpha in the comment. Also, the tables with unaligned accesses will probably vary with the card, so there's not really any need to mention them here.

Alex

Quoted 9 lines
Quoted 8 lines

+               val = le32_to_cpu(get_unaligned((u32 *)&ctx->ps[idx])); if (print)
                       DEBUG("PS[0x%02X,0x%04X]", idx, val); break;
--
1.6.5.3

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
--

#3 lore raw
Quoted 42 lines · Alex Deucher
Quoted 28 lines · Matt Turner

Updated patch to use get_unaligned_le32, as suggested by Dave.

Quoted 25 lines · Matt Turner

Noticed on a DEC Alpha.

Start up into console mode caused 15 unaligned accesses, and starting X caused another 48.

CC Jerome Glisse <[email protected]>
CC Alex Deucher <[email protected]>
CC Dave Airlie <[email protected]>

---
 drivers/gpu/drm/radeon/atom.c |    5 ++++-

 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/gpu/drm/radeon/atom.c +1 -0
index bd0c843..c1d3c24 100644
@@ -24,6 +24,7 @@
 
  #include <linux/module.h>
  #include <linux/sched.h>
+#include <asm/unaligned.h>
 
  #define ATOM_DEBUG
 
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/radeon/atom.c +0 -0
@@ -212,7 +213,9 @@ static uint32_t atom_get_src_int(atom_exec_context *ctx, uint8_t attr,

       case ATOM_ARG_PS:
               idx = U8(*ptr);
               (*ptr)++;
-               val = le32_to_cpu(ctx->ps[idx]);
+               /* get_unaligned avoids unaligned accesses from atombios tables
+                * 21, 24, 42. */

Not a big deal, but you might want to mention that this is needed for alpha in the comment.  Also, the tables with unaligned accesses will probably vary with the card, so there's not really any need to mention them here.

Quoted 1 line

Alex

Alright, please check out the attached patch.

Thanks,
Matt

From cf5a4d8cfd9eb4290e1bc5c8020a074454f5f019 Mon Sep 17 00:00:00 2001
From: Matt Turner <[email protected]>
Date: Sat, 13 Feb 2010 20:20:19 -0500
Subject: [PATCH] drm/radeon/kms/atom: use get_unaligned_le32() for ctx->ps

Noticed on a DEC Alpha.

Start up into console mode caused 15 unaligned accesses, and starting X caused another 48.

CC Jerome Glisse <[email protected]>
CC Alex Deucher <[email protected]>
CC Dave Airlie <[email protected]>
---
 drivers/gpu/drm/radeon/atom.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/gpu/drm/radeon/atom.c +4 -1
index bd0c843..a742d22 100644
@@ -24,6 +24,7 @@
 
 #include <linux/module.h>
 #include <linux/sched.h>
+#include <asm/unaligned.h>
 
 #define ATOM_DEBUG
 
@@ -212,7 +213,9 @@ static uint32_t atom_get_src_int(atom_exec_context *ctx, uint8_t attr,
 	case ATOM_ARG_PS:
 		idx = U8(*ptr);
 		(*ptr)++;
-		val = le32_to_cpu(ctx->ps[idx]);
+		/* get_unaligned_le32 avoids unaligned accesses from atombios
+		 * tables, noticed on a DEC Alpha.
+		val = get_unaligned_le32((u32 *)&ctx->ps[idx]);
 		if (print)
 			DEBUG("PS[0x%02X,0x%04X]", idx, val);
 		break;
Signature · 1 line
1.6.5.3

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev

--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel

#4 lore raw

Ugh. I missed a */

From cf5a4d8cfd9eb4290e1bc5c8020a074454f5f019 Mon Sep 17 00:00:00 2001
From: Matt Turner <[email protected]>
Date: Sat, 13 Feb 2010 20:20:19 -0500
Subject: [PATCH] drm/radeon/kms/atom: use get_unaligned_le32() for ctx->ps

Noticed on a DEC Alpha.

Start up into console mode caused 15 unaligned accesses, and starting X caused another 48.

CC Jerome Glisse <[email protected]>
CC Alex Deucher <[email protected]>
CC Dave Airlie <[email protected]>
---
 drivers/gpu/drm/radeon/atom.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/gpu/drm/radeon/atom.c +4 -1
index bd0c843..a742d22 100644
@@ -24,6 +24,7 @@
 
 #include <linux/module.h>
 #include <linux/sched.h>
+#include <asm/unaligned.h>
 
 #define ATOM_DEBUG
 
@@ -212,7 +213,9 @@ static uint32_t atom_get_src_int(atom_exec_context *ctx, uint8_t attr,
 	case ATOM_ARG_PS:
 		idx = U8(*ptr);
 		(*ptr)++;
-		val = le32_to_cpu(ctx->ps[idx]);
+		/* get_unaligned_le32 avoids unaligned accesses from atombios
+		 * tables, noticed on a DEC Alpha. */
+		val = get_unaligned_le32((u32 *)&ctx->ps[idx]);
 		if (print)
 			DEBUG("PS[0x%02X,0x%04X]", idx, val);
 		break;
Signature · 1 line
1.6.5.3

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev

--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel