aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-5.4/701-net-0360-sdk_dpaa-sdk_fman-ls1043a-errata-detect-based-on-DTB.patch
blob: e9e5ae03dd800d4f4dc148e39829f4679b6a44f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
From 6dbf409f09fd85d738652c7867a5822f682d5682 Mon Sep 17 00:00:00 2001
From: Camelia Groza <camelia.groza@nxp.com>
Date: Thu, 12 Dec 2019 14:15:05 +0200
Subject: [PATCH] sdk_dpaa: sdk_fman: ls1043a errata: detect based on DTB
 property

Detect if the platform is vulnerable to the A010022 erratum based on device
tree properties instead of the SoC family.

Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
---
 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c | 31 +---------------------
 drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.h | 14 +++++-----
 .../net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c  | 25 ++++++++---------
 .../inc/integrations/LS1043/dpaa_integration_ext.h |  3 +++
 .../sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h     | 10 +++++++
 .../freescale/sdk_fman/src/wrapper/lnxwrp_fm.c     | 17 ++++++++++++
 6 files changed, 51 insertions(+), 49 deletions(-)

--- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c
@@ -1,4 +1,5 @@
 /* Copyright 2008-2013 Freescale Semiconductor Inc.
+ * Copyright 2019 NXP
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -105,11 +106,6 @@ static const char rtx[][3] = {
 	[TX] = "TX"
 };
 
-#ifndef CONFIG_PPC
-bool dpaa_errata_a010022;
-EXPORT_SYMBOL(dpaa_errata_a010022);
-#endif
-
 /* BM */
 
 #define DPAA_ETH_MAX_PAD (L1_CACHE_BYTES * 8)
@@ -1133,26 +1129,6 @@ static struct platform_driver dpa_driver
 	.remove		= dpa_remove
 };
 
-#ifndef CONFIG_PPC
-static bool __init __cold soc_has_errata_a010022(void)
-{
-#ifdef CONFIG_SOC_BUS
-	const struct soc_device_attribute soc_msi_matches[] = {
-		{ .family = "QorIQ LS1043A",
-		  .data = NULL },
-		{ },
-	};
-
-	if (soc_device_match(soc_msi_matches))
-		return true;
-
-	return false;
-#else
-	return true; /* cannot identify SoC */
-#endif
-}
-#endif
-
 static int __init __cold dpa_load(void)
 {
 	int	 _errno;
@@ -1168,11 +1144,6 @@ static int __init __cold dpa_load(void)
 	dpa_max_frm = fm_get_max_frm();
 	dpa_num_cpus = num_possible_cpus();
 
-#ifndef CONFIG_PPC
-	/* Detect if the current SoC requires the 4K alignment workaround */
-	dpaa_errata_a010022 = soc_has_errata_a010022();
-#endif
-
 #ifdef CONFIG_FSL_DPAA_DBG_LOOP
 	memset(dpa_loop_netdevs, 0, sizeof(dpa_loop_netdevs));
 #endif
--- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.h
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.h
@@ -1,4 +1,5 @@
 /* Copyright 2008-2012 Freescale Semiconductor Inc.
+ * Copyright 2019 NXP
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -98,15 +99,15 @@ struct dpa_buffer_layout_s {
  * space to account for further alignments.
  */
 #define DPA_MAX_FRM_SIZE	9600
-#ifdef CONFIG_PPC
+#ifndef FM_ERRATUM_A010022
 #define DPA_BP_RAW_SIZE \
 	((DPA_MAX_FRM_SIZE + DPA_MAX_FD_OFFSET + \
 	  sizeof(struct skb_shared_info) + 128) & ~(SMP_CACHE_BYTES - 1))
-#else /* CONFIG_PPC */
-#define DPA_BP_RAW_SIZE ((unlikely(dpaa_errata_a010022)) ? 2048 : \
+#else /* FM_ERRATUM_A010022 */
+#define DPA_BP_RAW_SIZE ((unlikely(fm_has_errata_a010022())) ? 2048 : \
 	((DPA_MAX_FRM_SIZE + DPA_MAX_FD_OFFSET + \
 	  sizeof(struct skb_shared_info) + 128) & ~(SMP_CACHE_BYTES - 1)))
-#endif /* CONFIG_PPC */
+#endif /* FM_ERRATUM_A010022 */
 #endif /* CONFIG_FSL_DPAA_ETH_JUMBO_FRAME */
 
 /* This is what FMan is ever allowed to use.
@@ -659,8 +660,7 @@ static inline void _dpa_bp_free_pf(void
  * on egress.
  */
 
-#ifndef CONFIG_PPC
-extern bool dpaa_errata_a010022; /* SoC affected by A010022 errata */
+#ifdef FM_ERRATUM_A010022
 #define CROSS_4K(start, size) \
 	(((uintptr_t)(start) + (size)) > \
 	 (((uintptr_t)(start) + 0x1000) & ~0xFFF))
@@ -668,6 +668,6 @@ extern bool dpaa_errata_a010022; /* SoC
  * we reserve 256 bytes instead to guarantee 256 data alignment.
  */
 #define DPAA_A010022_HEADROOM	256
-#endif  /* !CONFIG_PPC */
+#endif  /* FM_ERRATUM_A010022 */
 
 #endif	/* __DPA_H */
--- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c
@@ -1,4 +1,5 @@
 /* Copyright 2012 Freescale Semiconductor Inc.
+ * Copyright 2019 NXP
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -100,8 +101,8 @@ static int _dpa_bp_add_8_bufs(const stru
 		 * We only need enough space to store a pointer, but allocate
 		 * an entire cacheline for performance reasons.
 		 */
-#ifndef CONFIG_PPC
-		if (unlikely(dpaa_errata_a010022)) {
+#ifdef FM_ERRATUM_A010022
+		if (unlikely(fm_has_errata_a010022())) {
 			struct page *new_page = alloc_page(GFP_ATOMIC);
 			if (unlikely(!new_page))
 				goto netdev_alloc_failed;
@@ -764,7 +765,7 @@ int __hot skb_to_contig_fd(struct dpa_pr
 }
 EXPORT_SYMBOL(skb_to_contig_fd);
 
-#ifndef CONFIG_PPC
+#ifdef FM_ERRATUM_A010022
 /* Verify the conditions that trigger the A010022 errata:
  * - 4K memory address boundary crossings when the data/SG fragments aren't
  *   aligned to 256 bytes
@@ -940,8 +941,8 @@ int __hot skb_to_sg_fd(struct dpa_priv_s
 	/* Get a page frag to store the SGTable, or a full page if the errata
 	 * is in place and we need to avoid crossing a 4k boundary.
 	 */
-#ifndef CONFIG_PPC
-	if (unlikely(dpaa_errata_a010022)) {
+#ifdef FM_ERRATUM_A010022
+	if (unlikely(fm_has_errata_a010022())) {
 		struct page *new_page = alloc_page(GFP_ATOMIC);
 
 		if (unlikely(!new_page))
@@ -1120,8 +1121,8 @@ int __hot dpa_tx_extended(struct sk_buff
 
 	clear_fd(&fd);
 
-#ifndef CONFIG_PPC
-	if (unlikely(dpaa_errata_a010022) && a010022_check_skb(skb, priv))
+#ifdef FM_ERRATUM_A010022
+	if (unlikely(fm_has_errata_a010022()) && a010022_check_skb(skb, priv))
 		skb_need_wa = true;
 #endif
 
@@ -1193,12 +1194,12 @@ int __hot dpa_tx_extended(struct sk_buff
 			 * more fragments than we support. In this case,
 			 * we have no choice but to linearize it ourselves.
 			 */
-#ifndef CONFIG_PPC
+#ifdef FM_ERRATUM_A010022
 			/* No point in linearizing the skb now if we are going
 			 * to realign and linearize it again further down due
 			 * to the A010022 errata
 			 */
-			if (unlikely(dpaa_errata_a010022))
+			if (unlikely(fm_has_errata_a010022()))
 				skb_need_wa = true;
 			else
 #endif
@@ -1208,15 +1209,15 @@ int __hot dpa_tx_extended(struct sk_buff
 			/* Common out-of-memory error path */
 			goto enomem;
 
-#ifndef CONFIG_PPC
+#ifdef FM_ERRATUM_A010022
 		/* Verify the skb a second time if it has been updated since
 		 * the previous check
 		 */
-		if (unlikely(dpaa_errata_a010022) && skb_changed &&
+		if (unlikely(fm_has_errata_a010022()) && skb_changed &&
 		    a010022_check_skb(skb, priv))
 			skb_need_wa = true;
 
-		if (unlikely(dpaa_errata_a010022) && skb_need_wa) {
+		if (unlikely(fm_has_errata_a010022()) && skb_need_wa) {
 			nskb = a010022_realign_skb(skb, priv);
 			if (!nskb)
 				goto skb_to_fd_failed;
--- a/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/LS1043/dpaa_integration_ext.h
+++ b/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/LS1043/dpaa_integration_ext.h
@@ -1,5 +1,6 @@
 /*
  * Copyright 2012 Freescale Semiconductor Inc.
+ * Copyright 2019 NXP
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -270,6 +271,8 @@ typedef enum
 #define FM_AID_MODE_NO_TNUM_SW005 /* refer to pdm TKT068794 - only support of port_id on aid */
 #define FM_ERROR_VSP_NO_MATCH_SW006 /* refer to pdm TKT174304 - no match between errorQ and VSP */
 
+#define FM_ERRATUM_A010022
+
 /*****************************************************************************
  RMan INTEGRATION-SPECIFIC DEFINITIONS
 ******************************************************************************/
--- a/drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h
+++ b/drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h
@@ -1,5 +1,6 @@
 /*
  * Copyright 2008-2012 Freescale Semiconductor Inc.
+ * Copyright 2019 NXP
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -489,6 +490,15 @@ int fm_get_max_frm(void);
 int fm_get_rx_extra_headroom(void);
 
 /**************************************************************************//**
+ @Function	fm_has_errata_a010022
+
+ @Description   Detect if the SoC is vulnerable to the A010022 errata
+*//***************************************************************************/
+#ifdef FM_ERRATUM_A010022
+bool fm_has_errata_a010022(void);
+#endif
+
+/**************************************************************************//**
 @Function     fm_port_set_rate_limit
 
 @Description  Configure Shaper parameter on FM-port device (Tx port).
--- a/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm.c
@@ -1,5 +1,6 @@
 /*
  * Copyright 2008-2012 Freescale Semiconductor Inc.
+ * Copyright 2019 NXP
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -155,6 +156,10 @@ static int fsl_fm_pfc_quanta[] = {
 
 static t_LnxWrpFm   lnxWrpFm;
 
+#ifdef FM_ERRATUM_A010022
+static bool fm_has_err_a010022;
+#endif
+
 int fm_get_max_frm()
 {
 	return fsl_fm_max_frm;
@@ -167,6 +172,14 @@ int fm_get_rx_extra_headroom()
 }
 EXPORT_SYMBOL(fm_get_rx_extra_headroom);
 
+#ifdef FM_ERRATUM_A010022
+bool fm_has_errata_a010022(void)
+{
+	return fm_has_err_a010022;
+}
+EXPORT_SYMBOL(fm_has_errata_a010022);
+#endif
+
 static int __init fm_set_max_frm(char *str)
 {
 	int ret = 0;
@@ -749,6 +762,10 @@ static t_LnxWrpFmDev * ReadFmDevTreeNode
             p_LnxWrpFmDev->defPcd = e_NO_PCD;
     }
 
+#ifdef FM_ERRATUM_A010022
+    fm_has_err_a010022 = of_property_read_bool(fm_node, "fsl,erratum-a010022");
+#endif
+
     of_node_put(fm_node);
 
     p_LnxWrpFmDev->hcCh =