amdgpu_ids.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright 2017 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. */
  23. #ifndef __AMDGPU_IDS_H__
  24. #define __AMDGPU_IDS_H__
  25. #include <linux/types.h>
  26. #include <linux/mutex.h>
  27. #include <linux/list.h>
  28. #include <linux/dma-fence.h>
  29. #include "amdgpu_sync.h"
  30. /* maximum number of VMIDs */
  31. #define AMDGPU_NUM_VMID 16
  32. struct amdgpu_device;
  33. struct amdgpu_vm;
  34. struct amdgpu_ring;
  35. struct amdgpu_sync;
  36. struct amdgpu_job;
  37. struct amdgpu_vmid {
  38. struct list_head list;
  39. struct amdgpu_sync active;
  40. struct dma_fence *last_flush;
  41. uint64_t owner;
  42. uint64_t pd_gpu_addr;
  43. /* last flushed PD/PT update */
  44. struct dma_fence *flushed_updates;
  45. uint32_t current_gpu_reset_count;
  46. uint32_t gds_base;
  47. uint32_t gds_size;
  48. uint32_t gws_base;
  49. uint32_t gws_size;
  50. uint32_t oa_base;
  51. uint32_t oa_size;
  52. unsigned pasid;
  53. struct dma_fence *pasid_mapping;
  54. };
  55. struct amdgpu_vmid_mgr {
  56. struct mutex lock;
  57. unsigned num_ids;
  58. struct list_head ids_lru;
  59. struct amdgpu_vmid ids[AMDGPU_NUM_VMID];
  60. atomic_t reserved_vmid_num;
  61. };
  62. int amdgpu_pasid_alloc(unsigned int bits);
  63. void amdgpu_pasid_free(unsigned int pasid);
  64. void amdgpu_pasid_free_delayed(struct reservation_object *resv,
  65. unsigned int pasid);
  66. bool amdgpu_vmid_had_gpu_reset(struct amdgpu_device *adev,
  67. struct amdgpu_vmid *id);
  68. int amdgpu_vmid_alloc_reserved(struct amdgpu_device *adev,
  69. struct amdgpu_vm *vm,
  70. unsigned vmhub);
  71. void amdgpu_vmid_free_reserved(struct amdgpu_device *adev,
  72. struct amdgpu_vm *vm,
  73. unsigned vmhub);
  74. int amdgpu_vmid_grab(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
  75. struct amdgpu_sync *sync, struct dma_fence *fence,
  76. struct amdgpu_job *job);
  77. void amdgpu_vmid_reset(struct amdgpu_device *adev, unsigned vmhub,
  78. unsigned vmid);
  79. void amdgpu_vmid_reset_all(struct amdgpu_device *adev);
  80. void amdgpu_vmid_mgr_init(struct amdgpu_device *adev);
  81. void amdgpu_vmid_mgr_fini(struct amdgpu_device *adev);
  82. #endif