vc4_drv.h 23 KB

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