diff options
author | David Ahern <david.ahern@oracle.com> | 2015-04-29 16:52:51 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-04-30 16:26:30 -0400 |
commit | 17d5ceb6e43ea545d6d92db2f3ddb035233ba335 (patch) | |
tree | a9ba6e6173cc539a0168c3f1bbced7b7676e5db2 | |
parent | f94813f3c1d02090cc02dcfcbed339897830acb8 (diff) |
net/mlx4_core: Fix unaligned accesses
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>
Acked-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | 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 a4079811b176..e30bf57ad7a1 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 Enhanced QoS support (default: on)"); | |||
56 | #define MLX4_GET(dest, source, offset) \ | 56 | #define MLX4_GET(dest, source, offset) \ |
57 | do { \ | 57 | do { \ |
58 | void *__p = (char *) (source) + (offset); \ | 58 | void *__p = (char *) (source) + (offset); \ |
59 | u64 val; \ | ||
59 | switch (sizeof (dest)) { \ | 60 | switch (sizeof (dest)) { \ |
60 | case 1: (dest) = *(u8 *) __p; break; \ | 61 | case 1: (dest) = *(u8 *) __p; break; \ |
61 | case 2: (dest) = be16_to_cpup(__p); break; \ | 62 | case 2: (dest) = be16_to_cpup(__p); break; \ |
62 | case 4: (dest) = be32_to_cpup(__p); break; \ | 63 | case 4: (dest) = be32_to_cpup(__p); break; \ |
63 | case 8: (dest) = be64_to_cpup(__p); break; \ | 64 | case 8: val = get_unaligned((u64 *)__p); \ |
65 | (dest) = be64_to_cpu(val); break; \ | ||
64 | default: __buggy_use_of_MLX4_GET(); \ | 66 | default: __buggy_use_of_MLX4_GET(); \ |
65 | } \ | 67 | } \ |
66 | } while (0) | 68 | } while (0) |
@@ -1605,9 +1607,17 @@ static void get_board_id(void *vsd, char *board_id) | |||
1605 | * swaps each 4-byte word before passing it back to | 1607 | * swaps each 4-byte word before passing it back to |
1606 | * us. Therefore we need to swab it before printing. | 1608 | * us. Therefore we need to swab it before printing. |
1607 | */ | 1609 | */ |
1608 | for (i = 0; i < 4; ++i) | 1610 | u32 *bid_u32 = (u32 *)board_id; |
1609 | ((u32 *) board_id)[i] = | 1611 | |
1610 | swab32(*(u32 *) (vsd + VSD_OFFSET_MLX_BOARD_ID + i * 4)); | 1612 | for (i = 0; i < 4; ++i) { |
1613 | u32 *addr; | ||
1614 | u32 val; | ||
1615 | |||
1616 | addr = (u32 *) (vsd + VSD_OFFSET_MLX_BOARD_ID + i * 4); | ||
1617 | val = get_unaligned(addr); | ||
1618 | val = swab32(val); | ||
1619 | put_unaligned(val, &bid_u32[i]); | ||
1620 | } | ||
1611 | } | 1621 | } |
1612 | } | 1622 | } |
1613 | 1623 | ||