spu_run.rst 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. .. SPDX-License-Identifier: GPL-2.0
  2. =======
  3. spu_run
  4. =======
  5. Name
  6. ====
  7. spu_run - execute an spu context
  8. Synopsis
  9. ========
  10. ::
  11. #include <sys/spu.h>
  12. int spu_run(int fd, unsigned int *npc, unsigned int *event);
  13. Description
  14. ===========
  15. The spu_run system call is used on PowerPC machines that implement the
  16. Cell Broadband Engine Architecture in order to access Synergistic Pro-
  17. cessor Units (SPUs). It uses the fd that was returned from spu_cre-
  18. ate(2) to address a specific SPU context. When the context gets sched-
  19. uled to a physical SPU, it starts execution at the instruction pointer
  20. passed in npc.
  21. Execution of SPU code happens synchronously, meaning that spu_run does
  22. not return while the SPU is still running. If there is a need to exe-
  23. cute SPU code in parallel with other code on either the main CPU or
  24. other SPUs, you need to create a new thread of execution first, e.g.
  25. using the pthread_create(3) call.
  26. When spu_run returns, the current value of the SPU instruction pointer
  27. is written back to npc, so you can call spu_run again without updating
  28. the pointers.
  29. event can be a NULL pointer or point to an extended status code that
  30. gets filled when spu_run returns. It can be one of the following con-
  31. stants:
  32. SPE_EVENT_DMA_ALIGNMENT
  33. A DMA alignment error
  34. SPE_EVENT_SPE_DATA_SEGMENT
  35. A DMA segmentation error
  36. SPE_EVENT_SPE_DATA_STORAGE
  37. A DMA storage error
  38. If NULL is passed as the event argument, these errors will result in a
  39. signal delivered to the calling process.
  40. Return Value
  41. ============
  42. spu_run returns the value of the spu_status register or -1 to indicate
  43. an error and set errno to one of the error codes listed below. The
  44. spu_status register value contains a bit mask of status codes and
  45. optionally a 14 bit code returned from the stop-and-signal instruction
  46. on the SPU. The bit masks for the status codes are:
  47. 0x02
  48. SPU was stopped by stop-and-signal.
  49. 0x04
  50. SPU was stopped by halt.
  51. 0x08
  52. SPU is waiting for a channel.
  53. 0x10
  54. SPU is in single-step mode.
  55. 0x20
  56. SPU has tried to execute an invalid instruction.
  57. 0x40
  58. SPU has tried to access an invalid channel.
  59. 0x3fff0000
  60. The bits masked with this value contain the code returned from
  61. stop-and-signal.
  62. There are always one or more of the lower eight bits set or an error
  63. code is returned from spu_run.
  64. Errors
  65. ======
  66. EAGAIN or EWOULDBLOCK
  67. fd is in non-blocking mode and spu_run would block.
  68. EBADF fd is not a valid file descriptor.
  69. EFAULT npc is not a valid pointer or status is neither NULL nor a valid
  70. pointer.
  71. EINTR A signal occurred while spu_run was in progress. The npc value
  72. has been updated to the new program counter value if necessary.
  73. EINVAL fd is not a file descriptor returned from spu_create(2).
  74. ENOMEM Insufficient memory was available to handle a page fault result-
  75. ing from an MFC direct memory access.
  76. ENOSYS the functionality is not provided by the current system, because
  77. either the hardware does not provide SPUs or the spufs module is
  78. not loaded.
  79. Notes
  80. =====
  81. spu_run is meant to be used from libraries that implement a more
  82. abstract interface to SPUs, not to be used from regular applications.
  83. See http://www.bsc.es/projects/deepcomputing/linuxoncell/ for the rec-
  84. ommended libraries.
  85. Conforming to
  86. =============
  87. This call is Linux specific and only implemented by the ppc64 architec-
  88. ture. Programs using this system call are not portable.
  89. Bugs
  90. ====
  91. The code does not yet fully implement all features lined out here.
  92. Author
  93. ======
  94. Arnd Bergmann <arndb@de.ibm.com>
  95. See Also
  96. ========
  97. capabilities(7), close(2), spu_create(2), spufs(7)