aboutsummaryrefslogtreecommitdiff
path: root/resources/libreboot/patch/kgpe-d16/0102-cpu-amd-family_10h-family_15h-Set-up-link-XCS-token-.patch
blob: 086b9e44a0fdc281b97cf8158dba5b4d639e344c (plain) (blame)
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
From 89f102b6b680c94a31ff812bba7be5016e15580a Mon Sep 17 00:00:00 2001
From: Timothy Pearson <tpearson@raptorengineeringinc.com>
Date: Fri, 7 Aug 2015 23:59:17 -0500
Subject: [PATCH 102/143] cpu/amd/family_10h-family_15h: Set up link XCS token
 counts on Family 15h

Change-Id: I4cf6549234041c395a18a89332d95f20a596fc3e
Signed-off-by: Timothy Pearson <tpearson@raptorengineeringinc.com>
---
 src/cpu/amd/family_10h-family_15h/init_cpus.c |  304 +++++++++++++++++++++++++
 1 file changed, 304 insertions(+)

diff --git a/src/cpu/amd/family_10h-family_15h/init_cpus.c b/src/cpu/amd/family_10h-family_15h/init_cpus.c
index 67893ca1..e93c15b 100644
--- a/src/cpu/amd/family_10h-family_15h/init_cpus.c
+++ b/src/cpu/amd/family_10h-family_15h/init_cpus.c
@@ -1057,6 +1057,12 @@ static void cpuSetAMDPCI(u8 node)
 	uint32_t dword;
 	uint64_t revision;
 
+	/* FIXME
+	 * This should be configurable
+	 */
+	uint8_t sockets = 2;
+	uint8_t sockets_populated = 2;
+
 	printk(BIOS_DEBUG, "cpuSetAMDPCI %02d", node);
 
 	revision = mctGetLogicalCPUID(node);
@@ -1163,6 +1169,15 @@ static void cpuSetAMDPCI(u8 node)
 		uint8_t compute_unit_count = 0;
 		uint8_t compute_unit_buffer_count;
 
+		uint32_t f3xe8;
+		uint8_t dual_node = 0;
+
+		f3xe8 = pci_read_config32(NODE_PCI(0, 3), 0xe8);
+
+		/* Check for dual node capability */
+		if (f3xe8 & 0x20000000)
+			dual_node = 1;
+
 		/* Determine the number of active compute units on this node */
 		f5x80 = pci_read_config32(NODE_PCI(node, 5), 0x80);
 		cu_enabled = f5x80 & 0xf;
@@ -1188,6 +1203,295 @@ static void cpuSetAMDPCI(u8 node)
 		dword &= ~(0x1f << 4);			/* L3FreeListCBC = compute_unit_buffer_count */
 		dword |= (compute_unit_buffer_count << 4);
 		pci_write_config32(NODE_PCI(node, 3), 0x1a0, dword);
+
+		/* Set up the Link to XCS Token Counts */
+		uint8_t isoc_rsp_tok_1;
+		uint8_t isoc_preq_tok_1;
+		uint8_t isoc_req_tok_1;
+		uint8_t probe_tok_1;
+		uint8_t rsp_tok_1;
+		uint8_t preq_tok_1;
+		uint8_t req_tok_1;
+		uint8_t isoc_rsp_tok_0;
+		uint8_t isoc_preq_tok_0;
+		uint8_t isoc_req_tok_0;
+		uint8_t free_tokens;
+		uint8_t probe_tok_0;
+		uint8_t rsp_tok_0;
+		uint8_t preq_tok_0;
+		uint8_t req_tok_0;
+
+		uint8_t link;
+		uint8_t ganged;
+		uint8_t iolink;
+		uint8_t probe_filter_enabled = !!dual_node;
+		for (link = 0; link < 4; link++) {
+			if (AMD_CpuFindCapability(node, link, &offset)) {
+				ganged = !!(pci_read_config32(NODE_PCI(node, 0), (link << 2) + 0x170) & 0x1);
+				iolink = (AMD_checkLinkType(node, link, offset) & HTPHY_LINKTYPE_NONCOHERENT);
+
+				/* Set defaults */
+				isoc_rsp_tok_1 = 0;
+				isoc_preq_tok_1 = 0;
+				isoc_req_tok_1 = 0;
+				probe_tok_1 = !ganged;
+				rsp_tok_1 = !ganged;
+				preq_tok_1 = !ganged;
+				req_tok_1 = !ganged;
+				isoc_rsp_tok_0 = 0;
+				isoc_preq_tok_0 = 0;
+				isoc_req_tok_0 = 0;
+				free_tokens = 0;
+				probe_tok_0 = ((ganged)?2:1);
+				rsp_tok_0 = ((ganged)?2:1);
+				preq_tok_0 = ((ganged)?2:1);
+				req_tok_0 = ((ganged)?2:1);
+
+				if (!iolink && ganged) {
+					if (!dual_node) {
+						isoc_rsp_tok_1 = 0;
+						isoc_preq_tok_1 = 0;
+						isoc_req_tok_1 = 0;
+						probe_tok_1 = 0;
+						rsp_tok_1 = 0;
+						preq_tok_1 = 0;
+						req_tok_1 = 0;
+						isoc_rsp_tok_0 = 0;
+						isoc_preq_tok_0 = 0;
+						isoc_req_tok_0 = 1;
+						free_tokens = 3;
+						probe_tok_0 = 2;
+						rsp_tok_0 = 2;
+						preq_tok_0 = 2;
+						req_tok_0 = 2;
+					} else {
+						if ((sockets == 1)
+							|| ((sockets == 2) && (sockets_populated == 1))) {
+							isoc_rsp_tok_1 = 0;
+							isoc_preq_tok_1 = 0;
+							isoc_req_tok_1 = 0;
+							probe_tok_1 = 0;
+							rsp_tok_1 = 0;
+							preq_tok_1 = 0;
+							req_tok_1 = 0;
+							isoc_rsp_tok_0 = 0;
+							isoc_preq_tok_0 = 0;
+							isoc_req_tok_0 = 1;
+							free_tokens = 0;
+							probe_tok_0 = 2;
+							rsp_tok_0 = 2;
+							preq_tok_0 = 2;
+							req_tok_0 = 2;
+						} else if (((sockets == 2) && (sockets_populated == 2))
+							|| ((sockets == 4) && (sockets_populated == 2))) {
+							isoc_rsp_tok_1 = 0;
+							isoc_preq_tok_1 = 0;
+							isoc_req_tok_1 = 0;
+							probe_tok_1 = 0;
+							rsp_tok_1 = 0;
+							preq_tok_1 = 0;
+							req_tok_1 = 0;
+							isoc_rsp_tok_0 = 0;
+							isoc_preq_tok_0 = 0;
+							isoc_req_tok_0 = 1;
+							free_tokens = 0;
+							probe_tok_0 = 1;
+							rsp_tok_0 = 2;
+							preq_tok_0 = 2;
+							req_tok_0 = 2;
+						} else if ((sockets == 4) && (sockets_populated == 4)) {
+							isoc_rsp_tok_1 = 0;
+							isoc_preq_tok_1 = 0;
+							isoc_req_tok_1 = 0;
+							probe_tok_1 = 0;
+							rsp_tok_1 = 0;
+							preq_tok_1 = 0;
+							req_tok_1 = 0;
+							isoc_rsp_tok_0 = 0;
+							isoc_preq_tok_0 = 0;
+							isoc_req_tok_0 = 1;
+							free_tokens = 0;
+							probe_tok_0 = 2;
+							rsp_tok_0 = 1;
+							preq_tok_0 = 1;
+							req_tok_0 = 2;
+						}
+					}
+				} else if (!iolink && !ganged) {
+					if ((sockets == 1)
+						|| ((sockets == 2) && (sockets_populated == 1))) {
+						if (probe_filter_enabled) {
+							isoc_rsp_tok_1 = 0;
+							isoc_preq_tok_1 = 0;
+							isoc_req_tok_1 = 0;
+							probe_tok_1 = 1;
+							rsp_tok_1 = 1;
+							preq_tok_1 = 1;
+							req_tok_1 = 1;
+							isoc_rsp_tok_0 = 0;
+							isoc_preq_tok_0 = 0;
+							isoc_req_tok_0 = 1;
+							free_tokens = 0;
+							probe_tok_0 = 1;
+							rsp_tok_0 = 2;
+							preq_tok_0 = 1;
+							req_tok_0 = 1;
+						} else {
+							isoc_rsp_tok_1 = 0;
+							isoc_preq_tok_1 = 0;
+							isoc_req_tok_1 = 0;
+							probe_tok_1 = 1;
+							rsp_tok_1 = 1;
+							preq_tok_1 = 1;
+							req_tok_1 = 1;
+							isoc_rsp_tok_0 = 0;
+							isoc_preq_tok_0 = 0;
+							isoc_req_tok_0 = 1;
+							free_tokens = 0;
+							probe_tok_0 = 1;
+							rsp_tok_0 = 1;
+							preq_tok_0 = 1;
+							req_tok_0 = 1;
+						}
+					} else if ((sockets == 2) && (sockets_populated == 2)) {
+						isoc_rsp_tok_1 = 0;
+						isoc_preq_tok_1 = 0;
+						isoc_req_tok_1 = 1;
+						probe_tok_1 = 1;
+						rsp_tok_1 = 1;
+						preq_tok_1 = 1;
+						req_tok_1 = 1;
+						isoc_rsp_tok_0 = 0;
+						isoc_preq_tok_0 = 0;
+						isoc_req_tok_0 = 1;
+						free_tokens = 2;
+						probe_tok_0 = 1;
+						rsp_tok_0 = 1;
+						preq_tok_0 = 1;
+						req_tok_0 = 1;
+					} else if ((sockets == 4) && (sockets_populated == 2)) {
+						isoc_rsp_tok_1 = 0;
+						isoc_preq_tok_1 = 0;
+						isoc_req_tok_1 = 1;
+						probe_tok_1 = 1;
+						rsp_tok_1 = 1;
+						preq_tok_1 = 1;
+						req_tok_1 = 1;
+						isoc_rsp_tok_0 = 0;
+						isoc_preq_tok_0 = 0;
+						isoc_req_tok_0 = 1;
+						free_tokens = 4;
+						probe_tok_0 = 1;
+						rsp_tok_0 = 1;
+						preq_tok_0 = 1;
+						req_tok_0 = 1;
+					} else if ((sockets == 4) && (sockets_populated == 4)) {
+						isoc_rsp_tok_1 = 0;
+						isoc_preq_tok_1 = 0;
+						isoc_req_tok_1 = 1;
+						probe_tok_1 = 1;
+						rsp_tok_1 = 1;
+						preq_tok_1 = 1;
+						req_tok_1 = 1;
+						isoc_rsp_tok_0 = 0;
+						isoc_preq_tok_0 = 0;
+						isoc_req_tok_0 = 1;
+						free_tokens = 0;
+						probe_tok_0 = 1;
+						rsp_tok_0 = 1;
+						preq_tok_0 = 1;
+						req_tok_0 = 1;
+					}
+				} else if (iolink && ganged) {
+					if (!dual_node) {
+						isoc_rsp_tok_1 = 0;
+						isoc_preq_tok_1 = 0;
+						isoc_req_tok_1 = 0;
+						probe_tok_1 = 0;
+						rsp_tok_1 = 0;
+						preq_tok_1 = 0;
+						req_tok_1 = 0;
+						isoc_rsp_tok_0 = 0;
+						isoc_preq_tok_0 = 0;
+						isoc_req_tok_0 = 1;
+						free_tokens = 3;
+						probe_tok_0 = 0;
+						rsp_tok_0 = 2;
+						preq_tok_0 = 2;
+						req_tok_0 = 2;
+					} else if ((sockets == 1)
+						|| (sockets == 2)
+						|| ((sockets == 4) && (sockets_populated == 2))) {
+						isoc_rsp_tok_1 = 0;
+						isoc_preq_tok_1 = 0;
+						isoc_req_tok_1 = 0;
+						probe_tok_1 = 0;
+						rsp_tok_1 = 0;
+						preq_tok_1 = 0;
+						req_tok_1 = 0;
+						isoc_rsp_tok_0 = 0;
+						isoc_preq_tok_0 = 0;
+						isoc_req_tok_0 = 1;
+						free_tokens = 0;
+						probe_tok_0 = 0;
+						rsp_tok_0 = 2;
+						preq_tok_0 = 2;
+						req_tok_0 = 2;
+					} else if ((sockets == 4) && (sockets_populated == 4)) {
+						isoc_rsp_tok_1 = 0;
+						isoc_preq_tok_1 = 0;
+						isoc_req_tok_1 = 0;
+						probe_tok_1 = 0;
+						rsp_tok_1 = 0;
+						preq_tok_1 = 0;
+						req_tok_1 = 0;
+						isoc_rsp_tok_0 = 0;
+						isoc_preq_tok_0 = 0;
+						isoc_req_tok_0 = 2;
+						free_tokens = 0;
+						probe_tok_0 = 2;
+						rsp_tok_0 = 2;
+						preq_tok_0 = 2;
+						req_tok_0 = 2;
+					}
+				}
+
+				dword = pci_read_config32(NODE_PCI(node, 3), (link << 2) + 0x148);
+				dword &= ~(0x3 << 30);			/* FreeTok[3:2] = free_tokens[3:2] */
+				dword |= (((free_tokens >> 2) & 0x3) << 30);
+				dword &= ~(0x1 << 28);			/* IsocRspTok1 = isoc_rsp_tok_1 */
+				dword |= (((isoc_rsp_tok_1) & 0x1) << 28);
+				dword &= ~(0x1 << 26);			/* IsocPreqTok1 = isoc_preq_tok_1 */
+				dword |= (((isoc_preq_tok_1) & 0x1) << 26);
+				dword &= ~(0x1 << 24);			/* IsocReqTok1 = isoc_req_tok_1 */
+				dword |= (((isoc_req_tok_1) & 0x1) << 24);
+				dword &= ~(0x3 << 22);			/* ProbeTok1 = probe_tok_1 */
+				dword |= (((probe_tok_1) & 0x3) << 22);
+				dword &= ~(0x3 << 20);			/* RspTok1 = rsp_tok_1 */
+				dword |= (((rsp_tok_1) & 0x3) << 20);
+				dword &= ~(0x3 << 18);			/* PReqTok1 = preq_tok_1 */
+				dword |= (((preq_tok_1) & 0x3) << 18);
+				dword &= ~(0x3 << 16);			/* ReqTok1 = req_tok_1 */
+				dword |= (((req_tok_1) & 0x3) << 16);
+				dword &= ~(0x3 << 14);			/* FreeTok[1:0] = free_tokens[1:0] */
+				dword |= (((free_tokens) & 0x3) << 14);
+				dword &= ~(0x3 << 12);			/* IsocRspTok0 = isoc_rsp_tok_0 */
+				dword |= (((isoc_rsp_tok_0) & 0x3) << 12);
+				dword &= ~(0x3 << 10);			/* IsocPreqTok0 = isoc_preq_tok_0 */
+				dword |= (((isoc_preq_tok_0) & 0x3) << 10);
+				dword &= ~(0x3 << 8);			/* IsocReqTok0 = isoc_req_tok_0 */
+				dword |= (((isoc_req_tok_0) & 0x3) << 8);
+				dword &= ~(0x3 << 6);			/* ProbeTok0 = probe_tok_0 */
+				dword |= (((probe_tok_0) & 0x3) << 6);
+				dword &= ~(0x3 << 4);			/* RspTok0 = rsp_tok_0 */
+				dword |= (((rsp_tok_0) & 0x3) << 4);
+				dword &= ~(0x3 << 2);			/* PReqTok0 = preq_tok_0 */
+				dword |= (((preq_tok_0) & 0x3) << 2);
+				dword &= ~(0x3 << 0);			/* ReqTok0 = req_tok_0 */
+				dword |= (((req_tok_0) & 0x3) << 0);
+				pci_write_config32(NODE_PCI(node, 3), (link << 2) + 0x148, dword);
+			}
+		}
 	}
 
 	printk(BIOS_DEBUG, " done\n");
-- 
1.7.9.5