hw_fence_drv_utils.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. * @lock: memory to lock
  23. * @val: if true, api locks the memory, if false it unlocks the memory
  24. */
  25. void global_atomic_store(uint64_t *lock, bool val);
  26. /**
  27. * hw_fence_utils_init_virq() - Initialilze doorbell (i.e. vIRQ) for SVM to HLOS signaling
  28. * @drv_data: hw fence driver data
  29. *
  30. * Returns zero if success, otherwise returns negative error code.
  31. */
  32. int hw_fence_utils_init_virq(struct hw_fence_driver_data *drv_data);
  33. /**
  34. * hw_fence_utils_process_doorbell_mask() - Sends doorbell mask to process the signaled clients
  35. * this API is only exported for simulation purposes.
  36. * @drv_data: hw fence driver data.
  37. * @db_flags: doorbell flag
  38. */
  39. void hw_fence_utils_process_doorbell_mask(struct hw_fence_driver_data *drv_data, u64 db_flags);
  40. /**
  41. * hw_fence_utils_alloc_mem() - Allocates the carved-out memory pool that will be used for the HW
  42. * Fence global table, locks and queues.
  43. * @hw_fence_drv_data: hw fence driver data
  44. *
  45. * Returns zero if success, otherwise returns negative error code.
  46. */
  47. int hw_fence_utils_alloc_mem(struct hw_fence_driver_data *hw_fence_drv_data);
  48. /**
  49. * hw_fence_utils_reserve_mem() - Reserves memory from the carved-out memory pool.
  50. * @drv_data: hw fence driver data.
  51. * @type: memory reservation type.
  52. * @phys: physical address of the carved-out memory pool
  53. *
  54. * Returns zero if success, otherwise returns negative error code.
  55. */
  56. int hw_fence_utils_reserve_mem(struct hw_fence_driver_data *drv_data,
  57. enum hw_fence_mem_reserve type, phys_addr_t *phys, void **pa, u32 *size, int client_id);
  58. /**
  59. * hw_fence_utils_parse_dt_props() - Init dt properties
  60. * @drv_data: hw fence driver data
  61. *
  62. * Returns zero if success, otherwise returns negative error code.
  63. */
  64. int hw_fence_utils_parse_dt_props(struct hw_fence_driver_data *drv_data);
  65. /**
  66. * hw_fence_utils_map_ipcc() - Maps IPCC registers and enable signaling
  67. * @drv_data: hw fence driver data
  68. *
  69. * Returns zero if success, otherwise returns negative error code.
  70. */
  71. int hw_fence_utils_map_ipcc(struct hw_fence_driver_data *drv_data);
  72. /**
  73. * hw_fence_utils_map_qtime() - Maps qtime register
  74. * @drv_data: hw fence driver data
  75. *
  76. * Returns zero if success, otherwise returns negative error code.
  77. */
  78. int hw_fence_utils_map_qtime(struct hw_fence_driver_data *drv_data);
  79. /**
  80. * hw_fence_utils_map_ctl_start() - Maps ctl_start registers from dpu hw
  81. * @drv_data: hw fence driver data
  82. *
  83. * Returns zero if success, otherwise returns negative error code. This API is only used
  84. * for simulation purposes in platforms where dpu does not support ipc signal.
  85. */
  86. int hw_fence_utils_map_ctl_start(struct hw_fence_driver_data *drv_data);
  87. /**
  88. * hw_fence_utils_cleanup_fence() - Cleanup the hw-fence from a specified client
  89. * @drv_data: hw fence driver data
  90. * @hw_fence_client: client, for which the fence must be cleared
  91. * @hw_fence: hw-fence to cleanup
  92. * @hash: hash of the hw-fence to cleanup
  93. * @reset_flags: flags to determine how to handle the reset
  94. *
  95. * Returns zero if success, otherwise returns negative error code.
  96. */
  97. int hw_fence_utils_cleanup_fence(struct hw_fence_driver_data *drv_data,
  98. struct msm_hw_fence_client *hw_fence_client, struct msm_hw_fence *hw_fence, u64 hash,
  99. u32 reset_flags);
  100. #endif /* __HW_FENCE_DRV_UTILS_H */