1 From b95f457bb7ba38f03a71b474e35f53670322f0db Mon Sep 17 00:00:00 2001
2 From: Camelia Groza <camelia.groza@nxp.com>
3 Date: Mon, 15 Jan 2018 17:41:01 +0200
4 Subject: [PATCH] sdk_dpaa: update buffer recycling conditions
6 Guarantee there is enough space inside the skb's headroom to store the
7 skb back-pointer before recycling the buffer. The back-pointer is stored
8 right before the buffer's start.
10 Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
12 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c | 8 +++++++-
13 1 file changed, 7 insertions(+), 1 deletion(-)
15 --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c
16 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c
17 @@ -350,7 +350,13 @@ bool dpa_buf_is_recyclable(struct sk_buf
18 /* left align to the nearest cacheline */
19 new = (unsigned char *)((unsigned long)new & ~(SMP_CACHE_BYTES - 1));
21 - if (likely(new >= skb->head &&
22 + /* Make sure there is enough space to store the skb back-pointer in
23 + * the headroom, right before the start of the buffer.
25 + * Guarantee that both maximum size and maximum data offsets aren't
28 + if (likely(new >= (skb->head + sizeof(void *)) &&
29 new >= (skb->data - DPA_MAX_FD_OFFSET) &&
30 skb_end_pointer(skb) - new <= DPA_RECYCLE_MAX_SIZE)) {