vc4_drv.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776
  1. /*
  2. * Copyright (C) 2015 Broadcom
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #include <linux/reservation.h>
  9. #include <drm/drmP.h>
  10. #include <drm/drm_encoder.h>
  11. #include <drm/drm_gem_cma_helper.h>
  12. #include "uapi/drm/vc4_drm.h"
  13. /* Don't forget to update vc4_bo.c: bo_type_names[] when adding to
  14. * this.
  15. */
  16. enum vc4_kernel_bo_type {
  17. /* Any kernel allocation (gem_create_object hook) before it
  18. * gets another type set.
  19. */
  20. VC4_BO_TYPE_KERNEL,
  21. VC4_BO_TYPE_V3D,
  22. VC4_BO_TYPE_V3D_SHADER,
  23. VC4_BO_TYPE_DUMB,
  24. VC4_BO_TYPE_BIN,
  25. VC4_BO_TYPE_RCL,
  26. VC4_BO_TYPE_BCL,
  27. VC4_BO_TYPE_KERNEL_CACHE,
  28. VC4_BO_TYPE_COUNT
  29. };
  30. /* Performance monitor object. The perform lifetime is controlled by userspace
  31. * using perfmon related ioctls. A perfmon can be attached to a submit_cl
  32. * request, and when this is the case, HW perf counters will be activated just
  33. * before the submit_cl is submitted to the GPU and disabled when the job is
  34. * done. This way, only events related to a specific job will be counted.
  35. */
  36. struct vc4_perfmon {
  37. /* Tracks the number of users of the perfmon, when this counter reaches
  38. * zero the perfmon is destroyed.
  39. */
  40. refcount_t refcnt;
  41. /* Number of counters activated in this perfmon instance
  42. * (should be less than DRM_VC4_MAX_PERF_COUNTERS).
  43. */
  44. u8 ncounters;
  45. /* Events counted by the HW perf counters. */
  46. u8 events[DRM_VC4_MAX_PERF_COUNTERS];
  47. /* Storage for counter values. Counters are incremented by the HW
  48. * perf counter values every time the perfmon is attached to a GPU job.
  49. * This way, perfmon users don't have to retrieve the results after
  50. * each job if they want to track events covering several submissions.
  51. * Note that counter values can't be reset, but you can fake a reset by
  52. * destroying the perfmon and creating a new one.
  53. */
  54. u64 counters[0];
  55. };
  56. struct vc4_dev {
  57. struct drm_device *dev;
  58. struct vc4_hdmi *hdmi;
  59. struct vc4_hvs *hvs;
  60. struct vc4_v3d *v3d;
  61. struct vc4_dpi *dpi;
  62. struct vc4_dsi *dsi1;
  63. struct vc4_vec *vec;
  64. struct vc4_hang_state *hang_state;
  65. /* The kernel-space BO cache. Tracks buffers that have been
  66. * unreferenced by all other users (refcounts of 0!) but not
  67. * yet freed, so we can do cheap allocations.
  68. */
  69. struct vc4_bo_cache {
  70. /* Array of list heads for entries in the BO cache,
  71. * based on number of pages, so we can do O(1) lookups
  72. * in the cache when allocating.
  73. */
  74. struct list_head *size_list;
  75. uint32_t size_list_size;
  76. /* List of all BOs in the cache, ordered by age, so we
  77. * can do O(1) lookups when trying to free old
  78. * buffers.
  79. */
  80. struct list_head time_list;
  81. struct work_struct time_work;
  82. struct timer_list time_timer;
  83. } bo_cache;
  84. u32 num_labels;
  85. struct vc4_label {
  86. const char *name;
  87. u32 num_allocated;
  88. u32 size_allocated;
  89. } *bo_labels;
  90. /* Protects bo_cache and bo_labels. */
  91. struct mutex bo_lock;
  92. /* Purgeable BO pool. All BOs in this pool can have their memory
  93. * reclaimed if the driver is unable to allocate new BOs. We also
  94. * keep stats related to the purge mechanism here.
  95. */
  96. struct {
  97. struct list_head list;
  98. unsigned int num;
  99. size_t size;
  100. unsigned int purged_num;
  101. size_t purged_size;
  102. struct mutex lock;
  103. } purgeable;
  104. uint64_t dma_fence_context;
  105. /* Sequence number for the last job queued in bin_job_list.
  106. * Starts at 0 (no jobs emitted).
  107. */
  108. uint64_t emit_seqno;
  109. /* Sequence number for the last completed job on the GPU.
  110. * Starts at 0 (no jobs completed).
  111. */
  112. uint64_t finished_seqno;
  113. /* List of all struct vc4_exec_info for jobs to be executed in
  114. * the binner. The first job in the list is the one currently
  115. * programmed into ct0ca for execution.
  116. */
  117. struct list_head bin_job_list;
  118. /* List of all struct vc4_exec_info for jobs that have
  119. * completed binning and are ready for rendering. The first
  120. * job in the list is the one currently programmed into ct1ca
  121. * for execution.
  122. */
  123. struct list_head render_job_list;
  124. /* List of the finished vc4_exec_infos waiting to be freed by
  125. * job_done_work.
  126. */
  127. struct list_head job_done_list;
  128. /* Spinlock used to synchronize the job_list and seqno
  129. * accesses between the IRQ handler and GEM ioctls.
  130. */
  131. spinlock_t job_lock;
  132. wait_queue_head_t job_wait_queue;
  133. struct work_struct job_done_work;
  134. /* Used to track the active perfmon if any. Access to this field is
  135. * protected by job_lock.
  136. */
  137. struct vc4_perfmon *active_perfmon;
  138. /* List of struct vc4_seqno_cb for callbacks to be made from a
  139. * workqueue when the given seqno is passed.
  140. */
  141. struct list_head seqno_cb_list;
  142. /* The memory used for storing binner tile alloc, tile state,
  143. * and overflow memory allocations. This is freed when V3D
  144. * powers down.
  145. */
  146. struct vc4_bo *bin_bo;
  147. /* Size of blocks allocated within bin_bo. */
  148. uint32_t bin_alloc_size;
  149. /* Bitmask of the bin_alloc_size chunks in bin_bo that are
  150. * used.
  151. */
  152. uint32_t bin_alloc_used;
  153. /* Bitmask of the current bin_alloc used for overflow memory. */
  154. uint32_t bin_alloc_overflow;
  155. struct work_struct overflow_mem_work;
  156. int power_refcount;
  157. /* Mutex controlling the power refcount. */
  158. struct mutex power_lock;
  159. struct {
  160. struct timer_list timer;
  161. struct work_struct reset_work;
  162. } hangcheck;
  163. struct semaphore async_modeset;
  164. };
  165. static inline struct vc4_dev *
  166. to_vc4_dev(struct drm_device *dev)
  167. {
  168. return (struct vc4_dev *)dev->dev_private;
  169. }
  170. struct vc4_bo {
  171. struct drm_gem_cma_object base;
  172. /* seqno of the last job to render using this BO. */
  173. uint64_t seqno;
  174. /* seqno of the last job to use the RCL to write to this BO.
  175. *
  176. * Note that this doesn't include binner overflow memory
  177. * writes.
  178. */
  179. uint64_t write_seqno;
  180. bool t_format;
  181. /* List entry for the BO's position in either
  182. * vc4_exec_info->unref_list or vc4_dev->bo_cache.time_list
  183. */
  184. struct list_head unref_head;
  185. /* Time in jiffies when the BO was put in vc4->bo_cache. */
  186. unsigned long free_time;
  187. /* List entry for the BO's position in vc4_dev->bo_cache.size_list */
  188. struct list_head size_head;
  189. /* Struct for shader validation state, if created by
  190. * DRM_IOCTL_VC4_CREATE_SHADER_BO.
  191. */
  192. struct vc4_validated_shader_info *validated_shader;
  193. /* normally (resv == &_resv) except for imported bo's */
  194. struct reservation_object *resv;
  195. struct reservation_object _resv;
  196. /* One of enum vc4_kernel_bo_type, or VC4_BO_TYPE_COUNT + i
  197. * for user-allocated labels.
  198. */
  199. int label;
  200. /* Count the number of active users. This is needed to determine
  201. * whether we can move the BO to the purgeable list or not (when the BO
  202. * is used by the GPU or the display engine we can't purge it).
  203. */
  204. refcount_t usecnt;
  205. /* Store purgeable/purged state here */
  206. u32 madv;
  207. struct mutex madv_lock;
  208. };
  209. static inline struct vc4_bo *
  210. to_vc4_bo(struct drm_gem_object *bo)
  211. {
  212. return (struct vc4_bo *)bo;
  213. }
  214. struct vc4_fence {
  215. struct dma_fence base;
  216. struct drm_device *dev;
  217. /* vc4 seqno for signaled() test */
  218. uint64_t seqno;
  219. };
  220. static inline struct vc4_fence *
  221. to_vc4_fence(struct dma_fence *fence)
  222. {
  223. return (struct vc4_fence *)fence;
  224. }
  225. struct vc4_seqno_cb {
  226. struct work_struct work;
  227. uint64_t seqno;
  228. void (*func)(struct vc4_seqno_cb *cb);
  229. };
  230. struct vc4_v3d {
  231. struct vc4_dev *vc4;
  232. struct platform_device *pdev;
  233. void __iomem *regs;
  234. struct clk *clk;
  235. };
  236. struct vc4_hvs {
  237. struct platform_device *pdev;
  238. void __iomem *regs;
  239. u32 __iomem *dlist;
  240. /* Memory manager for CRTCs to allocate space in the display
  241. * list. Units are dwords.
  242. */
  243. struct drm_mm dlist_mm;
  244. /* Memory manager for the LBM memory used by HVS scaling. */
  245. struct drm_mm lbm_mm;
  246. spinlock_t mm_lock;
  247. struct drm_mm_node mitchell_netravali_filter;
  248. };
  249. struct vc4_plane {
  250. struct drm_plane base;
  251. };
  252. static inline struct vc4_plane *
  253. to_vc4_plane(struct drm_plane *plane)
  254. {
  255. return (struct vc4_plane *)plane;
  256. }
  257. enum vc4_scaling_mode {
  258. VC4_SCALING_NONE,
  259. VC4_SCALING_TPZ,
  260. VC4_SCALING_PPF,
  261. };
  262. struct vc4_plane_state {
  263. struct drm_plane_state base;
  264. /* System memory copy of the display list for this element, computed
  265. * at atomic_check time.
  266. */
  267. u32 *dlist;
  268. u32 dlist_size; /* Number of dwords allocated for the display list */
  269. u32 dlist_count; /* Number of used dwords in the display list. */
  270. /* Offset in the dlist to various words, for pageflip or
  271. * cursor updates.
  272. */
  273. u32 pos0_offset;
  274. u32 pos2_offset;
  275. u32 ptr0_offset;
  276. /* Offset where the plane's dlist was last stored in the
  277. * hardware at vc4_crtc_atomic_flush() time.
  278. */
  279. u32 __iomem *hw_dlist;
  280. /* Clipped coordinates of the plane on the display. */
  281. int crtc_x, crtc_y, crtc_w, crtc_h;
  282. /* Clipped area being scanned from in the FB. */
  283. u32 src_x, src_y;
  284. u32 src_w[2], src_h[2];
  285. /* Scaling selection for the RGB/Y plane and the Cb/Cr planes. */
  286. enum vc4_scaling_mode x_scaling[2], y_scaling[2];
  287. bool is_unity;
  288. bool is_yuv;
  289. /* Offset to start scanning out from the start of the plane's
  290. * BO.
  291. */
  292. u32 offsets[3];
  293. /* Our allocation in LBM for temporary storage during scaling. */
  294. struct drm_mm_node lbm;
  295. /* Set when the plane has per-pixel alpha content or does not cover
  296. * the entire screen. This is a hint to the CRTC that it might need
  297. * to enable background color fill.
  298. */
  299. bool needs_bg_fill;
  300. };
  301. static inline struct vc4_plane_state *
  302. to_vc4_plane_state(struct drm_plane_state *state)
  303. {
  304. return (struct vc4_plane_state *)state;
  305. }
  306. enum vc4_encoder_type {
  307. VC4_ENCODER_TYPE_NONE,
  308. VC4_ENCODER_TYPE_HDMI,
  309. VC4_ENCODER_TYPE_VEC,
  310. VC4_ENCODER_TYPE_DSI0,
  311. VC4_ENCODER_TYPE_DSI1,
  312. VC4_ENCODER_TYPE_SMI,
  313. VC4_ENCODER_TYPE_DPI,
  314. };
  315. struct vc4_encoder {
  316. struct drm_encoder base;
  317. enum vc4_encoder_type type;
  318. u32 clock_select;
  319. };
  320. static inline struct vc4_encoder *
  321. to_vc4_encoder(struct drm_encoder *encoder)
  322. {
  323. return container_of(encoder, struct vc4_encoder, base);
  324. }
  325. #define V3D_READ(offset) readl(vc4->v3d->regs + offset)
  326. #define V3D_WRITE(offset, val) writel(val, vc4->v3d->regs + offset)
  327. #define HVS_READ(offset) readl(vc4->hvs->regs + offset)
  328. #define HVS_WRITE(offset, val) writel(val, vc4->hvs->regs + offset)
  329. struct vc4_exec_info {
  330. /* Sequence number for this bin/render job. */
  331. uint64_t seqno;
  332. /* Latest write_seqno of any BO that binning depends on. */
  333. uint64_t bin_dep_seqno;
  334. struct dma_fence *fence;
  335. /* Last current addresses the hardware was processing when the
  336. * hangcheck timer checked on us.
  337. */
  338. uint32_t last_ct0ca, last_ct1ca;
  339. /* Kernel-space copy of the ioctl arguments */
  340. struct drm_vc4_submit_cl *args;
  341. /* This is the array of BOs that were looked up at the start of exec.
  342. * Command validation will use indices into this array.
  343. */
  344. struct drm_gem_cma_object **bo;
  345. uint32_t bo_count;
  346. /* List of BOs that are being written by the RCL. Other than
  347. * the binner temporary storage, this is all the BOs written
  348. * by the job.
  349. */
  350. struct drm_gem_cma_object *rcl_write_bo[4];
  351. uint32_t rcl_write_bo_count;
  352. /* Pointers for our position in vc4->job_list */
  353. struct list_head head;
  354. /* List of other BOs used in the job that need to be released
  355. * once the job is complete.
  356. */
  357. struct list_head unref_list;
  358. /* Current unvalidated indices into @bo loaded by the non-hardware
  359. * VC4_PACKET_GEM_HANDLES.
  360. */
  361. uint32_t bo_index[2];
  362. /* This is the BO where we store the validated command lists, shader
  363. * records, and uniforms.
  364. */
  365. struct drm_gem_cma_object *exec_bo;
  366. /**
  367. * This tracks the per-shader-record state (packet 64) that
  368. * determines the length of the shader record and the offset
  369. * it's expected to be found at. It gets read in from the
  370. * command lists.
  371. */
  372. struct vc4_shader_state {
  373. uint32_t addr;
  374. /* Maximum vertex index referenced by any primitive using this
  375. * shader state.
  376. */
  377. uint32_t max_index;
  378. } *shader_state;
  379. /** How many shader states the user declared they were using. */
  380. uint32_t shader_state_size;
  381. /** How many shader state records the validator has seen. */
  382. uint32_t shader_state_count;
  383. bool found_tile_binning_mode_config_packet;
  384. bool found_start_tile_binning_packet;
  385. bool found_increment_semaphore_packet;
  386. bool found_flush;
  387. uint8_t bin_tiles_x, bin_tiles_y;
  388. /* Physical address of the start of the tile alloc array
  389. * (where each tile's binned CL will start)
  390. */
  391. uint32_t tile_alloc_offset;
  392. /* Bitmask of which binner slots are freed when this job completes. */
  393. uint32_t bin_slots;
  394. /**
  395. * Computed addresses pointing into exec_bo where we start the
  396. * bin thread (ct0) and render thread (ct1).
  397. */
  398. uint32_t ct0ca, ct0ea;
  399. uint32_t ct1ca, ct1ea;
  400. /* Pointer to the unvalidated bin CL (if present). */
  401. void *bin_u;
  402. /* Pointers to the shader recs. These paddr gets incremented as CL
  403. * packets are relocated in validate_gl_shader_state, and the vaddrs
  404. * (u and v) get incremented and size decremented as the shader recs
  405. * themselves are validated.
  406. */
  407. void *shader_rec_u;
  408. void *shader_rec_v;
  409. uint32_t shader_rec_p;
  410. uint32_t shader_rec_size;
  411. /* Pointers to the uniform data. These pointers are incremented, and
  412. * size decremented, as each batch of uniforms is uploaded.
  413. */
  414. void *uniforms_u;
  415. void *uniforms_v;
  416. uint32_t uniforms_p;
  417. uint32_t uniforms_size;
  418. /* Pointer to a performance monitor object if the user requested it,
  419. * NULL otherwise.
  420. */
  421. struct vc4_perfmon *perfmon;
  422. };
  423. /* Per-open file private data. Any driver-specific resource that has to be
  424. * released when the DRM file is closed should be placed here.
  425. */
  426. struct vc4_file {
  427. struct {
  428. struct idr idr;
  429. struct mutex lock;
  430. } perfmon;
  431. };
  432. static inline struct vc4_exec_info *
  433. vc4_first_bin_job(struct vc4_dev *vc4)
  434. {
  435. return list_first_entry_or_null(&vc4->bin_job_list,
  436. struct vc4_exec_info, head);
  437. }
  438. static inline struct vc4_exec_info *
  439. vc4_first_render_job(struct vc4_dev *vc4)
  440. {
  441. return list_first_entry_or_null(&vc4->render_job_list,
  442. struct vc4_exec_info, head);
  443. }
  444. static inline struct vc4_exec_info *
  445. vc4_last_render_job(struct vc4_dev *vc4)
  446. {
  447. if (list_empty(&vc4->render_job_list))
  448. return NULL;
  449. return list_last_entry(&vc4->render_job_list,
  450. struct vc4_exec_info, head);
  451. }
  452. /**
  453. * struct vc4_texture_sample_info - saves the offsets into the UBO for texture
  454. * setup parameters.
  455. *
  456. * This will be used at draw time to relocate the reference to the texture
  457. * contents in p0, and validate that the offset combined with
  458. * width/height/stride/etc. from p1 and p2/p3 doesn't sample outside the BO.
  459. * Note that the hardware treats unprovided config parameters as 0, so not all
  460. * of them need to be set up for every texure sample, and we'll store ~0 as
  461. * the offset to mark the unused ones.
  462. *
  463. * See the VC4 3D architecture guide page 41 ("Texture and Memory Lookup Unit
  464. * Setup") for definitions of the texture parameters.
  465. */
  466. struct vc4_texture_sample_info {
  467. bool is_direct;
  468. uint32_t p_offset[4];
  469. };
  470. /**
  471. * struct vc4_validated_shader_info - information about validated shaders that
  472. * needs to be used from command list validation.
  473. *
  474. * For a given shader, each time a shader state record references it, we need
  475. * to verify that the shader doesn't read more uniforms than the shader state
  476. * record's uniform BO pointer can provide, and we need to apply relocations
  477. * and validate the shader state record's uniforms that define the texture
  478. * samples.
  479. */
  480. struct vc4_validated_shader_info {
  481. uint32_t uniforms_size;
  482. uint32_t uniforms_src_size;
  483. uint32_t num_texture_samples;
  484. struct vc4_texture_sample_info *texture_samples;
  485. uint32_t num_uniform_addr_offsets;
  486. uint32_t *uniform_addr_offsets;
  487. bool is_threaded;
  488. };
  489. /**
  490. * _wait_for - magic (register) wait macro
  491. *
  492. * Does the right thing for modeset paths when run under kdgb or similar atomic
  493. * contexts. Note that it's important that we check the condition again after
  494. * having timed out, since the timeout could be due to preemption or similar and
  495. * we've never had a chance to check the condition before the timeout.
  496. */
  497. #define _wait_for(COND, MS, W) ({ \
  498. unsigned long timeout__ = jiffies + msecs_to_jiffies(MS) + 1; \
  499. int ret__ = 0; \
  500. while (!(COND)) { \
  501. if (time_after(jiffies, timeout__)) { \
  502. if (!(COND)) \
  503. ret__ = -ETIMEDOUT; \
  504. break; \
  505. } \
  506. if (W && drm_can_sleep()) { \
  507. msleep(W); \
  508. } else { \
  509. cpu_relax(); \
  510. } \
  511. } \
  512. ret__; \
  513. })
  514. #define wait_for(COND, MS) _wait_for(COND, MS, 1)
  515. /* vc4_bo.c */
  516. struct drm_gem_object *vc4_create_object(struct drm_device *dev, size_t size);
  517. void vc4_free_object(struct drm_gem_object *gem_obj);
  518. struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t size,
  519. bool from_cache, enum vc4_kernel_bo_type type);
  520. int vc4_dumb_create(struct drm_file *file_priv,
  521. struct drm_device *dev,
  522. struct drm_mode_create_dumb *args);
  523. struct dma_buf *vc4_prime_export(struct drm_device *dev,
  524. struct drm_gem_object *obj, int flags);
  525. int vc4_create_bo_ioctl(struct drm_device *dev, void *data,
  526. struct drm_file *file_priv);
  527. int vc4_create_shader_bo_ioctl(struct drm_device *dev, void *data,
  528. struct drm_file *file_priv);
  529. int vc4_mmap_bo_ioctl(struct drm_device *dev, void *data,
  530. struct drm_file *file_priv);
  531. int vc4_set_tiling_ioctl(struct drm_device *dev, void *data,
  532. struct drm_file *file_priv);
  533. int vc4_get_tiling_ioctl(struct drm_device *dev, void *data,
  534. struct drm_file *file_priv);
  535. int vc4_get_hang_state_ioctl(struct drm_device *dev, void *data,
  536. struct drm_file *file_priv);
  537. int vc4_label_bo_ioctl(struct drm_device *dev, void *data,
  538. struct drm_file *file_priv);
  539. int vc4_fault(struct vm_fault *vmf);
  540. int vc4_mmap(struct file *filp, struct vm_area_struct *vma);
  541. struct reservation_object *vc4_prime_res_obj(struct drm_gem_object *obj);
  542. int vc4_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma);
  543. struct drm_gem_object *vc4_prime_import_sg_table(struct drm_device *dev,
  544. struct dma_buf_attachment *attach,
  545. struct sg_table *sgt);
  546. void *vc4_prime_vmap(struct drm_gem_object *obj);
  547. int vc4_bo_cache_init(struct drm_device *dev);
  548. void vc4_bo_cache_destroy(struct drm_device *dev);
  549. int vc4_bo_stats_debugfs(struct seq_file *m, void *arg);
  550. int vc4_bo_inc_usecnt(struct vc4_bo *bo);
  551. void vc4_bo_dec_usecnt(struct vc4_bo *bo);
  552. void vc4_bo_add_to_purgeable_pool(struct vc4_bo *bo);
  553. void vc4_bo_remove_from_purgeable_pool(struct vc4_bo *bo);
  554. /* vc4_crtc.c */
  555. extern struct platform_driver vc4_crtc_driver;
  556. int vc4_crtc_debugfs_regs(struct seq_file *m, void *arg);
  557. bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
  558. bool in_vblank_irq, int *vpos, int *hpos,
  559. ktime_t *stime, ktime_t *etime,
  560. const struct drm_display_mode *mode);
  561. /* vc4_debugfs.c */
  562. int vc4_debugfs_init(struct drm_minor *minor);
  563. /* vc4_drv.c */
  564. void __iomem *vc4_ioremap_regs(struct platform_device *dev, int index);
  565. /* vc4_dpi.c */
  566. extern struct platform_driver vc4_dpi_driver;
  567. int vc4_dpi_debugfs_regs(struct seq_file *m, void *unused);
  568. /* vc4_dsi.c */
  569. extern struct platform_driver vc4_dsi_driver;
  570. int vc4_dsi_debugfs_regs(struct seq_file *m, void *unused);
  571. /* vc4_fence.c */
  572. extern const struct dma_fence_ops vc4_fence_ops;
  573. /* vc4_gem.c */
  574. void vc4_gem_init(struct drm_device *dev);
  575. void vc4_gem_destroy(struct drm_device *dev);
  576. int vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
  577. struct drm_file *file_priv);
  578. int vc4_wait_seqno_ioctl(struct drm_device *dev, void *data,
  579. struct drm_file *file_priv);
  580. int vc4_wait_bo_ioctl(struct drm_device *dev, void *data,
  581. struct drm_file *file_priv);
  582. void vc4_submit_next_bin_job(struct drm_device *dev);
  583. void vc4_submit_next_render_job(struct drm_device *dev);
  584. void vc4_move_job_to_render(struct drm_device *dev, struct vc4_exec_info *exec);
  585. int vc4_wait_for_seqno(struct drm_device *dev, uint64_t seqno,
  586. uint64_t timeout_ns, bool interruptible);
  587. void vc4_job_handle_completed(struct vc4_dev *vc4);
  588. int vc4_queue_seqno_cb(struct drm_device *dev,
  589. struct vc4_seqno_cb *cb, uint64_t seqno,
  590. void (*func)(struct vc4_seqno_cb *cb));
  591. int vc4_gem_madvise_ioctl(struct drm_device *dev, void *data,
  592. struct drm_file *file_priv);
  593. /* vc4_hdmi.c */
  594. extern struct platform_driver vc4_hdmi_driver;
  595. int vc4_hdmi_debugfs_regs(struct seq_file *m, void *unused);
  596. /* vc4_vec.c */
  597. extern struct platform_driver vc4_vec_driver;
  598. int vc4_vec_debugfs_regs(struct seq_file *m, void *unused);
  599. /* vc4_irq.c */
  600. irqreturn_t vc4_irq(int irq, void *arg);
  601. void vc4_irq_preinstall(struct drm_device *dev);
  602. int vc4_irq_postinstall(struct drm_device *dev);
  603. void vc4_irq_uninstall(struct drm_device *dev);
  604. void vc4_irq_reset(struct drm_device *dev);
  605. /* vc4_hvs.c */
  606. extern struct platform_driver vc4_hvs_driver;
  607. void vc4_hvs_dump_state(struct drm_device *dev);
  608. int vc4_hvs_debugfs_regs(struct seq_file *m, void *unused);
  609. /* vc4_kms.c */
  610. int vc4_kms_load(struct drm_device *dev);
  611. /* vc4_plane.c */
  612. struct drm_plane *vc4_plane_init(struct drm_device *dev,
  613. enum drm_plane_type type);
  614. u32 vc4_plane_write_dlist(struct drm_plane *plane, u32 __iomem *dlist);
  615. u32 vc4_plane_dlist_size(const struct drm_plane_state *state);
  616. void vc4_plane_async_set_fb(struct drm_plane *plane,
  617. struct drm_framebuffer *fb);
  618. /* vc4_v3d.c */
  619. extern struct platform_driver vc4_v3d_driver;
  620. int vc4_v3d_debugfs_ident(struct seq_file *m, void *unused);
  621. int vc4_v3d_debugfs_regs(struct seq_file *m, void *unused);
  622. int vc4_v3d_get_bin_slot(struct vc4_dev *vc4);
  623. /* vc4_validate.c */
  624. int
  625. vc4_validate_bin_cl(struct drm_device *dev,
  626. void *validated,
  627. void *unvalidated,
  628. struct vc4_exec_info *exec);
  629. int
  630. vc4_validate_shader_recs(struct drm_device *dev, struct vc4_exec_info *exec);
  631. struct drm_gem_cma_object *vc4_use_bo(struct vc4_exec_info *exec,
  632. uint32_t hindex);
  633. int vc4_get_rcl(struct drm_device *dev, struct vc4_exec_info *exec);
  634. bool vc4_check_tex_size(struct vc4_exec_info *exec,
  635. struct drm_gem_cma_object *fbo,
  636. uint32_t offset, uint8_t tiling_format,
  637. uint32_t width, uint32_t height, uint8_t cpp);
  638. /* vc4_validate_shader.c */
  639. struct vc4_validated_shader_info *
  640. vc4_validate_shader(struct drm_gem_cma_object *shader_obj);
  641. /* vc4_perfmon.c */
  642. void vc4_perfmon_get(struct vc4_perfmon *perfmon);
  643. void vc4_perfmon_put(struct vc4_perfmon *perfmon);
  644. void vc4_perfmon_start(struct vc4_dev *vc4, struct vc4_perfmon *perfmon);
  645. void vc4_perfmon_stop(struct vc4_dev *vc4, struct vc4_perfmon *perfmon,
  646. bool capture);
  647. struct vc4_perfmon *vc4_perfmon_find(struct vc4_file *vc4file, int id);
  648. void vc4_perfmon_open_file(struct vc4_file *vc4file);
  649. void vc4_perfmon_close_file(struct vc4_file *vc4file);
  650. int vc4_perfmon_create_ioctl(struct drm_device *dev, void *data,
  651. struct drm_file *file_priv);
  652. int vc4_perfmon_destroy_ioctl(struct drm_device *dev, void *data,
  653. struct drm_file *file_priv);
  654. int vc4_perfmon_get_values_ioctl(struct drm_device *dev, void *data,
  655. struct drm_file *file_priv);