hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
....@@ -1,50 +1,5 @@
1
-/*
2
- This file is provided under a dual BSD/GPLv2 license. When using or
3
- redistributing this file, you may do so under either license.
4
-
5
- GPL LICENSE SUMMARY
6
- Copyright(c) 2015 Intel Corporation.
7
- This program is free software; you can redistribute it and/or modify
8
- it under the terms of version 2 of the GNU General Public License as
9
- published by the Free Software Foundation.
10
-
11
- This program is distributed in the hope that it will be useful, but
12
- WITHOUT ANY WARRANTY; without even the implied warranty of
13
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
- General Public License for more details.
15
-
16
- Contact Information:
17
- qat-linux@intel.com
18
-
19
- BSD LICENSE
20
- Copyright(c) 2015 Intel Corporation.
21
- Redistribution and use in source and binary forms, with or without
22
- modification, are permitted provided that the following conditions
23
- are met:
24
-
25
- * Redistributions of source code must retain the above copyright
26
- notice, this list of conditions and the following disclaimer.
27
- * Redistributions in binary form must reproduce the above copyright
28
- notice, this list of conditions and the following disclaimer in
29
- the documentation and/or other materials provided with the
30
- distribution.
31
- * Neither the name of Intel Corporation nor the names of its
32
- contributors may be used to endorse or promote products derived
33
- from this software without specific prior written permission.
34
-
35
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
38
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
43
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
45
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46
-*/
47
-
1
+// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only)
2
+/* Copyright(c) 2015 - 2020 Intel Corporation */
483 #include <linux/delay.h>
494 #include "adf_accel_devices.h"
505 #include "adf_common_drv.h"
....@@ -156,37 +111,19 @@
156111
157112 mutex_lock(lock);
158113
159
- /* Check if PF2VF CSR is in use by remote function */
114
+ /* Check if the PFVF CSR is in use by remote function */
160115 val = ADF_CSR_RD(pmisc_bar_addr, pf2vf_offset);
161116 if ((val & remote_in_use_mask) == remote_in_use_pattern) {
162117 dev_dbg(&GET_DEV(accel_dev),
163
- "PF2VF CSR in use by remote function\n");
118
+ "PFVF CSR in use by remote function\n");
164119 ret = -EBUSY;
165120 goto out;
166121 }
167122
168
- /* Attempt to get ownership of PF2VF CSR */
169123 msg &= ~local_in_use_mask;
170124 msg |= local_in_use_pattern;
171
- ADF_CSR_WR(pmisc_bar_addr, pf2vf_offset, msg);
172125
173
- /* Wait in case remote func also attempting to get ownership */
174
- msleep(ADF_IOV_MSG_COLLISION_DETECT_DELAY);
175
-
176
- val = ADF_CSR_RD(pmisc_bar_addr, pf2vf_offset);
177
- if ((val & local_in_use_mask) != local_in_use_pattern) {
178
- dev_dbg(&GET_DEV(accel_dev),
179
- "PF2VF CSR in use by remote - collision detected\n");
180
- ret = -EBUSY;
181
- goto out;
182
- }
183
-
184
- /*
185
- * This function now owns the PV2VF CSR. The IN_USE_BY pattern must
186
- * remain in the PF2VF CSR for all writes including ACK from remote
187
- * until this local function relinquishes the CSR. Send the message
188
- * by interrupting the remote.
189
- */
126
+ /* Attempt to get ownership of the PFVF CSR */
190127 ADF_CSR_WR(pmisc_bar_addr, pf2vf_offset, msg | int_bit);
191128
192129 /* Wait for confirmation from remote func it received the message */
....@@ -195,6 +132,12 @@
195132 val = ADF_CSR_RD(pmisc_bar_addr, pf2vf_offset);
196133 } while ((val & int_bit) && (count++ < ADF_IOV_MSG_ACK_MAX_RETRY));
197134
135
+ if (val & int_bit) {
136
+ dev_dbg(&GET_DEV(accel_dev), "ACK not received from remote\n");
137
+ val &= ~int_bit;
138
+ ret = -EIO;
139
+ }
140
+
198141 if (val != msg) {
199142 dev_dbg(&GET_DEV(accel_dev),
200143 "Collision - PFVF CSR overwritten by remote function\n");
....@@ -202,13 +145,7 @@
202145 goto out;
203146 }
204147
205
- if (val & int_bit) {
206
- dev_dbg(&GET_DEV(accel_dev), "ACK not received from remote\n");
207
- val &= ~int_bit;
208
- ret = -EIO;
209
- }
210
-
211
- /* Finished with PF2VF CSR; relinquish it and leave msg in CSR */
148
+ /* Finished with the PFVF CSR; relinquish it and leave msg in CSR */
212149 ADF_CSR_WR(pmisc_bar_addr, pf2vf_offset, val & ~local_in_use_mask);
213150 out:
214151 mutex_unlock(lock);
....@@ -216,12 +153,13 @@
216153 }
217154
218155 /**
219
- * adf_iov_putmsg() - send PF2VF message
156
+ * adf_iov_putmsg() - send PFVF message
220157 * @accel_dev: Pointer to acceleration device.
221158 * @msg: Message to send
222
- * @vf_nr: VF number to which the message will be sent
159
+ * @vf_nr: VF number to which the message will be sent if on PF, ignored
160
+ * otherwise
223161 *
224
- * Function sends a messge from the PF to a VF
162
+ * Function sends a message through the PFVF channel
225163 *
226164 * Return: 0 on success, error code otherwise.
227165 */
....@@ -399,7 +337,7 @@
399337 /* VF is newer than PF and decides whether it is compatible */
400338 if (accel_dev->vf.pf_version >= hw_data->min_iov_compat_ver)
401339 break;
402
- /* fall through */
340
+ fallthrough;
403341 case ADF_PF2VF_VF_INCOMPATIBLE:
404342 dev_err(&GET_DEV(accel_dev),
405343 "PF (vers %d) and VF (vers %d) are not compatible\n",