.. | .. |
---|
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 */ |
---|
48 | 3 | #include <linux/delay.h> |
---|
49 | 4 | #include "adf_accel_devices.h" |
---|
50 | 5 | #include "adf_common_drv.h" |
---|
.. | .. |
---|
156 | 111 | |
---|
157 | 112 | mutex_lock(lock); |
---|
158 | 113 | |
---|
159 | | - /* Check if PF2VF CSR is in use by remote function */ |
---|
| 114 | + /* Check if the PFVF CSR is in use by remote function */ |
---|
160 | 115 | val = ADF_CSR_RD(pmisc_bar_addr, pf2vf_offset); |
---|
161 | 116 | if ((val & remote_in_use_mask) == remote_in_use_pattern) { |
---|
162 | 117 | dev_dbg(&GET_DEV(accel_dev), |
---|
163 | | - "PF2VF CSR in use by remote function\n"); |
---|
| 118 | + "PFVF CSR in use by remote function\n"); |
---|
164 | 119 | ret = -EBUSY; |
---|
165 | 120 | goto out; |
---|
166 | 121 | } |
---|
167 | 122 | |
---|
168 | | - /* Attempt to get ownership of PF2VF CSR */ |
---|
169 | 123 | msg &= ~local_in_use_mask; |
---|
170 | 124 | msg |= local_in_use_pattern; |
---|
171 | | - ADF_CSR_WR(pmisc_bar_addr, pf2vf_offset, msg); |
---|
172 | 125 | |
---|
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 */ |
---|
190 | 127 | ADF_CSR_WR(pmisc_bar_addr, pf2vf_offset, msg | int_bit); |
---|
191 | 128 | |
---|
192 | 129 | /* Wait for confirmation from remote func it received the message */ |
---|
.. | .. |
---|
195 | 132 | val = ADF_CSR_RD(pmisc_bar_addr, pf2vf_offset); |
---|
196 | 133 | } while ((val & int_bit) && (count++ < ADF_IOV_MSG_ACK_MAX_RETRY)); |
---|
197 | 134 | |
---|
| 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 | + |
---|
198 | 141 | if (val != msg) { |
---|
199 | 142 | dev_dbg(&GET_DEV(accel_dev), |
---|
200 | 143 | "Collision - PFVF CSR overwritten by remote function\n"); |
---|
.. | .. |
---|
202 | 145 | goto out; |
---|
203 | 146 | } |
---|
204 | 147 | |
---|
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 */ |
---|
212 | 149 | ADF_CSR_WR(pmisc_bar_addr, pf2vf_offset, val & ~local_in_use_mask); |
---|
213 | 150 | out: |
---|
214 | 151 | mutex_unlock(lock); |
---|
.. | .. |
---|
216 | 153 | } |
---|
217 | 154 | |
---|
218 | 155 | /** |
---|
219 | | - * adf_iov_putmsg() - send PF2VF message |
---|
| 156 | + * adf_iov_putmsg() - send PFVF message |
---|
220 | 157 | * @accel_dev: Pointer to acceleration device. |
---|
221 | 158 | * @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 |
---|
223 | 161 | * |
---|
224 | | - * Function sends a messge from the PF to a VF |
---|
| 162 | + * Function sends a message through the PFVF channel |
---|
225 | 163 | * |
---|
226 | 164 | * Return: 0 on success, error code otherwise. |
---|
227 | 165 | */ |
---|
.. | .. |
---|
399 | 337 | /* VF is newer than PF and decides whether it is compatible */ |
---|
400 | 338 | if (accel_dev->vf.pf_version >= hw_data->min_iov_compat_ver) |
---|
401 | 339 | break; |
---|
402 | | - /* fall through */ |
---|
| 340 | + fallthrough; |
---|
403 | 341 | case ADF_PF2VF_VF_INCOMPATIBLE: |
---|
404 | 342 | dev_err(&GET_DEV(accel_dev), |
---|
405 | 343 | "PF (vers %d) and VF (vers %d) are not compatible\n", |
---|