aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/ats.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/ats.c')
-rw-r--r--drivers/pci/ats.c90
1 files changed, 45 insertions, 45 deletions
diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c
index b0dd08e6a9da..9dd90b30f91a 100644
--- a/drivers/pci/ats.c
+++ b/drivers/pci/ats.c
@@ -175,21 +175,22 @@ int pci_enable_pri(struct pci_dev *pdev, u32 reqs)
175 u32 max_requests; 175 u32 max_requests;
176 int pos; 176 int pos;
177 177
178 pos = pci_find_ext_capability(pdev, PCI_PRI_CAP); 178 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PRI);
179 if (!pos) 179 if (!pos)
180 return -EINVAL; 180 return -EINVAL;
181 181
182 pci_read_config_word(pdev, pos + PCI_PRI_CONTROL_OFF, &control); 182 pci_read_config_word(pdev, pos + PCI_PRI_CTRL, &control);
183 pci_read_config_word(pdev, pos + PCI_PRI_STATUS_OFF, &status); 183 pci_read_config_word(pdev, pos + PCI_PRI_STATUS, &status);
184 if ((control & PCI_PRI_ENABLE) || !(status & PCI_PRI_STATUS_STOPPED)) 184 if ((control & PCI_PRI_CTRL_ENABLE) ||
185 !(status & PCI_PRI_STATUS_STOPPED))
185 return -EBUSY; 186 return -EBUSY;
186 187
187 pci_read_config_dword(pdev, pos + PCI_PRI_MAX_REQ_OFF, &max_requests); 188 pci_read_config_dword(pdev, pos + PCI_PRI_MAX_REQ, &max_requests);
188 reqs = min(max_requests, reqs); 189 reqs = min(max_requests, reqs);
189 pci_write_config_dword(pdev, pos + PCI_PRI_ALLOC_REQ_OFF, reqs); 190 pci_write_config_dword(pdev, pos + PCI_PRI_ALLOC_REQ, reqs);
190 191
191 control |= PCI_PRI_ENABLE; 192 control |= PCI_PRI_CTRL_ENABLE;
192 pci_write_config_word(pdev, pos + PCI_PRI_CONTROL_OFF, control); 193 pci_write_config_word(pdev, pos + PCI_PRI_CTRL, control);
193 194
194 return 0; 195 return 0;
195} 196}
@@ -206,13 +207,13 @@ void pci_disable_pri(struct pci_dev *pdev)
206 u16 control; 207 u16 control;
207 int pos; 208 int pos;
208 209
209 pos = pci_find_ext_capability(pdev, PCI_PRI_CAP); 210 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PRI);
210 if (!pos) 211 if (!pos)
211 return; 212 return;
212 213
213 pci_read_config_word(pdev, pos + PCI_PRI_CONTROL_OFF, &control); 214 pci_read_config_word(pdev, pos + PCI_PRI_CTRL, &control);
214 control &= ~PCI_PRI_ENABLE; 215 control &= ~PCI_PRI_CTRL_ENABLE;
215 pci_write_config_word(pdev, pos + PCI_PRI_CONTROL_OFF, control); 216 pci_write_config_word(pdev, pos + PCI_PRI_CTRL, control);
216} 217}
217EXPORT_SYMBOL_GPL(pci_disable_pri); 218EXPORT_SYMBOL_GPL(pci_disable_pri);
218 219
@@ -227,13 +228,13 @@ bool pci_pri_enabled(struct pci_dev *pdev)
227 u16 control; 228 u16 control;
228 int pos; 229 int pos;
229 230
230 pos = pci_find_ext_capability(pdev, PCI_PRI_CAP); 231 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PRI);
231 if (!pos) 232 if (!pos)
232 return false; 233 return false;
233 234
234 pci_read_config_word(pdev, pos + PCI_PRI_CONTROL_OFF, &control); 235 pci_read_config_word(pdev, pos + PCI_PRI_CTRL, &control);
235 236
236 return (control & PCI_PRI_ENABLE) ? true : false; 237 return (control & PCI_PRI_CTRL_ENABLE) ? true : false;
237} 238}
238EXPORT_SYMBOL_GPL(pci_pri_enabled); 239EXPORT_SYMBOL_GPL(pci_pri_enabled);
239 240
@@ -249,17 +250,17 @@ int pci_reset_pri(struct pci_dev *pdev)
249 u16 control; 250 u16 control;
250 int pos; 251 int pos;
251 252
252 pos = pci_find_ext_capability(pdev, PCI_PRI_CAP); 253 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PRI);
253 if (!pos) 254 if (!pos)
254 return -EINVAL; 255 return -EINVAL;
255 256
256 pci_read_config_word(pdev, pos + PCI_PRI_CONTROL_OFF, &control); 257 pci_read_config_word(pdev, pos + PCI_PRI_CTRL, &control);
257 if (control & PCI_PRI_ENABLE) 258 if (control & PCI_PRI_CTRL_ENABLE)
258 return -EBUSY; 259 return -EBUSY;
259 260
260 control |= PCI_PRI_RESET; 261 control |= PCI_PRI_CTRL_RESET;
261 262
262 pci_write_config_word(pdev, pos + PCI_PRI_CONTROL_OFF, control); 263 pci_write_config_word(pdev, pos + PCI_PRI_CTRL, control);
263 264
264 return 0; 265 return 0;
265} 266}
@@ -282,14 +283,14 @@ bool pci_pri_stopped(struct pci_dev *pdev)
282 u16 control, status; 283 u16 control, status;
283 int pos; 284 int pos;
284 285
285 pos = pci_find_ext_capability(pdev, PCI_PRI_CAP); 286 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PRI);
286 if (!pos) 287 if (!pos)
287 return true; 288 return true;
288 289
289 pci_read_config_word(pdev, pos + PCI_PRI_CONTROL_OFF, &control); 290 pci_read_config_word(pdev, pos + PCI_PRI_CTRL, &control);
290 pci_read_config_word(pdev, pos + PCI_PRI_STATUS_OFF, &status); 291 pci_read_config_word(pdev, pos + PCI_PRI_STATUS, &status);
291 292
292 if (control & PCI_PRI_ENABLE) 293 if (control & PCI_PRI_CTRL_ENABLE)
293 return false; 294 return false;
294 295
295 return (status & PCI_PRI_STATUS_STOPPED) ? true : false; 296 return (status & PCI_PRI_STATUS_STOPPED) ? true : false;
@@ -311,15 +312,15 @@ int pci_pri_status(struct pci_dev *pdev)
311 u16 status, control; 312 u16 status, control;
312 int pos; 313 int pos;
313 314
314 pos = pci_find_ext_capability(pdev, PCI_PRI_CAP); 315 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PRI);
315 if (!pos) 316 if (!pos)
316 return -EINVAL; 317 return -EINVAL;
317 318
318 pci_read_config_word(pdev, pos + PCI_PRI_CONTROL_OFF, &control); 319 pci_read_config_word(pdev, pos + PCI_PRI_CTRL, &control);
319 pci_read_config_word(pdev, pos + PCI_PRI_STATUS_OFF, &status); 320 pci_read_config_word(pdev, pos + PCI_PRI_STATUS, &status);
320 321
321 /* Stopped bit is undefined when enable == 1, so clear it */ 322 /* Stopped bit is undefined when enable == 1, so clear it */
322 if (control & PCI_PRI_ENABLE) 323 if (control & PCI_PRI_CTRL_ENABLE)
323 status &= ~PCI_PRI_STATUS_STOPPED; 324 status &= ~PCI_PRI_STATUS_STOPPED;
324 325
325 return status; 326 return status;
@@ -342,25 +343,25 @@ int pci_enable_pasid(struct pci_dev *pdev, int features)
342 u16 control, supported; 343 u16 control, supported;
343 int pos; 344 int pos;
344 345
345 pos = pci_find_ext_capability(pdev, PCI_PASID_CAP); 346 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PASID);
346 if (!pos) 347 if (!pos)
347 return -EINVAL; 348 return -EINVAL;
348 349
349 pci_read_config_word(pdev, pos + PCI_PASID_CONTROL_OFF, &control); 350 pci_read_config_word(pdev, pos + PCI_PASID_CTRL, &control);
350 pci_read_config_word(pdev, pos + PCI_PASID_CAP_OFF, &supported); 351 pci_read_config_word(pdev, pos + PCI_PASID_CAP, &supported);
351 352
352 if (!(supported & PCI_PASID_ENABLE)) 353 if (control & PCI_PASID_CTRL_ENABLE)
353 return -EINVAL; 354 return -EINVAL;
354 355
355 supported &= PCI_PASID_EXEC | PCI_PASID_PRIV; 356 supported &= PCI_PASID_CAP_EXEC | PCI_PASID_CAP_PRIV;
356 357
357 /* User wants to enable anything unsupported? */ 358 /* User wants to enable anything unsupported? */
358 if ((supported & features) != features) 359 if ((supported & features) != features)
359 return -EINVAL; 360 return -EINVAL;
360 361
361 control = PCI_PASID_ENABLE | features; 362 control = PCI_PASID_CTRL_ENABLE | features;
362 363
363 pci_write_config_word(pdev, pos + PCI_PASID_CONTROL_OFF, control); 364 pci_write_config_word(pdev, pos + PCI_PASID_CTRL, control);
364 365
365 return 0; 366 return 0;
366} 367}
@@ -376,11 +377,11 @@ void pci_disable_pasid(struct pci_dev *pdev)
376 u16 control = 0; 377 u16 control = 0;
377 int pos; 378 int pos;
378 379
379 pos = pci_find_ext_capability(pdev, PCI_PASID_CAP); 380 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PASID);
380 if (!pos) 381 if (!pos)
381 return; 382 return;
382 383
383 pci_write_config_word(pdev, pos + PCI_PASID_CONTROL_OFF, control); 384 pci_write_config_word(pdev, pos + PCI_PASID_CTRL, control);
384} 385}
385EXPORT_SYMBOL_GPL(pci_disable_pasid); 386EXPORT_SYMBOL_GPL(pci_disable_pasid);
386 387
@@ -391,22 +392,21 @@ EXPORT_SYMBOL_GPL(pci_disable_pasid);
391 * Returns a negative value when no PASI capability is present. 392 * Returns a negative value when no PASI capability is present.
392 * Otherwise is returns a bitmask with supported features. Current 393 * Otherwise is returns a bitmask with supported features. Current
393 * features reported are: 394 * features reported are:
394 * PCI_PASID_ENABLE - PASID capability can be enabled 395 * PCI_PASID_CAP_EXEC - Execute permission supported
395 * PCI_PASID_EXEC - Execute permission supported 396 * PCI_PASID_CAP_PRIV - Priviledged mode supported
396 * PCI_PASID_PRIV - Priviledged mode supported
397 */ 397 */
398int pci_pasid_features(struct pci_dev *pdev) 398int pci_pasid_features(struct pci_dev *pdev)
399{ 399{
400 u16 supported; 400 u16 supported;
401 int pos; 401 int pos;
402 402
403 pos = pci_find_ext_capability(pdev, PCI_PASID_CAP); 403 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PASID);
404 if (!pos) 404 if (!pos)
405 return -EINVAL; 405 return -EINVAL;
406 406
407 pci_read_config_word(pdev, pos + PCI_PASID_CAP_OFF, &supported); 407 pci_read_config_word(pdev, pos + PCI_PASID_CAP, &supported);
408 408
409 supported &= PCI_PASID_ENABLE | PCI_PASID_EXEC | PCI_PASID_PRIV; 409 supported &= PCI_PASID_CAP_EXEC | PCI_PASID_CAP_PRIV;
410 410
411 return supported; 411 return supported;
412} 412}
@@ -426,11 +426,11 @@ int pci_max_pasids(struct pci_dev *pdev)
426 u16 supported; 426 u16 supported;
427 int pos; 427 int pos;
428 428
429 pos = pci_find_ext_capability(pdev, PCI_PASID_CAP); 429 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PASID);
430 if (!pos) 430 if (!pos)
431 return -EINVAL; 431 return -EINVAL;
432 432
433 pci_read_config_word(pdev, pos + PCI_PASID_CAP_OFF, &supported); 433 pci_read_config_word(pdev, pos + PCI_PASID_CAP, &supported);
434 434
435 supported = (supported & PASID_NUMBER_MASK) >> PASID_NUMBER_SHIFT; 435 supported = (supported & PASID_NUMBER_MASK) >> PASID_NUMBER_SHIFT;
436 436