cam_smmu_api.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef _CAM_SMMU_API_H_
  7. #define _CAM_SMMU_API_H_
  8. #include <linux/dma-direction.h>
  9. #include <linux/module.h>
  10. #include <linux/dma-buf.h>
  11. #include <linux/dma-direction.h>
  12. #include <linux/of_platform.h>
  13. #include <linux/iommu.h>
  14. #include <linux/random.h>
  15. #include <linux/spinlock_types.h>
  16. #include <linux/mutex.h>
  17. #include <linux/msm_ion.h>
  18. #define BYTE_SIZE 8
  19. #define COOKIE_NUM_BYTE 2
  20. #define COOKIE_SIZE (BYTE_SIZE*COOKIE_NUM_BYTE)
  21. #define COOKIE_MASK ((1<<COOKIE_SIZE) - 1)
  22. #define MULTI_CLIENT_REGION_SHIFT 28
  23. #define CAM_SMMU_HDL_MASK ((BIT(MULTI_CLIENT_REGION_SHIFT)) - 1)
  24. #define GET_SMMU_TABLE_IDX(x) ((((x) & CAM_SMMU_HDL_MASK) >> COOKIE_SIZE) & COOKIE_MASK)
  25. #define CAM_SMMU_GET_IOVA_DELTA(val1, val2) \
  26. ({ \
  27. (val1) > (val2) ? (val1) - (val2) : (val2) - (val1); \
  28. })
  29. /*Enum for possible CAM SMMU operations */
  30. enum cam_smmu_ops_param {
  31. CAM_SMMU_ATTACH,
  32. CAM_SMMU_DETACH,
  33. CAM_SMMU_VOTE,
  34. CAM_SMMU_DEVOTE,
  35. CAM_SMMU_OPS_INVALID
  36. };
  37. enum cam_smmu_map_dir {
  38. CAM_SMMU_MAP_READ,
  39. CAM_SMMU_MAP_WRITE,
  40. CAM_SMMU_MAP_RW,
  41. CAM_SMMU_MAP_INVALID
  42. };
  43. enum cam_smmu_region_id {
  44. CAM_SMMU_REGION_FIRMWARE,
  45. CAM_SMMU_REGION_SHARED,
  46. CAM_SMMU_REGION_SCRATCH,
  47. CAM_SMMU_REGION_IO,
  48. CAM_SMMU_REGION_SECHEAP,
  49. CAM_SMMU_REGION_QDSS,
  50. CAM_SMMU_REGION_FWUNCACHED,
  51. CAM_SMMU_REGION_DEVICE,
  52. };
  53. enum cam_smmu_subregion_id {
  54. CAM_SMMU_SUBREGION_GENERIC,
  55. CAM_SMMU_SUBREGION_SYNX_HWMUTEX,
  56. CAM_SMMU_SUBREGION_IPC_HWMUTEX,
  57. CAM_SMMU_SUBREGION_GLOBAL_SYNC_MEM,
  58. CAM_SMMU_SUBREGION_GLOBAL_CNTR,
  59. CAM_SMMU_SUBREGION_MAX,
  60. };
  61. /**
  62. * @brief : Represents camera security framework version
  63. *
  64. * @param arch_ver : Captures the version of the high level secure
  65. * camera architecture.
  66. * @param max_ver : Captures the version of the solution with in the
  67. * high level architecture.
  68. * @param min_ver : Captures the version of the memory assignment
  69. * mechanism with in the solution.
  70. */
  71. struct cam_csf_version {
  72. uint32_t arch_ver;
  73. uint32_t max_ver;
  74. uint32_t min_ver;
  75. };
  76. /**
  77. * @brief : cam_smmu_buffer_tracker
  78. *
  79. * @param: list : list to be inserted into list of tracked buggers
  80. * @param: ref_count : Ptr to kref object of a physical buffer allocated per CB
  81. * @param: ion_fd : fd of buffer
  82. * @param: i_ino : inode of buffer
  83. * @param: cb_name : CB which this buffer belongs to
  84. */
  85. struct cam_smmu_buffer_tracker {
  86. struct list_head list;
  87. struct kref *ref_count;
  88. int ion_fd;
  89. unsigned long i_ino;
  90. const char *cb_name;
  91. };
  92. /**
  93. * @brief : cam_smmu_pf_info
  94. *
  95. * @param domain : Iommu domain received in iommu page fault handler
  96. * @param dev : Device received in iommu page fault handler
  97. * @param iova : IOVA where page fault occurred
  98. * @param flags : Flags received in iommu page fault handler
  99. * @param token : Userdata given during callback registration
  100. * @param buf_info : Closest mapped buffer info
  101. * @param bid : bus id
  102. * @param pid : unique id for hw group of ports
  103. * @param mid : port id of hw
  104. * @param is_secure : Faulted memory in secure or non-secure region
  105. * @param in_map_region : Faulted memory fall in mapped region or not
  106. */
  107. struct cam_smmu_pf_info {
  108. struct iommu_domain *domain;
  109. struct device *dev;
  110. unsigned long iova;
  111. int flags;
  112. void *token;
  113. uint32_t buf_info;
  114. uint32_t bid;
  115. uint32_t pid;
  116. uint32_t mid;
  117. bool is_secure;
  118. bool in_map_region;
  119. };
  120. /**
  121. * @brief : Structure to store dma buf information
  122. *
  123. * @param buf : dma buffer
  124. * @param attach : attachment info between dma buf and device
  125. * @param table : scattered list
  126. */
  127. struct region_buf_info {
  128. struct dma_buf *buf;
  129. struct dma_buf_attachment *attach;
  130. struct sg_table *table;
  131. };
  132. /**
  133. * @brief : Structure to store region information
  134. *
  135. * @param iova_start : Start address of region
  136. * @param iova_len : length of region
  137. * @param discard_iova_start : iova addr start from where should not be used
  138. * @param discard_iova_len : length of discard iova region
  139. * @param phy_addr : pa to which this va is mapped to
  140. */
  141. struct cam_smmu_region_info {
  142. dma_addr_t iova_start;
  143. size_t iova_len;
  144. dma_addr_t discard_iova_start;
  145. size_t discard_iova_len;
  146. dma_addr_t phy_addr;
  147. struct region_buf_info buf_info;
  148. };
  149. /**
  150. * @brief : Gets an smmu handle
  151. *
  152. * @param identifier: Unique identifier to be used by clients which they
  153. * should get from device tree. CAM SMMU driver will
  154. * not enforce how this string is obtained and will
  155. * only validate this against the list of permitted
  156. * identifiers
  157. * @param handle_ptr: Based on the indentifier, CAM SMMU drivier will
  158. * fill the handle pointed by handle_ptr
  159. * @return Status of operation. Negative in case of error. Zero otherwise.
  160. */
  161. int cam_smmu_get_handle(char *identifier, int *handle_ptr);
  162. /**
  163. * @brief : Performs IOMMU operations
  164. *
  165. * @param handle: Handle to identify the CAM SMMU client (VFE, CPP, FD etc.)
  166. * @param op : Operation to be performed. Can be either CAM_SMMU_ATTACH
  167. * or CAM_SMMU_DETACH
  168. *
  169. * @return Status of operation. Negative in case of error. Zero otherwise.
  170. */
  171. int cam_smmu_ops(int handle, enum cam_smmu_ops_param op);
  172. /**
  173. * @brief : Maps user space IOVA for calling driver
  174. *
  175. * @param handle: Handle to identify the CAM SMMU client (VFE, CPP, FD etc.)
  176. * @param ion_fd: ION handle identifying the memory buffer.
  177. * @param dmabuf: DMA buf handle identifying the memory buffer.
  178. * @param dis_delayed_unmap: Whether to disable Delayed Unmap feature
  179. * for this mapping
  180. * @dir : Mapping direction: which will traslate toDMA_BIDIRECTIONAL,
  181. * DMA_TO_DEVICE or DMA_FROM_DEVICE
  182. * @dma_addr : Pointer to physical address where mapped address will be
  183. * returned if region_id is CAM_SMMU_REGION_IO. If region_id is
  184. * CAM_SMMU_REGION_SHARED, dma_addr is used as an input parameter
  185. * which specifies the cpu virtual address to map.
  186. * @len_ptr : Length of buffer mapped returned by CAM SMMU driver.
  187. * @region_id : Memory region identifier
  188. * @is_internal: Specifies if this buffer is kernel allocated.
  189. * @ref_count: Double ptr to store ref_cnt object in memmgr.
  190. * @return Status of operation. Negative in case of error. Zero otherwise.
  191. */
  192. int cam_smmu_map_user_iova(int handle, int ion_fd, struct dma_buf *dmabuf,
  193. bool dis_delayed_unmap, enum cam_smmu_map_dir dir, dma_addr_t *dma_addr, size_t *len_ptr,
  194. enum cam_smmu_region_id region_id, bool is_internal, struct kref **ref_count);
  195. /**
  196. * @brief : Maps kernel space IOVA for calling driver
  197. *
  198. * @param handle : Handle to identify the CAM SMMU client (VFE, CPP, FD etc.)
  199. * @param buf : dma_buf allocated for kernel usage in mem_mgr
  200. * @dir : Mapping direction: which will traslate toDMA_BIDIRECTIONAL,
  201. * DMA_TO_DEVICE or DMA_FROM_DEVICE
  202. * @dma_addr : Pointer to physical address where mapped address will be
  203. * returned if region_id is CAM_SMMU_REGION_IO. If region_id is
  204. * CAM_SMMU_REGION_SHARED, dma_addr is used as an input
  205. * parameter which specifies the cpu virtual address to map.
  206. * @len_ptr : Length of buffer mapped returned by CAM SMMU driver.
  207. * @region_id : Memory region identifier
  208. * @return Status of operation. Negative in case of error. Zero otherwise.
  209. */
  210. int cam_smmu_map_kernel_iova(int handle,
  211. struct dma_buf *buf, enum cam_smmu_map_dir dir,
  212. dma_addr_t *dma_addr, size_t *len_ptr,
  213. enum cam_smmu_region_id region_id);
  214. /**
  215. * @brief : Unmaps user space IOVA for calling driver
  216. *
  217. * @param handle: Handle to identify the CAMSMMU client (VFE, CPP, FD etc.)
  218. * @param ion_fd: ION handle identifying the memory buffer.
  219. * @param dma_buf: DMA Buf handle identifying the memory buffer.
  220. * @param region_id: Region id from which to unmap buffer.
  221. * @param force_unmap: If this unmap operation is part of memmgr cleanup
  222. *
  223. * @return Status of operation. Negative in case of error. Zero otherwise.
  224. */
  225. int cam_smmu_unmap_user_iova(int handle,
  226. int ion_fd, struct dma_buf *dma_buf, enum cam_smmu_region_id region_id,
  227. bool force_unmap);
  228. /**
  229. * @brief : Unmaps kernel IOVA for calling driver
  230. *
  231. * @param handle: Handle to identify the CAMSMMU client (VFE, CPP, FD etc.)
  232. * @param buf : dma_buf allocated for the kernel
  233. *
  234. * @return Status of operation. Negative in case of error. Zero otherwise.
  235. */
  236. int cam_smmu_unmap_kernel_iova(int handle,
  237. struct dma_buf *buf, enum cam_smmu_region_id region_id);
  238. /**
  239. * @brief : Allocates a scratch buffer
  240. *
  241. * This function allocates a scratch virtual buffer of length virt_len in the
  242. * device virtual address space mapped to phys_len physically contiguous bytes
  243. * in that device's SMMU.
  244. *
  245. * virt_len and phys_len are expected to be aligned to PAGE_SIZE and with each
  246. * other, otherwise -EINVAL is returned.
  247. *
  248. * -EINVAL will be returned if virt_len is less than phys_len.
  249. *
  250. * Passing a too large phys_len might also cause failure if that much size is
  251. * not available for allocation in a physically contiguous way.
  252. *
  253. * @param handle : Handle to identify the CAMSMMU client (VFE, CPP, FD etc.)
  254. * @param dir : Direction of mapping which will translate to IOMMU_READ
  255. * IOMMU_WRITE or a bit mask of both.
  256. * @param paddr_ptr: Device virtual address that the client device will be
  257. * able to read from/write to
  258. * @param virt_len : Virtual length of the scratch buffer
  259. * @param phys_len : Physical length of the scratch buffer
  260. *
  261. * @return Status of operation. Negative in case of error. Zero otherwise.
  262. */
  263. int cam_smmu_get_scratch_iova(int handle,
  264. enum cam_smmu_map_dir dir,
  265. dma_addr_t *paddr_ptr,
  266. size_t virt_len,
  267. size_t phys_len);
  268. /**
  269. * @brief : Frees a scratch buffer
  270. *
  271. * This function frees a scratch buffer and releases the corresponding SMMU
  272. * mappings.
  273. *
  274. * @param handle : Handle to identify the CAMSMMU client (IFE, ICP, etc.)
  275. * @param paddr : Device virtual address of client's scratch buffer that
  276. * will be freed.
  277. *
  278. * @return Status of operation. Negative in case of error. Zero otherwise.
  279. */
  280. int cam_smmu_put_scratch_iova(int handle,
  281. dma_addr_t paddr);
  282. /**
  283. *@brief : Destroys an smmu handle
  284. *
  285. * @param handle: Handle to identify the CAM SMMU client (VFE, CPP, FD etc.)
  286. *
  287. * @return Status of operation. Negative in case of error. Zero otherwise.
  288. */
  289. int cam_smmu_destroy_handle(int handle);
  290. /**
  291. * @brief : Returns if context bank identified by handle has a shared region
  292. *
  293. * @param handle: Handle to identify the context bank
  294. * @return : True if context banks supports shared region, false otherwise
  295. * @note : Currently, only ICP context banks support shared regions.
  296. */
  297. bool cam_smmu_supports_shared_region(int handle);
  298. /**
  299. * @brief : Registers smmu fault handler for client
  300. *
  301. * @param handle: Handle to identify the CAM SMMU client (VFE, CPP, FD etc.)
  302. * @param handler_cb: It is triggered in IOMMU page fault
  303. * @param token: It is input param when trigger page fault handler
  304. */
  305. void cam_smmu_set_client_page_fault_handler(int handle,
  306. void (*handler_cb)(struct cam_smmu_pf_info *pf_info), void *token);
  307. /**
  308. * @brief : Unregisters smmu fault handler for client
  309. *
  310. * @param handle: Handle to identify the CAM SMMU client (VFE, CPP, FD etc.)
  311. * @param token: It is input param when trigger page fault handler
  312. */
  313. void cam_smmu_unset_client_page_fault_handler(int handle, void *token);
  314. /**
  315. * @brief Maps memory from an ION fd into IOVA space
  316. *
  317. * @param handle: SMMU handle identifying the context bank to map to
  318. * @param ion_fd: ION fd of memory to map to
  319. * @param dma_buf: DMA buf of memory to map to
  320. * @param paddr_ptr: Pointer IOVA address that will be returned
  321. * @param len_ptr: Length of memory mapped
  322. * @param buf_tracker: List to add tracked buffers to
  323. * @param ref_count: Double ptr to ref_count object for memmgr table
  324. *
  325. * @return Status of operation. Negative in case of error. Zero otherwise.
  326. */
  327. int cam_smmu_get_iova(int handle, int ion_fd, struct dma_buf *dma_buf,
  328. dma_addr_t *paddr_ptr, size_t *len_ptr, struct list_head *buf_tracker,
  329. struct kref **ref_count);
  330. /**
  331. * @brief Maps memory from an ION fd into IOVA space
  332. *
  333. * @param handle: SMMU handle identifying the secure context bank to map to
  334. * @param ion_fd: ION fd of memory to map to
  335. * @param dma_buf: DMA Buf of memory to map to
  336. * @param paddr_ptr: Pointer IOVA address that will be returned
  337. * @param len_ptr: Length of memory mapped
  338. * @param buf_tracker: List to add tracked buffers to
  339. * @param ref_count: Double ptr to ref_count object for memmgr table
  340. *
  341. * @return Status of operation. Negative in case of error. Zero otherwise.
  342. */
  343. int cam_smmu_get_stage2_iova(int handle, int ion_fd, struct dma_buf *dma_buf,
  344. dma_addr_t *paddr_ptr, size_t *len_ptr, struct list_head *buf_tracker,
  345. struct kref **ref_count);
  346. /**
  347. * @brief Unmaps memory from context bank
  348. *
  349. * @param handle: SMMU handle identifying the context bank
  350. * @param ion_fd: ION fd of memory to unmap
  351. * @param dma_buf: DMA Buf of memory to unmap
  352. *
  353. * @return Status of operation. Negative in case of error. Zero otherwise.
  354. */
  355. int cam_smmu_put_iova(int handle, int ion_fd, struct dma_buf *dma_buf);
  356. /**
  357. * @brief Maps secure memory for SMMU handle
  358. *
  359. * @param handle: SMMU handle identifying secure context bank
  360. * @param ion_fd: ION fd to map securely
  361. * @param dmabuf: DMA buf to map securely
  362. * @param dir: DMA Direction for the mapping
  363. * @param dma_addr: Returned IOVA address after mapping
  364. * @param len_ptr: Length of memory mapped
  365. * @param ref_count: Double ptr to store ref_cnt object in memmgr
  366. *
  367. * @return Status of operation. Negative in case of error. Zero otherwise.
  368. */
  369. int cam_smmu_map_stage2_iova(int handle, int ion_fd, struct dma_buf *dmabuf,
  370. enum cam_smmu_map_dir dir, dma_addr_t *dma_addr, size_t *len_ptr,
  371. struct kref **ref_count);
  372. /**
  373. * @brief Unmaps secure memopry for SMMU handle
  374. *
  375. * @param handle: SMMU handle identifying secure context bank
  376. * @param ion_fd: ION fd to unmap
  377. * @param dma_buf: DMA Buf to unmap
  378. * @param force_unmap: If this unmap operation is part of memmgr cleanup
  379. *
  380. * @return Status of operation. Negative in case of error. Zero otherwise.
  381. */
  382. int cam_smmu_unmap_stage2_iova(int handle, int ion_fd, struct dma_buf *dma_buf,
  383. bool force_unmap);
  384. /**
  385. * @brief Allocates firmware for context bank
  386. *
  387. * @param smmu_hdl: SMMU handle identifying context bank
  388. * @param iova: IOVA address of allocated firmware
  389. * @param kvaddr: CPU mapped address of allocated firmware
  390. * @param len: Length of allocated firmware memory
  391. *
  392. * @return Status of operation. Negative in case of error. Zero otherwise.
  393. */
  394. int cam_smmu_alloc_firmware(int32_t smmu_hdl,
  395. dma_addr_t *iova,
  396. uintptr_t *kvaddr,
  397. size_t *len);
  398. /**
  399. * @brief Deallocates firmware memory for context bank
  400. *
  401. * @param smmu_hdl: SMMU handle identifying the context bank
  402. *
  403. * @return Status of operation. Negative in case of error. Zero otherwise.
  404. */
  405. int cam_smmu_dealloc_firmware(int32_t smmu_hdl);
  406. /**
  407. * @brief Gets region information specified by smmu handle and region id
  408. *
  409. * @param smmu_hdl: SMMU handle identifying the context bank
  410. * @param region_id: Region id for which information is desired
  411. * @param region_info: Struct populated with region information
  412. *
  413. * @return Status of operation. Negative in case of error. Zero otherwise.
  414. */
  415. int cam_smmu_get_region_info(int32_t smmu_hdl,
  416. enum cam_smmu_region_id region_id,
  417. struct cam_smmu_region_info *region_info);
  418. /**
  419. * @brief Reserves a region with buffer
  420. *
  421. * @param region: Region id
  422. * @param smmu_hdl: SMMU handle identifying the context bank
  423. * @param iova: IOVA of secondary heap after reservation has completed
  424. * @param buf: Allocated dma_buf for secondary heap
  425. * @param request_len: Length of secondary heap after reservation has completed
  426. *
  427. * @return Status of operation. Negative in case of error. Zero otherwise.
  428. */
  429. int cam_smmu_reserve_buf_region(enum cam_smmu_region_id region,
  430. int32_t smmu_hdl, struct dma_buf *buf,
  431. dma_addr_t *iova, size_t *request_len);
  432. /**
  433. * @brief Releases buffer in reserved region
  434. *
  435. * @param region: Region id
  436. * @param smmu_hdl: SMMU handle identifying the context bank
  437. *
  438. * @return Status of operation. Negative in case of error. Zero otherwise.
  439. */
  440. int cam_smmu_release_buf_region(enum cam_smmu_region_id region,
  441. int32_t smmu_hdl);
  442. /**
  443. * @brief Map va for phy addr range for a given context bank
  444. *
  445. * @param smmu_hdl: SMMU handle identifying context bank
  446. * @param region_id: Region ID
  447. * @optional param subregion_id: Subregion ID
  448. * @param iova: IOVA address of allocated qdss
  449. * @param len: Length of allocated qdss memory
  450. *
  451. * @return Status of operation. Negative in case of error. Zero otherwise.
  452. */
  453. int cam_smmu_map_phy_mem_region(int32_t smmu_hdl,
  454. uint32_t region_id, uint32_t subregion_id,
  455. dma_addr_t *iova, size_t *len);
  456. /**
  457. * @brief Unmap call for map_phy_mem for given context bank
  458. *
  459. * @param smmu_hdl: SMMU handle identifying the context bank
  460. * @param region_id: Region ID
  461. * @optional param subregion_id: Subregion ID
  462. *
  463. * @return Status of operation. Negative in case of error. Zero otherwise.
  464. */
  465. int cam_smmu_unmap_phy_mem_region(int32_t smmu_hdl,
  466. uint32_t region_id, uint32_t subregion_id);
  467. /**
  468. * @brief Get start addr & len of I/O region for a given cb
  469. *
  470. * @param smmu_hdl: SMMU handle identifying the context bank
  471. * @param iova: IOVA address of allocated I/O region
  472. * @param len: Length of allocated I/O memory
  473. * @param discard_iova_start: Start address of io space to discard
  474. * @param discard_iova_len: Length of io space to discard
  475. *
  476. * @return Status of operation. Negative in case of error. Zero otherwise.
  477. */
  478. int cam_smmu_get_io_region_info(int32_t smmu_hdl,
  479. dma_addr_t *iova, size_t *len,
  480. dma_addr_t *discard_iova_start, size_t *discard_iova_len);
  481. /**
  482. * @brief : API to reset the call context bank page fault count
  483. * This should be done on the starting of new camera open
  484. * @return void.
  485. */
  486. void cam_smmu_reset_cb_page_fault_cnt(void);
  487. /**
  488. * @brief : API to register SMMU hw to platform framework.
  489. * @return struct platform_device pointer on on success, or ERR_PTR() on error.
  490. */
  491. int cam_smmu_init_module(void);
  492. /**
  493. * @brief : API to remove SMMU Hw from platform framework.
  494. */
  495. void cam_smmu_exit_module(void);
  496. /**
  497. * @brief : API to determine whether to force all allocations to CACHED
  498. */
  499. int cam_smmu_need_force_alloc_cached(bool *force_alloc_cached);
  500. /**
  501. * @brief : API to determine whether padding is needed for shared buffers
  502. */
  503. bool cam_smmu_need_shared_buffer_padding(void);
  504. /**
  505. * @brief : API to determine whether certain HW is 36-bit memory addressable
  506. */
  507. bool cam_smmu_is_expanded_memory(void);
  508. /**
  509. * @brief : API to query whether page fault non fatal is enable for a device's context bank
  510. */
  511. int cam_smmu_is_cb_non_fatal_fault_en(int smmu_hdl, bool *non_fatal_en);
  512. /**
  513. * @brief : API to initialize any SMMU config, also get any capabilities
  514. * such as num banks and the CSF version in use that's received from SMMU proxy driver
  515. *
  516. * @return Status of operation. Negative in case of error. Zero otherwise.
  517. */
  518. int cam_smmu_driver_init(struct cam_csf_version *csf_ver, int32_t *num_cbs);
  519. /**
  520. * @brief : API to deinitialize any initialized SMMU config
  521. */
  522. void cam_smmu_driver_deinit(void);
  523. /**
  524. * @brief : API to putref on tracked buffers whoose ref counts
  525. * are incremented
  526. */
  527. void cam_smmu_buffer_tracker_putref(struct list_head *mapped_io_list);
  528. /**
  529. * @brief : API to putref on a specific tracked buffer
  530. */
  531. void cam_smmu_buffer_tracker_buffer_putref(struct cam_smmu_buffer_tracker *entry);
  532. /**
  533. * @brief : Add tracked buffers to list that belongs to a context
  534. */
  535. int cam_smmu_add_buf_to_track_list(int ion_fd, unsigned long inode,
  536. struct kref **ref_count, struct list_head *buf_tracker, int idx);
  537. #endif /* _CAM_SMMU_API_H_ */