hw_fence_drv_utils.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef __HW_FENCE_DRV_UTILS_H
  6. #define __HW_FENCE_DRV_UTILS_H
  7. /**
  8. * enum hw_fence_mem_reserve - Types of reservations for the carved-out memory.
  9. * HW_FENCE_MEM_RESERVE_CTRL_QUEUE: Reserve memory for the ctrl rx/tx queues.
  10. * HW_FENCE_MEM_RESERVE_LOCKS_REGION: Reserve memory for the per-client locks memory region.
  11. * HW_FENCE_MEM_RESERVE_TABLE: Reserve memory for the hw-fences global table.
  12. * HW_FENCE_MEM_RESERVE_CLIENT_QUEUE: Reserve memory per-client for the rx/tx queues.
  13. */
  14. enum hw_fence_mem_reserve {
  15. HW_FENCE_MEM_RESERVE_CTRL_QUEUE,
  16. HW_FENCE_MEM_RESERVE_LOCKS_REGION,
  17. HW_FENCE_MEM_RESERVE_TABLE,
  18. HW_FENCE_MEM_RESERVE_CLIENT_QUEUE
  19. };
  20. /**
  21. * global_atomic_store() - Inter-processor lock
  22. * @drv_data: hw fence driver data
  23. * @lock: memory to lock
  24. * @val: if true, api locks the memory, if false it unlocks the memory
  25. */
  26. void global_atomic_store(struct hw_fence_driver_data *drv_data, uint64_t *lock, bool val);
  27. /**
  28. * hw_fence_utils_init_virq() - Initialilze doorbell (i.e. vIRQ) for SVM to HLOS signaling
  29. * @drv_data: hw fence driver data
  30. *
  31. * Returns zero if success, otherwise returns negative error code.
  32. */
  33. int hw_fence_utils_init_virq(struct hw_fence_driver_data *drv_data);
  34. /**
  35. * hw_fence_utils_process_doorbell_mask() - Sends doorbell mask to process the signaled clients
  36. * this API is only exported for simulation purposes.
  37. * @drv_data: hw fence driver data.
  38. * @db_flags: doorbell flag
  39. */
  40. void hw_fence_utils_process_doorbell_mask(struct hw_fence_driver_data *drv_data, u64 db_flags);
  41. /**
  42. * hw_fence_utils_alloc_mem() - Allocates the carved-out memory pool that will be used for the HW
  43. * Fence global table, locks and queues.
  44. * @hw_fence_drv_data: hw fence driver data
  45. *
  46. * Returns zero if success, otherwise returns negative error code.
  47. */
  48. int hw_fence_utils_alloc_mem(struct hw_fence_driver_data *hw_fence_drv_data);
  49. /**
  50. * hw_fence_utils_reserve_mem() - Reserves memory from the carved-out memory pool.
  51. * @drv_data: hw fence driver data.
  52. * @type: memory reservation type.
  53. * @phys: physical address of the carved-out memory pool
  54. *
  55. * Returns zero if success, otherwise returns negative error code.
  56. */
  57. int hw_fence_utils_reserve_mem(struct hw_fence_driver_data *drv_data,
  58. enum hw_fence_mem_reserve type, phys_addr_t *phys, void **pa, u32 *size, int client_id);
  59. /**
  60. * hw_fence_utils_parse_dt_props() - Init dt properties
  61. * @drv_data: hw fence driver data
  62. *
  63. * Returns zero if success, otherwise returns negative error code.
  64. */
  65. int hw_fence_utils_parse_dt_props(struct hw_fence_driver_data *drv_data);
  66. /**
  67. * hw_fence_utils_map_ipcc() - Maps IPCC registers and enable signaling
  68. * @drv_data: hw fence driver data
  69. *
  70. * Returns zero if success, otherwise returns negative error code.
  71. */
  72. int hw_fence_utils_map_ipcc(struct hw_fence_driver_data *drv_data);
  73. /**
  74. * hw_fence_utils_map_qtime() - Maps qtime register
  75. * @drv_data: hw fence driver data
  76. *
  77. * Returns zero if success, otherwise returns negative error code.
  78. */
  79. int hw_fence_utils_map_qtime(struct hw_fence_driver_data *drv_data);
  80. /**
  81. * hw_fence_utils_map_ctl_start() - Maps ctl_start registers from dpu hw
  82. * @drv_data: hw fence driver data
  83. *
  84. * Returns zero if success, otherwise returns negative error code. This API is only used
  85. * for simulation purposes in platforms where dpu does not support ipc signal.
  86. */
  87. int hw_fence_utils_map_ctl_start(struct hw_fence_driver_data *drv_data);
  88. /**
  89. * hw_fence_utils_cleanup_fence() - Cleanup the hw-fence from a specified client
  90. * @drv_data: hw fence driver data
  91. * @hw_fence_client: client, for which the fence must be cleared
  92. * @hw_fence: hw-fence to cleanup
  93. * @hash: hash of the hw-fence to cleanup
  94. * @reset_flags: flags to determine how to handle the reset
  95. *
  96. * Returns zero if success, otherwise returns negative error code.
  97. */
  98. int hw_fence_utils_cleanup_fence(struct hw_fence_driver_data *drv_data,
  99. struct msm_hw_fence_client *hw_fence_client, struct msm_hw_fence *hw_fence, u64 hash,
  100. u32 reset_flags);
  101. #endif /* __HW_FENCE_DRV_UTILS_H */