hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/mailbox/bcm-pdc-mailbox.c
....@@ -1,17 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright 2016 Broadcom
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License, version 2, as
6
- * published by the Free Software Foundation (the "GPL").
7
- *
8
- * This program is distributed in the hope that it will be useful, but
9
- * WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
- * General Public License version 2 (GPLv2) for more details.
12
- *
13
- * You should have received a copy of the GNU General Public License
14
- * version 2 (GPLv2) along with this source code.
154 */
165
176 /*
....@@ -406,8 +395,6 @@
406395 */
407396 struct scatterlist *src_sg[PDC_RING_ENTRIES];
408397
409
- struct dentry *debugfs_stats; /* debug FS stats file for this PDC */
410
-
411398 /* counters */
412399 u32 pdc_requests; /* number of request messages submitted */
413400 u32 pdc_replies; /* number of reply messages received */
....@@ -449,33 +436,33 @@
449436
450437 pdcs = filp->private_data;
451438 out_offset = 0;
452
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
439
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
453440 "SPU %u stats:\n", pdcs->pdc_idx);
454
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
441
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
455442 "PDC requests....................%u\n",
456443 pdcs->pdc_requests);
457
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
444
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
458445 "PDC responses...................%u\n",
459446 pdcs->pdc_replies);
460
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
447
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
461448 "Tx not done.....................%u\n",
462449 pdcs->last_tx_not_done);
463
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
450
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
464451 "Tx ring full....................%u\n",
465452 pdcs->tx_ring_full);
466
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
453
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
467454 "Rx ring full....................%u\n",
468455 pdcs->rx_ring_full);
469
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
456
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
470457 "Tx desc write fail. Ring full...%u\n",
471458 pdcs->txnobuf);
472
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
459
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
473460 "Rx desc write fail. Ring full...%u\n",
474461 pdcs->rxnobuf);
475
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
462
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
476463 "Receive overflow................%u\n",
477464 pdcs->rx_oflow);
478
- out_offset += snprintf(buf + out_offset, out_count - out_offset,
465
+ out_offset += scnprintf(buf + out_offset, out_count - out_offset,
479466 "Num frags in rx ring............%u\n",
480467 NRXDACTIVE(pdcs->rxin, pdcs->last_rx_curr,
481468 pdcs->nrxpost));
....@@ -512,9 +499,8 @@
512499 debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
513500
514501 /* S_IRUSR == 0400 */
515
- pdcs->debugfs_stats = debugfs_create_file(spu_stats_name, 0400,
516
- debugfs_dir, pdcs,
517
- &pdc_debugfs_stats);
502
+ debugfs_create_file(spu_stats_name, 0400, debugfs_dir, pdcs,
503
+ &pdc_debugfs_stats);
518504 }
519505
520506 static void pdc_free_debugfs(void)
....@@ -693,7 +679,7 @@
693679
694680 /* read last_rx_curr from register once */
695681 pdcs->last_rx_curr =
696
- (ioread32(&pdcs->rxregs_64->status0) &
682
+ (ioread32((const void __iomem *)&pdcs->rxregs_64->status0) &
697683 CRYPTO_D64_RS0_CD_MASK) / RING_ENTRY_SIZE;
698684
699685 do {
....@@ -976,9 +962,9 @@
976962 * a DMA receive interrupt. Reenables the receive interrupt.
977963 * @data: PDC state structure
978964 */
979
-static void pdc_tasklet_cb(unsigned long data)
965
+static void pdc_tasklet_cb(struct tasklet_struct *t)
980966 {
981
- struct pdc_state *pdcs = (struct pdc_state *)data;
967
+ struct pdc_state *pdcs = from_tasklet(pdcs, t, rx_tasklet);
982968
983969 pdc_receive(pdcs);
984970
....@@ -1471,7 +1457,7 @@
14711457 mbc->chans[chan_index].con_priv = pdcs;
14721458
14731459 /* Register mailbox controller */
1474
- err = mbox_controller_register(mbc);
1460
+ err = devm_mbox_controller_register(dev, mbc);
14751461 if (err) {
14761462 dev_crit(dev,
14771463 "Failed to register PDC mailbox controller. Error %d.",
....@@ -1603,7 +1589,7 @@
16031589 pdc_hw_init(pdcs);
16041590
16051591 /* Init tasklet for deferred DMA rx processing */
1606
- tasklet_init(&pdcs->rx_tasklet, pdc_tasklet_cb, (unsigned long)pdcs);
1592
+ tasklet_setup(&pdcs->rx_tasklet, pdc_tasklet_cb);
16071593
16081594 err = pdc_interrupts_init(pdcs);
16091595 if (err)
....@@ -1614,7 +1600,6 @@
16141600 if (err)
16151601 goto cleanup_buf_pool;
16161602
1617
- pdcs->debugfs_stats = NULL;
16181603 pdc_setup_debugfs(pdcs);
16191604
16201605 dev_dbg(dev, "pdc_probe() successful");
....@@ -1640,8 +1625,6 @@
16401625 tasklet_kill(&pdcs->rx_tasklet);
16411626
16421627 pdc_hw_disable(pdcs);
1643
-
1644
- mbox_controller_unregister(&pdcs->mbc);
16451628
16461629 dma_pool_destroy(pdcs->rx_buf_pool);
16471630 dma_pool_destroy(pdcs->ring_pool);