1c8b75bcaSEric Anholt /* 2c8b75bcaSEric Anholt * Copyright (C) 2015 Broadcom 3c8b75bcaSEric Anholt * 4c8b75bcaSEric Anholt * This program is free software; you can redistribute it and/or modify 5c8b75bcaSEric Anholt * it under the terms of the GNU General Public License version 2 as 6c8b75bcaSEric Anholt * published by the Free Software Foundation. 7c8b75bcaSEric Anholt */ 8c8b75bcaSEric Anholt 9abd7dbe9SSouptick Joarder #include <linux/mm_types.h> 10b7e8e25bSMasahiro Yamada #include <drm/drmP.h> 11e9eafcb5SSam Ravnborg #include <drm/drm_util.h> 129338203cSLaurent Pinchart #include <drm/drm_encoder.h> 13b7e8e25bSMasahiro Yamada #include <drm/drm_gem_cma_helper.h> 14766cc6b1SStefan Schake #include <drm/drm_atomic.h> 15818f5c8fSStefan Schake #include <drm/drm_syncobj.h> 169338203cSLaurent Pinchart 1765101d8cSBoris Brezillon #include "uapi/drm/vc4_drm.h" 1865101d8cSBoris Brezillon 19f3099462SEric Anholt /* Don't forget to update vc4_bo.c: bo_type_names[] when adding to 20f3099462SEric Anholt * this. 21f3099462SEric Anholt */ 22f3099462SEric Anholt enum vc4_kernel_bo_type { 23f3099462SEric Anholt /* Any kernel allocation (gem_create_object hook) before it 24f3099462SEric Anholt * gets another type set. 25f3099462SEric Anholt */ 26f3099462SEric Anholt VC4_BO_TYPE_KERNEL, 27f3099462SEric Anholt VC4_BO_TYPE_V3D, 28f3099462SEric Anholt VC4_BO_TYPE_V3D_SHADER, 29f3099462SEric Anholt VC4_BO_TYPE_DUMB, 30f3099462SEric Anholt VC4_BO_TYPE_BIN, 31f3099462SEric Anholt VC4_BO_TYPE_RCL, 32f3099462SEric Anholt VC4_BO_TYPE_BCL, 33f3099462SEric Anholt VC4_BO_TYPE_KERNEL_CACHE, 34f3099462SEric Anholt VC4_BO_TYPE_COUNT 35f3099462SEric Anholt }; 36f3099462SEric Anholt 3765101d8cSBoris Brezillon /* Performance monitor object. The perform lifetime is controlled by userspace 3865101d8cSBoris Brezillon * using perfmon related ioctls. A perfmon can be attached to a submit_cl 3965101d8cSBoris Brezillon * request, and when this is the case, HW perf counters will be activated just 4065101d8cSBoris Brezillon * before the submit_cl is submitted to the GPU and disabled when the job is 4165101d8cSBoris Brezillon * done. This way, only events related to a specific job will be counted. 4265101d8cSBoris Brezillon */ 4365101d8cSBoris Brezillon struct vc4_perfmon { 4465101d8cSBoris Brezillon /* Tracks the number of users of the perfmon, when this counter reaches 4565101d8cSBoris Brezillon * zero the perfmon is destroyed. 4665101d8cSBoris Brezillon */ 4765101d8cSBoris Brezillon refcount_t refcnt; 4865101d8cSBoris Brezillon 4965101d8cSBoris Brezillon /* Number of counters activated in this perfmon instance 5065101d8cSBoris Brezillon * (should be less than DRM_VC4_MAX_PERF_COUNTERS). 5165101d8cSBoris Brezillon */ 5265101d8cSBoris Brezillon u8 ncounters; 5365101d8cSBoris Brezillon 5465101d8cSBoris Brezillon /* Events counted by the HW perf counters. */ 5565101d8cSBoris Brezillon u8 events[DRM_VC4_MAX_PERF_COUNTERS]; 5665101d8cSBoris Brezillon 5765101d8cSBoris Brezillon /* Storage for counter values. Counters are incremented by the HW 5865101d8cSBoris Brezillon * perf counter values every time the perfmon is attached to a GPU job. 5965101d8cSBoris Brezillon * This way, perfmon users don't have to retrieve the results after 6065101d8cSBoris Brezillon * each job if they want to track events covering several submissions. 6165101d8cSBoris Brezillon * Note that counter values can't be reset, but you can fake a reset by 6265101d8cSBoris Brezillon * destroying the perfmon and creating a new one. 6365101d8cSBoris Brezillon */ 6465101d8cSBoris Brezillon u64 counters[0]; 6565101d8cSBoris Brezillon }; 6665101d8cSBoris Brezillon 67c8b75bcaSEric Anholt struct vc4_dev { 68c8b75bcaSEric Anholt struct drm_device *dev; 69c8b75bcaSEric Anholt 70c8b75bcaSEric Anholt struct vc4_hdmi *hdmi; 71c8b75bcaSEric Anholt struct vc4_hvs *hvs; 72d3f5168aSEric Anholt struct vc4_v3d *v3d; 7308302c35SEric Anholt struct vc4_dpi *dpi; 744078f575SEric Anholt struct vc4_dsi *dsi1; 75e4b81f8cSBoris Brezillon struct vc4_vec *vec; 76008095e0SBoris Brezillon struct vc4_txp *txp; 7748666d56SDerek Foreman 7821461365SEric Anholt struct vc4_hang_state *hang_state; 7921461365SEric Anholt 80c826a6e1SEric Anholt /* The kernel-space BO cache. Tracks buffers that have been 81c826a6e1SEric Anholt * unreferenced by all other users (refcounts of 0!) but not 82c826a6e1SEric Anholt * yet freed, so we can do cheap allocations. 83c826a6e1SEric Anholt */ 84c826a6e1SEric Anholt struct vc4_bo_cache { 85c826a6e1SEric Anholt /* Array of list heads for entries in the BO cache, 86c826a6e1SEric Anholt * based on number of pages, so we can do O(1) lookups 87c826a6e1SEric Anholt * in the cache when allocating. 88c826a6e1SEric Anholt */ 89c826a6e1SEric Anholt struct list_head *size_list; 90c826a6e1SEric Anholt uint32_t size_list_size; 91c826a6e1SEric Anholt 92c826a6e1SEric Anholt /* List of all BOs in the cache, ordered by age, so we 93c826a6e1SEric Anholt * can do O(1) lookups when trying to free old 94c826a6e1SEric Anholt * buffers. 95c826a6e1SEric Anholt */ 96c826a6e1SEric Anholt struct list_head time_list; 97c826a6e1SEric Anholt struct work_struct time_work; 98c826a6e1SEric Anholt struct timer_list time_timer; 99c826a6e1SEric Anholt } bo_cache; 100c826a6e1SEric Anholt 101f3099462SEric Anholt u32 num_labels; 102f3099462SEric Anholt struct vc4_label { 103f3099462SEric Anholt const char *name; 104c826a6e1SEric Anholt u32 num_allocated; 105c826a6e1SEric Anholt u32 size_allocated; 106f3099462SEric Anholt } *bo_labels; 107c826a6e1SEric Anholt 108f3099462SEric Anholt /* Protects bo_cache and bo_labels. */ 109c826a6e1SEric Anholt struct mutex bo_lock; 110d5b1a78aSEric Anholt 111b9f19259SBoris Brezillon /* Purgeable BO pool. All BOs in this pool can have their memory 112b9f19259SBoris Brezillon * reclaimed if the driver is unable to allocate new BOs. We also 113b9f19259SBoris Brezillon * keep stats related to the purge mechanism here. 114b9f19259SBoris Brezillon */ 115b9f19259SBoris Brezillon struct { 116b9f19259SBoris Brezillon struct list_head list; 117b9f19259SBoris Brezillon unsigned int num; 118b9f19259SBoris Brezillon size_t size; 119b9f19259SBoris Brezillon unsigned int purged_num; 120b9f19259SBoris Brezillon size_t purged_size; 121b9f19259SBoris Brezillon struct mutex lock; 122b9f19259SBoris Brezillon } purgeable; 123b9f19259SBoris Brezillon 124cdec4d36SEric Anholt uint64_t dma_fence_context; 125cdec4d36SEric Anholt 126ca26d28bSVarad Gautam /* Sequence number for the last job queued in bin_job_list. 127d5b1a78aSEric Anholt * Starts at 0 (no jobs emitted). 128d5b1a78aSEric Anholt */ 129d5b1a78aSEric Anholt uint64_t emit_seqno; 130d5b1a78aSEric Anholt 131d5b1a78aSEric Anholt /* Sequence number for the last completed job on the GPU. 132d5b1a78aSEric Anholt * Starts at 0 (no jobs completed). 133d5b1a78aSEric Anholt */ 134d5b1a78aSEric Anholt uint64_t finished_seqno; 135d5b1a78aSEric Anholt 136ca26d28bSVarad Gautam /* List of all struct vc4_exec_info for jobs to be executed in 137ca26d28bSVarad Gautam * the binner. The first job in the list is the one currently 138ca26d28bSVarad Gautam * programmed into ct0ca for execution. 139d5b1a78aSEric Anholt */ 140ca26d28bSVarad Gautam struct list_head bin_job_list; 141ca26d28bSVarad Gautam 142ca26d28bSVarad Gautam /* List of all struct vc4_exec_info for jobs that have 143ca26d28bSVarad Gautam * completed binning and are ready for rendering. The first 144ca26d28bSVarad Gautam * job in the list is the one currently programmed into ct1ca 145ca26d28bSVarad Gautam * for execution. 146ca26d28bSVarad Gautam */ 147ca26d28bSVarad Gautam struct list_head render_job_list; 148ca26d28bSVarad Gautam 149d5b1a78aSEric Anholt /* List of the finished vc4_exec_infos waiting to be freed by 150d5b1a78aSEric Anholt * job_done_work. 151d5b1a78aSEric Anholt */ 152d5b1a78aSEric Anholt struct list_head job_done_list; 153d5b1a78aSEric Anholt /* Spinlock used to synchronize the job_list and seqno 154d5b1a78aSEric Anholt * accesses between the IRQ handler and GEM ioctls. 155d5b1a78aSEric Anholt */ 156d5b1a78aSEric Anholt spinlock_t job_lock; 157d5b1a78aSEric Anholt wait_queue_head_t job_wait_queue; 158d5b1a78aSEric Anholt struct work_struct job_done_work; 159d5b1a78aSEric Anholt 16065101d8cSBoris Brezillon /* Used to track the active perfmon if any. Access to this field is 16165101d8cSBoris Brezillon * protected by job_lock. 16265101d8cSBoris Brezillon */ 16365101d8cSBoris Brezillon struct vc4_perfmon *active_perfmon; 16465101d8cSBoris Brezillon 165b501baccSEric Anholt /* List of struct vc4_seqno_cb for callbacks to be made from a 166b501baccSEric Anholt * workqueue when the given seqno is passed. 167b501baccSEric Anholt */ 168b501baccSEric Anholt struct list_head seqno_cb_list; 169b501baccSEric Anholt 170553c942fSEric Anholt /* The memory used for storing binner tile alloc, tile state, 171553c942fSEric Anholt * and overflow memory allocations. This is freed when V3D 172553c942fSEric Anholt * powers down. 173d5b1a78aSEric Anholt */ 174553c942fSEric Anholt struct vc4_bo *bin_bo; 175553c942fSEric Anholt 176553c942fSEric Anholt /* Size of blocks allocated within bin_bo. */ 177553c942fSEric Anholt uint32_t bin_alloc_size; 178553c942fSEric Anholt 179553c942fSEric Anholt /* Bitmask of the bin_alloc_size chunks in bin_bo that are 180553c942fSEric Anholt * used. 181553c942fSEric Anholt */ 182553c942fSEric Anholt uint32_t bin_alloc_used; 183553c942fSEric Anholt 184553c942fSEric Anholt /* Bitmask of the current bin_alloc used for overflow memory. */ 185553c942fSEric Anholt uint32_t bin_alloc_overflow; 186553c942fSEric Anholt 187531a1b62SBoris Brezillon /* Incremented when an underrun error happened after an atomic commit. 188531a1b62SBoris Brezillon * This is particularly useful to detect when a specific modeset is too 189531a1b62SBoris Brezillon * demanding in term of memory or HVS bandwidth which is hard to guess 190531a1b62SBoris Brezillon * at atomic check time. 191531a1b62SBoris Brezillon */ 192531a1b62SBoris Brezillon atomic_t underrun; 193531a1b62SBoris Brezillon 194d5b1a78aSEric Anholt struct work_struct overflow_mem_work; 195d5b1a78aSEric Anholt 19636cb6253SEric Anholt int power_refcount; 19736cb6253SEric Anholt 1986b5c029dSPaul Kocialkowski /* Set to true when the load tracker is active. */ 1996b5c029dSPaul Kocialkowski bool load_tracker_enabled; 2006b5c029dSPaul Kocialkowski 20136cb6253SEric Anholt /* Mutex controlling the power refcount. */ 20236cb6253SEric Anholt struct mutex power_lock; 20336cb6253SEric Anholt 204d5b1a78aSEric Anholt struct { 205d5b1a78aSEric Anholt struct timer_list timer; 206d5b1a78aSEric Anholt struct work_struct reset_work; 207d5b1a78aSEric Anholt } hangcheck; 208d5b1a78aSEric Anholt 209d5b1a78aSEric Anholt struct semaphore async_modeset; 210766cc6b1SStefan Schake 211766cc6b1SStefan Schake struct drm_modeset_lock ctm_state_lock; 212766cc6b1SStefan Schake struct drm_private_obj ctm_manager; 2134686da83SBoris Brezillon struct drm_private_obj load_tracker; 214*c9be804cSEric Anholt 215*c9be804cSEric Anholt /* List of vc4_debugfs_info_entry for adding to debugfs once 216*c9be804cSEric Anholt * the minor is available (after drm_dev_register()). 217*c9be804cSEric Anholt */ 218*c9be804cSEric Anholt struct list_head debugfs_list; 219c8b75bcaSEric Anholt }; 220c8b75bcaSEric Anholt 221c8b75bcaSEric Anholt static inline struct vc4_dev * 222c8b75bcaSEric Anholt to_vc4_dev(struct drm_device *dev) 223c8b75bcaSEric Anholt { 224c8b75bcaSEric Anholt return (struct vc4_dev *)dev->dev_private; 225c8b75bcaSEric Anholt } 226c8b75bcaSEric Anholt 227c8b75bcaSEric Anholt struct vc4_bo { 228c8b75bcaSEric Anholt struct drm_gem_cma_object base; 229c826a6e1SEric Anholt 2307edabee0SEric Anholt /* seqno of the last job to render using this BO. */ 231d5b1a78aSEric Anholt uint64_t seqno; 232d5b1a78aSEric Anholt 2337edabee0SEric Anholt /* seqno of the last job to use the RCL to write to this BO. 2347edabee0SEric Anholt * 2357edabee0SEric Anholt * Note that this doesn't include binner overflow memory 2367edabee0SEric Anholt * writes. 2377edabee0SEric Anholt */ 2387edabee0SEric Anholt uint64_t write_seqno; 2397edabee0SEric Anholt 24083753117SEric Anholt bool t_format; 24183753117SEric Anholt 242c826a6e1SEric Anholt /* List entry for the BO's position in either 243c826a6e1SEric Anholt * vc4_exec_info->unref_list or vc4_dev->bo_cache.time_list 244c826a6e1SEric Anholt */ 245c826a6e1SEric Anholt struct list_head unref_head; 246c826a6e1SEric Anholt 247c826a6e1SEric Anholt /* Time in jiffies when the BO was put in vc4->bo_cache. */ 248c826a6e1SEric Anholt unsigned long free_time; 249c826a6e1SEric Anholt 250c826a6e1SEric Anholt /* List entry for the BO's position in vc4_dev->bo_cache.size_list */ 251c826a6e1SEric Anholt struct list_head size_head; 252463873d5SEric Anholt 253463873d5SEric Anholt /* Struct for shader validation state, if created by 254463873d5SEric Anholt * DRM_IOCTL_VC4_CREATE_SHADER_BO. 255463873d5SEric Anholt */ 256463873d5SEric Anholt struct vc4_validated_shader_info *validated_shader; 257cdec4d36SEric Anholt 258f3099462SEric Anholt /* One of enum vc4_kernel_bo_type, or VC4_BO_TYPE_COUNT + i 259f3099462SEric Anholt * for user-allocated labels. 260f3099462SEric Anholt */ 261f3099462SEric Anholt int label; 262b9f19259SBoris Brezillon 263b9f19259SBoris Brezillon /* Count the number of active users. This is needed to determine 264b9f19259SBoris Brezillon * whether we can move the BO to the purgeable list or not (when the BO 265b9f19259SBoris Brezillon * is used by the GPU or the display engine we can't purge it). 266b9f19259SBoris Brezillon */ 267b9f19259SBoris Brezillon refcount_t usecnt; 268b9f19259SBoris Brezillon 269b9f19259SBoris Brezillon /* Store purgeable/purged state here */ 270b9f19259SBoris Brezillon u32 madv; 271b9f19259SBoris Brezillon struct mutex madv_lock; 272c8b75bcaSEric Anholt }; 273c8b75bcaSEric Anholt 274c8b75bcaSEric Anholt static inline struct vc4_bo * 275c8b75bcaSEric Anholt to_vc4_bo(struct drm_gem_object *bo) 276c8b75bcaSEric Anholt { 277c8b75bcaSEric Anholt return (struct vc4_bo *)bo; 278c8b75bcaSEric Anholt } 279c8b75bcaSEric Anholt 280cdec4d36SEric Anholt struct vc4_fence { 281cdec4d36SEric Anholt struct dma_fence base; 282cdec4d36SEric Anholt struct drm_device *dev; 283cdec4d36SEric Anholt /* vc4 seqno for signaled() test */ 284cdec4d36SEric Anholt uint64_t seqno; 285cdec4d36SEric Anholt }; 286cdec4d36SEric Anholt 287cdec4d36SEric Anholt static inline struct vc4_fence * 288cdec4d36SEric Anholt to_vc4_fence(struct dma_fence *fence) 289cdec4d36SEric Anholt { 290cdec4d36SEric Anholt return (struct vc4_fence *)fence; 291cdec4d36SEric Anholt } 292cdec4d36SEric Anholt 293b501baccSEric Anholt struct vc4_seqno_cb { 294b501baccSEric Anholt struct work_struct work; 295b501baccSEric Anholt uint64_t seqno; 296b501baccSEric Anholt void (*func)(struct vc4_seqno_cb *cb); 297b501baccSEric Anholt }; 298b501baccSEric Anholt 299d3f5168aSEric Anholt struct vc4_v3d { 300001bdb55SEric Anholt struct vc4_dev *vc4; 301d3f5168aSEric Anholt struct platform_device *pdev; 302d3f5168aSEric Anholt void __iomem *regs; 303b72a2816SEric Anholt struct clk *clk; 3043051719aSEric Anholt struct debugfs_regset32 regset; 305d3f5168aSEric Anholt }; 306d3f5168aSEric Anholt 307c8b75bcaSEric Anholt struct vc4_hvs { 308c8b75bcaSEric Anholt struct platform_device *pdev; 309c8b75bcaSEric Anholt void __iomem *regs; 310d8dbf44fSEric Anholt u32 __iomem *dlist; 311d8dbf44fSEric Anholt 312d8dbf44fSEric Anholt /* Memory manager for CRTCs to allocate space in the display 313d8dbf44fSEric Anholt * list. Units are dwords. 314d8dbf44fSEric Anholt */ 315d8dbf44fSEric Anholt struct drm_mm dlist_mm; 31621af94cfSEric Anholt /* Memory manager for the LBM memory used by HVS scaling. */ 31721af94cfSEric Anholt struct drm_mm lbm_mm; 318d8dbf44fSEric Anholt spinlock_t mm_lock; 31921af94cfSEric Anholt 32021af94cfSEric Anholt struct drm_mm_node mitchell_netravali_filter; 3213051719aSEric Anholt struct debugfs_regset32 regset; 322c8b75bcaSEric Anholt }; 323c8b75bcaSEric Anholt 324c8b75bcaSEric Anholt struct vc4_plane { 325c8b75bcaSEric Anholt struct drm_plane base; 326c8b75bcaSEric Anholt }; 327c8b75bcaSEric Anholt 328c8b75bcaSEric Anholt static inline struct vc4_plane * 329c8b75bcaSEric Anholt to_vc4_plane(struct drm_plane *plane) 330c8b75bcaSEric Anholt { 331c8b75bcaSEric Anholt return (struct vc4_plane *)plane; 332c8b75bcaSEric Anholt } 333c8b75bcaSEric Anholt 33482364698SStefan Schake enum vc4_scaling_mode { 33582364698SStefan Schake VC4_SCALING_NONE, 33682364698SStefan Schake VC4_SCALING_TPZ, 33782364698SStefan Schake VC4_SCALING_PPF, 33882364698SStefan Schake }; 33982364698SStefan Schake 34082364698SStefan Schake struct vc4_plane_state { 34182364698SStefan Schake struct drm_plane_state base; 34282364698SStefan Schake /* System memory copy of the display list for this element, computed 34382364698SStefan Schake * at atomic_check time. 34482364698SStefan Schake */ 34582364698SStefan Schake u32 *dlist; 34682364698SStefan Schake u32 dlist_size; /* Number of dwords allocated for the display list */ 34782364698SStefan Schake u32 dlist_count; /* Number of used dwords in the display list. */ 34882364698SStefan Schake 34982364698SStefan Schake /* Offset in the dlist to various words, for pageflip or 35082364698SStefan Schake * cursor updates. 35182364698SStefan Schake */ 35282364698SStefan Schake u32 pos0_offset; 35382364698SStefan Schake u32 pos2_offset; 35482364698SStefan Schake u32 ptr0_offset; 3550a038c1cSBoris Brezillon u32 lbm_offset; 35682364698SStefan Schake 35782364698SStefan Schake /* Offset where the plane's dlist was last stored in the 35882364698SStefan Schake * hardware at vc4_crtc_atomic_flush() time. 35982364698SStefan Schake */ 36082364698SStefan Schake u32 __iomem *hw_dlist; 36182364698SStefan Schake 36282364698SStefan Schake /* Clipped coordinates of the plane on the display. */ 36382364698SStefan Schake int crtc_x, crtc_y, crtc_w, crtc_h; 36482364698SStefan Schake /* Clipped area being scanned from in the FB. */ 36582364698SStefan Schake u32 src_x, src_y; 36682364698SStefan Schake 36782364698SStefan Schake u32 src_w[2], src_h[2]; 36882364698SStefan Schake 36982364698SStefan Schake /* Scaling selection for the RGB/Y plane and the Cb/Cr planes. */ 37082364698SStefan Schake enum vc4_scaling_mode x_scaling[2], y_scaling[2]; 37182364698SStefan Schake bool is_unity; 37282364698SStefan Schake bool is_yuv; 37382364698SStefan Schake 37482364698SStefan Schake /* Offset to start scanning out from the start of the plane's 37582364698SStefan Schake * BO. 37682364698SStefan Schake */ 37782364698SStefan Schake u32 offsets[3]; 37882364698SStefan Schake 37982364698SStefan Schake /* Our allocation in LBM for temporary storage during scaling. */ 38082364698SStefan Schake struct drm_mm_node lbm; 38182364698SStefan Schake 38282364698SStefan Schake /* Set when the plane has per-pixel alpha content or does not cover 38382364698SStefan Schake * the entire screen. This is a hint to the CRTC that it might need 38482364698SStefan Schake * to enable background color fill. 38582364698SStefan Schake */ 38682364698SStefan Schake bool needs_bg_fill; 3878d938449SBoris Brezillon 3888d938449SBoris Brezillon /* Mark the dlist as initialized. Useful to avoid initializing it twice 3898d938449SBoris Brezillon * when async update is not possible. 3908d938449SBoris Brezillon */ 3918d938449SBoris Brezillon bool dlist_initialized; 3924686da83SBoris Brezillon 3934686da83SBoris Brezillon /* Load of this plane on the HVS block. The load is expressed in HVS 3944686da83SBoris Brezillon * cycles/sec. 3954686da83SBoris Brezillon */ 3964686da83SBoris Brezillon u64 hvs_load; 3974686da83SBoris Brezillon 3984686da83SBoris Brezillon /* Memory bandwidth needed for this plane. This is expressed in 3994686da83SBoris Brezillon * bytes/sec. 4004686da83SBoris Brezillon */ 4014686da83SBoris Brezillon u64 membus_load; 40282364698SStefan Schake }; 40382364698SStefan Schake 40482364698SStefan Schake static inline struct vc4_plane_state * 40582364698SStefan Schake to_vc4_plane_state(struct drm_plane_state *state) 40682364698SStefan Schake { 40782364698SStefan Schake return (struct vc4_plane_state *)state; 40882364698SStefan Schake } 40982364698SStefan Schake 410c8b75bcaSEric Anholt enum vc4_encoder_type { 411ab8df60eSBoris Brezillon VC4_ENCODER_TYPE_NONE, 412c8b75bcaSEric Anholt VC4_ENCODER_TYPE_HDMI, 413c8b75bcaSEric Anholt VC4_ENCODER_TYPE_VEC, 414c8b75bcaSEric Anholt VC4_ENCODER_TYPE_DSI0, 415c8b75bcaSEric Anholt VC4_ENCODER_TYPE_DSI1, 416c8b75bcaSEric Anholt VC4_ENCODER_TYPE_SMI, 417c8b75bcaSEric Anholt VC4_ENCODER_TYPE_DPI, 418c8b75bcaSEric Anholt }; 419c8b75bcaSEric Anholt 420c8b75bcaSEric Anholt struct vc4_encoder { 421c8b75bcaSEric Anholt struct drm_encoder base; 422c8b75bcaSEric Anholt enum vc4_encoder_type type; 423c8b75bcaSEric Anholt u32 clock_select; 424c8b75bcaSEric Anholt }; 425c8b75bcaSEric Anholt 426c8b75bcaSEric Anholt static inline struct vc4_encoder * 427c8b75bcaSEric Anholt to_vc4_encoder(struct drm_encoder *encoder) 428c8b75bcaSEric Anholt { 429c8b75bcaSEric Anholt return container_of(encoder, struct vc4_encoder, base); 430c8b75bcaSEric Anholt } 431c8b75bcaSEric Anholt 43279271807SStefan Schake struct vc4_crtc_data { 43379271807SStefan Schake /* Which channel of the HVS this pixelvalve sources from. */ 43479271807SStefan Schake int hvs_channel; 43579271807SStefan Schake 43679271807SStefan Schake enum vc4_encoder_type encoder_types[4]; 437*c9be804cSEric Anholt const char *debugfs_name; 43879271807SStefan Schake }; 43979271807SStefan Schake 44079271807SStefan Schake struct vc4_crtc { 44179271807SStefan Schake struct drm_crtc base; 4423051719aSEric Anholt struct platform_device *pdev; 44379271807SStefan Schake const struct vc4_crtc_data *data; 44479271807SStefan Schake void __iomem *regs; 44579271807SStefan Schake 44679271807SStefan Schake /* Timestamp at start of vblank irq - unaffected by lock delays. */ 44779271807SStefan Schake ktime_t t_vblank; 44879271807SStefan Schake 44979271807SStefan Schake /* Which HVS channel we're using for our CRTC. */ 45079271807SStefan Schake int channel; 45179271807SStefan Schake 45279271807SStefan Schake u8 lut_r[256]; 45379271807SStefan Schake u8 lut_g[256]; 45479271807SStefan Schake u8 lut_b[256]; 45579271807SStefan Schake /* Size in pixels of the COB memory allocated to this CRTC. */ 45679271807SStefan Schake u32 cob_size; 45779271807SStefan Schake 45879271807SStefan Schake struct drm_pending_vblank_event *event; 4593051719aSEric Anholt 4603051719aSEric Anholt struct debugfs_regset32 regset; 46179271807SStefan Schake }; 46279271807SStefan Schake 46379271807SStefan Schake static inline struct vc4_crtc * 46479271807SStefan Schake to_vc4_crtc(struct drm_crtc *crtc) 46579271807SStefan Schake { 46679271807SStefan Schake return (struct vc4_crtc *)crtc; 46779271807SStefan Schake } 46879271807SStefan Schake 469d3f5168aSEric Anholt #define V3D_READ(offset) readl(vc4->v3d->regs + offset) 470d3f5168aSEric Anholt #define V3D_WRITE(offset, val) writel(val, vc4->v3d->regs + offset) 471c8b75bcaSEric Anholt #define HVS_READ(offset) readl(vc4->hvs->regs + offset) 472c8b75bcaSEric Anholt #define HVS_WRITE(offset, val) writel(val, vc4->hvs->regs + offset) 473c8b75bcaSEric Anholt 4743051719aSEric Anholt #define VC4_REG32(reg) { .name = #reg, .offset = reg } 4753051719aSEric Anholt 476d5b1a78aSEric Anholt struct vc4_exec_info { 477d5b1a78aSEric Anholt /* Sequence number for this bin/render job. */ 478d5b1a78aSEric Anholt uint64_t seqno; 479d5b1a78aSEric Anholt 4807edabee0SEric Anholt /* Latest write_seqno of any BO that binning depends on. */ 4817edabee0SEric Anholt uint64_t bin_dep_seqno; 4827edabee0SEric Anholt 483cdec4d36SEric Anholt struct dma_fence *fence; 484cdec4d36SEric Anholt 485c4ce60dcSEric Anholt /* Last current addresses the hardware was processing when the 486c4ce60dcSEric Anholt * hangcheck timer checked on us. 487c4ce60dcSEric Anholt */ 488c4ce60dcSEric Anholt uint32_t last_ct0ca, last_ct1ca; 489c4ce60dcSEric Anholt 490d5b1a78aSEric Anholt /* Kernel-space copy of the ioctl arguments */ 491d5b1a78aSEric Anholt struct drm_vc4_submit_cl *args; 492d5b1a78aSEric Anholt 493d5b1a78aSEric Anholt /* This is the array of BOs that were looked up at the start of exec. 494d5b1a78aSEric Anholt * Command validation will use indices into this array. 495d5b1a78aSEric Anholt */ 496d5b1a78aSEric Anholt struct drm_gem_cma_object **bo; 497d5b1a78aSEric Anholt uint32_t bo_count; 498d5b1a78aSEric Anholt 4997edabee0SEric Anholt /* List of BOs that are being written by the RCL. Other than 5007edabee0SEric Anholt * the binner temporary storage, this is all the BOs written 5017edabee0SEric Anholt * by the job. 5027edabee0SEric Anholt */ 5037edabee0SEric Anholt struct drm_gem_cma_object *rcl_write_bo[4]; 5047edabee0SEric Anholt uint32_t rcl_write_bo_count; 5057edabee0SEric Anholt 506d5b1a78aSEric Anholt /* Pointers for our position in vc4->job_list */ 507d5b1a78aSEric Anholt struct list_head head; 508d5b1a78aSEric Anholt 509d5b1a78aSEric Anholt /* List of other BOs used in the job that need to be released 510d5b1a78aSEric Anholt * once the job is complete. 511d5b1a78aSEric Anholt */ 512d5b1a78aSEric Anholt struct list_head unref_list; 513d5b1a78aSEric Anholt 514d5b1a78aSEric Anholt /* Current unvalidated indices into @bo loaded by the non-hardware 515d5b1a78aSEric Anholt * VC4_PACKET_GEM_HANDLES. 516d5b1a78aSEric Anholt */ 517d5b1a78aSEric Anholt uint32_t bo_index[2]; 518d5b1a78aSEric Anholt 519d5b1a78aSEric Anholt /* This is the BO where we store the validated command lists, shader 520d5b1a78aSEric Anholt * records, and uniforms. 521d5b1a78aSEric Anholt */ 522d5b1a78aSEric Anholt struct drm_gem_cma_object *exec_bo; 523d5b1a78aSEric Anholt 524d5b1a78aSEric Anholt /** 525d5b1a78aSEric Anholt * This tracks the per-shader-record state (packet 64) that 526d5b1a78aSEric Anholt * determines the length of the shader record and the offset 527d5b1a78aSEric Anholt * it's expected to be found at. It gets read in from the 528d5b1a78aSEric Anholt * command lists. 529d5b1a78aSEric Anholt */ 530d5b1a78aSEric Anholt struct vc4_shader_state { 531d5b1a78aSEric Anholt uint32_t addr; 532d5b1a78aSEric Anholt /* Maximum vertex index referenced by any primitive using this 533d5b1a78aSEric Anholt * shader state. 534d5b1a78aSEric Anholt */ 535d5b1a78aSEric Anholt uint32_t max_index; 536d5b1a78aSEric Anholt } *shader_state; 537d5b1a78aSEric Anholt 538d5b1a78aSEric Anholt /** How many shader states the user declared they were using. */ 539d5b1a78aSEric Anholt uint32_t shader_state_size; 540d5b1a78aSEric Anholt /** How many shader state records the validator has seen. */ 541d5b1a78aSEric Anholt uint32_t shader_state_count; 542d5b1a78aSEric Anholt 543d5b1a78aSEric Anholt bool found_tile_binning_mode_config_packet; 544d5b1a78aSEric Anholt bool found_start_tile_binning_packet; 545d5b1a78aSEric Anholt bool found_increment_semaphore_packet; 546d5b1a78aSEric Anholt bool found_flush; 547d5b1a78aSEric Anholt uint8_t bin_tiles_x, bin_tiles_y; 548553c942fSEric Anholt /* Physical address of the start of the tile alloc array 549553c942fSEric Anholt * (where each tile's binned CL will start) 550553c942fSEric Anholt */ 551d5b1a78aSEric Anholt uint32_t tile_alloc_offset; 552553c942fSEric Anholt /* Bitmask of which binner slots are freed when this job completes. */ 553553c942fSEric Anholt uint32_t bin_slots; 554d5b1a78aSEric Anholt 555d5b1a78aSEric Anholt /** 556d5b1a78aSEric Anholt * Computed addresses pointing into exec_bo where we start the 557d5b1a78aSEric Anholt * bin thread (ct0) and render thread (ct1). 558d5b1a78aSEric Anholt */ 559d5b1a78aSEric Anholt uint32_t ct0ca, ct0ea; 560d5b1a78aSEric Anholt uint32_t ct1ca, ct1ea; 561d5b1a78aSEric Anholt 562d5b1a78aSEric Anholt /* Pointer to the unvalidated bin CL (if present). */ 563d5b1a78aSEric Anholt void *bin_u; 564d5b1a78aSEric Anholt 565d5b1a78aSEric Anholt /* Pointers to the shader recs. These paddr gets incremented as CL 566d5b1a78aSEric Anholt * packets are relocated in validate_gl_shader_state, and the vaddrs 567d5b1a78aSEric Anholt * (u and v) get incremented and size decremented as the shader recs 568d5b1a78aSEric Anholt * themselves are validated. 569d5b1a78aSEric Anholt */ 570d5b1a78aSEric Anholt void *shader_rec_u; 571d5b1a78aSEric Anholt void *shader_rec_v; 572d5b1a78aSEric Anholt uint32_t shader_rec_p; 573d5b1a78aSEric Anholt uint32_t shader_rec_size; 574d5b1a78aSEric Anholt 575d5b1a78aSEric Anholt /* Pointers to the uniform data. These pointers are incremented, and 576d5b1a78aSEric Anholt * size decremented, as each batch of uniforms is uploaded. 577d5b1a78aSEric Anholt */ 578d5b1a78aSEric Anholt void *uniforms_u; 579d5b1a78aSEric Anholt void *uniforms_v; 580d5b1a78aSEric Anholt uint32_t uniforms_p; 581d5b1a78aSEric Anholt uint32_t uniforms_size; 58265101d8cSBoris Brezillon 58365101d8cSBoris Brezillon /* Pointer to a performance monitor object if the user requested it, 58465101d8cSBoris Brezillon * NULL otherwise. 58565101d8cSBoris Brezillon */ 58665101d8cSBoris Brezillon struct vc4_perfmon *perfmon; 58765101d8cSBoris Brezillon }; 58865101d8cSBoris Brezillon 58965101d8cSBoris Brezillon /* Per-open file private data. Any driver-specific resource that has to be 59065101d8cSBoris Brezillon * released when the DRM file is closed should be placed here. 59165101d8cSBoris Brezillon */ 59265101d8cSBoris Brezillon struct vc4_file { 59365101d8cSBoris Brezillon struct { 59465101d8cSBoris Brezillon struct idr idr; 59565101d8cSBoris Brezillon struct mutex lock; 59665101d8cSBoris Brezillon } perfmon; 597d5b1a78aSEric Anholt }; 598d5b1a78aSEric Anholt 599d5b1a78aSEric Anholt static inline struct vc4_exec_info * 600ca26d28bSVarad Gautam vc4_first_bin_job(struct vc4_dev *vc4) 601d5b1a78aSEric Anholt { 60257b9f569SMasahiro Yamada return list_first_entry_or_null(&vc4->bin_job_list, 60357b9f569SMasahiro Yamada struct vc4_exec_info, head); 604ca26d28bSVarad Gautam } 605ca26d28bSVarad Gautam 606ca26d28bSVarad Gautam static inline struct vc4_exec_info * 607ca26d28bSVarad Gautam vc4_first_render_job(struct vc4_dev *vc4) 608ca26d28bSVarad Gautam { 60957b9f569SMasahiro Yamada return list_first_entry_or_null(&vc4->render_job_list, 610ca26d28bSVarad Gautam struct vc4_exec_info, head); 611d5b1a78aSEric Anholt } 612d5b1a78aSEric Anholt 6139326e6f2SEric Anholt static inline struct vc4_exec_info * 6149326e6f2SEric Anholt vc4_last_render_job(struct vc4_dev *vc4) 6159326e6f2SEric Anholt { 6169326e6f2SEric Anholt if (list_empty(&vc4->render_job_list)) 6179326e6f2SEric Anholt return NULL; 6189326e6f2SEric Anholt return list_last_entry(&vc4->render_job_list, 6199326e6f2SEric Anholt struct vc4_exec_info, head); 6209326e6f2SEric Anholt } 6219326e6f2SEric Anholt 622c8b75bcaSEric Anholt /** 623463873d5SEric Anholt * struct vc4_texture_sample_info - saves the offsets into the UBO for texture 624463873d5SEric Anholt * setup parameters. 625463873d5SEric Anholt * 626463873d5SEric Anholt * This will be used at draw time to relocate the reference to the texture 627463873d5SEric Anholt * contents in p0, and validate that the offset combined with 628463873d5SEric Anholt * width/height/stride/etc. from p1 and p2/p3 doesn't sample outside the BO. 629463873d5SEric Anholt * Note that the hardware treats unprovided config parameters as 0, so not all 630463873d5SEric Anholt * of them need to be set up for every texure sample, and we'll store ~0 as 631463873d5SEric Anholt * the offset to mark the unused ones. 632463873d5SEric Anholt * 633463873d5SEric Anholt * See the VC4 3D architecture guide page 41 ("Texture and Memory Lookup Unit 634463873d5SEric Anholt * Setup") for definitions of the texture parameters. 635463873d5SEric Anholt */ 636463873d5SEric Anholt struct vc4_texture_sample_info { 637463873d5SEric Anholt bool is_direct; 638463873d5SEric Anholt uint32_t p_offset[4]; 639463873d5SEric Anholt }; 640463873d5SEric Anholt 641463873d5SEric Anholt /** 642463873d5SEric Anholt * struct vc4_validated_shader_info - information about validated shaders that 643463873d5SEric Anholt * needs to be used from command list validation. 644463873d5SEric Anholt * 645463873d5SEric Anholt * For a given shader, each time a shader state record references it, we need 646463873d5SEric Anholt * to verify that the shader doesn't read more uniforms than the shader state 647463873d5SEric Anholt * record's uniform BO pointer can provide, and we need to apply relocations 648463873d5SEric Anholt * and validate the shader state record's uniforms that define the texture 649463873d5SEric Anholt * samples. 650463873d5SEric Anholt */ 651463873d5SEric Anholt struct vc4_validated_shader_info { 652463873d5SEric Anholt uint32_t uniforms_size; 653463873d5SEric Anholt uint32_t uniforms_src_size; 654463873d5SEric Anholt uint32_t num_texture_samples; 655463873d5SEric Anholt struct vc4_texture_sample_info *texture_samples; 6566d45c81dSEric Anholt 6576d45c81dSEric Anholt uint32_t num_uniform_addr_offsets; 6586d45c81dSEric Anholt uint32_t *uniform_addr_offsets; 659c778cc5dSJonas Pfeil 660c778cc5dSJonas Pfeil bool is_threaded; 661463873d5SEric Anholt }; 662463873d5SEric Anholt 663463873d5SEric Anholt /** 664c8b75bcaSEric Anholt * _wait_for - magic (register) wait macro 665c8b75bcaSEric Anholt * 666c8b75bcaSEric Anholt * Does the right thing for modeset paths when run under kdgb or similar atomic 667c8b75bcaSEric Anholt * contexts. Note that it's important that we check the condition again after 668c8b75bcaSEric Anholt * having timed out, since the timeout could be due to preemption or similar and 669c8b75bcaSEric Anholt * we've never had a chance to check the condition before the timeout. 670c8b75bcaSEric Anholt */ 671c8b75bcaSEric Anholt #define _wait_for(COND, MS, W) ({ \ 672c8b75bcaSEric Anholt unsigned long timeout__ = jiffies + msecs_to_jiffies(MS) + 1; \ 673c8b75bcaSEric Anholt int ret__ = 0; \ 674c8b75bcaSEric Anholt while (!(COND)) { \ 675c8b75bcaSEric Anholt if (time_after(jiffies, timeout__)) { \ 676c8b75bcaSEric Anholt if (!(COND)) \ 677c8b75bcaSEric Anholt ret__ = -ETIMEDOUT; \ 678c8b75bcaSEric Anholt break; \ 679c8b75bcaSEric Anholt } \ 680c8b75bcaSEric Anholt if (W && drm_can_sleep()) { \ 681c8b75bcaSEric Anholt msleep(W); \ 682c8b75bcaSEric Anholt } else { \ 683c8b75bcaSEric Anholt cpu_relax(); \ 684c8b75bcaSEric Anholt } \ 685c8b75bcaSEric Anholt } \ 686c8b75bcaSEric Anholt ret__; \ 687c8b75bcaSEric Anholt }) 688c8b75bcaSEric Anholt 689c8b75bcaSEric Anholt #define wait_for(COND, MS) _wait_for(COND, MS, 1) 690c8b75bcaSEric Anholt 691c8b75bcaSEric Anholt /* vc4_bo.c */ 692c826a6e1SEric Anholt struct drm_gem_object *vc4_create_object(struct drm_device *dev, size_t size); 693c8b75bcaSEric Anholt void vc4_free_object(struct drm_gem_object *gem_obj); 694c826a6e1SEric Anholt struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t size, 695f3099462SEric Anholt bool from_cache, enum vc4_kernel_bo_type type); 696c8b75bcaSEric Anholt int vc4_dumb_create(struct drm_file *file_priv, 697c8b75bcaSEric Anholt struct drm_device *dev, 698c8b75bcaSEric Anholt struct drm_mode_create_dumb *args); 699c8b75bcaSEric Anholt struct dma_buf *vc4_prime_export(struct drm_device *dev, 700c8b75bcaSEric Anholt struct drm_gem_object *obj, int flags); 701d5bc60f6SEric Anholt int vc4_create_bo_ioctl(struct drm_device *dev, void *data, 702d5bc60f6SEric Anholt struct drm_file *file_priv); 703463873d5SEric Anholt int vc4_create_shader_bo_ioctl(struct drm_device *dev, void *data, 704463873d5SEric Anholt struct drm_file *file_priv); 705d5bc60f6SEric Anholt int vc4_mmap_bo_ioctl(struct drm_device *dev, void *data, 706d5bc60f6SEric Anholt struct drm_file *file_priv); 70783753117SEric Anholt int vc4_set_tiling_ioctl(struct drm_device *dev, void *data, 70883753117SEric Anholt struct drm_file *file_priv); 70983753117SEric Anholt int vc4_get_tiling_ioctl(struct drm_device *dev, void *data, 71083753117SEric Anholt struct drm_file *file_priv); 71121461365SEric Anholt int vc4_get_hang_state_ioctl(struct drm_device *dev, void *data, 71221461365SEric Anholt struct drm_file *file_priv); 713f3099462SEric Anholt int vc4_label_bo_ioctl(struct drm_device *dev, void *data, 714f3099462SEric Anholt struct drm_file *file_priv); 715abd7dbe9SSouptick Joarder vm_fault_t vc4_fault(struct vm_fault *vmf); 716463873d5SEric Anholt int vc4_mmap(struct file *filp, struct vm_area_struct *vma); 717463873d5SEric Anholt int vc4_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma); 718cdec4d36SEric Anholt struct drm_gem_object *vc4_prime_import_sg_table(struct drm_device *dev, 719cdec4d36SEric Anholt struct dma_buf_attachment *attach, 720cdec4d36SEric Anholt struct sg_table *sgt); 721463873d5SEric Anholt void *vc4_prime_vmap(struct drm_gem_object *obj); 722f3099462SEric Anholt int vc4_bo_cache_init(struct drm_device *dev); 723c826a6e1SEric Anholt void vc4_bo_cache_destroy(struct drm_device *dev); 724b9f19259SBoris Brezillon int vc4_bo_inc_usecnt(struct vc4_bo *bo); 725b9f19259SBoris Brezillon void vc4_bo_dec_usecnt(struct vc4_bo *bo); 726b9f19259SBoris Brezillon void vc4_bo_add_to_purgeable_pool(struct vc4_bo *bo); 727b9f19259SBoris Brezillon void vc4_bo_remove_from_purgeable_pool(struct vc4_bo *bo); 728c8b75bcaSEric Anholt 729c8b75bcaSEric Anholt /* vc4_crtc.c */ 730c8b75bcaSEric Anholt extern struct platform_driver vc4_crtc_driver; 7311bf6ad62SDaniel Vetter bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id, 7321bf6ad62SDaniel Vetter bool in_vblank_irq, int *vpos, int *hpos, 7331bf59f1dSMario Kleiner ktime_t *stime, ktime_t *etime, 7341bf59f1dSMario Kleiner const struct drm_display_mode *mode); 735008095e0SBoris Brezillon void vc4_crtc_handle_vblank(struct vc4_crtc *crtc); 736008095e0SBoris Brezillon void vc4_crtc_txp_armed(struct drm_crtc_state *state); 737666e7358SBoris Brezillon void vc4_crtc_get_margins(struct drm_crtc_state *state, 738666e7358SBoris Brezillon unsigned int *right, unsigned int *left, 739666e7358SBoris Brezillon unsigned int *top, unsigned int *bottom); 740c8b75bcaSEric Anholt 741c8b75bcaSEric Anholt /* vc4_debugfs.c */ 742c8b75bcaSEric Anholt int vc4_debugfs_init(struct drm_minor *minor); 743*c9be804cSEric Anholt #ifdef CONFIG_DEBUG_FS 744*c9be804cSEric Anholt void vc4_debugfs_add_file(struct drm_device *drm, 745*c9be804cSEric Anholt const char *filename, 746*c9be804cSEric Anholt int (*show)(struct seq_file*, void*), 747*c9be804cSEric Anholt void *data); 748*c9be804cSEric Anholt void vc4_debugfs_add_regset32(struct drm_device *drm, 749*c9be804cSEric Anholt const char *filename, 750*c9be804cSEric Anholt struct debugfs_regset32 *regset); 751*c9be804cSEric Anholt #else 752*c9be804cSEric Anholt static inline void vc4_debugfs_add_file(struct drm_device *drm, 753*c9be804cSEric Anholt const char *filename, 754*c9be804cSEric Anholt int (*show)(struct seq_file*, void*), 755*c9be804cSEric Anholt void *data) 756*c9be804cSEric Anholt { 757*c9be804cSEric Anholt } 758*c9be804cSEric Anholt 759*c9be804cSEric Anholt static inline void vc4_debugfs_add_regset32(struct drm_device *drm, 760*c9be804cSEric Anholt const char *filename, 761*c9be804cSEric Anholt struct debugfs_regset32 *regset) 762*c9be804cSEric Anholt { 763*c9be804cSEric Anholt } 764*c9be804cSEric Anholt #endif 765c8b75bcaSEric Anholt 766c8b75bcaSEric Anholt /* vc4_drv.c */ 767c8b75bcaSEric Anholt void __iomem *vc4_ioremap_regs(struct platform_device *dev, int index); 768c8b75bcaSEric Anholt 76908302c35SEric Anholt /* vc4_dpi.c */ 77008302c35SEric Anholt extern struct platform_driver vc4_dpi_driver; 77108302c35SEric Anholt 7724078f575SEric Anholt /* vc4_dsi.c */ 7734078f575SEric Anholt extern struct platform_driver vc4_dsi_driver; 7744078f575SEric Anholt 775cdec4d36SEric Anholt /* vc4_fence.c */ 776cdec4d36SEric Anholt extern const struct dma_fence_ops vc4_fence_ops; 777cdec4d36SEric Anholt 778d5b1a78aSEric Anholt /* vc4_gem.c */ 779d5b1a78aSEric Anholt void vc4_gem_init(struct drm_device *dev); 780d5b1a78aSEric Anholt void vc4_gem_destroy(struct drm_device *dev); 781d5b1a78aSEric Anholt int vc4_submit_cl_ioctl(struct drm_device *dev, void *data, 782d5b1a78aSEric Anholt struct drm_file *file_priv); 783d5b1a78aSEric Anholt int vc4_wait_seqno_ioctl(struct drm_device *dev, void *data, 784d5b1a78aSEric Anholt struct drm_file *file_priv); 785d5b1a78aSEric Anholt int vc4_wait_bo_ioctl(struct drm_device *dev, void *data, 786d5b1a78aSEric Anholt struct drm_file *file_priv); 787ca26d28bSVarad Gautam void vc4_submit_next_bin_job(struct drm_device *dev); 788ca26d28bSVarad Gautam void vc4_submit_next_render_job(struct drm_device *dev); 789ca26d28bSVarad Gautam void vc4_move_job_to_render(struct drm_device *dev, struct vc4_exec_info *exec); 790d5b1a78aSEric Anholt int vc4_wait_for_seqno(struct drm_device *dev, uint64_t seqno, 791d5b1a78aSEric Anholt uint64_t timeout_ns, bool interruptible); 792d5b1a78aSEric Anholt void vc4_job_handle_completed(struct vc4_dev *vc4); 793b501baccSEric Anholt int vc4_queue_seqno_cb(struct drm_device *dev, 794b501baccSEric Anholt struct vc4_seqno_cb *cb, uint64_t seqno, 795b501baccSEric Anholt void (*func)(struct vc4_seqno_cb *cb)); 796b9f19259SBoris Brezillon int vc4_gem_madvise_ioctl(struct drm_device *dev, void *data, 797b9f19259SBoris Brezillon struct drm_file *file_priv); 798d5b1a78aSEric Anholt 799c8b75bcaSEric Anholt /* vc4_hdmi.c */ 800c8b75bcaSEric Anholt extern struct platform_driver vc4_hdmi_driver; 801c8b75bcaSEric Anholt 8029a8d5e4aSBoris Brezillon /* vc4_vec.c */ 803e4b81f8cSBoris Brezillon extern struct platform_driver vc4_vec_driver; 804e4b81f8cSBoris Brezillon 805008095e0SBoris Brezillon /* vc4_txp.c */ 806008095e0SBoris Brezillon extern struct platform_driver vc4_txp_driver; 807008095e0SBoris Brezillon 808d5b1a78aSEric Anholt /* vc4_irq.c */ 809d5b1a78aSEric Anholt irqreturn_t vc4_irq(int irq, void *arg); 810d5b1a78aSEric Anholt void vc4_irq_preinstall(struct drm_device *dev); 811d5b1a78aSEric Anholt int vc4_irq_postinstall(struct drm_device *dev); 812d5b1a78aSEric Anholt void vc4_irq_uninstall(struct drm_device *dev); 813d5b1a78aSEric Anholt void vc4_irq_reset(struct drm_device *dev); 814d5b1a78aSEric Anholt 815c8b75bcaSEric Anholt /* vc4_hvs.c */ 816c8b75bcaSEric Anholt extern struct platform_driver vc4_hvs_driver; 817c8b75bcaSEric Anholt void vc4_hvs_dump_state(struct drm_device *dev); 818531a1b62SBoris Brezillon void vc4_hvs_unmask_underrun(struct drm_device *dev, int channel); 819531a1b62SBoris Brezillon void vc4_hvs_mask_underrun(struct drm_device *dev, int channel); 820c8b75bcaSEric Anholt 821c8b75bcaSEric Anholt /* vc4_kms.c */ 822c8b75bcaSEric Anholt int vc4_kms_load(struct drm_device *dev); 823c8b75bcaSEric Anholt 824c8b75bcaSEric Anholt /* vc4_plane.c */ 825c8b75bcaSEric Anholt struct drm_plane *vc4_plane_init(struct drm_device *dev, 826c8b75bcaSEric Anholt enum drm_plane_type type); 827c8b75bcaSEric Anholt u32 vc4_plane_write_dlist(struct drm_plane *plane, u32 __iomem *dlist); 8282f196b7cSDaniel Vetter u32 vc4_plane_dlist_size(const struct drm_plane_state *state); 829b501baccSEric Anholt void vc4_plane_async_set_fb(struct drm_plane *plane, 830b501baccSEric Anholt struct drm_framebuffer *fb); 831463873d5SEric Anholt 832d3f5168aSEric Anholt /* vc4_v3d.c */ 833d3f5168aSEric Anholt extern struct platform_driver vc4_v3d_driver; 834553c942fSEric Anholt int vc4_v3d_get_bin_slot(struct vc4_dev *vc4); 835cb74f6eeSEric Anholt int vc4_v3d_pm_get(struct vc4_dev *vc4); 836cb74f6eeSEric Anholt void vc4_v3d_pm_put(struct vc4_dev *vc4); 837d5b1a78aSEric Anholt 838d5b1a78aSEric Anholt /* vc4_validate.c */ 839d5b1a78aSEric Anholt int 840d5b1a78aSEric Anholt vc4_validate_bin_cl(struct drm_device *dev, 841d5b1a78aSEric Anholt void *validated, 842d5b1a78aSEric Anholt void *unvalidated, 843d5b1a78aSEric Anholt struct vc4_exec_info *exec); 844d5b1a78aSEric Anholt 845d5b1a78aSEric Anholt int 846d5b1a78aSEric Anholt vc4_validate_shader_recs(struct drm_device *dev, struct vc4_exec_info *exec); 847d5b1a78aSEric Anholt 848d5b1a78aSEric Anholt struct drm_gem_cma_object *vc4_use_bo(struct vc4_exec_info *exec, 849d5b1a78aSEric Anholt uint32_t hindex); 850d5b1a78aSEric Anholt 851d5b1a78aSEric Anholt int vc4_get_rcl(struct drm_device *dev, struct vc4_exec_info *exec); 852d5b1a78aSEric Anholt 853d5b1a78aSEric Anholt bool vc4_check_tex_size(struct vc4_exec_info *exec, 854d5b1a78aSEric Anholt struct drm_gem_cma_object *fbo, 855d5b1a78aSEric Anholt uint32_t offset, uint8_t tiling_format, 856d5b1a78aSEric Anholt uint32_t width, uint32_t height, uint8_t cpp); 857d3f5168aSEric Anholt 858463873d5SEric Anholt /* vc4_validate_shader.c */ 859463873d5SEric Anholt struct vc4_validated_shader_info * 860463873d5SEric Anholt vc4_validate_shader(struct drm_gem_cma_object *shader_obj); 86165101d8cSBoris Brezillon 86265101d8cSBoris Brezillon /* vc4_perfmon.c */ 86365101d8cSBoris Brezillon void vc4_perfmon_get(struct vc4_perfmon *perfmon); 86465101d8cSBoris Brezillon void vc4_perfmon_put(struct vc4_perfmon *perfmon); 86565101d8cSBoris Brezillon void vc4_perfmon_start(struct vc4_dev *vc4, struct vc4_perfmon *perfmon); 86665101d8cSBoris Brezillon void vc4_perfmon_stop(struct vc4_dev *vc4, struct vc4_perfmon *perfmon, 86765101d8cSBoris Brezillon bool capture); 86865101d8cSBoris Brezillon struct vc4_perfmon *vc4_perfmon_find(struct vc4_file *vc4file, int id); 86965101d8cSBoris Brezillon void vc4_perfmon_open_file(struct vc4_file *vc4file); 87065101d8cSBoris Brezillon void vc4_perfmon_close_file(struct vc4_file *vc4file); 87165101d8cSBoris Brezillon int vc4_perfmon_create_ioctl(struct drm_device *dev, void *data, 87265101d8cSBoris Brezillon struct drm_file *file_priv); 87365101d8cSBoris Brezillon int vc4_perfmon_destroy_ioctl(struct drm_device *dev, void *data, 87465101d8cSBoris Brezillon struct drm_file *file_priv); 87565101d8cSBoris Brezillon int vc4_perfmon_get_values_ioctl(struct drm_device *dev, void *data, 87665101d8cSBoris Brezillon struct drm_file *file_priv); 877