netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/mlx4_core: Fix unaligned accesses
@ 2015-04-29 20:52 David Ahern
  2015-04-30 13:26 ` Or Gerlitz
  0 siblings, 1 reply; 3+ messages in thread
From: David Ahern @ 2015-04-29 20:52 UTC (permalink / raw)
  To: netdev, ogerlitz; +Cc: David Ahern

Addresses the following kernel logs seen during boot:

Kernel unaligned access at TPC[100ee150] mlx4_QUERY_HCA+0x80/0x248 [mlx4_core]
Kernel unaligned access at TPC[100f071c] mlx4_QUERY_ADAPTER+0x100/0x12c [mlx4_core]
Kernel unaligned access at TPC[100f071c] mlx4_QUERY_ADAPTER+0x100/0x12c [mlx4_core]
Kernel unaligned access at TPC[100f071c] mlx4_QUERY_ADAPTER+0x100/0x12c [mlx4_core]
Kernel unaligned access at TPC[100f071c] mlx4_QUERY_ADAPTER+0x100/0x12c [mlx4_core]

Signed-off-by: David Ahern <david.ahern@oracle.com>
---
 drivers/net/ethernet/mellanox/mlx4/fw.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c
index 5a21e5d..a8e5661 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -56,11 +56,13 @@ MODULE_PARM_DESC(enable_qos, "Enable Quality of Service support in the HCA (defa
 #define MLX4_GET(dest, source, offset)				      \
 	do {							      \
 		void *__p = (char *) (source) + (offset);	      \
+		u64 val;                                              \
 		switch (sizeof (dest)) {			      \
 		case 1: (dest) = *(u8 *) __p;	    break;	      \
 		case 2: (dest) = be16_to_cpup(__p); break;	      \
 		case 4: (dest) = be32_to_cpup(__p); break;	      \
-		case 8: (dest) = be64_to_cpup(__p); break;	      \
+		case 8: val = get_unaligned((u64 *)__p);              \
+			(dest) = be64_to_cpu(val);  break;            \
 		default: __buggy_use_of_MLX4_GET();		      \
 		}						      \
 	} while (0)
@@ -1526,9 +1528,17 @@ static void get_board_id(void *vsd, char *board_id)
 		 * swaps each 4-byte word before passing it back to
 		 * us.  Therefore we need to swab it before printing.
 		 */
-		for (i = 0; i < 4; ++i)
-			((u32 *) board_id)[i] =
-				swab32(*(u32 *) (vsd + VSD_OFFSET_MLX_BOARD_ID + i * 4));
+		u32 *bid_u32 = (u32 *)board_id;
+
+		for (i = 0; i < 4; ++i) {
+			u32 *addr;
+			u32 val;
+
+			addr = (u32 *) (vsd + VSD_OFFSET_MLX_BOARD_ID + i * 4);
+			val = get_unaligned(addr);
+			val = swab32(val);
+			put_unaligned(val, &bid_u32[i]);
+		}
 	}
 }
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net/mlx4_core: Fix unaligned accesses
  2015-04-29 20:52 [PATCH] net/mlx4_core: Fix unaligned accesses David Ahern
@ 2015-04-30 13:26 ` Or Gerlitz
  2015-04-30 20:26   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Or Gerlitz @ 2015-04-30 13:26 UTC (permalink / raw)
  To: David Ahern; +Cc: Linux Netdev List, Or Gerlitz

On Wed, Apr 29, 2015 at 11:52 PM, David Ahern <david.ahern@oracle.com> wrote:
> Addresses the following kernel logs seen during boot:
>
> Kernel unaligned access at TPC[100ee150] mlx4_QUERY_HCA+0x80/0x248 [mlx4_core]
> Kernel unaligned access at TPC[100f071c] mlx4_QUERY_ADAPTER+0x100/0x12c [mlx4_core]
> Kernel unaligned access at TPC[100f071c] mlx4_QUERY_ADAPTER+0x100/0x12c [mlx4_core]
> Kernel unaligned access at TPC[100f071c] mlx4_QUERY_ADAPTER+0x100/0x12c [mlx4_core]
> Kernel unaligned access at TPC[100f071c] mlx4_QUERY_ADAPTER+0x100/0x12c [mlx4_core]
>
> Signed-off-by: David Ahern <david.ahern@oracle.com>

Looks OK

Acked-by: Or Gerlitz <ogerlitz@mellanox.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net/mlx4_core: Fix unaligned accesses
  2015-04-30 13:26 ` Or Gerlitz
@ 2015-04-30 20:26   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2015-04-30 20:26 UTC (permalink / raw)
  To: gerlitz.or; +Cc: david.ahern, netdev, ogerlitz

From: Or Gerlitz <gerlitz.or@gmail.com>
Date: Thu, 30 Apr 2015 16:26:42 +0300

> On Wed, Apr 29, 2015 at 11:52 PM, David Ahern <david.ahern@oracle.com> wrote:
>> Addresses the following kernel logs seen during boot:
>>
>> Kernel unaligned access at TPC[100ee150] mlx4_QUERY_HCA+0x80/0x248 [mlx4_core]
>> Kernel unaligned access at TPC[100f071c] mlx4_QUERY_ADAPTER+0x100/0x12c [mlx4_core]
>> Kernel unaligned access at TPC[100f071c] mlx4_QUERY_ADAPTER+0x100/0x12c [mlx4_core]
>> Kernel unaligned access at TPC[100f071c] mlx4_QUERY_ADAPTER+0x100/0x12c [mlx4_core]
>> Kernel unaligned access at TPC[100f071c] mlx4_QUERY_ADAPTER+0x100/0x12c [mlx4_core]
>>
>> Signed-off-by: David Ahern <david.ahern@oracle.com>
> 
> Looks OK
> 
> Acked-by: Or Gerlitz <ogerlitz@mellanox.com>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-30 20:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-29 20:52 [PATCH] net/mlx4_core: Fix unaligned accesses David Ahern
2015-04-30 13:26 ` Or Gerlitz
2015-04-30 20:26   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).