adsprpc_shared.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef ADSPRPC_SHARED_H
  7. #define ADSPRPC_SHARED_H
  8. #include <linux/types.h>
  9. #include <linux/cdev.h>
  10. #define FASTRPC_IOCTL_INVOKE _IOWR('R', 1, struct fastrpc_ioctl_invoke)
  11. #define FASTRPC_IOCTL_MMAP _IOWR('R', 2, struct fastrpc_ioctl_mmap)
  12. #define FASTRPC_IOCTL_MUNMAP _IOWR('R', 3, struct fastrpc_ioctl_munmap)
  13. #define FASTRPC_IOCTL_MMAP_64 _IOWR('R', 14, struct fastrpc_ioctl_mmap_64)
  14. #define FASTRPC_IOCTL_MUNMAP_64 _IOWR('R', 15, struct fastrpc_ioctl_munmap_64)
  15. #define FASTRPC_IOCTL_INVOKE_FD _IOWR('R', 4, struct fastrpc_ioctl_invoke_fd)
  16. #define FASTRPC_IOCTL_SETMODE _IOWR('R', 5, uint32_t)
  17. #define FASTRPC_IOCTL_INIT _IOWR('R', 6, struct fastrpc_ioctl_init)
  18. #define FASTRPC_IOCTL_INVOKE_ATTRS \
  19. _IOWR('R', 7, struct fastrpc_ioctl_invoke_attrs)
  20. #define FASTRPC_IOCTL_GETINFO _IOWR('R', 8, uint32_t)
  21. //#define FASTRPC_IOCTL_GETPERF _IOWR('R', 9, struct fastrpc_ioctl_perf)
  22. #define FASTRPC_IOCTL_INIT_ATTRS _IOWR('R', 10, struct fastrpc_ioctl_init_attrs)
  23. #define FASTRPC_IOCTL_INVOKE_CRC _IOWR('R', 11, struct fastrpc_ioctl_invoke_crc)
  24. #define FASTRPC_IOCTL_CONTROL _IOWR('R', 12, struct fastrpc_ioctl_control)
  25. #define FASTRPC_IOCTL_MUNMAP_FD _IOWR('R', 13, struct fastrpc_ioctl_munmap_fd)
  26. #define FASTRPC_IOCTL_GET_DSP_INFO \
  27. _IOWR('R', 17, struct fastrpc_ioctl_capability)
  28. #define FASTRPC_IOCTL_INVOKE2 _IOWR('R', 18, struct fastrpc_ioctl_invoke2)
  29. #define FASTRPC_IOCTL_MEM_MAP _IOWR('R', 19, struct fastrpc_ioctl_mem_map)
  30. #define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 20, struct fastrpc_ioctl_mem_unmap)
  31. #define FASTRPC_IOCTL_INVOKE_PERF \
  32. _IOWR('R', 21, struct fastrpc_ioctl_invoke_perf)
  33. #define FASTRPC_IOCTL_NOTIF_RSP \
  34. _IOWR('R', 22, struct fastrpc_ioctl_notif_rsp)
  35. #define FASTRPC_IOCTL_DSPSIGNAL_CREATE _IOWR('R', 23, struct fastrpc_ioctl_dspsignal_create)
  36. #define FASTRPC_IOCTL_DSPSIGNAL_DESTROY _IOWR('R', 24, struct fastrpc_ioctl_dspsignal_destroy)
  37. #define FASTRPC_IOCTL_DSPSIGNAL_SIGNAL _IOWR('R', 25, struct fastrpc_ioctl_dspsignal_signal)
  38. #define FASTRPC_IOCTL_DSPSIGNAL_WAIT _IOWR('R', 26, struct fastrpc_ioctl_dspsignal_wait)
  39. #define FASTRPC_IOCTL_DSPSIGNAL_CANCEL_WAIT \
  40. _IOWR('R', 27, struct fastrpc_ioctl_dspsignal_cancel_wait)
  41. #define FASTRPC_GLINK_GUID "fastrpcglink-apps-dsp"
  42. #define FASTRPC_SMD_GUID "fastrpcsmd-apps-dsp"
  43. #define DEVICE_NAME "adsprpc-smd"
  44. #define DEVICE_NAME_SECURE "adsprpc-smd-secure"
  45. /* Pre-defined parameter for print gfa structure*/
  46. #define smq_invoke_ctx_params "pid: %d, tgid: %d, handle: %d, sc: 0x%x, fl: %p, fd: %p, magic: %d\n"
  47. #define fastrpc_file_params "fl->tgid: %d, fl->cid: %d, fl->ssrcount: %p, fl->pd: %d, fl->profile: %p, fl->mode: %p, fl->tgid_open: %d, fl->num_cached_buf: %d, num_pers_hdrs: %d, fl->sessionid: %d, fl->servloc_name: %s, fl->file_close: %d, fl->dsp_proc_init: %d,fl->apps: %p, fl->qos_request: %d, fl->dev_minor: %d, fl->debug_buf: %s fl->debug_buf_alloced_attempted: %d, fl->wake_enable: %d, fl->ws_timeout: %d, fl->untrusted_process: %d\n"
  48. #define fastrpc_mmap_params "fd: %d, flags: %p, buf: %p, phys: %p, size : %d, va : %p, map->raddr: %p, len : %d, refs : %d, secure: %d\n"
  49. #define fastrpc_buf_params "buf->fl: %p, buf->phys: %p, buf->virt: %p, buf->size: %d, buf->dma_attr: %ld, buf->raddr: %p, buf->flags: %d, buf->type: %d, buf->in_use: %d\n"
  50. /* Set for buffers that have no virtual mapping in userspace */
  51. #define FASTRPC_ATTR_NOVA 0x1
  52. /* Set for buffers that are NOT dma coherent */
  53. #define FASTRPC_ATTR_NON_COHERENT 0x2
  54. /* Set for buffers that are dma coherent */
  55. #define FASTRPC_ATTR_COHERENT 0x4
  56. /* Fastrpc attribute for keeping the map persistent */
  57. #define FASTRPC_ATTR_KEEP_MAP 0x8
  58. /* Fastrpc attribute for no mapping of fd */
  59. #define FASTRPC_ATTR_NOMAP (16)
  60. /*
  61. * Fastrpc attribute to skip flush by fastrpc
  62. */
  63. #define FASTRPC_ATTR_FORCE_NOFLUSH (32)
  64. /*
  65. * Fastrpc attribute to skip invalidate by fastrpc
  66. */
  67. #define FASTRPC_ATTR_FORCE_NOINVALIDATE (64)
  68. /* Driver should operate in parallel with the co-processor */
  69. #define FASTRPC_MODE_PARALLEL 0
  70. /* Driver should operate in serial mode with the co-processor */
  71. #define FASTRPC_MODE_SERIAL 1
  72. /* Driver should operate in profile mode with the co-processor */
  73. #define FASTRPC_MODE_PROFILE 2
  74. /* Set FastRPC session ID to 1 */
  75. #define FASTRPC_MODE_SESSION 4
  76. /* Retrives number of input buffers from the scalars parameter */
  77. #define REMOTE_SCALARS_INBUFS(sc) (((sc) >> 16) & 0x0ff)
  78. /* Retrives number of output buffers from the scalars parameter */
  79. #define REMOTE_SCALARS_OUTBUFS(sc) (((sc) >> 8) & 0x0ff)
  80. /* Retrives number of input handles from the scalars parameter */
  81. #define REMOTE_SCALARS_INHANDLES(sc) (((sc) >> 4) & 0x0f)
  82. /* Retrives number of output handles from the scalars parameter */
  83. #define REMOTE_SCALARS_OUTHANDLES(sc) ((sc) & 0x0f)
  84. /* Remote domains ID */
  85. #define ADSP_DOMAIN_ID (0)
  86. #define MDSP_DOMAIN_ID (1)
  87. #define SDSP_DOMAIN_ID (2)
  88. #define CDSP_DOMAIN_ID (3)
  89. #define MAX_DOMAIN_ID CDSP_DOMAIN_ID
  90. #define NUM_CHANNELS 4 /* adsp, mdsp, slpi, cdsp*/
  91. #define NUM_SESSIONS 14 /* max 11 compute, 3 cpz */
  92. #define VALID_FASTRPC_CID(cid) \
  93. (cid >= ADSP_DOMAIN_ID && cid < NUM_CHANNELS)
  94. #define REMOTE_SCALARS_LENGTH(sc) (REMOTE_SCALARS_INBUFS(sc) +\
  95. REMOTE_SCALARS_OUTBUFS(sc) +\
  96. REMOTE_SCALARS_INHANDLES(sc) +\
  97. REMOTE_SCALARS_OUTHANDLES(sc))
  98. #define REMOTE_SCALARS_MAKEX(attr, method, in, out, oin, oout) \
  99. ((((uint32_t) (attr) & 0x7) << 29) | \
  100. (((uint32_t) (method) & 0x1f) << 24) | \
  101. (((uint32_t) (in) & 0xff) << 16) | \
  102. (((uint32_t) (out) & 0xff) << 8) | \
  103. (((uint32_t) (oin) & 0x0f) << 4) | \
  104. ((uint32_t) (oout) & 0x0f))
  105. #define REMOTE_SCALARS_MAKE(method, in, out) \
  106. REMOTE_SCALARS_MAKEX(0, method, in, out, 0, 0)
  107. #ifdef VERIFY_PRINT_ERROR
  108. #define VERIFY_EPRINTF(format, ...) pr_err(format, ##__VA_ARGS__)
  109. #else
  110. #define VERIFY_EPRINTF(format, args) ((void)0)
  111. #endif
  112. #ifndef VERIFY_PRINT_INFO
  113. #define VERIFY_IPRINTF(args) ((void)0)
  114. #endif
  115. #ifndef VERIFY
  116. #define __STR__(x) #x ":"
  117. #define __TOSTR__(x) __STR__(x)
  118. #define __FILE_LINE__ __FILE__ ":" __TOSTR__(__LINE__)
  119. #define __ADSPRPC_LINE__ "adsprpc:" __TOSTR__(__LINE__)
  120. #define VERIFY(err, val) \
  121. do {\
  122. VERIFY_IPRINTF(__FILE_LINE__"info: calling: " #val "\n");\
  123. if ((val) == 0) {\
  124. (err) = (err) == 0 ? -1 : (err);\
  125. VERIFY_EPRINTF(__ADSPRPC_LINE__" error: %d: "#val "\n", (err));\
  126. } else {\
  127. VERIFY_IPRINTF(__FILE_LINE__"info: passed: " #val "\n");\
  128. } \
  129. } while (0)
  130. #endif
  131. #define ADSPRPC_ERR(fmt, args...)\
  132. pr_err("Error: adsprpc (%d): %s: %s: " fmt, __LINE__,\
  133. current->comm, __func__, ##args)
  134. #define ADSPRPC_INFO(fmt, args...)\
  135. pr_info("Info: adsprpc (%d): %s: %s: " fmt, __LINE__,\
  136. current->comm, __func__, ##args)
  137. #define ADSPRPC_WARN(fmt, args...)\
  138. pr_warn("Warning: adsprpc (%d): %s: %s: " fmt, __LINE__,\
  139. current->comm, __func__, ##args)
  140. #define ADSPRPC_DEBUG(fmt, args...)\
  141. pr_debug("Debug: adsprpc (%d): %s: %s: " fmt, __LINE__,\
  142. current->comm, __func__, ##args)
  143. #define DEBUG_PRINT_SIZE_LIMIT (512*1024)
  144. #define remote_arg64_t union remote_arg64
  145. struct remote_buf64 {
  146. uint64_t pv;
  147. uint64_t len;
  148. };
  149. struct remote_dma_handle64 {
  150. int fd;
  151. uint32_t offset;
  152. uint32_t len;
  153. };
  154. union remote_arg64 {
  155. struct remote_buf64 buf;
  156. struct remote_dma_handle64 dma;
  157. uint32_t h;
  158. };
  159. #define remote_arg_t union remote_arg
  160. struct remote_buf {
  161. void *pv; /* buffer pointer */
  162. size_t len; /* length of buffer */
  163. };
  164. /* structure to hold fd and size of buffer shared with DSP,
  165. * which contains inital debug parameters that needs to be passed
  166. * during process initialization.
  167. */
  168. struct fastrpc_proc_sharedbuf_info {
  169. int buf_fd;
  170. int buf_size;
  171. };
  172. struct remote_dma_handle {
  173. int fd;
  174. uint32_t offset;
  175. };
  176. union remote_arg {
  177. struct remote_buf buf; /* buffer info */
  178. struct remote_dma_handle dma;
  179. uint32_t h; /* remote handle */
  180. };
  181. struct fastrpc_ioctl_invoke {
  182. uint32_t handle; /* remote handle */
  183. uint32_t sc; /* scalars describing the data */
  184. remote_arg_t *pra; /* remote arguments list */
  185. };
  186. struct fastrpc_ioctl_invoke_fd {
  187. struct fastrpc_ioctl_invoke inv;
  188. int *fds; /* fd list */
  189. };
  190. struct fastrpc_ioctl_invoke_attrs {
  191. struct fastrpc_ioctl_invoke inv;
  192. int *fds; /* fd list */
  193. unsigned int *attrs; /* attribute list */
  194. };
  195. struct fastrpc_ioctl_invoke_crc {
  196. struct fastrpc_ioctl_invoke inv;
  197. int *fds; /* fd list */
  198. unsigned int *attrs; /* attribute list */
  199. unsigned int *crc;
  200. };
  201. struct fastrpc_ioctl_invoke_perf {
  202. struct fastrpc_ioctl_invoke inv;
  203. int *fds;
  204. unsigned int *attrs;
  205. unsigned int *crc;
  206. uint64_t *perf_kernel;
  207. uint64_t *perf_dsp;
  208. };
  209. struct fastrpc_async_job {
  210. uint32_t isasyncjob; /* flag to distinguish async job */
  211. uint64_t jobid; /* job id generated by user */
  212. uint32_t reserved; /* reserved */
  213. };
  214. struct fastrpc_ioctl_invoke_async {
  215. struct fastrpc_ioctl_invoke inv;
  216. int *fds; /* fd list */
  217. unsigned int *attrs; /* attribute list */
  218. unsigned int *crc;
  219. uint64_t *perf_kernel;
  220. uint64_t *perf_dsp;
  221. struct fastrpc_async_job *job; /* async job*/
  222. };
  223. struct fastrpc_ioctl_invoke_async_no_perf {
  224. struct fastrpc_ioctl_invoke inv;
  225. int *fds; /* fd list */
  226. unsigned int *attrs; /* attribute list */
  227. unsigned int *crc;
  228. struct fastrpc_async_job *job; /* async job*/
  229. };
  230. struct fastrpc_ioctl_async_response {
  231. uint64_t jobid;/* job id generated by user */
  232. int result; /* result from DSP */
  233. uint64_t *perf_kernel;
  234. uint64_t *perf_dsp;
  235. uint32_t handle;
  236. uint32_t sc;
  237. };
  238. struct fastrpc_ioctl_notif_rsp {
  239. int domain; /* Domain of User PD */
  240. int session; /* Session ID of User PD */
  241. uint32_t status; /* Status of the process */
  242. };
  243. /* INIT a new process or attach to guestos */
  244. enum fastrpc_init_flags {
  245. FASTRPC_INIT_NO_CREATE = -1,
  246. FASTRPC_INIT_ATTACH = 0,
  247. FASTRPC_INIT_CREATE = 1,
  248. FASTRPC_INIT_CREATE_STATIC = 2,
  249. FASTRPC_INIT_ATTACH_SENSORS = 3,
  250. };
  251. enum fastrpc_invoke2_type {
  252. FASTRPC_INVOKE2_ASYNC = 1,
  253. FASTRPC_INVOKE2_ASYNC_RESPONSE = 2,
  254. FASTRPC_INVOKE2_KERNEL_OPTIMIZATIONS,
  255. FASTRPC_INVOKE2_STATUS_NOTIF,
  256. FASTRPC_INVOKE2_PROC_SHAREDBUF_INFO,
  257. };
  258. struct fastrpc_ioctl_invoke2 {
  259. uint32_t req; /* type of invocation request */
  260. uintptr_t invparam; /* invocation request param */
  261. uint32_t size; /* size of invocation param */
  262. int err; /* reserved */
  263. };
  264. struct fastrpc_ioctl_init {
  265. uint32_t flags; /* one of FASTRPC_INIT_* macros */
  266. uintptr_t file; /* pointer to elf file */
  267. uint32_t filelen; /* elf file length */
  268. int32_t filefd; /* ION fd for the file */
  269. uintptr_t mem; /* mem for the PD */
  270. uint32_t memlen; /* mem length */
  271. int32_t memfd; /* ION fd for the mem */
  272. };
  273. struct fastrpc_ioctl_init_attrs {
  274. struct fastrpc_ioctl_init init;
  275. int attrs;
  276. unsigned int siglen;
  277. };
  278. struct fastrpc_ioctl_munmap {
  279. uintptr_t vaddrout; /* address to unmap */
  280. size_t size; /* size */
  281. };
  282. struct fastrpc_ioctl_munmap_64 {
  283. uint64_t vaddrout; /* address to unmap */
  284. size_t size; /* size */
  285. };
  286. struct fastrpc_ioctl_mmap {
  287. int fd; /* ion fd */
  288. uint32_t flags; /* flags for dsp to map with */
  289. uintptr_t vaddrin; /* optional virtual address */
  290. size_t size; /* size */
  291. uintptr_t vaddrout; /* dsps virtual address */
  292. };
  293. struct fastrpc_ioctl_mmap_64 {
  294. int fd; /* ion fd */
  295. uint32_t flags; /* flags for dsp to map with */
  296. uint64_t vaddrin; /* optional virtual address */
  297. size_t size; /* size */
  298. uint64_t vaddrout; /* dsps virtual address */
  299. };
  300. struct fastrpc_ioctl_munmap_fd {
  301. int fd; /* fd */
  302. uint32_t flags; /* control flags */
  303. uintptr_t va; /* va */
  304. ssize_t len; /* length */
  305. };
  306. struct fastrpc_ioctl_dspsignal_create {
  307. uint32_t signal_id; /* Signal ID */
  308. uint32_t flags; /* Flags, currently unused */
  309. };
  310. struct fastrpc_ioctl_dspsignal_destroy {
  311. uint32_t signal_id; /* Signal ID */
  312. };
  313. struct fastrpc_ioctl_dspsignal_signal {
  314. uint32_t signal_id; /* Signal ID */
  315. };
  316. struct fastrpc_ioctl_dspsignal_wait {
  317. uint32_t signal_id; /* Signal ID */
  318. uint32_t timeout_usec; /* Timeout in microseconds. UINT32_MAX for an infinite wait */
  319. };
  320. struct fastrpc_ioctl_dspsignal_cancel_wait {
  321. uint32_t signal_id; /* Signal ID */
  322. };
  323. /**
  324. * Control flags for mapping memory on DSP user process
  325. */
  326. enum fastrpc_map_flags {
  327. /**
  328. * Map memory pages with RW- permission and CACHE WRITEBACK.
  329. * The driver is responsible for cache maintenance when passed
  330. * the buffer to FastRPC calls. Same virtual address will be
  331. * assigned for subsequent FastRPC calls.
  332. */
  333. FASTRPC_MAP_STATIC = 0,
  334. /* Reserved */
  335. FASTRPC_MAP_RESERVED,
  336. /**
  337. * Map memory pages with RW- permission and CACHE WRITEBACK.
  338. * Mapping tagged with a file descriptor. User is responsible for
  339. * CPU and DSP cache maintenance for the buffer. Get virtual address
  340. * of buffer on DSP using HAP_mmap_get() and HAP_mmap_put() APIs.
  341. */
  342. FASTRPC_MAP_FD = 2,
  343. /**
  344. * Mapping delayed until user call HAP_mmap() and HAP_munmap()
  345. * functions on DSP. It is useful to map a buffer with cache modes
  346. * other than default modes. User is responsible for CPU and DSP
  347. * cache maintenance for the buffer.
  348. */
  349. FASTRPC_MAP_FD_DELAYED,
  350. /**
  351. * This flag is used to skip CPU mapping,
  352. * otherwise behaves similar to FASTRPC_MAP_FD_DELAYED flag.
  353. */
  354. FASTRPC_MAP_FD_NOMAP = 16,
  355. FASTRPC_MAP_MAX,
  356. };
  357. struct fastrpc_mem_map {
  358. int fd; /* ion fd */
  359. int offset; /* buffer offset */
  360. uint32_t flags; /* flags defined in enum fastrpc_map_flags */
  361. int attrs; /* buffer attributes used for SMMU mapping */
  362. uintptr_t vaddrin; /* buffer virtual address */
  363. size_t length; /* buffer length */
  364. uint64_t vaddrout; /* [out] remote virtual address */
  365. };
  366. /* Map and unmap IOCTL methods reserved memory size for future extensions */
  367. #define MAP_RESERVED_NUM (14)
  368. #define UNMAP_RESERVED_NUM (10)
  369. /* map memory to DSP device */
  370. struct fastrpc_ioctl_mem_map {
  371. int version; /* Initial version 0 */
  372. union {
  373. struct fastrpc_mem_map m;
  374. int reserved[MAP_RESERVED_NUM];
  375. };
  376. };
  377. struct fastrpc_mem_unmap {
  378. int fd; /* ion fd */
  379. uint64_t vaddr; /* remote process (dsp) virtual address */
  380. size_t length; /* buffer size */
  381. };
  382. /* unmap memory to DSP device */
  383. struct fastrpc_ioctl_mem_unmap {
  384. int version; /* Initial version 0 */
  385. union {
  386. struct fastrpc_mem_unmap um;
  387. int reserved[UNMAP_RESERVED_NUM];
  388. };
  389. };
  390. /*
  391. * This enum is shared with DSP. So, existing values should NOT
  392. * be modified. Only new members can be added.
  393. */
  394. enum dsp_map_flags {
  395. /* Add memory to static PD pool, protection thru XPU */
  396. ADSP_MMAP_HEAP_ADDR = 4,
  397. /* MAP static DMA buffer on DSP User PD */
  398. ADSP_MMAP_DMA_BUFFER = 6,
  399. /* Add memory to static PD pool, protection thru hypervisor */
  400. ADSP_MMAP_REMOTE_HEAP_ADDR = 8,
  401. /* Add memory to userPD pool, for user heap */
  402. ADSP_MMAP_ADD_PAGES = 0x1000,
  403. /* Add memory to userPD pool, for LLC heap */
  404. ADSP_MMAP_ADD_PAGES_LLC = 0x3000,
  405. /* Map persistent header buffer on DSP */
  406. ADSP_MMAP_PERSIST_HDR = 0x4000,
  407. };
  408. enum fastrpc_control_type {
  409. FASTRPC_CONTROL_LATENCY = 1,
  410. /* Share SMMU context bank */
  411. FASTRPC_CONTROL_SMMU = 2,
  412. FASTRPC_CONTROL_KALLOC = 3,
  413. FASTRPC_CONTROL_WAKELOCK = 4,
  414. FASTRPC_CONTROL_PM = 5,
  415. /* Clean process on DSP */
  416. FASTRPC_CONTROL_DSPPROCESS_CLEAN = 6,
  417. FASTRPC_CONTROL_RPC_POLL = 7,
  418. FASTRPC_CONTROL_ASYNC_WAKE = 8,
  419. FASTRPC_CONTROL_NOTIF_WAKE = 9,
  420. };
  421. struct fastrpc_ctrl_latency {
  422. uint32_t enable; /* latency control enable */
  423. uint32_t latency; /* latency request in us */
  424. };
  425. struct fastrpc_ctrl_kalloc {
  426. uint32_t kalloc_support; /* Remote memory allocation from kernel */
  427. };
  428. struct fastrpc_ctrl_wakelock {
  429. uint32_t enable; /* wakelock control enable */
  430. };
  431. struct fastrpc_ctrl_pm {
  432. uint32_t timeout; /* timeout(in ms) for PM to keep system awake */
  433. };
  434. struct fastrpc_ctrl_smmu {
  435. uint32_t sharedcb; /* Set to SMMU share context bank */
  436. };
  437. struct fastrpc_ioctl_control {
  438. uint32_t req;
  439. union {
  440. struct fastrpc_ctrl_latency lp;
  441. struct fastrpc_ctrl_kalloc kalloc;
  442. struct fastrpc_ctrl_wakelock wp;
  443. struct fastrpc_ctrl_pm pm;
  444. struct fastrpc_ctrl_smmu smmu;
  445. };
  446. };
  447. #define FASTRPC_MAX_DSP_ATTRIBUTES (256)
  448. #define FASTRPC_MAX_ATTRIBUTES (260)
  449. enum fastrpc_dsp_capability {
  450. ASYNC_FASTRPC_CAP = 9,
  451. DMA_HANDLE_REVERSE_RPC_CAP = 129,
  452. };
  453. struct fastrpc_ioctl_capability {
  454. uint32_t domain;
  455. uint32_t attribute_ID;
  456. uint32_t capability;
  457. };
  458. struct smq_null_invoke {
  459. uint64_t ctx; /* invoke caller context */
  460. uint32_t handle; /* handle to invoke */
  461. uint32_t sc; /* scalars structure describing the data */
  462. };
  463. struct smq_phy_page {
  464. uint64_t addr; /* physical address */
  465. uint64_t size; /* size of contiguous region */
  466. };
  467. struct smq_invoke_buf {
  468. int num; /* number of contiguous regions */
  469. int pgidx; /* index to start of contiguous region */
  470. };
  471. struct smq_invoke {
  472. struct smq_null_invoke header;
  473. struct smq_phy_page page; /* remote arg and list of pages address */
  474. };
  475. struct smq_msg {
  476. uint32_t pid; /* process group id */
  477. uint32_t tid; /* thread id */
  478. struct smq_invoke invoke;
  479. };
  480. struct smq_invoke_rsp {
  481. uint64_t ctx; /* invoke caller context */
  482. int retval; /* invoke return value */
  483. };
  484. enum fastrpc_response_flags {
  485. NORMAL_RESPONSE = 0,
  486. EARLY_RESPONSE = 1,
  487. USER_EARLY_SIGNAL = 2,
  488. COMPLETE_SIGNAL = 3,
  489. STATUS_RESPONSE = 4,
  490. POLL_MODE = 5,
  491. };
  492. enum fastrpc_process_create_state {
  493. PROCESS_CREATE_DEFAULT = 0, /* Process is not created */
  494. PROCESS_CREATE_IS_INPROGRESS = 1, /* Process creation is in progress */
  495. PROCESS_CREATE_SUCCESS = 2, /* Process creation is successful */
  496. };
  497. struct smq_invoke_rspv2 {
  498. uint64_t ctx; /* invoke caller context */
  499. int retval; /* invoke return value */
  500. uint32_t flags; /* early response flags */
  501. uint32_t early_wake_time; /* user predicted early wakeup time in us */
  502. uint32_t version; /* Version number for validation */
  503. };
  504. enum fastrpc_status_flags {
  505. FASTRPC_USERPD_UP = 0,
  506. FASTRPC_USERPD_EXIT = 1,
  507. FASTRPC_USERPD_FORCE_KILL = 2,
  508. FASTRPC_USERPD_EXCEPTION = 3,
  509. FASTRPC_DSP_SSR = 4,
  510. };
  511. struct smq_notif_rspv3 {
  512. uint64_t ctx; /* response context */
  513. uint32_t type; /* Notification type */
  514. int pid; /* user process pid */
  515. uint32_t status; /* userpd status notification */
  516. };
  517. enum fastrpc_process_exit_states {
  518. /* Process Default State */
  519. FASTRPC_PROCESS_DEFAULT_STATE = 0,
  520. /* Process exit initiated */
  521. FASTRPC_PROCESS_EXIT_START = 1,
  522. /* Process exit issued to DSP */
  523. FASTRPC_PROCESS_DSP_EXIT_INIT = 2,
  524. /* Process exit in DSP complete */
  525. FASTRPC_PROCESS_DSP_EXIT_COMPLETE = 3,
  526. /* Process exit in DSP error */
  527. FASTRPC_PROCESS_DSP_EXIT_ERROR = 4,
  528. };
  529. struct fastrpc_file;
  530. int fastrpc_transport_send(int cid, void *rpc_msg, uint32_t rpc_msg_size, int tvm_remote_domain);
  531. inline int fastrpc_handle_rpc_response(void *data, int len, int cid);
  532. inline int verify_transport_device(int cid, int tvm_remote_domain);
  533. int fastrpc_transport_init(void);
  534. void fastrpc_transport_deinit(void);
  535. void fastrpc_transport_session_init(int cid, char *subsys);
  536. void fastrpc_transport_session_deinit(int cid);
  537. int fastrpc_wait_for_transport_interrupt(int cid, unsigned int flags);
  538. int fastrpc_set_tvm_remote_domain(struct fastrpc_file *fl, struct fastrpc_ioctl_init *init);
  539. static inline struct smq_invoke_buf *smq_invoke_buf_start(remote_arg64_t *pra,
  540. uint32_t sc)
  541. {
  542. unsigned int len = REMOTE_SCALARS_LENGTH(sc);
  543. return (struct smq_invoke_buf *)(&pra[len]);
  544. }
  545. static inline struct smq_phy_page *smq_phy_page_start(uint32_t sc,
  546. struct smq_invoke_buf *buf)
  547. {
  548. unsigned int nTotal = REMOTE_SCALARS_LENGTH(sc);
  549. return (struct smq_phy_page *)(&buf[nTotal]);
  550. }
  551. /*
  552. * Fastrpc context ID bit-map:
  553. *
  554. * bits 0-3 : type of remote PD
  555. * bit 4 : type of job (sync/async)
  556. * bit 5 : reserved
  557. * bits 6-15 : index in context table
  558. * bits 16-63 : incrementing context ID
  559. */
  560. #define FASTRPC_CTX_MAX (1024)
  561. /* Length of glink transaction history to store */
  562. #define GLINK_MSG_HISTORY_LEN (128)
  563. /* Type of fastrpc DMA bufs sent to DSP */
  564. enum fastrpc_buf_type {
  565. METADATA_BUF,
  566. COPYDATA_BUF,
  567. INITMEM_BUF,
  568. USERHEAP_BUF,
  569. };
  570. /* Types of RPC calls to DSP */
  571. enum fastrpc_msg_type {
  572. USER_MSG = 0,
  573. KERNEL_MSG_WITH_ZERO_PID,
  574. KERNEL_MSG_WITH_NONZERO_PID,
  575. };
  576. /* Fastrpc remote pd type */
  577. enum fastrpc_remote_pd_type {
  578. FASTRPC_ROOT_PD = 0,
  579. FASTRPC_USER_PD,
  580. FASTRPC_SENSORS_PD,
  581. };
  582. #define DSPSIGNAL_TIMEOUT_NONE 0xffffffff
  583. #define DSPSIGNAL_NUM_SIGNALS 1024
  584. // Signal state and completions are stored in groups of DSPSIGNAL_GROUP_SIZE.
  585. // Must be a power of two.
  586. #define DSPSIGNAL_GROUP_SIZE 256
  587. struct secure_vm {
  588. int *vmid;
  589. int *vmperm;
  590. int vmcount;
  591. };
  592. struct gid_list {
  593. unsigned int *gids;
  594. unsigned int gidcount;
  595. };
  596. struct qos_cores {
  597. int *coreno;
  598. int corecount;
  599. };
  600. struct fastrpc_buf {
  601. struct hlist_node hn;
  602. struct hlist_node hn_rem;
  603. struct hlist_node hn_init;
  604. struct fastrpc_file *fl;
  605. void *virt;
  606. uint64_t phys;
  607. size_t size;
  608. unsigned long dma_attr;
  609. uintptr_t raddr;
  610. uint32_t flags;
  611. int type; /* One of "fastrpc_buf_type" */
  612. bool in_use; /* Used only for persistent header buffers */
  613. struct timespec64 buf_start_time;
  614. struct timespec64 buf_end_time;
  615. };
  616. struct fastrpc_ctx_lst;
  617. struct fastrpc_tx_msg {
  618. struct smq_msg msg; /* Msg sent to remote subsystem */
  619. int transport_send_err; /* transport error */
  620. int64_t ns; /* Timestamp (in ns) of msg */
  621. uint64_t xo_time_in_us; /* XO Timestamp (in us) of sent message */
  622. uint64_t xo_time_in_us_interrupted; /* XO Timestamp (in us) of interrupted ctx */
  623. uint64_t xo_time_in_us_restored; /* XO Timestamp (in us) of restored ctx */
  624. };
  625. struct fastrpc_rx_msg {
  626. struct smq_invoke_rspv2 rsp; /* Response from remote subsystem */
  627. int64_t ns; /* Timestamp (in ns) of response */
  628. uint64_t xo_time_in_us; /* XO Timestamp (in us) of response */
  629. };
  630. struct fastrpc_transport_log {
  631. unsigned int tx_index; /* Current index of 'tx_msgs' array */
  632. unsigned int rx_index; /* Current index of 'rx_msgs' array */
  633. /* Rolling history of messages sent to remote subsystem */
  634. struct fastrpc_tx_msg tx_msgs[GLINK_MSG_HISTORY_LEN];
  635. /* Rolling history of responses from remote subsystem */
  636. struct fastrpc_rx_msg rx_msgs[GLINK_MSG_HISTORY_LEN];
  637. spinlock_t lock;
  638. };
  639. struct overlap {
  640. uintptr_t start;
  641. uintptr_t end;
  642. int raix;
  643. uintptr_t mstart;
  644. uintptr_t mend;
  645. uintptr_t offset;
  646. int do_cmo; /*used for cache maintenance of inrout buffers*/
  647. };
  648. struct fastrpc_perf {
  649. uint64_t count;
  650. uint64_t flush;
  651. uint64_t map;
  652. uint64_t copy;
  653. uint64_t link;
  654. uint64_t getargs;
  655. uint64_t putargs;
  656. uint64_t invargs;
  657. uint64_t invoke;
  658. uint64_t tid;
  659. };
  660. struct smq_notif_rsp {
  661. struct list_head notifn;
  662. int domain;
  663. int session;
  664. enum fastrpc_status_flags status;
  665. };
  666. struct smq_invoke_ctx {
  667. struct hlist_node hn;
  668. /* Async node to add to async job ctx list */
  669. struct list_head asyncn;
  670. struct completion work;
  671. int retval;
  672. int pid;
  673. int tgid;
  674. remote_arg_t *lpra;
  675. remote_arg64_t *rpra;
  676. remote_arg64_t *lrpra; /* Local copy of rpra for put_args */
  677. int *fds;
  678. unsigned int *attrs;
  679. struct fastrpc_mmap **maps;
  680. struct fastrpc_buf *buf;
  681. struct fastrpc_buf *copybuf; /*used to copy non-ion buffers */
  682. size_t used;
  683. struct fastrpc_file *fl;
  684. uint32_t handle;
  685. uint32_t sc;
  686. struct overlap *overs;
  687. struct overlap **overps;
  688. struct smq_msg msg;
  689. uint32_t *crc;
  690. uint64_t *perf_kernel;
  691. uint64_t *perf_dsp;
  692. unsigned int magic;
  693. uint64_t ctxid;
  694. struct fastrpc_perf *perf;
  695. /* response flags from remote processor */
  696. enum fastrpc_response_flags rsp_flags;
  697. /* user hint of completion time in us */
  698. uint32_t early_wake_time;
  699. /* work done status flag */
  700. bool is_work_done;
  701. /* Store Async job in the context*/
  702. struct fastrpc_async_job asyncjob;
  703. /* Async early flag to check the state of context */
  704. bool is_early_wakeup;
  705. uint32_t sc_interrupted;
  706. struct fastrpc_file *fl_interrupted;
  707. uint32_t handle_interrupted;
  708. uint64_t xo_time_in_us_created; /* XO Timestamp (in us) of ctx creation */
  709. uint64_t xo_time_in_us_interrupted; /* XO Timestamp (in us) of interrupted ctx */
  710. uint64_t xo_time_in_us_restored; /* XO Timestamp (in us) of restored ctx */
  711. int tx_index; /* index of current ctx in channel gmsg_log array */
  712. bool is_job_sent_to_remote_ss; /* Flag to check if job is sent to remote sub system */
  713. };
  714. struct fastrpc_ctx_lst {
  715. struct hlist_head pending;
  716. struct hlist_head interrupted;
  717. /* Number of active contexts queued to DSP */
  718. uint32_t num_active_ctxs;
  719. /* Queue which holds all async job contexts of process */
  720. struct list_head async_queue;
  721. /* Queue which holds all status notifications of process */
  722. struct list_head notif_queue;
  723. };
  724. struct fastrpc_smmu {
  725. struct device *dev;
  726. const char *dev_name;
  727. int cb;
  728. int enabled;
  729. int faults;
  730. int secure;
  731. int coherent;
  732. int sharedcb;
  733. /* gen pool for QRTR */
  734. struct gen_pool *frpc_genpool;
  735. /* fastrpc gen pool buffer */
  736. struct fastrpc_buf *frpc_genpool_buf;
  737. /* fastrpc gen pool buffer fixed IOVA */
  738. unsigned long genpool_iova;
  739. /* fastrpc gen pool buffer size */
  740. size_t genpool_size;
  741. };
  742. struct fastrpc_session_ctx {
  743. struct device *dev;
  744. struct fastrpc_smmu smmu;
  745. int used;
  746. };
  747. struct fastrpc_static_pd {
  748. char *servloc_name;
  749. char *spdname;
  750. void *pdrhandle;
  751. uint64_t pdrcount;
  752. uint64_t prevpdrcount;
  753. atomic_t ispdup;
  754. int cid;
  755. wait_queue_head_t wait_for_pdup;
  756. };
  757. struct fastrpc_dsp_capabilities {
  758. uint32_t is_cached; //! Flag if dsp attributes are cached
  759. uint32_t dsp_attributes[FASTRPC_MAX_DSP_ATTRIBUTES];
  760. };
  761. struct fastrpc_channel_ctx {
  762. char *name;
  763. char *subsys;
  764. struct device *dev;
  765. struct fastrpc_session_ctx session[NUM_SESSIONS];
  766. struct fastrpc_static_pd spd[NUM_SESSIONS];
  767. struct completion work;
  768. struct completion workport;
  769. struct notifier_block nb;
  770. struct mutex smd_mutex;
  771. uint64_t sesscount;
  772. uint64_t ssrcount;
  773. int in_hib;
  774. void *handle;
  775. uint64_t prevssrcount;
  776. int subsystemstate;
  777. int vmid;
  778. struct secure_vm rhvm;
  779. void *rh_dump_dev;
  780. /* Indicates, if channel is restricted to secure node only */
  781. int secure;
  782. /* Indicates whether the channel supports unsigned PD */
  783. bool unsigned_support;
  784. struct fastrpc_dsp_capabilities dsp_cap_kernel;
  785. /* cpu capabilities shared to DSP */
  786. uint64_t cpuinfo_todsp;
  787. bool cpuinfo_status;
  788. struct smq_invoke_ctx *ctxtable[FASTRPC_CTX_MAX];
  789. spinlock_t ctxlock;
  790. struct fastrpc_transport_log gmsg_log;
  791. struct hlist_head initmems;
  792. /* Store gfa structure debug details */
  793. struct fastrpc_buf *buf;
  794. };
  795. struct fastrpc_apps {
  796. struct fastrpc_channel_ctx *channel;
  797. struct cdev cdev;
  798. struct class *class;
  799. struct smq_phy_page range;
  800. struct hlist_head maps;
  801. uint32_t staticpd_flags;
  802. dev_t dev_no;
  803. int compat;
  804. struct hlist_head drivers;
  805. spinlock_t hlock;
  806. struct device *dev;
  807. /* Indicates fastrpc device node info */
  808. struct device *dev_fastrpc;
  809. unsigned int latency;
  810. int transport_initialized;
  811. /* Flag to determine fastrpc bus registration */
  812. int fastrpc_bus_register;
  813. bool legacy_remote_heap;
  814. /* Unique job id for each message */
  815. uint64_t jobid[NUM_CHANNELS];
  816. struct gid_list gidlist;
  817. struct device *secure_dev;
  818. struct device *non_secure_dev;
  819. /* Secure subsystems like ADSP/SLPI will use secure client */
  820. struct wakeup_source *wake_source_secure;
  821. /* Non-secure subsystem like CDSP will use regular client */
  822. struct wakeup_source *wake_source;
  823. uint32_t duplicate_rsp_err_cnt;
  824. struct qos_cores silvercores;
  825. uint32_t max_size_limit;
  826. struct hlist_head frpc_devices;
  827. struct hlist_head frpc_drivers;
  828. struct mutex mut_uid;
  829. /* Indicates cdsp device status */
  830. int remote_cdsp_status;
  831. /* Indicates secure context bank to be shared */
  832. int share_securecb;
  833. };
  834. struct fastrpc_mmap {
  835. struct hlist_node hn;
  836. struct fastrpc_file *fl;
  837. struct fastrpc_apps *apps;
  838. int fd;
  839. uint32_t flags;
  840. struct dma_buf *buf;
  841. struct sg_table *table;
  842. struct dma_buf_attachment *attach;
  843. struct ion_handle *handle;
  844. uint64_t phys;
  845. size_t size;
  846. uintptr_t va;
  847. size_t len;
  848. int refs;
  849. uintptr_t raddr;
  850. int secure;
  851. bool is_persistent; /* the map is persistenet across sessions */
  852. int frpc_md_index; /* Minidump unique index */
  853. uintptr_t attr;
  854. bool in_use; /* Indicates if persistent map is in use*/
  855. struct timespec64 map_start_time;
  856. struct timespec64 map_end_time;
  857. /* Mapping for fastrpc shell */
  858. bool is_filemap;
  859. char *servloc_name; /* Indicate which daemon mapped this */
  860. };
  861. enum fastrpc_perfkeys {
  862. PERF_COUNT = 0,
  863. PERF_FLUSH = 1,
  864. PERF_MAP = 2,
  865. PERF_COPY = 3,
  866. PERF_LINK = 4,
  867. PERF_GETARGS = 5,
  868. PERF_PUTARGS = 6,
  869. PERF_INVARGS = 7,
  870. PERF_INVOKE = 8,
  871. PERF_TID = 9,
  872. PERF_KEY_MAX = 10,
  873. };
  874. struct fastrpc_notif_queue {
  875. /* Number of pending status notifications in queue */
  876. atomic_t notif_queue_count;
  877. /* Wait queue to synchronize notifier thread and response */
  878. wait_queue_head_t notif_wait_queue;
  879. /* IRQ safe spin lock for protecting notif queue */
  880. spinlock_t nqlock;
  881. };
  882. enum fastrpc_dspsignal_state {
  883. DSPSIGNAL_STATE_UNUSED = 0,
  884. DSPSIGNAL_STATE_PENDING,
  885. DSPSIGNAL_STATE_SIGNALED,
  886. DSPSIGNAL_STATE_CANCELED
  887. };
  888. struct fastrpc_dspsignal {
  889. struct completion comp;
  890. int state;
  891. };
  892. struct fastrpc_file {
  893. struct hlist_node hn;
  894. spinlock_t hlock;
  895. struct hlist_head maps;
  896. struct hlist_head cached_bufs;
  897. uint32_t num_cached_buf;
  898. struct hlist_head remote_bufs;
  899. struct fastrpc_ctx_lst clst;
  900. struct fastrpc_session_ctx *sctx;
  901. struct fastrpc_buf *init_mem;
  902. /* No. of persistent headers */
  903. unsigned int num_pers_hdrs;
  904. /* Pre-allocated header buffer */
  905. struct fastrpc_buf *pers_hdr_buf;
  906. /* Pre-allocated buffer divided into N chunks */
  907. struct fastrpc_buf *hdr_bufs;
  908. struct fastrpc_session_ctx *secsctx;
  909. uint32_t mode;
  910. uint32_t profile;
  911. int sessionid;
  912. int tgid_open; /* Process ID during device open */
  913. int tgid; /* Process ID that uses device for RPC calls */
  914. int cid;
  915. int tvm_remote_domain;
  916. uint64_t ssrcount;
  917. int pd;
  918. char *servloc_name;
  919. int file_close;
  920. int dsp_proc_init;
  921. int sharedcb;
  922. struct fastrpc_apps *apps;
  923. struct dentry *debugfs_file;
  924. struct dev_pm_qos_request *dev_pm_qos_req;
  925. int qos_request;
  926. struct mutex map_mutex;
  927. struct mutex internal_map_mutex;
  928. /* Identifies the device (MINOR_NUM_DEV / MINOR_NUM_SECURE_DEV) */
  929. int dev_minor;
  930. char *debug_buf;
  931. /* Flag to indicate attempt has been made to allocate memory for debug_buf*/
  932. int debug_buf_alloced_attempted;
  933. /* Flag to enable PM wake/relax voting for every remote invoke */
  934. int wake_enable;
  935. struct gid_list gidlist;
  936. /* Number of jobs pending in Async Queue */
  937. atomic_t async_queue_job_count;
  938. /* Async wait queue to synchronize glink response and async thread */
  939. wait_queue_head_t async_wait_queue;
  940. /* IRQ safe spin lock for protecting async queue */
  941. spinlock_t aqlock;
  942. /* Process status notification queue */
  943. struct fastrpc_notif_queue proc_state_notif;
  944. uint32_t ws_timeout;
  945. bool untrusted_process;
  946. struct fastrpc_device *device;
  947. /* Process kill will wait on work when ram dump collection in progress */
  948. struct completion work;
  949. /* Flag to indicate ram dump collection status*/
  950. bool is_ramdump_pend;
  951. /* Process kill will wait on bus driver invoke thread to complete its process */
  952. struct completion dma_invoke;
  953. /* Flag to indicate invoke pending */
  954. bool is_dma_invoke_pend;
  955. /* Flag to indicate type of process (static, dynamic) */
  956. uint32_t proc_flags;
  957. /* If set, threads will poll for DSP response instead of glink wait */
  958. bool poll_mode;
  959. /* Threads poll for specified timeout and fall back to glink wait */
  960. uint32_t poll_timeout;
  961. /* Flag to indicate dynamic process creation status*/
  962. enum fastrpc_process_create_state dsp_process_state;
  963. bool is_unsigned_pd;
  964. /* Flag to indicate 32 bit driver*/
  965. bool is_compat;
  966. /* Completion objects and state for dspsignals */
  967. struct fastrpc_dspsignal *signal_groups[DSPSIGNAL_NUM_SIGNALS / DSPSIGNAL_GROUP_SIZE];
  968. spinlock_t dspsignals_lock;
  969. struct mutex signal_create_mutex;
  970. struct completion shutdown;
  971. /* Flag to indicate notif thread exit requested*/
  972. bool exit_notif;
  973. /* Flag to indicate async thread exit requested*/
  974. bool exit_async;
  975. /*
  976. * structure to hold fd and size of buffer shared with DSP,
  977. * which contains initial debug configurations and other initial
  978. * config paramters.
  979. */
  980. struct fastrpc_proc_sharedbuf_info sharedbuf_info;
  981. };
  982. union fastrpc_ioctl_param {
  983. struct fastrpc_ioctl_invoke_async inv;
  984. struct fastrpc_ioctl_mem_map mem_map;
  985. struct fastrpc_ioctl_mem_unmap mem_unmap;
  986. struct fastrpc_ioctl_mmap mmap;
  987. struct fastrpc_ioctl_mmap_64 mmap64;
  988. struct fastrpc_ioctl_munmap munmap;
  989. struct fastrpc_ioctl_munmap_64 munmap64;
  990. struct fastrpc_ioctl_munmap_fd munmap_fd;
  991. struct fastrpc_ioctl_init_attrs init;
  992. struct fastrpc_ioctl_control cp;
  993. struct fastrpc_ioctl_capability cap;
  994. struct fastrpc_ioctl_invoke2 inv2;
  995. struct fastrpc_ioctl_dspsignal_signal sig;
  996. struct fastrpc_ioctl_dspsignal_wait wait;
  997. struct fastrpc_ioctl_dspsignal_create cre;
  998. struct fastrpc_ioctl_dspsignal_destroy des;
  999. struct fastrpc_ioctl_dspsignal_cancel_wait canc;
  1000. };
  1001. int fastrpc_internal_invoke(struct fastrpc_file *fl, uint32_t mode,
  1002. uint32_t kernel,
  1003. struct fastrpc_ioctl_invoke_async *inv);
  1004. int fastrpc_internal_invoke2(struct fastrpc_file *fl,
  1005. struct fastrpc_ioctl_invoke2 *inv2);
  1006. int fastrpc_internal_munmap(struct fastrpc_file *fl,
  1007. struct fastrpc_ioctl_munmap *ud);
  1008. int fastrpc_internal_mem_map(struct fastrpc_file *fl,
  1009. struct fastrpc_ioctl_mem_map *ud);
  1010. int fastrpc_internal_mem_unmap(struct fastrpc_file *fl,
  1011. struct fastrpc_ioctl_mem_unmap *ud);
  1012. int fastrpc_internal_mmap(struct fastrpc_file *fl,
  1013. struct fastrpc_ioctl_mmap *ud);
  1014. int fastrpc_init_process(struct fastrpc_file *fl,
  1015. struct fastrpc_ioctl_init_attrs *uproc);
  1016. int fastrpc_get_info(struct fastrpc_file *fl, uint32_t *info);
  1017. int fastrpc_internal_control(struct fastrpc_file *fl,
  1018. struct fastrpc_ioctl_control *cp);
  1019. int fastrpc_setmode(unsigned long ioctl_param,
  1020. struct fastrpc_file *fl);
  1021. int fastrpc_get_info_from_kernel(
  1022. struct fastrpc_ioctl_capability *cap,
  1023. struct fastrpc_file *fl);
  1024. int fastrpc_dspsignal_signal(struct fastrpc_file *fl,
  1025. struct fastrpc_ioctl_dspsignal_signal *sig);
  1026. int fastrpc_dspsignal_wait(struct fastrpc_file *fl,
  1027. struct fastrpc_ioctl_dspsignal_wait *wait);
  1028. int fastrpc_dspsignal_create(struct fastrpc_file *fl,
  1029. struct fastrpc_ioctl_dspsignal_create *create);
  1030. int fastrpc_dspsignal_destroy(struct fastrpc_file *fl,
  1031. struct fastrpc_ioctl_dspsignal_destroy *destroy);
  1032. int fastrpc_dspsignal_cancel_wait(struct fastrpc_file *fl,
  1033. struct fastrpc_ioctl_dspsignal_cancel_wait *cancel);
  1034. void fastrpc_rproc_trace_events(const char *name, const char *event,
  1035. const char *subevent);
  1036. #endif