forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 ee930fffee469d076998274a2ca55e13dc1efb67
kernel/drivers/misc/genwqe/card_base.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /**
23 * IBM Accelerator Family 'GenWQE'
34 *
....@@ -7,15 +8,6 @@
78 * Author: Joerg-Stephan Vogt <jsvogt@de.ibm.com>
89 * Author: Michael Jung <mijung@gmx.net>
910 * 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.
1911 */
2012
2113 /*
....@@ -24,7 +16,6 @@
2416 * controlled from here.
2517 */
2618
27
-#include <linux/module.h>
2819 #include <linux/types.h>
2920 #include <linux/pci.h>
3021 #include <linux/err.h>
....@@ -174,6 +165,7 @@
174165
175166 /**
176167 * genwqe_bus_reset() - Card recovery
168
+ * @cd: GenWQE device information
177169 *
178170 * pci_reset_function() will recover the device and ensure that the
179171 * registers are accessible again when it completes with success. If
....@@ -271,6 +263,7 @@
271263
272264 /**
273265 * genwqe_recovery_on_fatal_gfir_required() - Version depended actions
266
+ * @cd: GenWQE device information
274267 *
275268 * Bitstreams older than 2013-02-17 have a bug where fatal GFIRs must
276269 * be ignored. This is e.g. true for the bitstream we gave to the card
....@@ -289,6 +282,7 @@
289282
290283 /**
291284 * genwqe_T_psec() - Calculate PF/VF timeout register content
285
+ * @cd: GenWQE device information
292286 *
293287 * Note: From a design perspective it turned out to be a bad idea to
294288 * use codes here to specifiy the frequency/speed values. An old
....@@ -312,6 +306,7 @@
312306
313307 /**
314308 * genwqe_setup_pf_jtimer() - Setup PF hardware timeouts for DDCB execution
309
+ * @cd: GenWQE device information
315310 *
316311 * Do this _after_ card_reset() is called. Otherwise the values will
317312 * vanish. The settings need to be done when the queues are inactive.
....@@ -338,6 +333,7 @@
338333
339334 /**
340335 * genwqe_setup_vf_jtimer() - Setup VF hardware timeouts for DDCB execution
336
+ * @cd: GenWQE device information
341337 */
342338 static bool genwqe_setup_vf_jtimer(struct genwqe_dev *cd)
343339 {
....@@ -552,6 +548,7 @@
552548
553549 /**
554550 * genwqe_stop() - Stop card operation
551
+ * @cd: GenWQE device information
555552 *
556553 * Recovery notes:
557554 * As long as genwqe_thread runs we might access registers during
....@@ -578,6 +575,8 @@
578575
579576 /**
580577 * 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
581580 *
582581 * If fatal_err is set no register access is possible anymore. It is
583582 * likely that genwqe_start fails in that situation. Proper error
....@@ -627,6 +626,7 @@
627626
628627 /**
629628 * genwqe_fir_checking() - Check the fault isolation registers of the card
629
+ * @cd: GenWQE device information
630630 *
631631 * If this code works ok, can be tried out with help of the genwqe_poke tool:
632632 * sudo ./tools/genwqe_poke 0x8 0xfefefefefef
....@@ -771,6 +771,7 @@
771771
772772 /**
773773 * genwqe_pci_fundamental_reset() - trigger a PCIe fundamental reset on the slot
774
+ * @pci_dev: PCI device information struct
774775 *
775776 * Note: pci_set_pcie_reset_state() is not implemented on all archs, so this
776777 * reset method will not work in all cases.
....@@ -835,8 +836,9 @@
835836 return rc;
836837 }
837838
838
-/*
839
+/**
839840 * genwqe_reload_bistream() - reload card bitstream
841
+ * @cd: GenWQE device information
840842 *
841843 * Set the appropriate register and call fundamental reset to reaload the card
842844 * bitstream.
....@@ -889,6 +891,7 @@
889891
890892 /**
891893 * genwqe_health_thread() - Health checking thread
894
+ * @data: GenWQE device information
892895 *
893896 * This thread is only started for the PF of the card.
894897 *
....@@ -1052,18 +1055,17 @@
10521055
10531056 static int genwqe_health_check_stop(struct genwqe_dev *cd)
10541057 {
1055
- int rc;
1056
-
10571058 if (!genwqe_health_thread_running(cd))
10581059 return -EIO;
10591060
1060
- rc = kthread_stop(cd->health_thread);
1061
+ kthread_stop(cd->health_thread);
10611062 cd->health_thread = NULL;
10621063 return 0;
10631064 }
10641065
10651066 /**
10661067 * genwqe_pci_setup() - Allocate PCIe related resources for our card
1068
+ * @cd: GenWQE device information
10671069 */
10681070 static int genwqe_pci_setup(struct genwqe_dev *cd)
10691071 {
....@@ -1149,6 +1151,7 @@
11491151
11501152 /**
11511153 * genwqe_pci_remove() - Free PCIe related resources for our card
1154
+ * @cd: GenWQE device information
11521155 */
11531156 static void genwqe_pci_remove(struct genwqe_dev *cd)
11541157 {
....@@ -1163,7 +1166,8 @@
11631166
11641167 /**
11651168 * genwqe_probe() - Device initialization
1166
- * @pdev: PCI device information struct
1169
+ * @pci_dev: PCI device information struct
1170
+ * @id: PCI device ID
11671171 *
11681172 * Callable for multiple cards. This function is called on bind.
11691173 *
....@@ -1223,6 +1227,7 @@
12231227
12241228 /**
12251229 * genwqe_remove() - Called when device is removed (hot-plugable)
1230
+ * @pci_dev: PCI device information struct
12261231 *
12271232 * Or when driver is unloaded respecitively when unbind is done.
12281233 */
....@@ -1242,14 +1247,16 @@
12421247 genwqe_dev_free(cd);
12431248 }
12441249
1245
-/*
1250
+/**
12461251 * genwqe_err_error_detected() - Error detection callback
1252
+ * @pci_dev: PCI device information struct
1253
+ * @state: PCI channel state
12471254 *
12481255 * This callback is called by the PCI subsystem whenever a PCI bus
12491256 * error is detected.
12501257 */
12511258 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)
12531260 {
12541261 struct genwqe_dev *cd;
12551262
....@@ -1333,7 +1340,7 @@
13331340 return 0;
13341341 }
13351342
1336
-static struct pci_error_handlers genwqe_err_handler = {
1343
+static const struct pci_error_handlers genwqe_err_handler = {
13371344 .error_detected = genwqe_err_error_detected,
13381345 .mmio_enabled = genwqe_err_result_none,
13391346 .slot_reset = genwqe_err_slot_reset,
....@@ -1351,6 +1358,8 @@
13511358
13521359 /**
13531360 * genwqe_devnode() - Set default access mode for genwqe devices.
1361
+ * @dev: Pointer to device (unused)
1362
+ * @mode: Carrier to pass-back given mode (permissions)
13541363 *
13551364 * Default mode should be rw for everybody. Do not change default
13561365 * device name.
....@@ -1378,10 +1387,6 @@
13781387 class_genwqe->devnode = genwqe_devnode;
13791388
13801389 debugfs_genwqe = debugfs_create_dir(GENWQE_DEVNAME, NULL);
1381
- if (!debugfs_genwqe) {
1382
- rc = -ENOMEM;
1383
- goto err_out;
1384
- }
13851390
13861391 rc = pci_register_driver(&genwqe_driver);
13871392 if (rc != 0) {
....@@ -1393,7 +1398,6 @@
13931398
13941399 err_out0:
13951400 debugfs_remove(debugfs_genwqe);
1396
- err_out:
13971401 class_destroy(class_genwqe);
13981402 return rc;
13991403 }