.. | .. |
---|
1 | | -/** |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
| 2 | +/* |
---|
2 | 3 | * IBM Accelerator Family 'GenWQE' |
---|
3 | 4 | * |
---|
4 | 5 | * (C) Copyright IBM Corp. 2013 |
---|
.. | .. |
---|
7 | 8 | * Author: Joerg-Stephan Vogt <jsvogt@de.ibm.com> |
---|
8 | 9 | * Author: Michael Jung <mijung@gmx.net> |
---|
9 | 10 | * Author: Michael Ruettger <michael@ibmra.de> |
---|
10 | | - * |
---|
11 | | - * This program is free software; you can redistribute it and/or modify |
---|
12 | | - * it under the terms of the GNU General Public License (version 2 only) |
---|
13 | | - * as published by the Free Software Foundation. |
---|
14 | | - * |
---|
15 | | - * This program is distributed in the hope that it will be useful, |
---|
16 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
18 | | - * GNU General Public License for more details. |
---|
19 | 11 | */ |
---|
20 | 12 | |
---|
21 | 13 | /* |
---|
.. | .. |
---|
27 | 19 | */ |
---|
28 | 20 | |
---|
29 | 21 | #include <linux/types.h> |
---|
30 | | -#include <linux/module.h> |
---|
31 | 22 | #include <linux/sched.h> |
---|
32 | 23 | #include <linux/wait.h> |
---|
33 | 24 | #include <linux/pci.h> |
---|
.. | .. |
---|
253 | 244 | (cd->card_state != GENWQE_CARD_USED); |
---|
254 | 245 | } |
---|
255 | 246 | |
---|
| 247 | +#define RET_DDCB_APPENDED 1 |
---|
| 248 | +#define RET_DDCB_TAPPED 2 |
---|
256 | 249 | /** |
---|
257 | 250 | * enqueue_ddcb() - Enqueue a DDCB |
---|
258 | 251 | * @cd: pointer to genwqe device descriptor |
---|
259 | 252 | * @queue: queue this operation should be done on |
---|
| 253 | + * @pddcb: pointer to ddcb structure |
---|
260 | 254 | * @ddcb_no: pointer to ddcb number being tapped |
---|
261 | 255 | * |
---|
262 | 256 | * Start execution of DDCB by tapping or append to queue via NEXT |
---|
.. | .. |
---|
268 | 262 | * Return: 1 if new DDCB is appended to previous |
---|
269 | 263 | * 2 if DDCB queue is tapped via register/simulation |
---|
270 | 264 | */ |
---|
271 | | -#define RET_DDCB_APPENDED 1 |
---|
272 | | -#define RET_DDCB_TAPPED 2 |
---|
273 | | - |
---|
274 | 265 | static int enqueue_ddcb(struct genwqe_dev *cd, struct ddcb_queue *queue, |
---|
275 | 266 | struct ddcb *pddcb, int ddcb_no) |
---|
276 | 267 | { |
---|
.. | .. |
---|
325 | 316 | |
---|
326 | 317 | /** |
---|
327 | 318 | * copy_ddcb_results() - Copy output state from real DDCB to request |
---|
| 319 | + * @req: pointer to requsted DDCB parameters |
---|
| 320 | + * @ddcb_no: pointer to ddcb number being tapped |
---|
328 | 321 | * |
---|
329 | 322 | * Copy DDCB ASV to request struct. There is no endian |
---|
330 | 323 | * conversion made, since data structure in ASV is still |
---|
.. | .. |
---|
365 | 358 | /** |
---|
366 | 359 | * genwqe_check_ddcb_queue() - Checks DDCB queue for completed work equests. |
---|
367 | 360 | * @cd: pointer to genwqe device descriptor |
---|
| 361 | + * @queue: queue to be checked |
---|
368 | 362 | * |
---|
369 | 363 | * Return: Number of DDCBs which were finished |
---|
370 | 364 | */ |
---|
.. | .. |
---|
562 | 556 | /** |
---|
563 | 557 | * get_next_ddcb() - Get next available DDCB |
---|
564 | 558 | * @cd: pointer to genwqe device descriptor |
---|
| 559 | + * @queue: DDCB queue |
---|
| 560 | + * @num: internal DDCB number |
---|
565 | 561 | * |
---|
566 | 562 | * DDCB's content is completely cleared but presets for PRE and |
---|
567 | 563 | * SEQNUM. This function must only be called when ddcb_lock is held. |
---|
.. | .. |
---|
909 | 905 | /** |
---|
910 | 906 | * __genwqe_execute_raw_ddcb() - Setup and execute DDCB |
---|
911 | 907 | * @cd: pointer to genwqe device descriptor |
---|
912 | | - * @req: user provided DDCB request |
---|
| 908 | + * @cmd: user provided DDCB command |
---|
913 | 909 | * @f_flags: file mode: blocking, non-blocking |
---|
914 | 910 | */ |
---|
915 | 911 | int __genwqe_execute_raw_ddcb(struct genwqe_dev *cd, |
---|
.. | .. |
---|
974 | 970 | |
---|
975 | 971 | /** |
---|
976 | 972 | * genwqe_next_ddcb_ready() - Figure out if the next DDCB is already finished |
---|
| 973 | + * @cd: pointer to genwqe device descriptor |
---|
977 | 974 | * |
---|
978 | 975 | * We use this as condition for our wait-queue code. |
---|
979 | 976 | */ |
---|
.. | .. |
---|
1002 | 999 | |
---|
1003 | 1000 | /** |
---|
1004 | 1001 | * genwqe_ddcbs_in_flight() - Check how many DDCBs are in flight |
---|
| 1002 | + * @cd: pointer to genwqe device descriptor |
---|
1005 | 1003 | * |
---|
1006 | 1004 | * Keep track on the number of DDCBs which ware currently in the |
---|
1007 | 1005 | * queue. This is needed for statistics as well as conditon if we want |
---|
.. | .. |
---|
1093 | 1091 | queue->ddcb_daddr); |
---|
1094 | 1092 | queue->ddcb_vaddr = NULL; |
---|
1095 | 1093 | queue->ddcb_daddr = 0ull; |
---|
1096 | | - return -ENODEV; |
---|
| 1094 | + return rc; |
---|
1097 | 1095 | |
---|
1098 | 1096 | } |
---|
1099 | 1097 | |
---|
.. | .. |
---|
1180 | 1178 | |
---|
1181 | 1179 | /** |
---|
1182 | 1180 | * genwqe_card_thread() - Work thread for the DDCB queue |
---|
| 1181 | + * @data: pointer to genwqe device descriptor |
---|
1183 | 1182 | * |
---|
1184 | 1183 | * The idea is to check if there are DDCBs in processing. If there are |
---|
1185 | 1184 | * some finished DDCBs, we process them and wakeup the |
---|
.. | .. |
---|
1188 | 1187 | */ |
---|
1189 | 1188 | static int genwqe_card_thread(void *data) |
---|
1190 | 1189 | { |
---|
1191 | | - int should_stop = 0, rc = 0; |
---|
| 1190 | + int should_stop = 0; |
---|
1192 | 1191 | struct genwqe_dev *cd = (struct genwqe_dev *)data; |
---|
1193 | 1192 | |
---|
1194 | 1193 | while (!kthread_should_stop()) { |
---|
.. | .. |
---|
1196 | 1195 | genwqe_check_ddcb_queue(cd, &cd->queue); |
---|
1197 | 1196 | |
---|
1198 | 1197 | if (GENWQE_POLLING_ENABLED) { |
---|
1199 | | - rc = wait_event_interruptible_timeout( |
---|
| 1198 | + wait_event_interruptible_timeout( |
---|
1200 | 1199 | cd->queue_waitq, |
---|
1201 | 1200 | genwqe_ddcbs_in_flight(cd) || |
---|
1202 | 1201 | (should_stop = kthread_should_stop()), 1); |
---|
1203 | 1202 | } else { |
---|
1204 | | - rc = wait_event_interruptible_timeout( |
---|
| 1203 | + wait_event_interruptible_timeout( |
---|
1205 | 1204 | cd->queue_waitq, |
---|
1206 | 1205 | genwqe_next_ddcb_ready(cd) || |
---|
1207 | 1206 | (should_stop = kthread_should_stop()), HZ); |
---|
.. | .. |
---|
1308 | 1307 | |
---|
1309 | 1308 | /** |
---|
1310 | 1309 | * queue_wake_up_all() - Handles fatal error case |
---|
| 1310 | + * @cd: pointer to genwqe device descriptor |
---|
1311 | 1311 | * |
---|
1312 | 1312 | * The PCI device got unusable and we have to stop all pending |
---|
1313 | 1313 | * requests as fast as we can. The code after this must purge the |
---|
.. | .. |
---|
1332 | 1332 | |
---|
1333 | 1333 | /** |
---|
1334 | 1334 | * genwqe_finish_queue() - Remove any genwqe devices and user-interfaces |
---|
| 1335 | + * @cd: pointer to genwqe device descriptor |
---|
1335 | 1336 | * |
---|
1336 | 1337 | * Relies on the pre-condition that there are no users of the card |
---|
1337 | 1338 | * device anymore e.g. with open file-descriptors. |
---|