| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /** |
|---|
| 2 | 3 | * IBM Accelerator Family 'GenWQE' |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 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 | /* |
|---|
| .. | .. |
|---|
| 24 | 16 | * controlled from here. |
|---|
| 25 | 17 | */ |
|---|
| 26 | 18 | |
|---|
| 27 | | -#include <linux/module.h> |
|---|
| 28 | 19 | #include <linux/types.h> |
|---|
| 29 | 20 | #include <linux/pci.h> |
|---|
| 30 | 21 | #include <linux/err.h> |
|---|
| .. | .. |
|---|
| 174 | 165 | |
|---|
| 175 | 166 | /** |
|---|
| 176 | 167 | * genwqe_bus_reset() - Card recovery |
|---|
| 168 | + * @cd: GenWQE device information |
|---|
| 177 | 169 | * |
|---|
| 178 | 170 | * pci_reset_function() will recover the device and ensure that the |
|---|
| 179 | 171 | * registers are accessible again when it completes with success. If |
|---|
| .. | .. |
|---|
| 271 | 263 | |
|---|
| 272 | 264 | /** |
|---|
| 273 | 265 | * genwqe_recovery_on_fatal_gfir_required() - Version depended actions |
|---|
| 266 | + * @cd: GenWQE device information |
|---|
| 274 | 267 | * |
|---|
| 275 | 268 | * Bitstreams older than 2013-02-17 have a bug where fatal GFIRs must |
|---|
| 276 | 269 | * be ignored. This is e.g. true for the bitstream we gave to the card |
|---|
| .. | .. |
|---|
| 289 | 282 | |
|---|
| 290 | 283 | /** |
|---|
| 291 | 284 | * genwqe_T_psec() - Calculate PF/VF timeout register content |
|---|
| 285 | + * @cd: GenWQE device information |
|---|
| 292 | 286 | * |
|---|
| 293 | 287 | * Note: From a design perspective it turned out to be a bad idea to |
|---|
| 294 | 288 | * use codes here to specifiy the frequency/speed values. An old |
|---|
| .. | .. |
|---|
| 312 | 306 | |
|---|
| 313 | 307 | /** |
|---|
| 314 | 308 | * genwqe_setup_pf_jtimer() - Setup PF hardware timeouts for DDCB execution |
|---|
| 309 | + * @cd: GenWQE device information |
|---|
| 315 | 310 | * |
|---|
| 316 | 311 | * Do this _after_ card_reset() is called. Otherwise the values will |
|---|
| 317 | 312 | * vanish. The settings need to be done when the queues are inactive. |
|---|
| .. | .. |
|---|
| 338 | 333 | |
|---|
| 339 | 334 | /** |
|---|
| 340 | 335 | * genwqe_setup_vf_jtimer() - Setup VF hardware timeouts for DDCB execution |
|---|
| 336 | + * @cd: GenWQE device information |
|---|
| 341 | 337 | */ |
|---|
| 342 | 338 | static bool genwqe_setup_vf_jtimer(struct genwqe_dev *cd) |
|---|
| 343 | 339 | { |
|---|
| .. | .. |
|---|
| 552 | 548 | |
|---|
| 553 | 549 | /** |
|---|
| 554 | 550 | * genwqe_stop() - Stop card operation |
|---|
| 551 | + * @cd: GenWQE device information |
|---|
| 555 | 552 | * |
|---|
| 556 | 553 | * Recovery notes: |
|---|
| 557 | 554 | * As long as genwqe_thread runs we might access registers during |
|---|
| .. | .. |
|---|
| 578 | 575 | |
|---|
| 579 | 576 | /** |
|---|
| 580 | 577 | * genwqe_recover_card() - Try to recover the card if it is possible |
|---|
| 578 | + * @cd: GenWQE device information |
|---|
| 579 | + * @fatal_err: Indicate whether to attempt soft reset |
|---|
| 581 | 580 | * |
|---|
| 582 | 581 | * If fatal_err is set no register access is possible anymore. It is |
|---|
| 583 | 582 | * likely that genwqe_start fails in that situation. Proper error |
|---|
| .. | .. |
|---|
| 627 | 626 | |
|---|
| 628 | 627 | /** |
|---|
| 629 | 628 | * genwqe_fir_checking() - Check the fault isolation registers of the card |
|---|
| 629 | + * @cd: GenWQE device information |
|---|
| 630 | 630 | * |
|---|
| 631 | 631 | * If this code works ok, can be tried out with help of the genwqe_poke tool: |
|---|
| 632 | 632 | * sudo ./tools/genwqe_poke 0x8 0xfefefefefef |
|---|
| .. | .. |
|---|
| 771 | 771 | |
|---|
| 772 | 772 | /** |
|---|
| 773 | 773 | * genwqe_pci_fundamental_reset() - trigger a PCIe fundamental reset on the slot |
|---|
| 774 | + * @pci_dev: PCI device information struct |
|---|
| 774 | 775 | * |
|---|
| 775 | 776 | * Note: pci_set_pcie_reset_state() is not implemented on all archs, so this |
|---|
| 776 | 777 | * reset method will not work in all cases. |
|---|
| .. | .. |
|---|
| 835 | 836 | return rc; |
|---|
| 836 | 837 | } |
|---|
| 837 | 838 | |
|---|
| 838 | | -/* |
|---|
| 839 | +/** |
|---|
| 839 | 840 | * genwqe_reload_bistream() - reload card bitstream |
|---|
| 841 | + * @cd: GenWQE device information |
|---|
| 840 | 842 | * |
|---|
| 841 | 843 | * Set the appropriate register and call fundamental reset to reaload the card |
|---|
| 842 | 844 | * bitstream. |
|---|
| .. | .. |
|---|
| 889 | 891 | |
|---|
| 890 | 892 | /** |
|---|
| 891 | 893 | * genwqe_health_thread() - Health checking thread |
|---|
| 894 | + * @data: GenWQE device information |
|---|
| 892 | 895 | * |
|---|
| 893 | 896 | * This thread is only started for the PF of the card. |
|---|
| 894 | 897 | * |
|---|
| .. | .. |
|---|
| 1052 | 1055 | |
|---|
| 1053 | 1056 | static int genwqe_health_check_stop(struct genwqe_dev *cd) |
|---|
| 1054 | 1057 | { |
|---|
| 1055 | | - int rc; |
|---|
| 1056 | | - |
|---|
| 1057 | 1058 | if (!genwqe_health_thread_running(cd)) |
|---|
| 1058 | 1059 | return -EIO; |
|---|
| 1059 | 1060 | |
|---|
| 1060 | | - rc = kthread_stop(cd->health_thread); |
|---|
| 1061 | + kthread_stop(cd->health_thread); |
|---|
| 1061 | 1062 | cd->health_thread = NULL; |
|---|
| 1062 | 1063 | return 0; |
|---|
| 1063 | 1064 | } |
|---|
| 1064 | 1065 | |
|---|
| 1065 | 1066 | /** |
|---|
| 1066 | 1067 | * genwqe_pci_setup() - Allocate PCIe related resources for our card |
|---|
| 1068 | + * @cd: GenWQE device information |
|---|
| 1067 | 1069 | */ |
|---|
| 1068 | 1070 | static int genwqe_pci_setup(struct genwqe_dev *cd) |
|---|
| 1069 | 1071 | { |
|---|
| .. | .. |
|---|
| 1149 | 1151 | |
|---|
| 1150 | 1152 | /** |
|---|
| 1151 | 1153 | * genwqe_pci_remove() - Free PCIe related resources for our card |
|---|
| 1154 | + * @cd: GenWQE device information |
|---|
| 1152 | 1155 | */ |
|---|
| 1153 | 1156 | static void genwqe_pci_remove(struct genwqe_dev *cd) |
|---|
| 1154 | 1157 | { |
|---|
| .. | .. |
|---|
| 1163 | 1166 | |
|---|
| 1164 | 1167 | /** |
|---|
| 1165 | 1168 | * genwqe_probe() - Device initialization |
|---|
| 1166 | | - * @pdev: PCI device information struct |
|---|
| 1169 | + * @pci_dev: PCI device information struct |
|---|
| 1170 | + * @id: PCI device ID |
|---|
| 1167 | 1171 | * |
|---|
| 1168 | 1172 | * Callable for multiple cards. This function is called on bind. |
|---|
| 1169 | 1173 | * |
|---|
| .. | .. |
|---|
| 1223 | 1227 | |
|---|
| 1224 | 1228 | /** |
|---|
| 1225 | 1229 | * genwqe_remove() - Called when device is removed (hot-plugable) |
|---|
| 1230 | + * @pci_dev: PCI device information struct |
|---|
| 1226 | 1231 | * |
|---|
| 1227 | 1232 | * Or when driver is unloaded respecitively when unbind is done. |
|---|
| 1228 | 1233 | */ |
|---|
| .. | .. |
|---|
| 1242 | 1247 | genwqe_dev_free(cd); |
|---|
| 1243 | 1248 | } |
|---|
| 1244 | 1249 | |
|---|
| 1245 | | -/* |
|---|
| 1250 | +/** |
|---|
| 1246 | 1251 | * genwqe_err_error_detected() - Error detection callback |
|---|
| 1252 | + * @pci_dev: PCI device information struct |
|---|
| 1253 | + * @state: PCI channel state |
|---|
| 1247 | 1254 | * |
|---|
| 1248 | 1255 | * This callback is called by the PCI subsystem whenever a PCI bus |
|---|
| 1249 | 1256 | * error is detected. |
|---|
| 1250 | 1257 | */ |
|---|
| 1251 | 1258 | static pci_ers_result_t genwqe_err_error_detected(struct pci_dev *pci_dev, |
|---|
| 1252 | | - enum pci_channel_state state) |
|---|
| 1259 | + pci_channel_state_t state) |
|---|
| 1253 | 1260 | { |
|---|
| 1254 | 1261 | struct genwqe_dev *cd; |
|---|
| 1255 | 1262 | |
|---|
| .. | .. |
|---|
| 1333 | 1340 | return 0; |
|---|
| 1334 | 1341 | } |
|---|
| 1335 | 1342 | |
|---|
| 1336 | | -static struct pci_error_handlers genwqe_err_handler = { |
|---|
| 1343 | +static const struct pci_error_handlers genwqe_err_handler = { |
|---|
| 1337 | 1344 | .error_detected = genwqe_err_error_detected, |
|---|
| 1338 | 1345 | .mmio_enabled = genwqe_err_result_none, |
|---|
| 1339 | 1346 | .slot_reset = genwqe_err_slot_reset, |
|---|
| .. | .. |
|---|
| 1351 | 1358 | |
|---|
| 1352 | 1359 | /** |
|---|
| 1353 | 1360 | * genwqe_devnode() - Set default access mode for genwqe devices. |
|---|
| 1361 | + * @dev: Pointer to device (unused) |
|---|
| 1362 | + * @mode: Carrier to pass-back given mode (permissions) |
|---|
| 1354 | 1363 | * |
|---|
| 1355 | 1364 | * Default mode should be rw for everybody. Do not change default |
|---|
| 1356 | 1365 | * device name. |
|---|
| .. | .. |
|---|
| 1378 | 1387 | class_genwqe->devnode = genwqe_devnode; |
|---|
| 1379 | 1388 | |
|---|
| 1380 | 1389 | debugfs_genwqe = debugfs_create_dir(GENWQE_DEVNAME, NULL); |
|---|
| 1381 | | - if (!debugfs_genwqe) { |
|---|
| 1382 | | - rc = -ENOMEM; |
|---|
| 1383 | | - goto err_out; |
|---|
| 1384 | | - } |
|---|
| 1385 | 1390 | |
|---|
| 1386 | 1391 | rc = pci_register_driver(&genwqe_driver); |
|---|
| 1387 | 1392 | if (rc != 0) { |
|---|
| .. | .. |
|---|
| 1393 | 1398 | |
|---|
| 1394 | 1399 | err_out0: |
|---|
| 1395 | 1400 | debugfs_remove(debugfs_genwqe); |
|---|
| 1396 | | - err_out: |
|---|
| 1397 | 1401 | class_destroy(class_genwqe); |
|---|
| 1398 | 1402 | return rc; |
|---|
| 1399 | 1403 | } |
|---|