netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/4] QorIQ DPAA FMan erratum A050385 workaround
@ 2020-03-03 15:55 Madalin Bucur
  2020-03-03 15:55 ` [PATCH net 1/4] dt-bindings: net: FMan erratum A050385 Madalin Bucur
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Madalin Bucur @ 2020-03-03 15:55 UTC (permalink / raw)
  To: davem
  Cc: netdev, robh+dt, mark.rutland, shawnguo, leoyang.li, devicetree,
	linux-kernel, Madalin Bucur

The patch set implements the workaround for FMan erratum A050385:

FMAN DMA read or writes under heavy traffic load may cause FMAN
internal resource leak; thus stopping further packet processing.

The FMAN internal queue can overflow when FMAN splits single
read or write transactions into multiple smaller transactions
such that more than 17 AXI transactions are in flight from FMAN
to interconnect. When the FMAN internal queue overflows, it can
stall further packet processing. The issue can occur with any one
of the following three conditions:

  1. FMAN AXI transaction crosses 4K address boundary (Errata
	 A010022)
  2. FMAN DMA address for an AXI transaction is not 16 byte
	 aligned, i.e. the last 4 bits of an address are non-zero
  3. Scatter Gather (SG) frames have more than one SG buffer in
	 the SG list and any one of the buffers, except the last
	 buffer in the SG list has data size that is not a multiple
	 of 16 bytes, i.e., other than 16, 32, 48, 64, etc.

With any one of the above three conditions present, there is
likelihood of stalled FMAN packet processing, especially under
stress with multiple ports injecting line-rate traffic.

To avoid situations that stall FMAN packet processing, all of the
above three conditions must be avoided; therefore, configure the
system with the following rules:

  1. Frame buffers must not span a 4KB address boundary, unless
	 the frame start address is 256 byte aligned
  2. All FMAN DMA start addresses (for example, BMAN buffer
	 address, FD[address] + FD[offset]) are 16B aligned
  3. SG table and buffer addresses are 16B aligned and the size
	 of SG buffers are multiple of 16 bytes, except for the last
	 SG buffer that can be of any size.

Additional workaround notes:
- Address alignment of 64 bytes is recommended for maximally
efficient system bus transactions (although 16 byte alignment is
sufficient to avoid the stall condition)
- To support frame sizes that are larger than 4K bytes, there are
two options:
  1. Large single buffer frames that span a 4KB page boundary can
	 be converted into SG frames to avoid transaction splits at
	 the 4KB boundary,
  2. Align the large single buffer to 256B address boundaries,
	 ensure that the frame address plus offset is 256B aligned.
- If software generated SG frames have buffers that are unaligned
and with random non-multiple of 16 byte lengths, before
transmitting such frames via FMAN, frames will need to be copied
into a new single buffer or multiple buffer SG frame that is
compliant with the three rules listed above.

Madalin Bucur (4):
  dt-bindings: net: FMan erratum A050385
  arm64: dts: ls1043a: FMan erratum A050385
  fsl/fman: detect FMan erratum A050385
  dpaa_eth: FMan erratum A050385 workaround

 Documentation/devicetree/bindings/net/fsl-fman.txt |   7 ++
 arch/arm64/boot/dts/freescale/fsl-ls1043-post.dtsi |   2 +
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c     | 111 ++++++++++++++++++++-
 drivers/net/ethernet/freescale/fman/fman.c         |  18 ++++
 drivers/net/ethernet/freescale/fman/fman.h         |  10 ++
 5 files changed, 145 insertions(+), 3 deletions(-)

-- 
2.1.0


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

* [PATCH net 1/4] dt-bindings: net: FMan erratum A050385
  2020-03-03 15:55 [PATCH net 0/4] QorIQ DPAA FMan erratum A050385 workaround Madalin Bucur
@ 2020-03-03 15:55 ` Madalin Bucur
  2020-03-03 15:55 ` [PATCH net 2/4] arm64: dts: ls1043a: " Madalin Bucur
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Madalin Bucur @ 2020-03-03 15:55 UTC (permalink / raw)
  To: davem
  Cc: netdev, robh+dt, mark.rutland, shawnguo, leoyang.li, devicetree,
	linux-kernel, Madalin Bucur

From: Madalin Bucur <madalin.bucur@nxp.com>

FMAN DMA read or writes under heavy traffic load may cause FMAN
internal resource leak; thus stopping further packet processing.

The FMAN internal queue can overflow when FMAN splits single
read or write transactions into multiple smaller transactions
such that more than 17 AXI transactions are in flight from FMAN
to interconnect. When the FMAN internal queue overflows, it can
stall further packet processing. The issue can occur with any one
of the following three conditions:

  1. FMAN AXI transaction crosses 4K address boundary (Errata
     A010022)
  2. FMAN DMA address for an AXI transaction is not 16 byte
     aligned, i.e. the last 4 bits of an address are non-zero
  3. Scatter Gather (SG) frames have more than one SG buffer in
     the SG list and any one of the buffers, except the last
     buffer in the SG list has data size that is not a multiple
     of 16 bytes, i.e., other than 16, 32, 48, 64, etc.

With any one of the above three conditions present, there is
likelihood of stalled FMAN packet processing, especially under
stress with multiple ports injecting line-rate traffic.

To avoid situations that stall FMAN packet processing, all of the
above three conditions must be avoided; therefore, configure the
system with the following rules:

  1. Frame buffers must not span a 4KB address boundary, unless
     the frame start address is 256 byte aligned
  2. All FMAN DMA start addresses (for example, BMAN buffer
     address, FD[address] + FD[offset]) are 16B aligned
  3. SG table and buffer addresses are 16B aligned and the size
     of SG buffers are multiple of 16 bytes, except for the last
     SG buffer that can be of any size.

Additional workaround notes:
- Address alignment of 64 bytes is recommended for maximally
efficient system bus transactions (although 16 byte alignment is
sufficient to avoid the stall condition)
- To support frame sizes that are larger than 4K bytes, there are
two options:
  1. Large single buffer frames that span a 4KB page boundary can
     be converted into SG frames to avoid transaction splits at
     the 4KB boundary,
  2. Align the large single buffer to 256B address boundaries,
     ensure that the frame address plus offset is 256B aligned.
- If software generated SG frames have buffers that are unaligned
and with random non-multiple of 16 byte lengths, before
transmitting such frames via FMAN, frames will need to be copied
into a new single buffer or multiple buffer SG frame that is
compliant with the three rules listed above.

Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
---
 Documentation/devicetree/bindings/net/fsl-fman.txt | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/fsl-fman.txt b/Documentation/devicetree/bindings/net/fsl-fman.txt
index 250f8d8cdce4..c00fb0d22c7b 100644
--- a/Documentation/devicetree/bindings/net/fsl-fman.txt
+++ b/Documentation/devicetree/bindings/net/fsl-fman.txt
@@ -110,6 +110,13 @@ PROPERTIES
 		Usage: required
 		Definition: See soc/fsl/qman.txt and soc/fsl/bman.txt
 
+- fsl,erratum-a050385
+		Usage: optional
+		Value type: boolean
+		Definition: A boolean property. Indicates the presence of the
+		erratum A050385 which indicates that DMA transactions that are
+		split can result in a FMan lock.
+
 =============================================================================
 FMan MURAM Node
 
-- 
2.1.0


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

* [PATCH net 2/4] arm64: dts: ls1043a: FMan erratum A050385
  2020-03-03 15:55 [PATCH net 0/4] QorIQ DPAA FMan erratum A050385 workaround Madalin Bucur
  2020-03-03 15:55 ` [PATCH net 1/4] dt-bindings: net: FMan erratum A050385 Madalin Bucur
@ 2020-03-03 15:55 ` Madalin Bucur
  2020-03-03 15:55 ` [PATCH net 3/4] fsl/fman: detect " Madalin Bucur
  2020-03-03 15:55 ` [PATCH net 4/4] dpaa_eth: FMan erratum A050385 workaround Madalin Bucur
  3 siblings, 0 replies; 8+ messages in thread
From: Madalin Bucur @ 2020-03-03 15:55 UTC (permalink / raw)
  To: davem
  Cc: netdev, robh+dt, mark.rutland, shawnguo, leoyang.li, devicetree,
	linux-kernel, Madalin Bucur

From: Madalin Bucur <madalin.bucur@nxp.com>

The LS1043A SoC is affected by the A050385 erratum stating that
FMAN DMA read or writes under heavy traffic load may cause FMAN
internal resource leak thus stopping further packet processing.

Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
---
 arch/arm64/boot/dts/freescale/fsl-ls1043-post.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1043-post.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1043-post.dtsi
index 6082ae022136..d237162a8744 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1043-post.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1043-post.dtsi
@@ -20,6 +20,8 @@
 };
 
 &fman0 {
+	fsl,erratum-a050385;
+
 	/* these aliases provide the FMan ports mapping */
 	enet0: ethernet@e0000 {
 	};
-- 
2.1.0


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

* [PATCH net 3/4] fsl/fman: detect FMan erratum A050385
  2020-03-03 15:55 [PATCH net 0/4] QorIQ DPAA FMan erratum A050385 workaround Madalin Bucur
  2020-03-03 15:55 ` [PATCH net 1/4] dt-bindings: net: FMan erratum A050385 Madalin Bucur
  2020-03-03 15:55 ` [PATCH net 2/4] arm64: dts: ls1043a: " Madalin Bucur
@ 2020-03-03 15:55 ` Madalin Bucur
  2020-03-03 23:52   ` David Miller
  2020-03-03 15:55 ` [PATCH net 4/4] dpaa_eth: FMan erratum A050385 workaround Madalin Bucur
  3 siblings, 1 reply; 8+ messages in thread
From: Madalin Bucur @ 2020-03-03 15:55 UTC (permalink / raw)
  To: davem
  Cc: netdev, robh+dt, mark.rutland, shawnguo, leoyang.li, devicetree,
	linux-kernel, Madalin Bucur

From: Madalin Bucur <madalin.bucur@nxp.com>

Detect the presence of the A050385 erratum.

Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
---
 drivers/net/ethernet/freescale/fman/fman.c | 18 ++++++++++++++++++
 drivers/net/ethernet/freescale/fman/fman.h | 10 ++++++++++
 2 files changed, 28 insertions(+)

diff --git a/drivers/net/ethernet/freescale/fman/fman.c b/drivers/net/ethernet/freescale/fman/fman.c
index 934111def0be..a673917b7411 100644
--- a/drivers/net/ethernet/freescale/fman/fman.c
+++ b/drivers/net/ethernet/freescale/fman/fman.c
@@ -1,5 +1,6 @@
 /*
  * Copyright 2008-2015 Freescale Semiconductor Inc.
+ * Copyright 2020 NXP
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -566,6 +567,10 @@ struct fman_cfg {
 	u32 qmi_def_tnums_thresh;
 };
 
+#ifdef DPAA_FMAN_ERRATUM_A050385
+static bool fman_has_err_a050385;
+#endif
+
 static irqreturn_t fman_exceptions(struct fman *fman,
 				   enum fman_exceptions exception)
 {
@@ -2518,6 +2523,14 @@ struct fman *fman_bind(struct device *fm_dev)
 }
 EXPORT_SYMBOL(fman_bind);
 
+#ifdef DPAA_FMAN_ERRATUM_A050385
+bool fman_has_errata_a050385(void)
+{
+	return fman_has_err_a050385;
+}
+EXPORT_SYMBOL(fman_has_errata_a050385);
+#endif
+
 static irqreturn_t fman_err_irq(int irq, void *handle)
 {
 	struct fman *fman = (struct fman *)handle;
@@ -2845,6 +2858,11 @@ static struct fman *read_dts_node(struct platform_device *of_dev)
 		goto fman_free;
 	}
 
+#ifdef DPAA_FMAN_ERRATUM_A050385
+	fman_has_err_a050385 =
+		of_property_read_bool(fm_node, "fsl,erratum-a050385");
+#endif
+
 	return fman;
 
 fman_node_put:
diff --git a/drivers/net/ethernet/freescale/fman/fman.h b/drivers/net/ethernet/freescale/fman/fman.h
index 935c317fa696..7b14ef4c306d 100644
--- a/drivers/net/ethernet/freescale/fman/fman.h
+++ b/drivers/net/ethernet/freescale/fman/fman.h
@@ -1,5 +1,6 @@
 /*
  * Copyright 2008-2015 Freescale Semiconductor Inc.
+ * Copyright 2020 NXP
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -37,6 +38,11 @@
 #include <linux/interrupt.h>
 #include <linux/of_irq.h>
 
+#ifdef CONFIG_ARM64
+/* only some ARM64 platforms are affected */
+#define DPAA_FMAN_ERRATUM_A050385 1
+#endif
+
 /* FM Frame descriptor macros  */
 /* Frame queue Context Override */
 #define FM_FD_CMD_FCO                   0x80000000
@@ -398,6 +404,10 @@ u16 fman_get_max_frm(void);
 
 int fman_get_rx_extra_headroom(void);
 
+#ifdef DPAA_FMAN_ERRATUM_A050385
+bool fman_has_errata_a050385(void);
+#endif
+
 struct fman *fman_bind(struct device *dev);
 
 #endif /* __FM_H */
-- 
2.1.0


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

* [PATCH net 4/4] dpaa_eth: FMan erratum A050385 workaround
  2020-03-03 15:55 [PATCH net 0/4] QorIQ DPAA FMan erratum A050385 workaround Madalin Bucur
                   ` (2 preceding siblings ...)
  2020-03-03 15:55 ` [PATCH net 3/4] fsl/fman: detect " Madalin Bucur
@ 2020-03-03 15:55 ` Madalin Bucur
  2020-03-03 23:54   ` David Miller
  3 siblings, 1 reply; 8+ messages in thread
From: Madalin Bucur @ 2020-03-03 15:55 UTC (permalink / raw)
  To: davem
  Cc: netdev, robh+dt, mark.rutland, shawnguo, leoyang.li, devicetree,
	linux-kernel, Madalin Bucur

From: Madalin Bucur <madalin.bucur@nxp.com>

Align buffers, data start, SG fragment length to avoid DMA splits.
These changes prevent the A050385 issue to manifest itself:

FMAN DMA read or writes under heavy traffic load may cause FMAN
internal resource leak; thus stopping further packet processing.

The FMAN internal queue can overflow when FMAN splits single
read or write transactions into multiple smaller transactions
such that more than 17 AXI transactions are in flight from FMAN
to interconnect. When the FMAN internal queue overflows, it can
stall further packet processing. The issue can occur with any one
of the following three conditions:

  1. FMAN AXI transaction crosses 4K address boundary (Errata
	 A010022)
  2. FMAN DMA address for an AXI transaction is not 16 byte
	 aligned, i.e. the last 4 bits of an address are non-zero
  3. Scatter Gather (SG) frames have more than one SG buffer in
	 the SG list and any one of the buffers, except the last
	 buffer in the SG list has data size that is not a multiple
	 of 16 bytes, i.e., other than 16, 32, 48, 64, etc.

With any one of the above three conditions present, there is
likelihood of stalled FMAN packet processing, especially under
stress with multiple ports injecting line-rate traffic.

To avoid situations that stall FMAN packet processing, all of the
above three conditions must be avoided; therefore, configure the
system with the following rules:

  1. Frame buffers must not span a 4KB address boundary, unless
	 the frame start address is 256 byte aligned
  2. All FMAN DMA start addresses (for example, BMAN buffer
	 address, FD[address] + FD[offset]) are 16B aligned
  3. SG table and buffer addresses are 16B aligned and the size
	 of SG buffers are multiple of 16 bytes, except for the last
	 SG buffer that can be of any size.

Additional workaround notes:
- Address alignment of 64 bytes is recommended for maximally
efficient system bus transactions (although 16 byte alignment is
sufficient to avoid the stall condition)
- To support frame sizes that are larger than 4K bytes, there are
two options:
  1. Large single buffer frames that span a 4KB page boundary can
	 be converted into SG frames to avoid transaction splits at
	 the 4KB boundary,
  2. Align the large single buffer to 256B address boundaries,
	 ensure that the frame address plus offset is 256B aligned.
- If software generated SG frames have buffers that are unaligned
and with random non-multiple of 16 byte lengths, before
transmitting such frames via FMAN, frames will need to be copied
into a new single buffer or multiple buffer SG frame that is
compliant with the three rules listed above.

Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
---
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 111 ++++++++++++++++++++++++-
 1 file changed, 108 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index fd93d542f497..3f2745a85e60 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -1,4 +1,5 @@
 /* Copyright 2008 - 2016 Freescale Semiconductor Inc.
+ * Copyright 2020 NXP
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -123,7 +124,23 @@ MODULE_PARM_DESC(tx_timeout, "The Tx timeout in ms");
 #define FSL_QMAN_MAX_OAL	127
 
 /* Default alignment for start of data in an Rx FD */
+#ifdef DPAA_FMAN_ERRATUM_A050385
+/* aligning data start to 0x40 avoids DMA transaction splits, unless the buffer
+ * is crossing a 4k page boundary
+ */
+#define DPAA_A050385_MIN_ALIGN 0x40
+/* aligning to 0x100 avoids DMA transaction splits caused by 4k page boundary
+ * crossings; also, all SG fragments except the last must have a size multiple
+ * of 0x100 to avoid DMA transaction splits
+ */
+#define DPAA_A050385_ALIGN 0x100
+#define DPAA_FD_DATA_ALIGNMENT  ((fman_has_errata_a050385()) ? \
+				 DPAA_A050385_MIN_ALIGN : 16)
+#define DPAA_FD_RX_DATA_ALIGNMENT DPAA_A050385_ALIGN
+#else
 #define DPAA_FD_DATA_ALIGNMENT  16
+#define DPAA_FD_RX_DATA_ALIGNMENT DPAA_FD_DATA_ALIGNMENT
+#endif
 
 /* The DPAA requires 256 bytes reserved and mapped for the SGT */
 #define DPAA_SGT_SIZE 256
@@ -158,8 +175,13 @@ MODULE_PARM_DESC(tx_timeout, "The Tx timeout in ms");
 #define DPAA_PARSE_RESULTS_SIZE sizeof(struct fman_prs_result)
 #define DPAA_TIME_STAMP_SIZE 8
 #define DPAA_HASH_RESULTS_SIZE 8
+#ifdef DPAA_FMAN_ERRATUM_A050385
+#define DPAA_RX_PRIV_DATA_SIZE (DPAA_A050385_ALIGN - (DPAA_PARSE_RESULTS_SIZE\
+	 + DPAA_TIME_STAMP_SIZE + DPAA_HASH_RESULTS_SIZE))
+#else
 #define DPAA_RX_PRIV_DATA_SIZE	(u16)(DPAA_TX_PRIV_DATA_SIZE + \
 					dpaa_rx_extra_headroom)
+#endif
 
 #define DPAA_ETH_PCD_RXQ_NUM	128
 
@@ -180,7 +202,12 @@ static struct dpaa_bp *dpaa_bp_array[BM_MAX_NUM_OF_POOLS];
 
 #define DPAA_BP_RAW_SIZE 4096
 
+#ifdef DPAA_FMAN_ERRATUM_A050385
+#define dpaa_bp_size(raw_size) ((SKB_WITH_OVERHEAD(raw_size)) & \
+				~(DPAA_A050385_ALIGN - 1))
+#else
 #define dpaa_bp_size(raw_size) SKB_WITH_OVERHEAD(raw_size)
+#endif
 
 static int dpaa_max_frm;
 
@@ -1192,7 +1219,7 @@ static int dpaa_eth_init_rx_port(struct fman_port *port, struct dpaa_bp *bp,
 	buf_prefix_content.pass_prs_result = true;
 	buf_prefix_content.pass_hash_result = true;
 	buf_prefix_content.pass_time_stamp = true;
-	buf_prefix_content.data_align = DPAA_FD_DATA_ALIGNMENT;
+	buf_prefix_content.data_align = DPAA_FD_RX_DATA_ALIGNMENT;
 
 	rx_p = &params.specific_params.rx_params;
 	rx_p->err_fqid = errq->fqid;
@@ -1662,6 +1689,8 @@ static u8 rx_csum_offload(const struct dpaa_priv *priv, const struct qm_fd *fd)
 	return CHECKSUM_NONE;
 }
 
+#define PTR_IS_ALIGNED(x, a) (IS_ALIGNED((unsigned long)(x), (a)))
+
 /* Build a linear skb around the received buffer.
  * We are guaranteed there is enough room at the end of the data buffer to
  * accommodate the shared info area of the skb.
@@ -1733,8 +1762,7 @@ static struct sk_buff *sg_fd_to_skb(const struct dpaa_priv *priv,
 
 		sg_addr = qm_sg_addr(&sgt[i]);
 		sg_vaddr = phys_to_virt(sg_addr);
-		WARN_ON(!IS_ALIGNED((unsigned long)sg_vaddr,
-				    SMP_CACHE_BYTES));
+		WARN_ON(!PTR_IS_ALIGNED(sg_vaddr, SMP_CACHE_BYTES));
 
 		dma_unmap_page(priv->rx_dma_dev, sg_addr,
 			       DPAA_BP_RAW_SIZE, DMA_FROM_DEVICE);
@@ -2022,6 +2050,75 @@ static inline int dpaa_xmit(struct dpaa_priv *priv,
 	return 0;
 }
 
+#ifdef DPAA_FMAN_ERRATUM_A050385
+int dpaa_a050385_wa(struct net_device *net_dev, struct sk_buff **s)
+{
+	struct dpaa_priv *priv = netdev_priv(net_dev);
+	struct sk_buff *new_skb, *skb = *s;
+	unsigned char *start, i;
+
+	/* check linear buffer alignment */
+	if (!PTR_IS_ALIGNED(skb->data, DPAA_A050385_ALIGN))
+		goto workaround;
+
+	/* linear buffers just need to have an aligned start */
+	if (!skb_is_nonlinear(skb))
+		return 0;
+
+	/* linear data size for nonlinear skbs needs to be aligned */
+	if (!IS_ALIGNED(skb_headlen(skb), DPAA_A050385_ALIGN))
+		goto workaround;
+
+	for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
+		skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
+
+		/* all fragments need to have aligned start addresses */
+		if (!IS_ALIGNED(skb_frag_off(frag), DPAA_A050385_ALIGN))
+			goto workaround;
+
+		/* all but last fragment need to have aligned sizes */
+		if (!IS_ALIGNED(skb_frag_size(frag), DPAA_A050385_ALIGN) &&
+		    (i < skb_shinfo(skb)->nr_frags - 1))
+			goto workaround;
+	}
+
+	return 0;
+
+workaround:
+	/* copy all the skb content into a new linear buffer */
+	new_skb = netdev_alloc_skb(net_dev, skb->len + DPAA_A050385_ALIGN - 1 +
+						priv->tx_headroom);
+	if (!new_skb)
+		return -ENOMEM;
+
+	/* NET_SKB_PAD bytes already reserved, adding up to tx_headroom */
+	skb_reserve(new_skb, priv->tx_headroom - NET_SKB_PAD);
+
+	/* Workaround for DPAA_A050385 requires data start to be aligned */
+	start = PTR_ALIGN(new_skb->data, DPAA_A050385_ALIGN);
+	if (start - new_skb->data != 0)
+		skb_reserve(new_skb, start - new_skb->data);
+
+	skb_put(new_skb, skb->len);
+	skb_copy_bits(skb, 0, new_skb->data, skb->len);
+	skb_copy_header(new_skb, skb);
+	new_skb->dev = skb->dev;
+
+	/* We move the headroom when we align it so we have to reset the
+	 * network and transport header offsets relative to the new data
+	 * pointer. The checksum offload relies on these offsets.
+	 */
+	skb_set_network_header(new_skb, skb_network_offset(skb));
+	skb_set_transport_header(new_skb, skb_transport_offset(skb));
+
+	/* TODO: does timestamping need the result in the old skb? */
+	dev_kfree_skb(skb);
+	*s = new_skb;
+
+	return 0;
+}
+#endif
+
 static netdev_tx_t
 dpaa_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
 {
@@ -2068,6 +2165,14 @@ dpaa_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
 		nonlinear = skb_is_nonlinear(skb);
 	}
 
+#ifdef DPAA_FMAN_ERRATUM_A050385
+	if (unlikely(fman_has_errata_a050385())) {
+		if (dpaa_a050385_wa(net_dev, &skb))
+			goto enomem;
+		nonlinear = skb_is_nonlinear(skb);
+	}
+#endif
+
 	if (nonlinear) {
 		/* Just create a S/G fd based on the skb */
 		err = skb_to_sg_fd(priv, skb, &fd);
-- 
2.1.0


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

* Re: [PATCH net 3/4] fsl/fman: detect FMan erratum A050385
  2020-03-03 15:55 ` [PATCH net 3/4] fsl/fman: detect " Madalin Bucur
@ 2020-03-03 23:52   ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2020-03-03 23:52 UTC (permalink / raw)
  To: madalin.bucur
  Cc: netdev, robh+dt, mark.rutland, shawnguo, leoyang.li, devicetree,
	linux-kernel, madalin.bucur

From: Madalin Bucur <madalin.bucur@oss.nxp.com>
Date: Tue,  3 Mar 2020 17:55:38 +0200

> @@ -37,6 +38,11 @@
>  #include <linux/interrupt.h>
>  #include <linux/of_irq.h>
>  
> +#ifdef CONFIG_ARM64
> +/* only some ARM64 platforms are affected */
> +#define DPAA_FMAN_ERRATUM_A050385 1
> +#endif

Please use Kconfig for expressing this.

Create a CONFIG_DPAA_ERRATUM_A050385 and 'select' it in the
driver Kconfig entry when ARM64 is true.

Thank you.

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

* Re: [PATCH net 4/4] dpaa_eth: FMan erratum A050385 workaround
  2020-03-03 15:55 ` [PATCH net 4/4] dpaa_eth: FMan erratum A050385 workaround Madalin Bucur
@ 2020-03-03 23:54   ` David Miller
  2020-03-04 15:51     ` Madalin Bucur (OSS)
  0 siblings, 1 reply; 8+ messages in thread
From: David Miller @ 2020-03-03 23:54 UTC (permalink / raw)
  To: madalin.bucur
  Cc: netdev, robh+dt, mark.rutland, shawnguo, leoyang.li, devicetree,
	linux-kernel, madalin.bucur

From: Madalin Bucur <madalin.bucur@oss.nxp.com>
Date: Tue,  3 Mar 2020 17:55:39 +0200

> +#define DPAA_FD_DATA_ALIGNMENT  ((fman_has_errata_a050385()) ? \

You don't need parenthesis around that fman_has_errata_a050385() call.

> +#define dpaa_bp_size(raw_size) ((SKB_WITH_OVERHEAD(raw_size)) & \

Similar again for SKB_WITH_OVERHEAD()

Also, how often does this errata code trigger on effected platforms and
what is the performance degradation from that?  I don't see this analysis
performed anywhere.


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

* RE: [PATCH net 4/4] dpaa_eth: FMan erratum A050385 workaround
  2020-03-03 23:54   ` David Miller
@ 2020-03-04 15:51     ` Madalin Bucur (OSS)
  0 siblings, 0 replies; 8+ messages in thread
From: Madalin Bucur (OSS) @ 2020-03-04 15:51 UTC (permalink / raw)
  To: David Miller, Madalin Bucur (OSS)
  Cc: netdev, robh+dt, mark.rutland, shawnguo, Leo Li, devicetree,
	linux-kernel

> -----Original Message-----
> From: David Miller <davem@davemloft.net>
> Sent: Wednesday, March 4, 2020 1:54 AM
> To: Madalin Bucur (OSS) <madalin.bucur@oss.nxp.com>
> Subject: Re: [PATCH net 4/4] dpaa_eth: FMan erratum A050385 workaround
> 
> From: Madalin Bucur <madalin.bucur@oss.nxp.com>
> Date: Tue,  3 Mar 2020 17:55:39 +0200
> 
> > +#define DPAA_FD_DATA_ALIGNMENT  ((fman_has_errata_a050385()) ? \
> 
> You don't need parenthesis around that fman_has_errata_a050385() call.
> 
> > +#define dpaa_bp_size(raw_size) ((SKB_WITH_OVERHEAD(raw_size)) & \
> 
> Similar again for SKB_WITH_OVERHEAD()

I'll send a v2, thanks.
 
> Also, how often does this errata code trigger on effected platforms and
> what is the performance degradation from that?  I don't see this analysis
> performed anywhere.

To reproduce this issue when the workaround is not applied, one
needs to ensure the FMan DMA transaction queue is already full
when a transaction split occurs so the system must be under high
traffic load (i.e. multiple ports at line rate). After the errata
occurs, the traffic stops. The only SoC impacted by this is the
LS1043A, the other ARM DPAA 1 SoC or the PPC DPAA 1 SoCs do not
have this erratum.

Madalin

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

end of thread, other threads:[~2020-03-04 15:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-03 15:55 [PATCH net 0/4] QorIQ DPAA FMan erratum A050385 workaround Madalin Bucur
2020-03-03 15:55 ` [PATCH net 1/4] dt-bindings: net: FMan erratum A050385 Madalin Bucur
2020-03-03 15:55 ` [PATCH net 2/4] arm64: dts: ls1043a: " Madalin Bucur
2020-03-03 15:55 ` [PATCH net 3/4] fsl/fman: detect " Madalin Bucur
2020-03-03 23:52   ` David Miller
2020-03-03 15:55 ` [PATCH net 4/4] dpaa_eth: FMan erratum A050385 workaround Madalin Bucur
2020-03-03 23:54   ` David Miller
2020-03-04 15:51     ` Madalin Bucur (OSS)

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).