hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/crypto/cavium/cpt/cptvf_reqmanager.c
....@@ -1,12 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2016 Cavium, Inc.
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of version 2 of the GNU General Public License
6
- * as published by the Free Software Foundation.
74 */
85
96 #include "cptvf.h"
7
+#include "cptvf_algs.h"
108 #include "request_manager.h"
119
1210 /**
....@@ -92,11 +90,11 @@
9290 case 3:
9391 sg_ptr->u.s.len2 = cpu_to_be16(list[i * 4 + 2].size);
9492 sg_ptr->ptr2 = cpu_to_be64(list[i * 4 + 2].dma_addr);
95
- /* Fall through */
93
+ fallthrough;
9694 case 2:
9795 sg_ptr->u.s.len1 = cpu_to_be16(list[i * 4 + 1].size);
9896 sg_ptr->ptr1 = cpu_to_be64(list[i * 4 + 1].dma_addr);
99
- /* Fall through */
97
+ fallthrough;
10098 case 1:
10199 sg_ptr->u.s.len0 = cpu_to_be16(list[i * 4 + 0].size);
102100 sg_ptr->ptr0 = cpu_to_be64(list[i * 4 + 0].dma_addr);
....@@ -176,11 +174,10 @@
176174 goto scatter_gather_clean;
177175 }
178176
179
- ((u16 *)info->in_buffer)[0] = req->outcnt;
180
- ((u16 *)info->in_buffer)[1] = req->incnt;
181
- ((u16 *)info->in_buffer)[2] = 0;
182
- ((u16 *)info->in_buffer)[3] = 0;
183
- *(u64 *)info->in_buffer = cpu_to_be64p((u64 *)info->in_buffer);
177
+ ((__be16 *)info->in_buffer)[0] = cpu_to_be16(req->outcnt);
178
+ ((__be16 *)info->in_buffer)[1] = cpu_to_be16(req->incnt);
179
+ ((__be16 *)info->in_buffer)[2] = 0;
180
+ ((__be16 *)info->in_buffer)[3] = 0;
184181
185182 memcpy(&info->in_buffer[8], info->gather_components,
186183 g_sz_bytes);
....@@ -223,7 +220,7 @@
223220 return ret;
224221 }
225222
226
-int send_cpt_command(struct cpt_vf *cptvf, union cpt_inst_s *cmd,
223
+static int send_cpt_command(struct cpt_vf *cptvf, union cpt_inst_s *cmd,
227224 u32 qno)
228225 {
229226 struct pci_dev *pdev = cptvf->pdev;
....@@ -270,7 +267,7 @@
270267 return ret;
271268 }
272269
273
-void do_request_cleanup(struct cpt_vf *cptvf,
270
+static void do_request_cleanup(struct cpt_vf *cptvf,
274271 struct cpt_info_buffer *info)
275272 {
276273 int i;
....@@ -308,25 +305,15 @@
308305 }
309306 }
310307
311
- if (info->scatter_components)
312
- kzfree(info->scatter_components);
313
-
314
- if (info->gather_components)
315
- kzfree(info->gather_components);
316
-
317
- if (info->out_buffer)
318
- kzfree(info->out_buffer);
319
-
320
- if (info->in_buffer)
321
- kzfree(info->in_buffer);
322
-
323
- if (info->completion_addr)
324
- kzfree((void *)info->completion_addr);
325
-
326
- kzfree(info);
308
+ kfree_sensitive(info->scatter_components);
309
+ kfree_sensitive(info->gather_components);
310
+ kfree_sensitive(info->out_buffer);
311
+ kfree_sensitive(info->in_buffer);
312
+ kfree_sensitive((void *)info->completion_addr);
313
+ kfree_sensitive(info);
327314 }
328315
329
-void do_post_process(struct cpt_vf *cptvf, struct cpt_info_buffer *info)
316
+static void do_post_process(struct cpt_vf *cptvf, struct cpt_info_buffer *info)
330317 {
331318 struct pci_dev *pdev = cptvf->pdev;
332319
....@@ -483,8 +470,6 @@
483470 vq_cmd.cmd.s.param2 = cpu_to_be16(cpt_req->param2);
484471 vq_cmd.cmd.s.dlen = cpu_to_be16(cpt_req->dlen);
485472
486
- /* 64-bit swap for microcode data reads, not needed for addresses*/
487
- vq_cmd.cmd.u64 = cpu_to_be64(vq_cmd.cmd.u64);
488473 vq_cmd.dptr = info->dptr_baddr;
489474 vq_cmd.rptr = info->rptr_baddr;
490475 vq_cmd.cptr.u64 = 0;