[PATCH AUTOSEL for 4.9 127/190] bnx2x: Align RX buffers

2018-03-07 Thread Sasha Levin
From: Scott Wood 

[ Upstream commit 9b70de6d0266888b3743f03802502e43131043c8 ]

The bnx2x driver is not providing proper alignment on the receive buffers it
passes to build_skb(), causing skb_shared_info to be misaligned.
skb_shared_info contains an atomic, and while PPC normally supports
unaligned accesses, it does not support unaligned atomics.

Aligning the size of rx buffers will ensure that page_frag_alloc() returns
aligned addresses.

This can be reproduced on PPC by setting the network MTU to 1450 (or other
non-multiple-of-4) and then generating sufficient inbound network traffic
(one or two large "wget"s usually does it), producing the following oops:

Unable to handle kernel paging request for unaligned access at address 
0xc0ffc43af656
Faulting instruction address: 0xc080ef8c
Oops: Kernel access of bad area, sig: 7 [#1]
SMP NR_CPUS=2048
NUMA
PowerNV
Modules linked in: vmx_crypto powernv_rng rng_core powernv_op_panel 
leds_powernv led_class nfsd ip_tables x_tables autofs4 xfs lpfc bnx2x mdio 
libcrc32c crc_t10dif crct10dif_generic crct10dif_common
CPU: 104 PID: 0 Comm: swapper/104 Not tainted 4.11.0-rc8-00088-g4c761da #2
task: c0ffd4892400 task.stack: c0ffd492
NIP: c080ef8c LR: c080eee8 CTR: c01f8320
REGS: c0c33710 TRAP: 0600   Not tainted  (4.11.0-rc8-00088-g4c761da)
MSR: 90009033 
  CR: 24082042  XER: 
CFAR: c080eea0 DAR: c0ffc43af656 DSISR:  SOFTE: 1
GPR00: c0907f64 c0c33990 c0dd3b00 c0ffcaf22100
GPR04: c0ffcaf22e00   
GPR08: 00b80008 c0ffc43af636 c0ffc43af656 
GPR12: c01f6f00 cfe1a000 049f c51f
GPR16: ef33  8a43 0001
GPR20: c0ffc58a90c0  dd86 
GPR24: c07fd0ed10c0  0158 014a
GPR28: c0ffc43af010 c0ffc9144000 c0ffcaf22e00 c0ffcaf22100
NIP [c080ef8c] __skb_clone+0xdc/0x140
LR [c080eee8] __skb_clone+0x38/0x140
Call Trace:
[c0c33990] [c080fb74] skb_clone+0x74/0x110 (unreliable)
[c0c339c0] [c0907f64] packet_rcv+0x144/0x510
[c0c33a40] [c0827b64] __netif_receive_skb_core+0x5b4/0xd80
[c0c33b00] [c082b2bc] netif_receive_skb_internal+0x2c/0xc0
[c0c33b40] [c082c49c] napi_gro_receive+0x11c/0x260
[c0c33b80] [d00066483d68] bnx2x_poll+0xcf8/0x17b0 [bnx2x]
[c0c33d00] [c082babc] net_rx_action+0x31c/0x480
[c0c33e10] [c00d5a44] __do_softirq+0x164/0x3d0
[c0c33f00] [c00d60a8] irq_exit+0x108/0x120
[c0c33f20] [c0015b98] __do_irq+0x98/0x200
[c0c33f90] [c0027f14] call_do_irq+0x14/0x24
[c0ffd4923a90] [c0015d94] do_IRQ+0x94/0x110
[c0ffd4923ae0] [c0008d90] hardware_interrupt_common+0x150/0x160

Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 0a5ee1d973ac..857fdfb0197b 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -2026,6 +2026,7 @@ static void bnx2x_set_rx_buf_size(struct bnx2x *bp)
  ETH_OVREHEAD +
  mtu +
  BNX2X_FW_RX_ALIGN_END;
+   fp->rx_buf_size = SKB_DATA_ALIGN(fp->rx_buf_size);
/* Note : rx_buf_size doesn't take into account NET_SKB_PAD */
if (fp->rx_buf_size + NET_SKB_PAD <= PAGE_SIZE)
fp->rx_frag_size = fp->rx_buf_size + NET_SKB_PAD;
-- 
2.14.1


[PATCH AUTOSEL for 4.9 127/190] bnx2x: Align RX buffers

2018-03-07 Thread Sasha Levin
From: Scott Wood 

[ Upstream commit 9b70de6d0266888b3743f03802502e43131043c8 ]

The bnx2x driver is not providing proper alignment on the receive buffers it
passes to build_skb(), causing skb_shared_info to be misaligned.
skb_shared_info contains an atomic, and while PPC normally supports
unaligned accesses, it does not support unaligned atomics.

Aligning the size of rx buffers will ensure that page_frag_alloc() returns
aligned addresses.

This can be reproduced on PPC by setting the network MTU to 1450 (or other
non-multiple-of-4) and then generating sufficient inbound network traffic
(one or two large "wget"s usually does it), producing the following oops:

Unable to handle kernel paging request for unaligned access at address 
0xc0ffc43af656
Faulting instruction address: 0xc080ef8c
Oops: Kernel access of bad area, sig: 7 [#1]
SMP NR_CPUS=2048
NUMA
PowerNV
Modules linked in: vmx_crypto powernv_rng rng_core powernv_op_panel 
leds_powernv led_class nfsd ip_tables x_tables autofs4 xfs lpfc bnx2x mdio 
libcrc32c crc_t10dif crct10dif_generic crct10dif_common
CPU: 104 PID: 0 Comm: swapper/104 Not tainted 4.11.0-rc8-00088-g4c761da #2
task: c0ffd4892400 task.stack: c0ffd492
NIP: c080ef8c LR: c080eee8 CTR: c01f8320
REGS: c0c33710 TRAP: 0600   Not tainted  (4.11.0-rc8-00088-g4c761da)
MSR: 90009033 
  CR: 24082042  XER: 
CFAR: c080eea0 DAR: c0ffc43af656 DSISR:  SOFTE: 1
GPR00: c0907f64 c0c33990 c0dd3b00 c0ffcaf22100
GPR04: c0ffcaf22e00   
GPR08: 00b80008 c0ffc43af636 c0ffc43af656 
GPR12: c01f6f00 cfe1a000 049f c51f
GPR16: ef33  8a43 0001
GPR20: c0ffc58a90c0  dd86 
GPR24: c07fd0ed10c0  0158 014a
GPR28: c0ffc43af010 c0ffc9144000 c0ffcaf22e00 c0ffcaf22100
NIP [c080ef8c] __skb_clone+0xdc/0x140
LR [c080eee8] __skb_clone+0x38/0x140
Call Trace:
[c0c33990] [c080fb74] skb_clone+0x74/0x110 (unreliable)
[c0c339c0] [c0907f64] packet_rcv+0x144/0x510
[c0c33a40] [c0827b64] __netif_receive_skb_core+0x5b4/0xd80
[c0c33b00] [c082b2bc] netif_receive_skb_internal+0x2c/0xc0
[c0c33b40] [c082c49c] napi_gro_receive+0x11c/0x260
[c0c33b80] [d00066483d68] bnx2x_poll+0xcf8/0x17b0 [bnx2x]
[c0c33d00] [c082babc] net_rx_action+0x31c/0x480
[c0c33e10] [c00d5a44] __do_softirq+0x164/0x3d0
[c0c33f00] [c00d60a8] irq_exit+0x108/0x120
[c0c33f20] [c0015b98] __do_irq+0x98/0x200
[c0c33f90] [c0027f14] call_do_irq+0x14/0x24
[c0ffd4923a90] [c0015d94] do_IRQ+0x94/0x110
[c0ffd4923ae0] [c0008d90] hardware_interrupt_common+0x150/0x160

Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 0a5ee1d973ac..857fdfb0197b 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -2026,6 +2026,7 @@ static void bnx2x_set_rx_buf_size(struct bnx2x *bp)
  ETH_OVREHEAD +
  mtu +
  BNX2X_FW_RX_ALIGN_END;
+   fp->rx_buf_size = SKB_DATA_ALIGN(fp->rx_buf_size);
/* Note : rx_buf_size doesn't take into account NET_SKB_PAD */
if (fp->rx_buf_size + NET_SKB_PAD <= PAGE_SIZE)
fp->rx_frag_size = fp->rx_buf_size + NET_SKB_PAD;
-- 
2.14.1