openwrt/target/linux/layerscape/patches-5.4/701-net-0024-sdk_dpaa-ls1043a-errata-verify-and-resize-headroom-a.patch
Yangbo Lu cddd459140 layerscape: add patches-5.4
Add patches for linux-5.4. The patches are from NXP LSDK-20.04 release
which was tagged LSDK-20.04-V5.4.
https://source.codeaurora.org/external/qoriq/qoriq-components/linux/

For boards LS1021A-IOT, and Traverse-LS1043 which are not involved in
LSDK, port the dts patches from 4.14.

The patches are sorted into the following categories:
  301-arch-xxxx
  302-dts-xxxx
  303-core-xxxx
  701-net-xxxx
  801-audio-xxxx
  802-can-xxxx
  803-clock-xxxx
  804-crypto-xxxx
  805-display-xxxx
  806-dma-xxxx
  807-gpio-xxxx
  808-i2c-xxxx
  809-jailhouse-xxxx
  810-keys-xxxx
  811-kvm-xxxx
  812-pcie-xxxx
  813-pm-xxxx
  814-qe-xxxx
  815-sata-xxxx
  816-sdhc-xxxx
  817-spi-xxxx
  818-thermal-xxxx
  819-uart-xxxx
  820-usb-xxxx
  821-vfio-xxxx

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2020-05-07 12:53:06 +02:00

107 lines
3.6 KiB
Diff

From f6413a7e32d1f98a258e0ed9abd4df3159902fd3 Mon Sep 17 00:00:00 2001
From: Camelia Groza <camelia.groza@nxp.com>
Date: Mon, 4 Sep 2017 13:57:21 +0300
Subject: [PATCH] sdk_dpaa: ls1043a errata: verify and resize headroom
alignment
If the skb's headroom isn't aligned to 16 bytes, reallocate the entire
skb and resize its headroom to priv->tx_headroom. Update the pointers
to the network and transport headers accordingly.
Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
---
.../net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c | 38 +++++++++++++++-------
1 file changed, 27 insertions(+), 11 deletions(-)
--- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c
@@ -742,14 +742,19 @@ int __hot skb_to_contig_fd(struct dpa_pr
EXPORT_SYMBOL(skb_to_contig_fd);
#ifndef CONFIG_PPC
-/* Verify the conditions that trigger the A010022 errata: 4K memory address
- * crossings.
+/* Verify the conditions that trigger the A010022 errata: data unaligned to
+ * 16 bytes and 4K memory address crossings.
*/
-bool a010022_check_skb(struct sk_buff *skb)
+static bool a010022_check_skb(struct sk_buff *skb, struct dpa_priv_s *priv)
{
int nr_frags, i = 0;
skb_frag_t *frag;
+ /* Check if the headroom is aligned */
+ if (((u16)skb->data - priv->tx_headroom) %
+ priv->buf_layout[TX].data_align != 0)
+ return true;
+
/* Check if the headroom crosses a boundary */
if (HAS_DMA_ISSUE(skb->head, skb_headroom(skb)))
return true;
@@ -767,7 +772,7 @@ bool a010022_check_skb(struct sk_buff *s
while (i < nr_frags) {
frag = &skb_shinfo(skb)->frags[i];
- /* Check if the paged fragment crosses a boundary from its
+ /* Check if a paged fragment crosses a boundary from its
* offset to its end.
*/
if (HAS_DMA_ISSUE(frag->page_offset, frag->size))
@@ -783,13 +788,17 @@ bool a010022_check_skb(struct sk_buff *s
* page. Build a new skb around the new buffer and release the old one.
* A performance drop should be expected.
*/
-struct sk_buff *a010022_realign_skb(struct sk_buff *skb)
+static struct sk_buff *a010022_realign_skb(struct sk_buff *skb,
+ struct dpa_priv_s *priv)
{
- int headroom = skb_headroom(skb);
+ int trans_offset = skb_transport_offset(skb);
+ int net_offset = skb_network_offset(skb);
struct sk_buff *nskb = NULL;
+ int nsize, headroom;
struct page *npage;
void *npage_addr;
- int nsize;
+
+ headroom = priv->tx_headroom;
npage = alloc_page(GFP_ATOMIC);
if (unlikely(!npage)) {
@@ -822,6 +831,13 @@ struct sk_buff *a010022_realign_skb(stru
}
copy_skb_header(nskb, skb);
+ /* 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(nskb, net_offset);
+ skb_set_transport_header(nskb, trans_offset);
+
dev_kfree_skb(skb);
return nskb;
@@ -1024,8 +1040,8 @@ int __hot dpa_tx_extended(struct sk_buff
#endif /* CONFIG_FSL_DPAA_TS */
#ifndef CONFIG_PPC
- if (unlikely(dpaa_errata_a010022) && a010022_check_skb(skb)) {
- skb = a010022_realign_skb(skb);
+ if (unlikely(dpaa_errata_a010022) && a010022_check_skb(skb, priv)) {
+ skb = a010022_realign_skb(skb, priv);
if (!skb)
goto skb_to_fd_failed;
}
@@ -1072,8 +1088,8 @@ int __hot dpa_tx_extended(struct sk_buff
skb = nskb;
#ifndef CONFIG_PPC
if (unlikely(dpaa_errata_a010022) &&
- a010022_check_skb(skb)) {
- skb = realign_skb(skb);
+ a010022_check_skb(skb, priv)) {
+ skb = a010022_realign_skb(skb, priv);
if (!skb)
goto skb_to_fd_failed;
}