12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
2444c4ba4SChristophe Lombard /*
3444c4ba4SChristophe Lombard * Copyright 2015 IBM Corp.
4444c4ba4SChristophe Lombard */
5444c4ba4SChristophe Lombard
6444c4ba4SChristophe Lombard
7444c4ba4SChristophe Lombard #include <linux/compiler.h>
8444c4ba4SChristophe Lombard #include <linux/types.h>
9444c4ba4SChristophe Lombard #include <linux/delay.h>
10444c4ba4SChristophe Lombard #include <asm/byteorder.h>
11444c4ba4SChristophe Lombard #include "hcalls.h"
12e7a801adSChristophe Lombard #include "trace.h"
13444c4ba4SChristophe Lombard
14444c4ba4SChristophe Lombard #define CXL_HCALL_TIMEOUT 60000
15444c4ba4SChristophe Lombard #define CXL_HCALL_TIMEOUT_DOWNLOAD 120000
16444c4ba4SChristophe Lombard
17444c4ba4SChristophe Lombard #define H_ATTACH_CA_PROCESS 0x344
18444c4ba4SChristophe Lombard #define H_CONTROL_CA_FUNCTION 0x348
19444c4ba4SChristophe Lombard #define H_DETACH_CA_PROCESS 0x34C
20444c4ba4SChristophe Lombard #define H_COLLECT_CA_INT_INFO 0x350
21444c4ba4SChristophe Lombard #define H_CONTROL_CA_FAULTS 0x354
22444c4ba4SChristophe Lombard #define H_DOWNLOAD_CA_FUNCTION 0x35C
23444c4ba4SChristophe Lombard #define H_DOWNLOAD_CA_FACILITY 0x364
24444c4ba4SChristophe Lombard #define H_CONTROL_CA_FACILITY 0x368
25444c4ba4SChristophe Lombard
26444c4ba4SChristophe Lombard #define H_CONTROL_CA_FUNCTION_RESET 1 /* perform a reset */
27444c4ba4SChristophe Lombard #define H_CONTROL_CA_FUNCTION_SUSPEND_PROCESS 2 /* suspend a process from being executed */
28444c4ba4SChristophe Lombard #define H_CONTROL_CA_FUNCTION_RESUME_PROCESS 3 /* resume a process to be executed */
29444c4ba4SChristophe Lombard #define H_CONTROL_CA_FUNCTION_READ_ERR_STATE 4 /* read the error state */
30444c4ba4SChristophe Lombard #define H_CONTROL_CA_FUNCTION_GET_AFU_ERR 5 /* collect the AFU error buffer */
31444c4ba4SChristophe Lombard #define H_CONTROL_CA_FUNCTION_GET_CONFIG 6 /* collect configuration record */
32444c4ba4SChristophe Lombard #define H_CONTROL_CA_FUNCTION_GET_DOWNLOAD_STATE 7 /* query to return download status */
33444c4ba4SChristophe Lombard #define H_CONTROL_CA_FUNCTION_TERMINATE_PROCESS 8 /* terminate the process before completion */
34444c4ba4SChristophe Lombard #define H_CONTROL_CA_FUNCTION_COLLECT_VPD 9 /* collect VPD */
35444c4ba4SChristophe Lombard #define H_CONTROL_CA_FUNCTION_GET_FUNCTION_ERR_INT 11 /* read the function-wide error data based on an interrupt */
36444c4ba4SChristophe Lombard #define H_CONTROL_CA_FUNCTION_ACK_FUNCTION_ERR_INT 12 /* acknowledge function-wide error data based on an interrupt */
37444c4ba4SChristophe Lombard #define H_CONTROL_CA_FUNCTION_GET_ERROR_LOG 13 /* retrieve the Platform Log ID (PLID) of an error log */
38444c4ba4SChristophe Lombard
39444c4ba4SChristophe Lombard #define H_CONTROL_CA_FAULTS_RESPOND_PSL 1
40444c4ba4SChristophe Lombard #define H_CONTROL_CA_FAULTS_RESPOND_AFU 2
41444c4ba4SChristophe Lombard
42444c4ba4SChristophe Lombard #define H_CONTROL_CA_FACILITY_RESET 1 /* perform a reset */
43444c4ba4SChristophe Lombard #define H_CONTROL_CA_FACILITY_COLLECT_VPD 2 /* collect VPD */
44444c4ba4SChristophe Lombard
45444c4ba4SChristophe Lombard #define H_DOWNLOAD_CA_FACILITY_DOWNLOAD 1 /* download adapter image */
46444c4ba4SChristophe Lombard #define H_DOWNLOAD_CA_FACILITY_VALIDATE 2 /* validate adapter image */
47444c4ba4SChristophe Lombard
48444c4ba4SChristophe Lombard
49444c4ba4SChristophe Lombard #define _CXL_LOOP_HCALL(call, rc, retbuf, fn, ...) \
50444c4ba4SChristophe Lombard { \
51444c4ba4SChristophe Lombard unsigned int delay, total_delay = 0; \
52444c4ba4SChristophe Lombard u64 token = 0; \
53444c4ba4SChristophe Lombard \
54444c4ba4SChristophe Lombard memset(retbuf, 0, sizeof(retbuf)); \
55444c4ba4SChristophe Lombard while (1) { \
56444c4ba4SChristophe Lombard rc = call(fn, retbuf, __VA_ARGS__, token); \
57444c4ba4SChristophe Lombard token = retbuf[0]; \
58444c4ba4SChristophe Lombard if (rc != H_BUSY && !H_IS_LONG_BUSY(rc)) \
59444c4ba4SChristophe Lombard break; \
60444c4ba4SChristophe Lombard \
61444c4ba4SChristophe Lombard if (rc == H_BUSY) \
62444c4ba4SChristophe Lombard delay = 10; \
63444c4ba4SChristophe Lombard else \
64444c4ba4SChristophe Lombard delay = get_longbusy_msecs(rc); \
65444c4ba4SChristophe Lombard \
66444c4ba4SChristophe Lombard total_delay += delay; \
67444c4ba4SChristophe Lombard if (total_delay > CXL_HCALL_TIMEOUT) { \
68444c4ba4SChristophe Lombard WARN(1, "Warning: Giving up waiting for CXL hcall " \
69444c4ba4SChristophe Lombard "%#x after %u msec\n", fn, total_delay); \
70444c4ba4SChristophe Lombard rc = H_BUSY; \
71444c4ba4SChristophe Lombard break; \
72444c4ba4SChristophe Lombard } \
73444c4ba4SChristophe Lombard msleep(delay); \
74444c4ba4SChristophe Lombard } \
75444c4ba4SChristophe Lombard }
76444c4ba4SChristophe Lombard #define CXL_H_WAIT_UNTIL_DONE(...) _CXL_LOOP_HCALL(plpar_hcall, __VA_ARGS__)
77444c4ba4SChristophe Lombard #define CXL_H9_WAIT_UNTIL_DONE(...) _CXL_LOOP_HCALL(plpar_hcall9, __VA_ARGS__)
78444c4ba4SChristophe Lombard
79444c4ba4SChristophe Lombard #define _PRINT_MSG(rc, format, ...) \
80444c4ba4SChristophe Lombard { \
81444c4ba4SChristophe Lombard if ((rc != H_SUCCESS) && (rc != H_CONTINUE)) \
82444c4ba4SChristophe Lombard pr_err(format, __VA_ARGS__); \
83444c4ba4SChristophe Lombard else \
84444c4ba4SChristophe Lombard pr_devel(format, __VA_ARGS__); \
85444c4ba4SChristophe Lombard } \
86444c4ba4SChristophe Lombard
87444c4ba4SChristophe Lombard
88444c4ba4SChristophe Lombard static char *afu_op_names[] = {
89444c4ba4SChristophe Lombard "UNKNOWN_OP", /* 0 undefined */
90444c4ba4SChristophe Lombard "RESET", /* 1 */
91444c4ba4SChristophe Lombard "SUSPEND_PROCESS", /* 2 */
92444c4ba4SChristophe Lombard "RESUME_PROCESS", /* 3 */
93444c4ba4SChristophe Lombard "READ_ERR_STATE", /* 4 */
94444c4ba4SChristophe Lombard "GET_AFU_ERR", /* 5 */
95444c4ba4SChristophe Lombard "GET_CONFIG", /* 6 */
96444c4ba4SChristophe Lombard "GET_DOWNLOAD_STATE", /* 7 */
97444c4ba4SChristophe Lombard "TERMINATE_PROCESS", /* 8 */
98444c4ba4SChristophe Lombard "COLLECT_VPD", /* 9 */
99444c4ba4SChristophe Lombard "UNKNOWN_OP", /* 10 undefined */
100444c4ba4SChristophe Lombard "GET_FUNCTION_ERR_INT", /* 11 */
101444c4ba4SChristophe Lombard "ACK_FUNCTION_ERR_INT", /* 12 */
102444c4ba4SChristophe Lombard "GET_ERROR_LOG", /* 13 */
103444c4ba4SChristophe Lombard };
104444c4ba4SChristophe Lombard
105444c4ba4SChristophe Lombard static char *control_adapter_op_names[] = {
106444c4ba4SChristophe Lombard "UNKNOWN_OP", /* 0 undefined */
107444c4ba4SChristophe Lombard "RESET", /* 1 */
108444c4ba4SChristophe Lombard "COLLECT_VPD", /* 2 */
109444c4ba4SChristophe Lombard };
110444c4ba4SChristophe Lombard
111444c4ba4SChristophe Lombard static char *download_op_names[] = {
112444c4ba4SChristophe Lombard "UNKNOWN_OP", /* 0 undefined */
113444c4ba4SChristophe Lombard "DOWNLOAD", /* 1 */
114444c4ba4SChristophe Lombard "VALIDATE", /* 2 */
115444c4ba4SChristophe Lombard };
116444c4ba4SChristophe Lombard
op_str(unsigned int op,char * name_array[],int array_len)117444c4ba4SChristophe Lombard static char *op_str(unsigned int op, char *name_array[], int array_len)
118444c4ba4SChristophe Lombard {
119444c4ba4SChristophe Lombard if (op >= array_len)
120444c4ba4SChristophe Lombard return "UNKNOWN_OP";
121444c4ba4SChristophe Lombard return name_array[op];
122444c4ba4SChristophe Lombard }
123444c4ba4SChristophe Lombard
124444c4ba4SChristophe Lombard #define OP_STR(op, name_array) op_str(op, name_array, ARRAY_SIZE(name_array))
125444c4ba4SChristophe Lombard
126444c4ba4SChristophe Lombard #define OP_STR_AFU(op) OP_STR(op, afu_op_names)
127444c4ba4SChristophe Lombard #define OP_STR_CONTROL_ADAPTER(op) OP_STR(op, control_adapter_op_names)
128444c4ba4SChristophe Lombard #define OP_STR_DOWNLOAD_ADAPTER(op) OP_STR(op, download_op_names)
129444c4ba4SChristophe Lombard
130444c4ba4SChristophe Lombard
cxl_h_attach_process(u64 unit_address,struct cxl_process_element_hcall * element,u64 * process_token,u64 * mmio_addr,u64 * mmio_size)131444c4ba4SChristophe Lombard long cxl_h_attach_process(u64 unit_address,
132444c4ba4SChristophe Lombard struct cxl_process_element_hcall *element,
133444c4ba4SChristophe Lombard u64 *process_token, u64 *mmio_addr, u64 *mmio_size)
134444c4ba4SChristophe Lombard {
135444c4ba4SChristophe Lombard unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
136444c4ba4SChristophe Lombard long rc;
137444c4ba4SChristophe Lombard
138444c4ba4SChristophe Lombard CXL_H_WAIT_UNTIL_DONE(rc, retbuf, H_ATTACH_CA_PROCESS, unit_address, virt_to_phys(element));
139444c4ba4SChristophe Lombard _PRINT_MSG(rc, "cxl_h_attach_process(%#.16llx, %#.16lx): %li\n",
140444c4ba4SChristophe Lombard unit_address, virt_to_phys(element), rc);
141e7a801adSChristophe Lombard trace_cxl_hcall_attach(unit_address, virt_to_phys(element), retbuf[0], retbuf[1], retbuf[2], rc);
142444c4ba4SChristophe Lombard
143444c4ba4SChristophe Lombard pr_devel("token: 0x%.8lx mmio_addr: 0x%lx mmio_size: 0x%lx\nProcess Element Structure:\n",
144444c4ba4SChristophe Lombard retbuf[0], retbuf[1], retbuf[2]);
145444c4ba4SChristophe Lombard cxl_dump_debug_buffer(element, sizeof(*element));
146444c4ba4SChristophe Lombard
147444c4ba4SChristophe Lombard switch (rc) {
148444c4ba4SChristophe Lombard case H_SUCCESS: /* The process info is attached to the coherent platform function */
149444c4ba4SChristophe Lombard *process_token = retbuf[0];
150444c4ba4SChristophe Lombard if (mmio_addr)
151444c4ba4SChristophe Lombard *mmio_addr = retbuf[1];
152444c4ba4SChristophe Lombard if (mmio_size)
153444c4ba4SChristophe Lombard *mmio_size = retbuf[2];
154444c4ba4SChristophe Lombard return 0;
155444c4ba4SChristophe Lombard case H_PARAMETER: /* An incorrect parameter was supplied. */
156444c4ba4SChristophe Lombard case H_FUNCTION: /* The function is not supported. */
157444c4ba4SChristophe Lombard return -EINVAL;
158444c4ba4SChristophe Lombard case H_AUTHORITY: /* The partition does not have authority to perform this hcall */
159444c4ba4SChristophe Lombard case H_RESOURCE: /* The coherent platform function does not have enough additional resource to attach the process */
160444c4ba4SChristophe Lombard case H_HARDWARE: /* A hardware event prevented the attach operation */
161444c4ba4SChristophe Lombard case H_STATE: /* The coherent platform function is not in a valid state */
162444c4ba4SChristophe Lombard case H_BUSY:
163444c4ba4SChristophe Lombard return -EBUSY;
164444c4ba4SChristophe Lombard default:
165444c4ba4SChristophe Lombard WARN(1, "Unexpected return code: %lx", rc);
166444c4ba4SChristophe Lombard return -EINVAL;
167444c4ba4SChristophe Lombard }
168444c4ba4SChristophe Lombard }
169444c4ba4SChristophe Lombard
170*b865c5b3SLee Jones /*
171444c4ba4SChristophe Lombard * cxl_h_detach_process - Detach a process element from a coherent
172444c4ba4SChristophe Lombard * platform function.
173444c4ba4SChristophe Lombard */
cxl_h_detach_process(u64 unit_address,u64 process_token)174444c4ba4SChristophe Lombard long cxl_h_detach_process(u64 unit_address, u64 process_token)
175444c4ba4SChristophe Lombard {
176444c4ba4SChristophe Lombard unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
177444c4ba4SChristophe Lombard long rc;
178444c4ba4SChristophe Lombard
179444c4ba4SChristophe Lombard CXL_H_WAIT_UNTIL_DONE(rc, retbuf, H_DETACH_CA_PROCESS, unit_address, process_token);
180444c4ba4SChristophe Lombard _PRINT_MSG(rc, "cxl_h_detach_process(%#.16llx, 0x%.8llx): %li\n", unit_address, process_token, rc);
181e7a801adSChristophe Lombard trace_cxl_hcall_detach(unit_address, process_token, rc);
182444c4ba4SChristophe Lombard
183444c4ba4SChristophe Lombard switch (rc) {
184444c4ba4SChristophe Lombard case H_SUCCESS: /* The process was detached from the coherent platform function */
185444c4ba4SChristophe Lombard return 0;
186444c4ba4SChristophe Lombard case H_PARAMETER: /* An incorrect parameter was supplied. */
187444c4ba4SChristophe Lombard return -EINVAL;
188444c4ba4SChristophe Lombard case H_AUTHORITY: /* The partition does not have authority to perform this hcall */
189444c4ba4SChristophe Lombard case H_RESOURCE: /* The function has page table mappings for MMIO */
190444c4ba4SChristophe Lombard case H_HARDWARE: /* A hardware event prevented the detach operation */
191444c4ba4SChristophe Lombard case H_STATE: /* The coherent platform function is not in a valid state */
192444c4ba4SChristophe Lombard case H_BUSY:
193444c4ba4SChristophe Lombard return -EBUSY;
194444c4ba4SChristophe Lombard default:
195444c4ba4SChristophe Lombard WARN(1, "Unexpected return code: %lx", rc);
196444c4ba4SChristophe Lombard return -EINVAL;
197444c4ba4SChristophe Lombard }
198444c4ba4SChristophe Lombard }
199444c4ba4SChristophe Lombard
200*b865c5b3SLee Jones /*
201444c4ba4SChristophe Lombard * cxl_h_control_function - This H_CONTROL_CA_FUNCTION hypervisor call allows
202444c4ba4SChristophe Lombard * the partition to manipulate or query
203444c4ba4SChristophe Lombard * certain coherent platform function behaviors.
204444c4ba4SChristophe Lombard */
cxl_h_control_function(u64 unit_address,u64 op,u64 p1,u64 p2,u64 p3,u64 p4,u64 * out)205444c4ba4SChristophe Lombard static long cxl_h_control_function(u64 unit_address, u64 op,
206444c4ba4SChristophe Lombard u64 p1, u64 p2, u64 p3, u64 p4, u64 *out)
207444c4ba4SChristophe Lombard {
208444c4ba4SChristophe Lombard unsigned long retbuf[PLPAR_HCALL9_BUFSIZE];
209444c4ba4SChristophe Lombard long rc;
210444c4ba4SChristophe Lombard
211444c4ba4SChristophe Lombard CXL_H9_WAIT_UNTIL_DONE(rc, retbuf, H_CONTROL_CA_FUNCTION, unit_address, op, p1, p2, p3, p4);
212444c4ba4SChristophe Lombard _PRINT_MSG(rc, "cxl_h_control_function(%#.16llx, %s(%#llx, %#llx, %#llx, %#llx, R4: %#lx)): %li\n",
213444c4ba4SChristophe Lombard unit_address, OP_STR_AFU(op), p1, p2, p3, p4, retbuf[0], rc);
214e7a801adSChristophe Lombard trace_cxl_hcall_control_function(unit_address, OP_STR_AFU(op), p1, p2, p3, p4, retbuf[0], rc);
215444c4ba4SChristophe Lombard
216444c4ba4SChristophe Lombard switch (rc) {
217444c4ba4SChristophe Lombard case H_SUCCESS: /* The operation is completed for the coherent platform function */
218444c4ba4SChristophe Lombard if ((op == H_CONTROL_CA_FUNCTION_GET_FUNCTION_ERR_INT ||
219444c4ba4SChristophe Lombard op == H_CONTROL_CA_FUNCTION_READ_ERR_STATE ||
220444c4ba4SChristophe Lombard op == H_CONTROL_CA_FUNCTION_COLLECT_VPD))
221444c4ba4SChristophe Lombard *out = retbuf[0];
222444c4ba4SChristophe Lombard return 0;
223444c4ba4SChristophe Lombard case H_PARAMETER: /* An incorrect parameter was supplied. */
224444c4ba4SChristophe Lombard case H_FUNCTION: /* The function is not supported. */
225444c4ba4SChristophe Lombard case H_NOT_FOUND: /* The operation supplied was not valid */
226444c4ba4SChristophe Lombard case H_NOT_AVAILABLE: /* The operation cannot be performed because the AFU has not been downloaded */
227444c4ba4SChristophe Lombard case H_SG_LIST: /* An block list entry was invalid */
228444c4ba4SChristophe Lombard return -EINVAL;
229444c4ba4SChristophe Lombard case H_AUTHORITY: /* The partition does not have authority to perform this hcall */
230444c4ba4SChristophe Lombard case H_RESOURCE: /* The function has page table mappings for MMIO */
231444c4ba4SChristophe Lombard case H_HARDWARE: /* A hardware event prevented the attach operation */
232444c4ba4SChristophe Lombard case H_STATE: /* The coherent platform function is not in a valid state */
233444c4ba4SChristophe Lombard case H_BUSY:
234444c4ba4SChristophe Lombard return -EBUSY;
235444c4ba4SChristophe Lombard default:
236444c4ba4SChristophe Lombard WARN(1, "Unexpected return code: %lx", rc);
237444c4ba4SChristophe Lombard return -EINVAL;
238444c4ba4SChristophe Lombard }
239444c4ba4SChristophe Lombard }
240444c4ba4SChristophe Lombard
241*b865c5b3SLee Jones /*
242444c4ba4SChristophe Lombard * cxl_h_reset_afu - Perform a reset to the coherent platform function.
243444c4ba4SChristophe Lombard */
cxl_h_reset_afu(u64 unit_address)244444c4ba4SChristophe Lombard long cxl_h_reset_afu(u64 unit_address)
245444c4ba4SChristophe Lombard {
246444c4ba4SChristophe Lombard return cxl_h_control_function(unit_address,
247444c4ba4SChristophe Lombard H_CONTROL_CA_FUNCTION_RESET,
248444c4ba4SChristophe Lombard 0, 0, 0, 0,
249444c4ba4SChristophe Lombard NULL);
250444c4ba4SChristophe Lombard }
251444c4ba4SChristophe Lombard
252*b865c5b3SLee Jones /*
253444c4ba4SChristophe Lombard * cxl_h_suspend_process - Suspend a process from being executed
254444c4ba4SChristophe Lombard * Parameter1 = process-token as returned from H_ATTACH_CA_PROCESS when
255444c4ba4SChristophe Lombard * process was attached.
256444c4ba4SChristophe Lombard */
cxl_h_suspend_process(u64 unit_address,u64 process_token)257444c4ba4SChristophe Lombard long cxl_h_suspend_process(u64 unit_address, u64 process_token)
258444c4ba4SChristophe Lombard {
259444c4ba4SChristophe Lombard return cxl_h_control_function(unit_address,
260444c4ba4SChristophe Lombard H_CONTROL_CA_FUNCTION_SUSPEND_PROCESS,
261444c4ba4SChristophe Lombard process_token, 0, 0, 0,
262444c4ba4SChristophe Lombard NULL);
263444c4ba4SChristophe Lombard }
264444c4ba4SChristophe Lombard
265*b865c5b3SLee Jones /*
266444c4ba4SChristophe Lombard * cxl_h_resume_process - Resume a process to be executed
267444c4ba4SChristophe Lombard * Parameter1 = process-token as returned from H_ATTACH_CA_PROCESS when
268444c4ba4SChristophe Lombard * process was attached.
269444c4ba4SChristophe Lombard */
cxl_h_resume_process(u64 unit_address,u64 process_token)270444c4ba4SChristophe Lombard long cxl_h_resume_process(u64 unit_address, u64 process_token)
271444c4ba4SChristophe Lombard {
272444c4ba4SChristophe Lombard return cxl_h_control_function(unit_address,
273444c4ba4SChristophe Lombard H_CONTROL_CA_FUNCTION_RESUME_PROCESS,
274444c4ba4SChristophe Lombard process_token, 0, 0, 0,
275444c4ba4SChristophe Lombard NULL);
276444c4ba4SChristophe Lombard }
277444c4ba4SChristophe Lombard
278*b865c5b3SLee Jones /*
279444c4ba4SChristophe Lombard * cxl_h_read_error_state - Checks the error state of the coherent
280444c4ba4SChristophe Lombard * platform function.
281444c4ba4SChristophe Lombard * R4 contains the error state
282444c4ba4SChristophe Lombard */
cxl_h_read_error_state(u64 unit_address,u64 * state)283444c4ba4SChristophe Lombard long cxl_h_read_error_state(u64 unit_address, u64 *state)
284444c4ba4SChristophe Lombard {
285444c4ba4SChristophe Lombard return cxl_h_control_function(unit_address,
286444c4ba4SChristophe Lombard H_CONTROL_CA_FUNCTION_READ_ERR_STATE,
287444c4ba4SChristophe Lombard 0, 0, 0, 0,
288444c4ba4SChristophe Lombard state);
289444c4ba4SChristophe Lombard }
290444c4ba4SChristophe Lombard
291*b865c5b3SLee Jones /*
292444c4ba4SChristophe Lombard * cxl_h_get_afu_err - collect the AFU error buffer
293444c4ba4SChristophe Lombard * Parameter1 = byte offset into error buffer to retrieve, valid values
294444c4ba4SChristophe Lombard * are between 0 and (ibm,error-buffer-size - 1)
295444c4ba4SChristophe Lombard * Parameter2 = 4K aligned real address of error buffer, to be filled in
296444c4ba4SChristophe Lombard * Parameter3 = length of error buffer, valid values are 4K or less
297444c4ba4SChristophe Lombard */
cxl_h_get_afu_err(u64 unit_address,u64 offset,u64 buf_address,u64 len)298444c4ba4SChristophe Lombard long cxl_h_get_afu_err(u64 unit_address, u64 offset,
299444c4ba4SChristophe Lombard u64 buf_address, u64 len)
300444c4ba4SChristophe Lombard {
301444c4ba4SChristophe Lombard return cxl_h_control_function(unit_address,
302444c4ba4SChristophe Lombard H_CONTROL_CA_FUNCTION_GET_AFU_ERR,
303444c4ba4SChristophe Lombard offset, buf_address, len, 0,
304444c4ba4SChristophe Lombard NULL);
305444c4ba4SChristophe Lombard }
306444c4ba4SChristophe Lombard
307*b865c5b3SLee Jones /*
308444c4ba4SChristophe Lombard * cxl_h_get_config - collect configuration record for the
309444c4ba4SChristophe Lombard * coherent platform function
310444c4ba4SChristophe Lombard * Parameter1 = # of configuration record to retrieve, valid values are
311444c4ba4SChristophe Lombard * between 0 and (ibm,#config-records - 1)
312444c4ba4SChristophe Lombard * Parameter2 = byte offset into configuration record to retrieve,
313444c4ba4SChristophe Lombard * valid values are between 0 and (ibm,config-record-size - 1)
314444c4ba4SChristophe Lombard * Parameter3 = 4K aligned real address of configuration record buffer,
315444c4ba4SChristophe Lombard * to be filled in
316444c4ba4SChristophe Lombard * Parameter4 = length of configuration buffer, valid values are 4K or less
317444c4ba4SChristophe Lombard */
cxl_h_get_config(u64 unit_address,u64 cr_num,u64 offset,u64 buf_address,u64 len)318444c4ba4SChristophe Lombard long cxl_h_get_config(u64 unit_address, u64 cr_num, u64 offset,
319444c4ba4SChristophe Lombard u64 buf_address, u64 len)
320444c4ba4SChristophe Lombard {
321444c4ba4SChristophe Lombard return cxl_h_control_function(unit_address,
322444c4ba4SChristophe Lombard H_CONTROL_CA_FUNCTION_GET_CONFIG,
323444c4ba4SChristophe Lombard cr_num, offset, buf_address, len,
324444c4ba4SChristophe Lombard NULL);
325444c4ba4SChristophe Lombard }
326444c4ba4SChristophe Lombard
327*b865c5b3SLee Jones /*
328444c4ba4SChristophe Lombard * cxl_h_terminate_process - Terminate the process before completion
329444c4ba4SChristophe Lombard * Parameter1 = process-token as returned from H_ATTACH_CA_PROCESS when
330444c4ba4SChristophe Lombard * process was attached.
331444c4ba4SChristophe Lombard */
cxl_h_terminate_process(u64 unit_address,u64 process_token)332444c4ba4SChristophe Lombard long cxl_h_terminate_process(u64 unit_address, u64 process_token)
333444c4ba4SChristophe Lombard {
334444c4ba4SChristophe Lombard return cxl_h_control_function(unit_address,
335444c4ba4SChristophe Lombard H_CONTROL_CA_FUNCTION_TERMINATE_PROCESS,
336444c4ba4SChristophe Lombard process_token, 0, 0, 0,
337444c4ba4SChristophe Lombard NULL);
338444c4ba4SChristophe Lombard }
339444c4ba4SChristophe Lombard
340*b865c5b3SLee Jones /*
341444c4ba4SChristophe Lombard * cxl_h_collect_vpd - Collect VPD for the coherent platform function.
342444c4ba4SChristophe Lombard * Parameter1 = # of VPD record to retrieve, valid values are between 0
343444c4ba4SChristophe Lombard * and (ibm,#config-records - 1).
344444c4ba4SChristophe Lombard * Parameter2 = 4K naturally aligned real buffer containing block
345444c4ba4SChristophe Lombard * list entries
346444c4ba4SChristophe Lombard * Parameter3 = number of block list entries in the block list, valid
347444c4ba4SChristophe Lombard * values are between 0 and 256
348444c4ba4SChristophe Lombard */
cxl_h_collect_vpd(u64 unit_address,u64 record,u64 list_address,u64 num,u64 * out)349444c4ba4SChristophe Lombard long cxl_h_collect_vpd(u64 unit_address, u64 record, u64 list_address,
350444c4ba4SChristophe Lombard u64 num, u64 *out)
351444c4ba4SChristophe Lombard {
352444c4ba4SChristophe Lombard return cxl_h_control_function(unit_address,
353444c4ba4SChristophe Lombard H_CONTROL_CA_FUNCTION_COLLECT_VPD,
354444c4ba4SChristophe Lombard record, list_address, num, 0,
355444c4ba4SChristophe Lombard out);
356444c4ba4SChristophe Lombard }
357444c4ba4SChristophe Lombard
358*b865c5b3SLee Jones /*
359444c4ba4SChristophe Lombard * cxl_h_get_fn_error_interrupt - Read the function-wide error data based on an interrupt
360444c4ba4SChristophe Lombard */
cxl_h_get_fn_error_interrupt(u64 unit_address,u64 * reg)361444c4ba4SChristophe Lombard long cxl_h_get_fn_error_interrupt(u64 unit_address, u64 *reg)
362444c4ba4SChristophe Lombard {
363444c4ba4SChristophe Lombard return cxl_h_control_function(unit_address,
364444c4ba4SChristophe Lombard H_CONTROL_CA_FUNCTION_GET_FUNCTION_ERR_INT,
365444c4ba4SChristophe Lombard 0, 0, 0, 0, reg);
366444c4ba4SChristophe Lombard }
367444c4ba4SChristophe Lombard
368*b865c5b3SLee Jones /*
369444c4ba4SChristophe Lombard * cxl_h_ack_fn_error_interrupt - Acknowledge function-wide error data
370444c4ba4SChristophe Lombard * based on an interrupt
371444c4ba4SChristophe Lombard * Parameter1 = value to write to the function-wide error interrupt register
372444c4ba4SChristophe Lombard */
cxl_h_ack_fn_error_interrupt(u64 unit_address,u64 value)373444c4ba4SChristophe Lombard long cxl_h_ack_fn_error_interrupt(u64 unit_address, u64 value)
374444c4ba4SChristophe Lombard {
375444c4ba4SChristophe Lombard return cxl_h_control_function(unit_address,
376444c4ba4SChristophe Lombard H_CONTROL_CA_FUNCTION_ACK_FUNCTION_ERR_INT,
377444c4ba4SChristophe Lombard value, 0, 0, 0,
378444c4ba4SChristophe Lombard NULL);
379444c4ba4SChristophe Lombard }
380444c4ba4SChristophe Lombard
381*b865c5b3SLee Jones /*
382444c4ba4SChristophe Lombard * cxl_h_get_error_log - Retrieve the Platform Log ID (PLID) of
383444c4ba4SChristophe Lombard * an error log
384444c4ba4SChristophe Lombard */
cxl_h_get_error_log(u64 unit_address,u64 value)385444c4ba4SChristophe Lombard long cxl_h_get_error_log(u64 unit_address, u64 value)
386444c4ba4SChristophe Lombard {
387444c4ba4SChristophe Lombard return cxl_h_control_function(unit_address,
388444c4ba4SChristophe Lombard H_CONTROL_CA_FUNCTION_GET_ERROR_LOG,
389444c4ba4SChristophe Lombard 0, 0, 0, 0,
390444c4ba4SChristophe Lombard NULL);
391444c4ba4SChristophe Lombard }
392444c4ba4SChristophe Lombard
393*b865c5b3SLee Jones /*
394444c4ba4SChristophe Lombard * cxl_h_collect_int_info - Collect interrupt info about a coherent
395444c4ba4SChristophe Lombard * platform function after an interrupt occurred.
396444c4ba4SChristophe Lombard */
cxl_h_collect_int_info(u64 unit_address,u64 process_token,struct cxl_irq_info * info)397444c4ba4SChristophe Lombard long cxl_h_collect_int_info(u64 unit_address, u64 process_token,
398444c4ba4SChristophe Lombard struct cxl_irq_info *info)
399444c4ba4SChristophe Lombard {
400444c4ba4SChristophe Lombard long rc;
401444c4ba4SChristophe Lombard
402444c4ba4SChristophe Lombard BUG_ON(sizeof(*info) != sizeof(unsigned long[PLPAR_HCALL9_BUFSIZE]));
403444c4ba4SChristophe Lombard
404444c4ba4SChristophe Lombard rc = plpar_hcall9(H_COLLECT_CA_INT_INFO, (unsigned long *) info,
405444c4ba4SChristophe Lombard unit_address, process_token);
406444c4ba4SChristophe Lombard _PRINT_MSG(rc, "cxl_h_collect_int_info(%#.16llx, 0x%llx): %li\n",
407444c4ba4SChristophe Lombard unit_address, process_token, rc);
408e7a801adSChristophe Lombard trace_cxl_hcall_collect_int_info(unit_address, process_token, rc);
409444c4ba4SChristophe Lombard
410444c4ba4SChristophe Lombard switch (rc) {
411444c4ba4SChristophe Lombard case H_SUCCESS: /* The interrupt info is returned in return registers. */
41266ef20c7SChristophe Lombard pr_devel("dsisr:%#llx, dar:%#llx, dsr:%#llx, pid_tid:%#llx, afu_err:%#llx, errstat:%#llx\n",
41366ef20c7SChristophe Lombard info->dsisr, info->dar, info->dsr, info->reserved,
41466ef20c7SChristophe Lombard info->afu_err, info->errstat);
415444c4ba4SChristophe Lombard return 0;
416444c4ba4SChristophe Lombard case H_PARAMETER: /* An incorrect parameter was supplied. */
417444c4ba4SChristophe Lombard return -EINVAL;
418444c4ba4SChristophe Lombard case H_AUTHORITY: /* The partition does not have authority to perform this hcall. */
419444c4ba4SChristophe Lombard case H_HARDWARE: /* A hardware event prevented the collection of the interrupt info.*/
420444c4ba4SChristophe Lombard case H_STATE: /* The coherent platform function is not in a valid state to collect interrupt info. */
421444c4ba4SChristophe Lombard return -EBUSY;
422444c4ba4SChristophe Lombard default:
423444c4ba4SChristophe Lombard WARN(1, "Unexpected return code: %lx", rc);
424444c4ba4SChristophe Lombard return -EINVAL;
425444c4ba4SChristophe Lombard }
426444c4ba4SChristophe Lombard }
427444c4ba4SChristophe Lombard
428*b865c5b3SLee Jones /*
429444c4ba4SChristophe Lombard * cxl_h_control_faults - Control the operation of a coherent platform
430444c4ba4SChristophe Lombard * function after a fault occurs.
431444c4ba4SChristophe Lombard *
432444c4ba4SChristophe Lombard * Parameters
433444c4ba4SChristophe Lombard * control-mask: value to control the faults
434444c4ba4SChristophe Lombard * looks like PSL_TFC_An shifted >> 32
435444c4ba4SChristophe Lombard * reset-mask: mask to control reset of function faults
436444c4ba4SChristophe Lombard * Set reset_mask = 1 to reset PSL errors
437444c4ba4SChristophe Lombard */
cxl_h_control_faults(u64 unit_address,u64 process_token,u64 control_mask,u64 reset_mask)438444c4ba4SChristophe Lombard long cxl_h_control_faults(u64 unit_address, u64 process_token,
439444c4ba4SChristophe Lombard u64 control_mask, u64 reset_mask)
440444c4ba4SChristophe Lombard {
441444c4ba4SChristophe Lombard unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
442444c4ba4SChristophe Lombard long rc;
443444c4ba4SChristophe Lombard
444444c4ba4SChristophe Lombard memset(retbuf, 0, sizeof(retbuf));
445444c4ba4SChristophe Lombard
446444c4ba4SChristophe Lombard rc = plpar_hcall(H_CONTROL_CA_FAULTS, retbuf, unit_address,
447444c4ba4SChristophe Lombard H_CONTROL_CA_FAULTS_RESPOND_PSL, process_token,
448444c4ba4SChristophe Lombard control_mask, reset_mask);
449444c4ba4SChristophe Lombard _PRINT_MSG(rc, "cxl_h_control_faults(%#.16llx, 0x%llx, %#llx, %#llx): %li (%#lx)\n",
450444c4ba4SChristophe Lombard unit_address, process_token, control_mask, reset_mask,
451444c4ba4SChristophe Lombard rc, retbuf[0]);
452e7a801adSChristophe Lombard trace_cxl_hcall_control_faults(unit_address, process_token,
453e7a801adSChristophe Lombard control_mask, reset_mask, retbuf[0], rc);
454444c4ba4SChristophe Lombard
455444c4ba4SChristophe Lombard switch (rc) {
456444c4ba4SChristophe Lombard case H_SUCCESS: /* Faults were successfully controlled for the function. */
457444c4ba4SChristophe Lombard return 0;
458444c4ba4SChristophe Lombard case H_PARAMETER: /* An incorrect parameter was supplied. */
459444c4ba4SChristophe Lombard return -EINVAL;
460444c4ba4SChristophe Lombard case H_HARDWARE: /* A hardware event prevented the control of faults. */
461444c4ba4SChristophe Lombard case H_STATE: /* The function was in an invalid state. */
462444c4ba4SChristophe Lombard case H_AUTHORITY: /* The partition does not have authority to perform this hcall; the coherent platform facilities may need to be licensed. */
463444c4ba4SChristophe Lombard return -EBUSY;
464444c4ba4SChristophe Lombard case H_FUNCTION: /* The function is not supported */
465444c4ba4SChristophe Lombard case H_NOT_FOUND: /* The operation supplied was not valid */
466444c4ba4SChristophe Lombard return -EINVAL;
467444c4ba4SChristophe Lombard default:
468444c4ba4SChristophe Lombard WARN(1, "Unexpected return code: %lx", rc);
469444c4ba4SChristophe Lombard return -EINVAL;
470444c4ba4SChristophe Lombard }
471444c4ba4SChristophe Lombard }
472444c4ba4SChristophe Lombard
473*b865c5b3SLee Jones /*
474444c4ba4SChristophe Lombard * cxl_h_control_facility - This H_CONTROL_CA_FACILITY hypervisor call
475444c4ba4SChristophe Lombard * allows the partition to manipulate or query
476444c4ba4SChristophe Lombard * certain coherent platform facility behaviors.
477444c4ba4SChristophe Lombard */
cxl_h_control_facility(u64 unit_address,u64 op,u64 p1,u64 p2,u64 p3,u64 p4,u64 * out)478444c4ba4SChristophe Lombard static long cxl_h_control_facility(u64 unit_address, u64 op,
479444c4ba4SChristophe Lombard u64 p1, u64 p2, u64 p3, u64 p4, u64 *out)
480444c4ba4SChristophe Lombard {
481444c4ba4SChristophe Lombard unsigned long retbuf[PLPAR_HCALL9_BUFSIZE];
482444c4ba4SChristophe Lombard long rc;
483444c4ba4SChristophe Lombard
484444c4ba4SChristophe Lombard CXL_H9_WAIT_UNTIL_DONE(rc, retbuf, H_CONTROL_CA_FACILITY, unit_address, op, p1, p2, p3, p4);
485444c4ba4SChristophe Lombard _PRINT_MSG(rc, "cxl_h_control_facility(%#.16llx, %s(%#llx, %#llx, %#llx, %#llx, R4: %#lx)): %li\n",
486444c4ba4SChristophe Lombard unit_address, OP_STR_CONTROL_ADAPTER(op), p1, p2, p3, p4, retbuf[0], rc);
487e7a801adSChristophe Lombard trace_cxl_hcall_control_facility(unit_address, OP_STR_CONTROL_ADAPTER(op), p1, p2, p3, p4, retbuf[0], rc);
488444c4ba4SChristophe Lombard
489444c4ba4SChristophe Lombard switch (rc) {
490444c4ba4SChristophe Lombard case H_SUCCESS: /* The operation is completed for the coherent platform facility */
491444c4ba4SChristophe Lombard if (op == H_CONTROL_CA_FACILITY_COLLECT_VPD)
492444c4ba4SChristophe Lombard *out = retbuf[0];
493444c4ba4SChristophe Lombard return 0;
494444c4ba4SChristophe Lombard case H_PARAMETER: /* An incorrect parameter was supplied. */
495444c4ba4SChristophe Lombard case H_FUNCTION: /* The function is not supported. */
496444c4ba4SChristophe Lombard case H_NOT_FOUND: /* The operation supplied was not valid */
497444c4ba4SChristophe Lombard case H_NOT_AVAILABLE: /* The operation cannot be performed because the AFU has not been downloaded */
498444c4ba4SChristophe Lombard case H_SG_LIST: /* An block list entry was invalid */
499444c4ba4SChristophe Lombard return -EINVAL;
500444c4ba4SChristophe Lombard case H_AUTHORITY: /* The partition does not have authority to perform this hcall */
501444c4ba4SChristophe Lombard case H_RESOURCE: /* The function has page table mappings for MMIO */
502444c4ba4SChristophe Lombard case H_HARDWARE: /* A hardware event prevented the attach operation */
503444c4ba4SChristophe Lombard case H_STATE: /* The coherent platform facility is not in a valid state */
504444c4ba4SChristophe Lombard case H_BUSY:
505444c4ba4SChristophe Lombard return -EBUSY;
506444c4ba4SChristophe Lombard default:
507444c4ba4SChristophe Lombard WARN(1, "Unexpected return code: %lx", rc);
508444c4ba4SChristophe Lombard return -EINVAL;
509444c4ba4SChristophe Lombard }
510444c4ba4SChristophe Lombard }
511444c4ba4SChristophe Lombard
512*b865c5b3SLee Jones /*
513444c4ba4SChristophe Lombard * cxl_h_reset_adapter - Perform a reset to the coherent platform facility.
514444c4ba4SChristophe Lombard */
cxl_h_reset_adapter(u64 unit_address)515444c4ba4SChristophe Lombard long cxl_h_reset_adapter(u64 unit_address)
516444c4ba4SChristophe Lombard {
517444c4ba4SChristophe Lombard return cxl_h_control_facility(unit_address,
518444c4ba4SChristophe Lombard H_CONTROL_CA_FACILITY_RESET,
519444c4ba4SChristophe Lombard 0, 0, 0, 0,
520444c4ba4SChristophe Lombard NULL);
521444c4ba4SChristophe Lombard }
522444c4ba4SChristophe Lombard
523*b865c5b3SLee Jones /*
524444c4ba4SChristophe Lombard * cxl_h_collect_vpd - Collect VPD for the coherent platform function.
525444c4ba4SChristophe Lombard * Parameter1 = 4K naturally aligned real buffer containing block
526444c4ba4SChristophe Lombard * list entries
527444c4ba4SChristophe Lombard * Parameter2 = number of block list entries in the block list, valid
528444c4ba4SChristophe Lombard * values are between 0 and 256
529444c4ba4SChristophe Lombard */
cxl_h_collect_vpd_adapter(u64 unit_address,u64 list_address,u64 num,u64 * out)530444c4ba4SChristophe Lombard long cxl_h_collect_vpd_adapter(u64 unit_address, u64 list_address,
531444c4ba4SChristophe Lombard u64 num, u64 *out)
532444c4ba4SChristophe Lombard {
533444c4ba4SChristophe Lombard return cxl_h_control_facility(unit_address,
534444c4ba4SChristophe Lombard H_CONTROL_CA_FACILITY_COLLECT_VPD,
535444c4ba4SChristophe Lombard list_address, num, 0, 0,
536444c4ba4SChristophe Lombard out);
537444c4ba4SChristophe Lombard }
538444c4ba4SChristophe Lombard
539*b865c5b3SLee Jones /*
540444c4ba4SChristophe Lombard * cxl_h_download_facility - This H_DOWNLOAD_CA_FACILITY
541444c4ba4SChristophe Lombard * hypervisor call provide platform support for
542444c4ba4SChristophe Lombard * downloading a base adapter image to the coherent
543444c4ba4SChristophe Lombard * platform facility, and for validating the entire
544444c4ba4SChristophe Lombard * image after the download.
545444c4ba4SChristophe Lombard * Parameters
546444c4ba4SChristophe Lombard * op: operation to perform to the coherent platform function
547444c4ba4SChristophe Lombard * Download: operation = 1, the base image in the coherent platform
548444c4ba4SChristophe Lombard * facility is first erased, and then
549444c4ba4SChristophe Lombard * programmed using the image supplied
550444c4ba4SChristophe Lombard * in the scatter/gather list.
551444c4ba4SChristophe Lombard * Validate: operation = 2, the base image in the coherent platform
552444c4ba4SChristophe Lombard * facility is compared with the image
553444c4ba4SChristophe Lombard * supplied in the scatter/gather list.
554444c4ba4SChristophe Lombard * list_address: 4K naturally aligned real buffer containing
555444c4ba4SChristophe Lombard * scatter/gather list entries.
556444c4ba4SChristophe Lombard * num: number of block list entries in the scatter/gather list.
557444c4ba4SChristophe Lombard */
cxl_h_download_facility(u64 unit_address,u64 op,u64 list_address,u64 num,u64 * out)558444c4ba4SChristophe Lombard static long cxl_h_download_facility(u64 unit_address, u64 op,
559444c4ba4SChristophe Lombard u64 list_address, u64 num,
560444c4ba4SChristophe Lombard u64 *out)
561444c4ba4SChristophe Lombard {
562444c4ba4SChristophe Lombard unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
563444c4ba4SChristophe Lombard unsigned int delay, total_delay = 0;
564444c4ba4SChristophe Lombard u64 token = 0;
565444c4ba4SChristophe Lombard long rc;
566444c4ba4SChristophe Lombard
567444c4ba4SChristophe Lombard if (*out != 0)
568444c4ba4SChristophe Lombard token = *out;
569444c4ba4SChristophe Lombard
570444c4ba4SChristophe Lombard memset(retbuf, 0, sizeof(retbuf));
571444c4ba4SChristophe Lombard while (1) {
572444c4ba4SChristophe Lombard rc = plpar_hcall(H_DOWNLOAD_CA_FACILITY, retbuf,
573444c4ba4SChristophe Lombard unit_address, op, list_address, num,
574444c4ba4SChristophe Lombard token);
575444c4ba4SChristophe Lombard token = retbuf[0];
576444c4ba4SChristophe Lombard if (rc != H_BUSY && !H_IS_LONG_BUSY(rc))
577444c4ba4SChristophe Lombard break;
578444c4ba4SChristophe Lombard
579444c4ba4SChristophe Lombard if (rc != H_BUSY) {
580444c4ba4SChristophe Lombard delay = get_longbusy_msecs(rc);
581444c4ba4SChristophe Lombard total_delay += delay;
582444c4ba4SChristophe Lombard if (total_delay > CXL_HCALL_TIMEOUT_DOWNLOAD) {
583444c4ba4SChristophe Lombard WARN(1, "Warning: Giving up waiting for CXL hcall "
584444c4ba4SChristophe Lombard "%#x after %u msec\n",
585444c4ba4SChristophe Lombard H_DOWNLOAD_CA_FACILITY, total_delay);
586444c4ba4SChristophe Lombard rc = H_BUSY;
587444c4ba4SChristophe Lombard break;
588444c4ba4SChristophe Lombard }
589444c4ba4SChristophe Lombard msleep(delay);
590444c4ba4SChristophe Lombard }
591444c4ba4SChristophe Lombard }
592444c4ba4SChristophe Lombard _PRINT_MSG(rc, "cxl_h_download_facility(%#.16llx, %s(%#llx, %#llx), %#lx): %li\n",
593444c4ba4SChristophe Lombard unit_address, OP_STR_DOWNLOAD_ADAPTER(op), list_address, num, retbuf[0], rc);
594e7a801adSChristophe Lombard trace_cxl_hcall_download_facility(unit_address, OP_STR_DOWNLOAD_ADAPTER(op), list_address, num, retbuf[0], rc);
595444c4ba4SChristophe Lombard
596444c4ba4SChristophe Lombard switch (rc) {
597444c4ba4SChristophe Lombard case H_SUCCESS: /* The operation is completed for the coherent platform facility */
598444c4ba4SChristophe Lombard return 0;
599444c4ba4SChristophe Lombard case H_PARAMETER: /* An incorrect parameter was supplied */
600444c4ba4SChristophe Lombard case H_FUNCTION: /* The function is not supported. */
601444c4ba4SChristophe Lombard case H_SG_LIST: /* An block list entry was invalid */
602444c4ba4SChristophe Lombard case H_BAD_DATA: /* Image verification failed */
603444c4ba4SChristophe Lombard return -EINVAL;
604444c4ba4SChristophe Lombard case H_AUTHORITY: /* The partition does not have authority to perform this hcall */
605444c4ba4SChristophe Lombard case H_RESOURCE: /* The function has page table mappings for MMIO */
606444c4ba4SChristophe Lombard case H_HARDWARE: /* A hardware event prevented the attach operation */
607444c4ba4SChristophe Lombard case H_STATE: /* The coherent platform facility is not in a valid state */
608444c4ba4SChristophe Lombard case H_BUSY:
609444c4ba4SChristophe Lombard return -EBUSY;
610444c4ba4SChristophe Lombard case H_CONTINUE:
611444c4ba4SChristophe Lombard *out = retbuf[0];
612444c4ba4SChristophe Lombard return 1; /* More data is needed for the complete image */
613444c4ba4SChristophe Lombard default:
614444c4ba4SChristophe Lombard WARN(1, "Unexpected return code: %lx", rc);
615444c4ba4SChristophe Lombard return -EINVAL;
616444c4ba4SChristophe Lombard }
617444c4ba4SChristophe Lombard }
618444c4ba4SChristophe Lombard
619*b865c5b3SLee Jones /*
620444c4ba4SChristophe Lombard * cxl_h_download_adapter_image - Download the base image to the coherent
621444c4ba4SChristophe Lombard * platform facility.
622444c4ba4SChristophe Lombard */
cxl_h_download_adapter_image(u64 unit_address,u64 list_address,u64 num,u64 * out)623444c4ba4SChristophe Lombard long cxl_h_download_adapter_image(u64 unit_address,
624444c4ba4SChristophe Lombard u64 list_address, u64 num,
625444c4ba4SChristophe Lombard u64 *out)
626444c4ba4SChristophe Lombard {
627444c4ba4SChristophe Lombard return cxl_h_download_facility(unit_address,
628444c4ba4SChristophe Lombard H_DOWNLOAD_CA_FACILITY_DOWNLOAD,
629444c4ba4SChristophe Lombard list_address, num, out);
630444c4ba4SChristophe Lombard }
631444c4ba4SChristophe Lombard
632*b865c5b3SLee Jones /*
633444c4ba4SChristophe Lombard * cxl_h_validate_adapter_image - Validate the base image in the coherent
634444c4ba4SChristophe Lombard * platform facility.
635444c4ba4SChristophe Lombard */
cxl_h_validate_adapter_image(u64 unit_address,u64 list_address,u64 num,u64 * out)636444c4ba4SChristophe Lombard long cxl_h_validate_adapter_image(u64 unit_address,
637444c4ba4SChristophe Lombard u64 list_address, u64 num,
638444c4ba4SChristophe Lombard u64 *out)
639444c4ba4SChristophe Lombard {
640444c4ba4SChristophe Lombard return cxl_h_download_facility(unit_address,
641444c4ba4SChristophe Lombard H_DOWNLOAD_CA_FACILITY_VALIDATE,
642444c4ba4SChristophe Lombard list_address, num, out);
643444c4ba4SChristophe Lombard }
644