ath79/mikrotik: use routerbootpart partitions
[oweals/openwrt.git] / target / linux / layerscape / patches-5.4 / 701-net-0360-sdk_dpaa-sdk_fman-ls1043a-errata-detect-based-on-DTB.patch
1 From 6dbf409f09fd85d738652c7867a5822f682d5682 Mon Sep 17 00:00:00 2001
2 From: Camelia Groza <camelia.groza@nxp.com>
3 Date: Thu, 12 Dec 2019 14:15:05 +0200
4 Subject: [PATCH] sdk_dpaa: sdk_fman: ls1043a errata: detect based on DTB
5  property
6
7 Detect if the platform is vulnerable to the A010022 erratum based on device
8 tree properties instead of the SoC family.
9
10 Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
11 ---
12  drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c | 31 +---------------------
13  drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.h | 14 +++++-----
14  .../net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c  | 25 ++++++++---------
15  .../inc/integrations/LS1043/dpaa_integration_ext.h |  3 +++
16  .../sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h     | 10 +++++++
17  .../freescale/sdk_fman/src/wrapper/lnxwrp_fm.c     | 17 ++++++++++++
18  6 files changed, 51 insertions(+), 49 deletions(-)
19
20 --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c
21 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c
22 @@ -1,4 +1,5 @@
23  /* Copyright 2008-2013 Freescale Semiconductor Inc.
24 + * Copyright 2019 NXP
25   *
26   * Redistribution and use in source and binary forms, with or without
27   * modification, are permitted provided that the following conditions are met:
28 @@ -105,11 +106,6 @@ static const char rtx[][3] = {
29         [TX] = "TX"
30  };
31  
32 -#ifndef CONFIG_PPC
33 -bool dpaa_errata_a010022;
34 -EXPORT_SYMBOL(dpaa_errata_a010022);
35 -#endif
36 -
37  /* BM */
38  
39  #define DPAA_ETH_MAX_PAD (L1_CACHE_BYTES * 8)
40 @@ -1133,26 +1129,6 @@ static struct platform_driver dpa_driver
41         .remove         = dpa_remove
42  };
43  
44 -#ifndef CONFIG_PPC
45 -static bool __init __cold soc_has_errata_a010022(void)
46 -{
47 -#ifdef CONFIG_SOC_BUS
48 -       const struct soc_device_attribute soc_msi_matches[] = {
49 -               { .family = "QorIQ LS1043A",
50 -                 .data = NULL },
51 -               { },
52 -       };
53 -
54 -       if (soc_device_match(soc_msi_matches))
55 -               return true;
56 -
57 -       return false;
58 -#else
59 -       return true; /* cannot identify SoC */
60 -#endif
61 -}
62 -#endif
63 -
64  static int __init __cold dpa_load(void)
65  {
66         int      _errno;
67 @@ -1168,11 +1144,6 @@ static int __init __cold dpa_load(void)
68         dpa_max_frm = fm_get_max_frm();
69         dpa_num_cpus = num_possible_cpus();
70  
71 -#ifndef CONFIG_PPC
72 -       /* Detect if the current SoC requires the 4K alignment workaround */
73 -       dpaa_errata_a010022 = soc_has_errata_a010022();
74 -#endif
75 -
76  #ifdef CONFIG_FSL_DPAA_DBG_LOOP
77         memset(dpa_loop_netdevs, 0, sizeof(dpa_loop_netdevs));
78  #endif
79 --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.h
80 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.h
81 @@ -1,4 +1,5 @@
82  /* Copyright 2008-2012 Freescale Semiconductor Inc.
83 + * Copyright 2019 NXP
84   *
85   * Redistribution and use in source and binary forms, with or without
86   * modification, are permitted provided that the following conditions are met:
87 @@ -98,15 +99,15 @@ struct dpa_buffer_layout_s {
88   * space to account for further alignments.
89   */
90  #define DPA_MAX_FRM_SIZE       9600
91 -#ifdef CONFIG_PPC
92 +#ifndef FM_ERRATUM_A010022
93  #define DPA_BP_RAW_SIZE \
94         ((DPA_MAX_FRM_SIZE + DPA_MAX_FD_OFFSET + \
95           sizeof(struct skb_shared_info) + 128) & ~(SMP_CACHE_BYTES - 1))
96 -#else /* CONFIG_PPC */
97 -#define DPA_BP_RAW_SIZE ((unlikely(dpaa_errata_a010022)) ? 2048 : \
98 +#else /* FM_ERRATUM_A010022 */
99 +#define DPA_BP_RAW_SIZE ((unlikely(fm_has_errata_a010022())) ? 2048 : \
100         ((DPA_MAX_FRM_SIZE + DPA_MAX_FD_OFFSET + \
101           sizeof(struct skb_shared_info) + 128) & ~(SMP_CACHE_BYTES - 1)))
102 -#endif /* CONFIG_PPC */
103 +#endif /* FM_ERRATUM_A010022 */
104  #endif /* CONFIG_FSL_DPAA_ETH_JUMBO_FRAME */
105  
106  /* This is what FMan is ever allowed to use.
107 @@ -659,8 +660,7 @@ static inline void _dpa_bp_free_pf(void
108   * on egress.
109   */
110  
111 -#ifndef CONFIG_PPC
112 -extern bool dpaa_errata_a010022; /* SoC affected by A010022 errata */
113 +#ifdef FM_ERRATUM_A010022
114  #define CROSS_4K(start, size) \
115         (((uintptr_t)(start) + (size)) > \
116          (((uintptr_t)(start) + 0x1000) & ~0xFFF))
117 @@ -668,6 +668,6 @@ extern bool dpaa_errata_a010022; /* SoC
118   * we reserve 256 bytes instead to guarantee 256 data alignment.
119   */
120  #define DPAA_A010022_HEADROOM  256
121 -#endif  /* !CONFIG_PPC */
122 +#endif  /* FM_ERRATUM_A010022 */
123  
124  #endif /* __DPA_H */
125 --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c
126 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c
127 @@ -1,4 +1,5 @@
128  /* Copyright 2012 Freescale Semiconductor Inc.
129 + * Copyright 2019 NXP
130   *
131   * Redistribution and use in source and binary forms, with or without
132   * modification, are permitted provided that the following conditions are met:
133 @@ -100,8 +101,8 @@ static int _dpa_bp_add_8_bufs(const stru
134                  * We only need enough space to store a pointer, but allocate
135                  * an entire cacheline for performance reasons.
136                  */
137 -#ifndef CONFIG_PPC
138 -               if (unlikely(dpaa_errata_a010022)) {
139 +#ifdef FM_ERRATUM_A010022
140 +               if (unlikely(fm_has_errata_a010022())) {
141                         struct page *new_page = alloc_page(GFP_ATOMIC);
142                         if (unlikely(!new_page))
143                                 goto netdev_alloc_failed;
144 @@ -764,7 +765,7 @@ int __hot skb_to_contig_fd(struct dpa_pr
145  }
146  EXPORT_SYMBOL(skb_to_contig_fd);
147  
148 -#ifndef CONFIG_PPC
149 +#ifdef FM_ERRATUM_A010022
150  /* Verify the conditions that trigger the A010022 errata:
151   * - 4K memory address boundary crossings when the data/SG fragments aren't
152   *   aligned to 256 bytes
153 @@ -940,8 +941,8 @@ int __hot skb_to_sg_fd(struct dpa_priv_s
154         /* Get a page frag to store the SGTable, or a full page if the errata
155          * is in place and we need to avoid crossing a 4k boundary.
156          */
157 -#ifndef CONFIG_PPC
158 -       if (unlikely(dpaa_errata_a010022)) {
159 +#ifdef FM_ERRATUM_A010022
160 +       if (unlikely(fm_has_errata_a010022())) {
161                 struct page *new_page = alloc_page(GFP_ATOMIC);
162  
163                 if (unlikely(!new_page))
164 @@ -1120,8 +1121,8 @@ int __hot dpa_tx_extended(struct sk_buff
165  
166         clear_fd(&fd);
167  
168 -#ifndef CONFIG_PPC
169 -       if (unlikely(dpaa_errata_a010022) && a010022_check_skb(skb, priv))
170 +#ifdef FM_ERRATUM_A010022
171 +       if (unlikely(fm_has_errata_a010022()) && a010022_check_skb(skb, priv))
172                 skb_need_wa = true;
173  #endif
174  
175 @@ -1193,12 +1194,12 @@ int __hot dpa_tx_extended(struct sk_buff
176                          * more fragments than we support. In this case,
177                          * we have no choice but to linearize it ourselves.
178                          */
179 -#ifndef CONFIG_PPC
180 +#ifdef FM_ERRATUM_A010022
181                         /* No point in linearizing the skb now if we are going
182                          * to realign and linearize it again further down due
183                          * to the A010022 errata
184                          */
185 -                       if (unlikely(dpaa_errata_a010022))
186 +                       if (unlikely(fm_has_errata_a010022()))
187                                 skb_need_wa = true;
188                         else
189  #endif
190 @@ -1208,15 +1209,15 @@ int __hot dpa_tx_extended(struct sk_buff
191                         /* Common out-of-memory error path */
192                         goto enomem;
193  
194 -#ifndef CONFIG_PPC
195 +#ifdef FM_ERRATUM_A010022
196                 /* Verify the skb a second time if it has been updated since
197                  * the previous check
198                  */
199 -               if (unlikely(dpaa_errata_a010022) && skb_changed &&
200 +               if (unlikely(fm_has_errata_a010022()) && skb_changed &&
201                     a010022_check_skb(skb, priv))
202                         skb_need_wa = true;
203  
204 -               if (unlikely(dpaa_errata_a010022) && skb_need_wa) {
205 +               if (unlikely(fm_has_errata_a010022()) && skb_need_wa) {
206                         nskb = a010022_realign_skb(skb, priv);
207                         if (!nskb)
208                                 goto skb_to_fd_failed;
209 --- a/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/LS1043/dpaa_integration_ext.h
210 +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/LS1043/dpaa_integration_ext.h
211 @@ -1,5 +1,6 @@
212  /*
213   * Copyright 2012 Freescale Semiconductor Inc.
214 + * Copyright 2019 NXP
215   *
216   * Redistribution and use in source and binary forms, with or without
217   * modification, are permitted provided that the following conditions are met:
218 @@ -270,6 +271,8 @@ typedef enum
219  #define FM_AID_MODE_NO_TNUM_SW005 /* refer to pdm TKT068794 - only support of port_id on aid */
220  #define FM_ERROR_VSP_NO_MATCH_SW006 /* refer to pdm TKT174304 - no match between errorQ and VSP */
221  
222 +#define FM_ERRATUM_A010022
223 +
224  /*****************************************************************************
225   RMan INTEGRATION-SPECIFIC DEFINITIONS
226  ******************************************************************************/
227 --- a/drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h
228 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h
229 @@ -1,5 +1,6 @@
230  /*
231   * Copyright 2008-2012 Freescale Semiconductor Inc.
232 + * Copyright 2019 NXP
233   *
234   * Redistribution and use in source and binary forms, with or without
235   * modification, are permitted provided that the following conditions are met:
236 @@ -489,6 +490,15 @@ int fm_get_max_frm(void);
237  int fm_get_rx_extra_headroom(void);
238  
239  /**************************************************************************//**
240 + @Function     fm_has_errata_a010022
241 +
242 + @Description   Detect if the SoC is vulnerable to the A010022 errata
243 +*//***************************************************************************/
244 +#ifdef FM_ERRATUM_A010022
245 +bool fm_has_errata_a010022(void);
246 +#endif
247 +
248 +/**************************************************************************//**
249  @Function     fm_port_set_rate_limit
250  
251  @Description  Configure Shaper parameter on FM-port device (Tx port).
252 --- a/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm.c
253 +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm.c
254 @@ -1,5 +1,6 @@
255  /*
256   * Copyright 2008-2012 Freescale Semiconductor Inc.
257 + * Copyright 2019 NXP
258   *
259   * Redistribution and use in source and binary forms, with or without
260   * modification, are permitted provided that the following conditions are met:
261 @@ -155,6 +156,10 @@ static int fsl_fm_pfc_quanta[] = {
262  
263  static t_LnxWrpFm   lnxWrpFm;
264  
265 +#ifdef FM_ERRATUM_A010022
266 +static bool fm_has_err_a010022;
267 +#endif
268 +
269  int fm_get_max_frm()
270  {
271         return fsl_fm_max_frm;
272 @@ -167,6 +172,14 @@ int fm_get_rx_extra_headroom()
273  }
274  EXPORT_SYMBOL(fm_get_rx_extra_headroom);
275  
276 +#ifdef FM_ERRATUM_A010022
277 +bool fm_has_errata_a010022(void)
278 +{
279 +       return fm_has_err_a010022;
280 +}
281 +EXPORT_SYMBOL(fm_has_errata_a010022);
282 +#endif
283 +
284  static int __init fm_set_max_frm(char *str)
285  {
286         int ret = 0;
287 @@ -749,6 +762,10 @@ static t_LnxWrpFmDev * ReadFmDevTreeNode
288              p_LnxWrpFmDev->defPcd = e_NO_PCD;
289      }
290  
291 +#ifdef FM_ERRATUM_A010022
292 +    fm_has_err_a010022 = of_property_read_bool(fm_node, "fsl,erratum-a010022");
293 +#endif
294 +
295      of_node_put(fm_node);
296  
297      p_LnxWrpFmDev->hcCh =