1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2c8b75bcaSEric Anholt /* 3c8b75bcaSEric Anholt * Copyright (C) 2015 Broadcom 4c8b75bcaSEric Anholt */ 5c8b75bcaSEric Anholt 6fd6d6d80SSam Ravnborg #include <linux/delay.h> 7fd6d6d80SSam Ravnborg #include <linux/refcount.h> 8fd6d6d80SSam Ravnborg #include <linux/uaccess.h> 9fd6d6d80SSam Ravnborg 10fd6d6d80SSam Ravnborg #include <drm/drm_atomic.h> 11fd6d6d80SSam Ravnborg #include <drm/drm_debugfs.h> 12fd6d6d80SSam Ravnborg #include <drm/drm_device.h> 139338203cSLaurent Pinchart #include <drm/drm_encoder.h> 14b7e8e25bSMasahiro Yamada #include <drm/drm_gem_cma_helper.h> 15fd6d6d80SSam Ravnborg #include <drm/drm_mm.h> 16fd6d6d80SSam Ravnborg #include <drm/drm_modeset_lock.h> 179338203cSLaurent Pinchart 1865101d8cSBoris Brezillon #include "uapi/drm/vc4_drm.h" 1965101d8cSBoris Brezillon 20fd6d6d80SSam Ravnborg struct drm_device; 21fd6d6d80SSam Ravnborg struct drm_gem_object; 22fd6d6d80SSam Ravnborg 23f3099462SEric Anholt /* Don't forget to update vc4_bo.c: bo_type_names[] when adding to 24f3099462SEric Anholt * this. 25f3099462SEric Anholt */ 26f3099462SEric Anholt enum vc4_kernel_bo_type { 27f3099462SEric Anholt /* Any kernel allocation (gem_create_object hook) before it 28f3099462SEric Anholt * gets another type set. 29f3099462SEric Anholt */ 30f3099462SEric Anholt VC4_BO_TYPE_KERNEL, 31f3099462SEric Anholt VC4_BO_TYPE_V3D, 32f3099462SEric Anholt VC4_BO_TYPE_V3D_SHADER, 33f3099462SEric Anholt VC4_BO_TYPE_DUMB, 34f3099462SEric Anholt VC4_BO_TYPE_BIN, 35f3099462SEric Anholt VC4_BO_TYPE_RCL, 36f3099462SEric Anholt VC4_BO_TYPE_BCL, 37f3099462SEric Anholt VC4_BO_TYPE_KERNEL_CACHE, 38f3099462SEric Anholt VC4_BO_TYPE_COUNT 39f3099462SEric Anholt }; 40f3099462SEric Anholt 4165101d8cSBoris Brezillon /* Performance monitor object. The perform lifetime is controlled by userspace 4265101d8cSBoris Brezillon * using perfmon related ioctls. A perfmon can be attached to a submit_cl 4365101d8cSBoris Brezillon * request, and when this is the case, HW perf counters will be activated just 4465101d8cSBoris Brezillon * before the submit_cl is submitted to the GPU and disabled when the job is 4565101d8cSBoris Brezillon * done. This way, only events related to a specific job will be counted. 4665101d8cSBoris Brezillon */ 4765101d8cSBoris Brezillon struct vc4_perfmon { 4865101d8cSBoris Brezillon /* Tracks the number of users of the perfmon, when this counter reaches 4965101d8cSBoris Brezillon * zero the perfmon is destroyed. 5065101d8cSBoris Brezillon */ 5165101d8cSBoris Brezillon refcount_t refcnt; 5265101d8cSBoris Brezillon 5365101d8cSBoris Brezillon /* Number of counters activated in this perfmon instance 5465101d8cSBoris Brezillon * (should be less than DRM_VC4_MAX_PERF_COUNTERS). 5565101d8cSBoris Brezillon */ 5665101d8cSBoris Brezillon u8 ncounters; 5765101d8cSBoris Brezillon 5865101d8cSBoris Brezillon /* Events counted by the HW perf counters. */ 5965101d8cSBoris Brezillon u8 events[DRM_VC4_MAX_PERF_COUNTERS]; 6065101d8cSBoris Brezillon 6165101d8cSBoris Brezillon /* Storage for counter values. Counters are incremented by the HW 6265101d8cSBoris Brezillon * perf counter values every time the perfmon is attached to a GPU job. 6365101d8cSBoris Brezillon * This way, perfmon users don't have to retrieve the results after 6465101d8cSBoris Brezillon * each job if they want to track events covering several submissions. 6565101d8cSBoris Brezillon * Note that counter values can't be reset, but you can fake a reset by 6665101d8cSBoris Brezillon * destroying the perfmon and creating a new one. 6765101d8cSBoris Brezillon */ 6865101d8cSBoris Brezillon u64 counters[0]; 6965101d8cSBoris Brezillon }; 7065101d8cSBoris Brezillon 71c8b75bcaSEric Anholt struct vc4_dev { 72c8b75bcaSEric Anholt struct drm_device *dev; 73c8b75bcaSEric Anholt 74c8b75bcaSEric Anholt struct vc4_hdmi *hdmi; 75c8b75bcaSEric Anholt struct vc4_hvs *hvs; 76d3f5168aSEric Anholt struct vc4_v3d *v3d; 7708302c35SEric Anholt struct vc4_dpi *dpi; 784078f575SEric Anholt struct vc4_dsi *dsi1; 79e4b81f8cSBoris Brezillon struct vc4_vec *vec; 80008095e0SBoris Brezillon struct vc4_txp *txp; 8148666d56SDerek Foreman 8221461365SEric Anholt struct vc4_hang_state *hang_state; 8321461365SEric Anholt 84c826a6e1SEric Anholt /* The kernel-space BO cache. Tracks buffers that have been 85c826a6e1SEric Anholt * unreferenced by all other users (refcounts of 0!) but not 86c826a6e1SEric Anholt * yet freed, so we can do cheap allocations. 87c826a6e1SEric Anholt */ 88c826a6e1SEric Anholt struct vc4_bo_cache { 89c826a6e1SEric Anholt /* Array of list heads for entries in the BO cache, 90c826a6e1SEric Anholt * based on number of pages, so we can do O(1) lookups 91c826a6e1SEric Anholt * in the cache when allocating. 92c826a6e1SEric Anholt */ 93c826a6e1SEric Anholt struct list_head *size_list; 94c826a6e1SEric Anholt uint32_t size_list_size; 95c826a6e1SEric Anholt 96c826a6e1SEric Anholt /* List of all BOs in the cache, ordered by age, so we 97c826a6e1SEric Anholt * can do O(1) lookups when trying to free old 98c826a6e1SEric Anholt * buffers. 99c826a6e1SEric Anholt */ 100c826a6e1SEric Anholt struct list_head time_list; 101c826a6e1SEric Anholt struct work_struct time_work; 102c826a6e1SEric Anholt struct timer_list time_timer; 103c826a6e1SEric Anholt } bo_cache; 104c826a6e1SEric Anholt 105f3099462SEric Anholt u32 num_labels; 106f3099462SEric Anholt struct vc4_label { 107f3099462SEric Anholt const char *name; 108c826a6e1SEric Anholt u32 num_allocated; 109c826a6e1SEric Anholt u32 size_allocated; 110f3099462SEric Anholt } *bo_labels; 111c826a6e1SEric Anholt 112f3099462SEric Anholt /* Protects bo_cache and bo_labels. */ 113c826a6e1SEric Anholt struct mutex bo_lock; 114d5b1a78aSEric Anholt 115b9f19259SBoris Brezillon /* Purgeable BO pool. All BOs in this pool can have their memory 116b9f19259SBoris Brezillon * reclaimed if the driver is unable to allocate new BOs. We also 117b9f19259SBoris Brezillon * keep stats related to the purge mechanism here. 118b9f19259SBoris Brezillon */ 119b9f19259SBoris Brezillon struct { 120b9f19259SBoris Brezillon struct list_head list; 121b9f19259SBoris Brezillon unsigned int num; 122b9f19259SBoris Brezillon size_t size; 123b9f19259SBoris Brezillon unsigned int purged_num; 124b9f19259SBoris Brezillon size_t purged_size; 125b9f19259SBoris Brezillon struct mutex lock; 126b9f19259SBoris Brezillon } purgeable; 127b9f19259SBoris Brezillon 128cdec4d36SEric Anholt uint64_t dma_fence_context; 129cdec4d36SEric Anholt 130ca26d28bSVarad Gautam /* Sequence number for the last job queued in bin_job_list. 131d5b1a78aSEric Anholt * Starts at 0 (no jobs emitted). 132d5b1a78aSEric Anholt */ 133d5b1a78aSEric Anholt uint64_t emit_seqno; 134d5b1a78aSEric Anholt 135d5b1a78aSEric Anholt /* Sequence number for the last completed job on the GPU. 136d5b1a78aSEric Anholt * Starts at 0 (no jobs completed). 137d5b1a78aSEric Anholt */ 138d5b1a78aSEric Anholt uint64_t finished_seqno; 139d5b1a78aSEric Anholt 140ca26d28bSVarad Gautam /* List of all struct vc4_exec_info for jobs to be executed in 141ca26d28bSVarad Gautam * the binner. The first job in the list is the one currently 142ca26d28bSVarad Gautam * programmed into ct0ca for execution. 143d5b1a78aSEric Anholt */ 144ca26d28bSVarad Gautam struct list_head bin_job_list; 145ca26d28bSVarad Gautam 146ca26d28bSVarad Gautam /* List of all struct vc4_exec_info for jobs that have 147ca26d28bSVarad Gautam * completed binning and are ready for rendering. The first 148ca26d28bSVarad Gautam * job in the list is the one currently programmed into ct1ca 149ca26d28bSVarad Gautam * for execution. 150ca26d28bSVarad Gautam */ 151ca26d28bSVarad Gautam struct list_head render_job_list; 152ca26d28bSVarad Gautam 153d5b1a78aSEric Anholt /* List of the finished vc4_exec_infos waiting to be freed by 154d5b1a78aSEric Anholt * job_done_work. 155d5b1a78aSEric Anholt */ 156d5b1a78aSEric Anholt struct list_head job_done_list; 157d5b1a78aSEric Anholt /* Spinlock used to synchronize the job_list and seqno 158d5b1a78aSEric Anholt * accesses between the IRQ handler and GEM ioctls. 159d5b1a78aSEric Anholt */ 160d5b1a78aSEric Anholt spinlock_t job_lock; 161d5b1a78aSEric Anholt wait_queue_head_t job_wait_queue; 162d5b1a78aSEric Anholt struct work_struct job_done_work; 163d5b1a78aSEric Anholt 16465101d8cSBoris Brezillon /* Used to track the active perfmon if any. Access to this field is 16565101d8cSBoris Brezillon * protected by job_lock. 16665101d8cSBoris Brezillon */ 16765101d8cSBoris Brezillon struct vc4_perfmon *active_perfmon; 16865101d8cSBoris Brezillon 169b501baccSEric Anholt /* List of struct vc4_seqno_cb for callbacks to be made from a 170b501baccSEric Anholt * workqueue when the given seqno is passed. 171b501baccSEric Anholt */ 172b501baccSEric Anholt struct list_head seqno_cb_list; 173b501baccSEric Anholt 174553c942fSEric Anholt /* The memory used for storing binner tile alloc, tile state, 175553c942fSEric Anholt * and overflow memory allocations. This is freed when V3D 176553c942fSEric Anholt * powers down. 177d5b1a78aSEric Anholt */ 178553c942fSEric Anholt struct vc4_bo *bin_bo; 179553c942fSEric Anholt 180553c942fSEric Anholt /* Size of blocks allocated within bin_bo. */ 181553c942fSEric Anholt uint32_t bin_alloc_size; 182553c942fSEric Anholt 183553c942fSEric Anholt /* Bitmask of the bin_alloc_size chunks in bin_bo that are 184553c942fSEric Anholt * used. 185553c942fSEric Anholt */ 186553c942fSEric Anholt uint32_t bin_alloc_used; 187553c942fSEric Anholt 188553c942fSEric Anholt /* Bitmask of the current bin_alloc used for overflow memory. */ 189553c942fSEric Anholt uint32_t bin_alloc_overflow; 190553c942fSEric Anholt 191531a1b62SBoris Brezillon /* Incremented when an underrun error happened after an atomic commit. 192531a1b62SBoris Brezillon * This is particularly useful to detect when a specific modeset is too 193531a1b62SBoris Brezillon * demanding in term of memory or HVS bandwidth which is hard to guess 194531a1b62SBoris Brezillon * at atomic check time. 195531a1b62SBoris Brezillon */ 196531a1b62SBoris Brezillon atomic_t underrun; 197531a1b62SBoris Brezillon 198d5b1a78aSEric Anholt struct work_struct overflow_mem_work; 199d5b1a78aSEric Anholt 20036cb6253SEric Anholt int power_refcount; 20136cb6253SEric Anholt 2026b5c029dSPaul Kocialkowski /* Set to true when the load tracker is active. */ 2036b5c029dSPaul Kocialkowski bool load_tracker_enabled; 2046b5c029dSPaul Kocialkowski 20536cb6253SEric Anholt /* Mutex controlling the power refcount. */ 20636cb6253SEric Anholt struct mutex power_lock; 20736cb6253SEric Anholt 208d5b1a78aSEric Anholt struct { 209d5b1a78aSEric Anholt struct timer_list timer; 210d5b1a78aSEric Anholt struct work_struct reset_work; 211d5b1a78aSEric Anholt } hangcheck; 212d5b1a78aSEric Anholt 213d5b1a78aSEric Anholt struct semaphore async_modeset; 214766cc6b1SStefan Schake 215766cc6b1SStefan Schake struct drm_modeset_lock ctm_state_lock; 216766cc6b1SStefan Schake struct drm_private_obj ctm_manager; 2174686da83SBoris Brezillon struct drm_private_obj load_tracker; 218c9be804cSEric Anholt 219c9be804cSEric Anholt /* List of vc4_debugfs_info_entry for adding to debugfs once 220c9be804cSEric Anholt * the minor is available (after drm_dev_register()). 221c9be804cSEric Anholt */ 222c9be804cSEric Anholt struct list_head debugfs_list; 22335c8b4b2SPaul Kocialkowski 22435c8b4b2SPaul Kocialkowski /* Mutex for binner bo allocation. */ 22535c8b4b2SPaul Kocialkowski struct mutex bin_bo_lock; 22635c8b4b2SPaul Kocialkowski /* Reference count for our binner bo. */ 22735c8b4b2SPaul Kocialkowski struct kref bin_bo_kref; 228c8b75bcaSEric Anholt }; 229c8b75bcaSEric Anholt 230c8b75bcaSEric Anholt static inline struct vc4_dev * 231c8b75bcaSEric Anholt to_vc4_dev(struct drm_device *dev) 232c8b75bcaSEric Anholt { 233c8b75bcaSEric Anholt return (struct vc4_dev *)dev->dev_private; 234c8b75bcaSEric Anholt } 235c8b75bcaSEric Anholt 236c8b75bcaSEric Anholt struct vc4_bo { 237c8b75bcaSEric Anholt struct drm_gem_cma_object base; 238c826a6e1SEric Anholt 2397edabee0SEric Anholt /* seqno of the last job to render using this BO. */ 240d5b1a78aSEric Anholt uint64_t seqno; 241d5b1a78aSEric Anholt 2427edabee0SEric Anholt /* seqno of the last job to use the RCL to write to this BO. 2437edabee0SEric Anholt * 2447edabee0SEric Anholt * Note that this doesn't include binner overflow memory 2457edabee0SEric Anholt * writes. 2467edabee0SEric Anholt */ 2477edabee0SEric Anholt uint64_t write_seqno; 2487edabee0SEric Anholt 24983753117SEric Anholt bool t_format; 25083753117SEric Anholt 251c826a6e1SEric Anholt /* List entry for the BO's position in either 252c826a6e1SEric Anholt * vc4_exec_info->unref_list or vc4_dev->bo_cache.time_list 253c826a6e1SEric Anholt */ 254c826a6e1SEric Anholt struct list_head unref_head; 255c826a6e1SEric Anholt 256c826a6e1SEric Anholt /* Time in jiffies when the BO was put in vc4->bo_cache. */ 257c826a6e1SEric Anholt unsigned long free_time; 258c826a6e1SEric Anholt 259c826a6e1SEric Anholt /* List entry for the BO's position in vc4_dev->bo_cache.size_list */ 260c826a6e1SEric Anholt struct list_head size_head; 261463873d5SEric Anholt 262463873d5SEric Anholt /* Struct for shader validation state, if created by 263463873d5SEric Anholt * DRM_IOCTL_VC4_CREATE_SHADER_BO. 264463873d5SEric Anholt */ 265463873d5SEric Anholt struct vc4_validated_shader_info *validated_shader; 266cdec4d36SEric Anholt 267f3099462SEric Anholt /* One of enum vc4_kernel_bo_type, or VC4_BO_TYPE_COUNT + i 268f3099462SEric Anholt * for user-allocated labels. 269f3099462SEric Anholt */ 270f3099462SEric Anholt int label; 271b9f19259SBoris Brezillon 272b9f19259SBoris Brezillon /* Count the number of active users. This is needed to determine 273b9f19259SBoris Brezillon * whether we can move the BO to the purgeable list or not (when the BO 274b9f19259SBoris Brezillon * is used by the GPU or the display engine we can't purge it). 275b9f19259SBoris Brezillon */ 276b9f19259SBoris Brezillon refcount_t usecnt; 277b9f19259SBoris Brezillon 278b9f19259SBoris Brezillon /* Store purgeable/purged state here */ 279b9f19259SBoris Brezillon u32 madv; 280b9f19259SBoris Brezillon struct mutex madv_lock; 281c8b75bcaSEric Anholt }; 282c8b75bcaSEric Anholt 283c8b75bcaSEric Anholt static inline struct vc4_bo * 284c8b75bcaSEric Anholt to_vc4_bo(struct drm_gem_object *bo) 285c8b75bcaSEric Anholt { 286c8b75bcaSEric Anholt return (struct vc4_bo *)bo; 287c8b75bcaSEric Anholt } 288c8b75bcaSEric Anholt 289cdec4d36SEric Anholt struct vc4_fence { 290cdec4d36SEric Anholt struct dma_fence base; 291cdec4d36SEric Anholt struct drm_device *dev; 292cdec4d36SEric Anholt /* vc4 seqno for signaled() test */ 293cdec4d36SEric Anholt uint64_t seqno; 294cdec4d36SEric Anholt }; 295cdec4d36SEric Anholt 296cdec4d36SEric Anholt static inline struct vc4_fence * 297cdec4d36SEric Anholt to_vc4_fence(struct dma_fence *fence) 298cdec4d36SEric Anholt { 299cdec4d36SEric Anholt return (struct vc4_fence *)fence; 300cdec4d36SEric Anholt } 301cdec4d36SEric Anholt 302b501baccSEric Anholt struct vc4_seqno_cb { 303b501baccSEric Anholt struct work_struct work; 304b501baccSEric Anholt uint64_t seqno; 305b501baccSEric Anholt void (*func)(struct vc4_seqno_cb *cb); 306b501baccSEric Anholt }; 307b501baccSEric Anholt 308d3f5168aSEric Anholt struct vc4_v3d { 309001bdb55SEric Anholt struct vc4_dev *vc4; 310d3f5168aSEric Anholt struct platform_device *pdev; 311d3f5168aSEric Anholt void __iomem *regs; 312b72a2816SEric Anholt struct clk *clk; 3133051719aSEric Anholt struct debugfs_regset32 regset; 314d3f5168aSEric Anholt }; 315d3f5168aSEric Anholt 316c8b75bcaSEric Anholt struct vc4_hvs { 317c8b75bcaSEric Anholt struct platform_device *pdev; 318c8b75bcaSEric Anholt void __iomem *regs; 319d8dbf44fSEric Anholt u32 __iomem *dlist; 320d8dbf44fSEric Anholt 321d8dbf44fSEric Anholt /* Memory manager for CRTCs to allocate space in the display 322d8dbf44fSEric Anholt * list. Units are dwords. 323d8dbf44fSEric Anholt */ 324d8dbf44fSEric Anholt struct drm_mm dlist_mm; 32521af94cfSEric Anholt /* Memory manager for the LBM memory used by HVS scaling. */ 32621af94cfSEric Anholt struct drm_mm lbm_mm; 327d8dbf44fSEric Anholt spinlock_t mm_lock; 32821af94cfSEric Anholt 32921af94cfSEric Anholt struct drm_mm_node mitchell_netravali_filter; 3303051719aSEric Anholt struct debugfs_regset32 regset; 331c8b75bcaSEric Anholt }; 332c8b75bcaSEric Anholt 333c8b75bcaSEric Anholt struct vc4_plane { 334c8b75bcaSEric Anholt struct drm_plane base; 335c8b75bcaSEric Anholt }; 336c8b75bcaSEric Anholt 337c8b75bcaSEric Anholt static inline struct vc4_plane * 338c8b75bcaSEric Anholt to_vc4_plane(struct drm_plane *plane) 339c8b75bcaSEric Anholt { 340c8b75bcaSEric Anholt return (struct vc4_plane *)plane; 341c8b75bcaSEric Anholt } 342c8b75bcaSEric Anholt 34382364698SStefan Schake enum vc4_scaling_mode { 34482364698SStefan Schake VC4_SCALING_NONE, 34582364698SStefan Schake VC4_SCALING_TPZ, 34682364698SStefan Schake VC4_SCALING_PPF, 34782364698SStefan Schake }; 34882364698SStefan Schake 34982364698SStefan Schake struct vc4_plane_state { 35082364698SStefan Schake struct drm_plane_state base; 35182364698SStefan Schake /* System memory copy of the display list for this element, computed 35282364698SStefan Schake * at atomic_check time. 35382364698SStefan Schake */ 35482364698SStefan Schake u32 *dlist; 35582364698SStefan Schake u32 dlist_size; /* Number of dwords allocated for the display list */ 35682364698SStefan Schake u32 dlist_count; /* Number of used dwords in the display list. */ 35782364698SStefan Schake 35882364698SStefan Schake /* Offset in the dlist to various words, for pageflip or 35982364698SStefan Schake * cursor updates. 36082364698SStefan Schake */ 36182364698SStefan Schake u32 pos0_offset; 36282364698SStefan Schake u32 pos2_offset; 36382364698SStefan Schake u32 ptr0_offset; 3640a038c1cSBoris Brezillon u32 lbm_offset; 36582364698SStefan Schake 36682364698SStefan Schake /* Offset where the plane's dlist was last stored in the 36782364698SStefan Schake * hardware at vc4_crtc_atomic_flush() time. 36882364698SStefan Schake */ 36982364698SStefan Schake u32 __iomem *hw_dlist; 37082364698SStefan Schake 37182364698SStefan Schake /* Clipped coordinates of the plane on the display. */ 37282364698SStefan Schake int crtc_x, crtc_y, crtc_w, crtc_h; 37382364698SStefan Schake /* Clipped area being scanned from in the FB. */ 37482364698SStefan Schake u32 src_x, src_y; 37582364698SStefan Schake 37682364698SStefan Schake u32 src_w[2], src_h[2]; 37782364698SStefan Schake 37882364698SStefan Schake /* Scaling selection for the RGB/Y plane and the Cb/Cr planes. */ 37982364698SStefan Schake enum vc4_scaling_mode x_scaling[2], y_scaling[2]; 38082364698SStefan Schake bool is_unity; 38182364698SStefan Schake bool is_yuv; 38282364698SStefan Schake 38382364698SStefan Schake /* Offset to start scanning out from the start of the plane's 38482364698SStefan Schake * BO. 38582364698SStefan Schake */ 38682364698SStefan Schake u32 offsets[3]; 38782364698SStefan Schake 38882364698SStefan Schake /* Our allocation in LBM for temporary storage during scaling. */ 38982364698SStefan Schake struct drm_mm_node lbm; 39082364698SStefan Schake 39182364698SStefan Schake /* Set when the plane has per-pixel alpha content or does not cover 39282364698SStefan Schake * the entire screen. This is a hint to the CRTC that it might need 39382364698SStefan Schake * to enable background color fill. 39482364698SStefan Schake */ 39582364698SStefan Schake bool needs_bg_fill; 3968d938449SBoris Brezillon 3978d938449SBoris Brezillon /* Mark the dlist as initialized. Useful to avoid initializing it twice 3988d938449SBoris Brezillon * when async update is not possible. 3998d938449SBoris Brezillon */ 4008d938449SBoris Brezillon bool dlist_initialized; 4014686da83SBoris Brezillon 4024686da83SBoris Brezillon /* Load of this plane on the HVS block. The load is expressed in HVS 4034686da83SBoris Brezillon * cycles/sec. 4044686da83SBoris Brezillon */ 4054686da83SBoris Brezillon u64 hvs_load; 4064686da83SBoris Brezillon 4074686da83SBoris Brezillon /* Memory bandwidth needed for this plane. This is expressed in 4084686da83SBoris Brezillon * bytes/sec. 4094686da83SBoris Brezillon */ 4104686da83SBoris Brezillon u64 membus_load; 41182364698SStefan Schake }; 41282364698SStefan Schake 41382364698SStefan Schake static inline struct vc4_plane_state * 41482364698SStefan Schake to_vc4_plane_state(struct drm_plane_state *state) 41582364698SStefan Schake { 41682364698SStefan Schake return (struct vc4_plane_state *)state; 41782364698SStefan Schake } 41882364698SStefan Schake 419c8b75bcaSEric Anholt enum vc4_encoder_type { 420ab8df60eSBoris Brezillon VC4_ENCODER_TYPE_NONE, 421c8b75bcaSEric Anholt VC4_ENCODER_TYPE_HDMI, 422c8b75bcaSEric Anholt VC4_ENCODER_TYPE_VEC, 423c8b75bcaSEric Anholt VC4_ENCODER_TYPE_DSI0, 424c8b75bcaSEric Anholt VC4_ENCODER_TYPE_DSI1, 425c8b75bcaSEric Anholt VC4_ENCODER_TYPE_SMI, 426c8b75bcaSEric Anholt VC4_ENCODER_TYPE_DPI, 427c8b75bcaSEric Anholt }; 428c8b75bcaSEric Anholt 429c8b75bcaSEric Anholt struct vc4_encoder { 430c8b75bcaSEric Anholt struct drm_encoder base; 431c8b75bcaSEric Anholt enum vc4_encoder_type type; 432c8b75bcaSEric Anholt u32 clock_select; 433c8b75bcaSEric Anholt }; 434c8b75bcaSEric Anholt 435c8b75bcaSEric Anholt static inline struct vc4_encoder * 436c8b75bcaSEric Anholt to_vc4_encoder(struct drm_encoder *encoder) 437c8b75bcaSEric Anholt { 438c8b75bcaSEric Anholt return container_of(encoder, struct vc4_encoder, base); 439c8b75bcaSEric Anholt } 440c8b75bcaSEric Anholt 44179271807SStefan Schake struct vc4_crtc_data { 44279271807SStefan Schake /* Which channel of the HVS this pixelvalve sources from. */ 44379271807SStefan Schake int hvs_channel; 44479271807SStefan Schake 44579271807SStefan Schake enum vc4_encoder_type encoder_types[4]; 446c9be804cSEric Anholt const char *debugfs_name; 44779271807SStefan Schake }; 44879271807SStefan Schake 44979271807SStefan Schake struct vc4_crtc { 45079271807SStefan Schake struct drm_crtc base; 4513051719aSEric Anholt struct platform_device *pdev; 45279271807SStefan Schake const struct vc4_crtc_data *data; 45379271807SStefan Schake void __iomem *regs; 45479271807SStefan Schake 45579271807SStefan Schake /* Timestamp at start of vblank irq - unaffected by lock delays. */ 45679271807SStefan Schake ktime_t t_vblank; 45779271807SStefan Schake 45879271807SStefan Schake /* Which HVS channel we're using for our CRTC. */ 45979271807SStefan Schake int channel; 46079271807SStefan Schake 46179271807SStefan Schake u8 lut_r[256]; 46279271807SStefan Schake u8 lut_g[256]; 46379271807SStefan Schake u8 lut_b[256]; 46479271807SStefan Schake /* Size in pixels of the COB memory allocated to this CRTC. */ 46579271807SStefan Schake u32 cob_size; 46679271807SStefan Schake 46779271807SStefan Schake struct drm_pending_vblank_event *event; 4683051719aSEric Anholt 4693051719aSEric Anholt struct debugfs_regset32 regset; 47079271807SStefan Schake }; 47179271807SStefan Schake 47279271807SStefan Schake static inline struct vc4_crtc * 47379271807SStefan Schake to_vc4_crtc(struct drm_crtc *crtc) 47479271807SStefan Schake { 47579271807SStefan Schake return (struct vc4_crtc *)crtc; 47679271807SStefan Schake } 47779271807SStefan Schake 478d3f5168aSEric Anholt #define V3D_READ(offset) readl(vc4->v3d->regs + offset) 479d3f5168aSEric Anholt #define V3D_WRITE(offset, val) writel(val, vc4->v3d->regs + offset) 480c8b75bcaSEric Anholt #define HVS_READ(offset) readl(vc4->hvs->regs + offset) 481c8b75bcaSEric Anholt #define HVS_WRITE(offset, val) writel(val, vc4->hvs->regs + offset) 482c8b75bcaSEric Anholt 4833051719aSEric Anholt #define VC4_REG32(reg) { .name = #reg, .offset = reg } 4843051719aSEric Anholt 485d5b1a78aSEric Anholt struct vc4_exec_info { 486d5b1a78aSEric Anholt /* Sequence number for this bin/render job. */ 487d5b1a78aSEric Anholt uint64_t seqno; 488d5b1a78aSEric Anholt 4897edabee0SEric Anholt /* Latest write_seqno of any BO that binning depends on. */ 4907edabee0SEric Anholt uint64_t bin_dep_seqno; 4917edabee0SEric Anholt 492cdec4d36SEric Anholt struct dma_fence *fence; 493cdec4d36SEric Anholt 494c4ce60dcSEric Anholt /* Last current addresses the hardware was processing when the 495c4ce60dcSEric Anholt * hangcheck timer checked on us. 496c4ce60dcSEric Anholt */ 497c4ce60dcSEric Anholt uint32_t last_ct0ca, last_ct1ca; 498c4ce60dcSEric Anholt 499d5b1a78aSEric Anholt /* Kernel-space copy of the ioctl arguments */ 500d5b1a78aSEric Anholt struct drm_vc4_submit_cl *args; 501d5b1a78aSEric Anholt 502d5b1a78aSEric Anholt /* This is the array of BOs that were looked up at the start of exec. 503d5b1a78aSEric Anholt * Command validation will use indices into this array. 504d5b1a78aSEric Anholt */ 505d5b1a78aSEric Anholt struct drm_gem_cma_object **bo; 506d5b1a78aSEric Anholt uint32_t bo_count; 507d5b1a78aSEric Anholt 5087edabee0SEric Anholt /* List of BOs that are being written by the RCL. Other than 5097edabee0SEric Anholt * the binner temporary storage, this is all the BOs written 5107edabee0SEric Anholt * by the job. 5117edabee0SEric Anholt */ 5127edabee0SEric Anholt struct drm_gem_cma_object *rcl_write_bo[4]; 5137edabee0SEric Anholt uint32_t rcl_write_bo_count; 5147edabee0SEric Anholt 515d5b1a78aSEric Anholt /* Pointers for our position in vc4->job_list */ 516d5b1a78aSEric Anholt struct list_head head; 517d5b1a78aSEric Anholt 518d5b1a78aSEric Anholt /* List of other BOs used in the job that need to be released 519d5b1a78aSEric Anholt * once the job is complete. 520d5b1a78aSEric Anholt */ 521d5b1a78aSEric Anholt struct list_head unref_list; 522d5b1a78aSEric Anholt 523d5b1a78aSEric Anholt /* Current unvalidated indices into @bo loaded by the non-hardware 524d5b1a78aSEric Anholt * VC4_PACKET_GEM_HANDLES. 525d5b1a78aSEric Anholt */ 526d5b1a78aSEric Anholt uint32_t bo_index[2]; 527d5b1a78aSEric Anholt 528d5b1a78aSEric Anholt /* This is the BO where we store the validated command lists, shader 529d5b1a78aSEric Anholt * records, and uniforms. 530d5b1a78aSEric Anholt */ 531d5b1a78aSEric Anholt struct drm_gem_cma_object *exec_bo; 532d5b1a78aSEric Anholt 533d5b1a78aSEric Anholt /** 534d5b1a78aSEric Anholt * This tracks the per-shader-record state (packet 64) that 535d5b1a78aSEric Anholt * determines the length of the shader record and the offset 536d5b1a78aSEric Anholt * it's expected to be found at. It gets read in from the 537d5b1a78aSEric Anholt * command lists. 538d5b1a78aSEric Anholt */ 539d5b1a78aSEric Anholt struct vc4_shader_state { 540d5b1a78aSEric Anholt uint32_t addr; 541d5b1a78aSEric Anholt /* Maximum vertex index referenced by any primitive using this 542d5b1a78aSEric Anholt * shader state. 543d5b1a78aSEric Anholt */ 544d5b1a78aSEric Anholt uint32_t max_index; 545d5b1a78aSEric Anholt } *shader_state; 546d5b1a78aSEric Anholt 547d5b1a78aSEric Anholt /** How many shader states the user declared they were using. */ 548d5b1a78aSEric Anholt uint32_t shader_state_size; 549d5b1a78aSEric Anholt /** How many shader state records the validator has seen. */ 550d5b1a78aSEric Anholt uint32_t shader_state_count; 551d5b1a78aSEric Anholt 552d5b1a78aSEric Anholt bool found_tile_binning_mode_config_packet; 553d5b1a78aSEric Anholt bool found_start_tile_binning_packet; 554d5b1a78aSEric Anholt bool found_increment_semaphore_packet; 555d5b1a78aSEric Anholt bool found_flush; 556d5b1a78aSEric Anholt uint8_t bin_tiles_x, bin_tiles_y; 557553c942fSEric Anholt /* Physical address of the start of the tile alloc array 558553c942fSEric Anholt * (where each tile's binned CL will start) 559553c942fSEric Anholt */ 560d5b1a78aSEric Anholt uint32_t tile_alloc_offset; 561553c942fSEric Anholt /* Bitmask of which binner slots are freed when this job completes. */ 562553c942fSEric Anholt uint32_t bin_slots; 563d5b1a78aSEric Anholt 564d5b1a78aSEric Anholt /** 565d5b1a78aSEric Anholt * Computed addresses pointing into exec_bo where we start the 566d5b1a78aSEric Anholt * bin thread (ct0) and render thread (ct1). 567d5b1a78aSEric Anholt */ 568d5b1a78aSEric Anholt uint32_t ct0ca, ct0ea; 569d5b1a78aSEric Anholt uint32_t ct1ca, ct1ea; 570d5b1a78aSEric Anholt 571d5b1a78aSEric Anholt /* Pointer to the unvalidated bin CL (if present). */ 572d5b1a78aSEric Anholt void *bin_u; 573d5b1a78aSEric Anholt 574d5b1a78aSEric Anholt /* Pointers to the shader recs. These paddr gets incremented as CL 575d5b1a78aSEric Anholt * packets are relocated in validate_gl_shader_state, and the vaddrs 576d5b1a78aSEric Anholt * (u and v) get incremented and size decremented as the shader recs 577d5b1a78aSEric Anholt * themselves are validated. 578d5b1a78aSEric Anholt */ 579d5b1a78aSEric Anholt void *shader_rec_u; 580d5b1a78aSEric Anholt void *shader_rec_v; 581d5b1a78aSEric Anholt uint32_t shader_rec_p; 582d5b1a78aSEric Anholt uint32_t shader_rec_size; 583d5b1a78aSEric Anholt 584d5b1a78aSEric Anholt /* Pointers to the uniform data. These pointers are incremented, and 585d5b1a78aSEric Anholt * size decremented, as each batch of uniforms is uploaded. 586d5b1a78aSEric Anholt */ 587d5b1a78aSEric Anholt void *uniforms_u; 588d5b1a78aSEric Anholt void *uniforms_v; 589d5b1a78aSEric Anholt uint32_t uniforms_p; 590d5b1a78aSEric Anholt uint32_t uniforms_size; 59165101d8cSBoris Brezillon 59265101d8cSBoris Brezillon /* Pointer to a performance monitor object if the user requested it, 59365101d8cSBoris Brezillon * NULL otherwise. 59465101d8cSBoris Brezillon */ 59565101d8cSBoris Brezillon struct vc4_perfmon *perfmon; 59635c8b4b2SPaul Kocialkowski 59735c8b4b2SPaul Kocialkowski /* Whether the exec has taken a reference to the binner BO, which should 59835c8b4b2SPaul Kocialkowski * happen with a VC4_PACKET_TILE_BINNING_MODE_CONFIG packet. 59935c8b4b2SPaul Kocialkowski */ 60035c8b4b2SPaul Kocialkowski bool bin_bo_used; 60165101d8cSBoris Brezillon }; 60265101d8cSBoris Brezillon 60365101d8cSBoris Brezillon /* Per-open file private data. Any driver-specific resource that has to be 60465101d8cSBoris Brezillon * released when the DRM file is closed should be placed here. 60565101d8cSBoris Brezillon */ 60665101d8cSBoris Brezillon struct vc4_file { 60765101d8cSBoris Brezillon struct { 60865101d8cSBoris Brezillon struct idr idr; 60965101d8cSBoris Brezillon struct mutex lock; 61065101d8cSBoris Brezillon } perfmon; 61135c8b4b2SPaul Kocialkowski 61235c8b4b2SPaul Kocialkowski bool bin_bo_used; 613d5b1a78aSEric Anholt }; 614d5b1a78aSEric Anholt 615d5b1a78aSEric Anholt static inline struct vc4_exec_info * 616ca26d28bSVarad Gautam vc4_first_bin_job(struct vc4_dev *vc4) 617d5b1a78aSEric Anholt { 61857b9f569SMasahiro Yamada return list_first_entry_or_null(&vc4->bin_job_list, 61957b9f569SMasahiro Yamada struct vc4_exec_info, head); 620ca26d28bSVarad Gautam } 621ca26d28bSVarad Gautam 622ca26d28bSVarad Gautam static inline struct vc4_exec_info * 623ca26d28bSVarad Gautam vc4_first_render_job(struct vc4_dev *vc4) 624ca26d28bSVarad Gautam { 62557b9f569SMasahiro Yamada return list_first_entry_or_null(&vc4->render_job_list, 626ca26d28bSVarad Gautam struct vc4_exec_info, head); 627d5b1a78aSEric Anholt } 628d5b1a78aSEric Anholt 6299326e6f2SEric Anholt static inline struct vc4_exec_info * 6309326e6f2SEric Anholt vc4_last_render_job(struct vc4_dev *vc4) 6319326e6f2SEric Anholt { 6329326e6f2SEric Anholt if (list_empty(&vc4->render_job_list)) 6339326e6f2SEric Anholt return NULL; 6349326e6f2SEric Anholt return list_last_entry(&vc4->render_job_list, 6359326e6f2SEric Anholt struct vc4_exec_info, head); 6369326e6f2SEric Anholt } 6379326e6f2SEric Anholt 638c8b75bcaSEric Anholt /** 639463873d5SEric Anholt * struct vc4_texture_sample_info - saves the offsets into the UBO for texture 640463873d5SEric Anholt * setup parameters. 641463873d5SEric Anholt * 642463873d5SEric Anholt * This will be used at draw time to relocate the reference to the texture 643463873d5SEric Anholt * contents in p0, and validate that the offset combined with 644463873d5SEric Anholt * width/height/stride/etc. from p1 and p2/p3 doesn't sample outside the BO. 645463873d5SEric Anholt * Note that the hardware treats unprovided config parameters as 0, so not all 646463873d5SEric Anholt * of them need to be set up for every texure sample, and we'll store ~0 as 647463873d5SEric Anholt * the offset to mark the unused ones. 648463873d5SEric Anholt * 649463873d5SEric Anholt * See the VC4 3D architecture guide page 41 ("Texture and Memory Lookup Unit 650463873d5SEric Anholt * Setup") for definitions of the texture parameters. 651463873d5SEric Anholt */ 652463873d5SEric Anholt struct vc4_texture_sample_info { 653463873d5SEric Anholt bool is_direct; 654463873d5SEric Anholt uint32_t p_offset[4]; 655463873d5SEric Anholt }; 656463873d5SEric Anholt 657463873d5SEric Anholt /** 658463873d5SEric Anholt * struct vc4_validated_shader_info - information about validated shaders that 659463873d5SEric Anholt * needs to be used from command list validation. 660463873d5SEric Anholt * 661463873d5SEric Anholt * For a given shader, each time a shader state record references it, we need 662463873d5SEric Anholt * to verify that the shader doesn't read more uniforms than the shader state 663463873d5SEric Anholt * record's uniform BO pointer can provide, and we need to apply relocations 664463873d5SEric Anholt * and validate the shader state record's uniforms that define the texture 665463873d5SEric Anholt * samples. 666463873d5SEric Anholt */ 667463873d5SEric Anholt struct vc4_validated_shader_info { 668463873d5SEric Anholt uint32_t uniforms_size; 669463873d5SEric Anholt uint32_t uniforms_src_size; 670463873d5SEric Anholt uint32_t num_texture_samples; 671463873d5SEric Anholt struct vc4_texture_sample_info *texture_samples; 6726d45c81dSEric Anholt 6736d45c81dSEric Anholt uint32_t num_uniform_addr_offsets; 6746d45c81dSEric Anholt uint32_t *uniform_addr_offsets; 675c778cc5dSJonas Pfeil 676c778cc5dSJonas Pfeil bool is_threaded; 677463873d5SEric Anholt }; 678463873d5SEric Anholt 679463873d5SEric Anholt /** 680*7f2a09ecSJames Hughes * __wait_for - magic wait macro 681c8b75bcaSEric Anholt * 682*7f2a09ecSJames Hughes * Macro to help avoid open coding check/wait/timeout patterns. Note that it's 683*7f2a09ecSJames Hughes * important that we check the condition again after having timed out, since the 684*7f2a09ecSJames Hughes * timeout could be due to preemption or similar and we've never had a chance to 685*7f2a09ecSJames Hughes * check the condition before the timeout. 686c8b75bcaSEric Anholt */ 687*7f2a09ecSJames Hughes #define __wait_for(OP, COND, US, Wmin, Wmax) ({ \ 688*7f2a09ecSJames Hughes const ktime_t end__ = ktime_add_ns(ktime_get_raw(), 1000ll * (US)); \ 689*7f2a09ecSJames Hughes long wait__ = (Wmin); /* recommended min for usleep is 10 us */ \ 690*7f2a09ecSJames Hughes int ret__; \ 691*7f2a09ecSJames Hughes might_sleep(); \ 692*7f2a09ecSJames Hughes for (;;) { \ 693*7f2a09ecSJames Hughes const bool expired__ = ktime_after(ktime_get_raw(), end__); \ 694*7f2a09ecSJames Hughes OP; \ 695*7f2a09ecSJames Hughes /* Guarantee COND check prior to timeout */ \ 696*7f2a09ecSJames Hughes barrier(); \ 697*7f2a09ecSJames Hughes if (COND) { \ 698*7f2a09ecSJames Hughes ret__ = 0; \ 699*7f2a09ecSJames Hughes break; \ 700*7f2a09ecSJames Hughes } \ 701*7f2a09ecSJames Hughes if (expired__) { \ 702c8b75bcaSEric Anholt ret__ = -ETIMEDOUT; \ 703c8b75bcaSEric Anholt break; \ 704c8b75bcaSEric Anholt } \ 705*7f2a09ecSJames Hughes usleep_range(wait__, wait__ * 2); \ 706*7f2a09ecSJames Hughes if (wait__ < (Wmax)) \ 707*7f2a09ecSJames Hughes wait__ <<= 1; \ 708c8b75bcaSEric Anholt } \ 709c8b75bcaSEric Anholt ret__; \ 710c8b75bcaSEric Anholt }) 711c8b75bcaSEric Anholt 712*7f2a09ecSJames Hughes #define _wait_for(COND, US, Wmin, Wmax) __wait_for(, (COND), (US), (Wmin), \ 713*7f2a09ecSJames Hughes (Wmax)) 714*7f2a09ecSJames Hughes #define wait_for(COND, MS) _wait_for((COND), (MS) * 1000, 10, 1000) 715c8b75bcaSEric Anholt 716c8b75bcaSEric Anholt /* vc4_bo.c */ 717c826a6e1SEric Anholt struct drm_gem_object *vc4_create_object(struct drm_device *dev, size_t size); 718c8b75bcaSEric Anholt void vc4_free_object(struct drm_gem_object *gem_obj); 719c826a6e1SEric Anholt struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t size, 720f3099462SEric Anholt bool from_cache, enum vc4_kernel_bo_type type); 721c8b75bcaSEric Anholt int vc4_dumb_create(struct drm_file *file_priv, 722c8b75bcaSEric Anholt struct drm_device *dev, 723c8b75bcaSEric Anholt struct drm_mode_create_dumb *args); 724e4fa8457SDaniel Vetter struct dma_buf *vc4_prime_export(struct drm_gem_object *obj, int flags); 725d5bc60f6SEric Anholt int vc4_create_bo_ioctl(struct drm_device *dev, void *data, 726d5bc60f6SEric Anholt struct drm_file *file_priv); 727463873d5SEric Anholt int vc4_create_shader_bo_ioctl(struct drm_device *dev, void *data, 728463873d5SEric Anholt struct drm_file *file_priv); 729d5bc60f6SEric Anholt int vc4_mmap_bo_ioctl(struct drm_device *dev, void *data, 730d5bc60f6SEric Anholt struct drm_file *file_priv); 73183753117SEric Anholt int vc4_set_tiling_ioctl(struct drm_device *dev, void *data, 73283753117SEric Anholt struct drm_file *file_priv); 73383753117SEric Anholt int vc4_get_tiling_ioctl(struct drm_device *dev, void *data, 73483753117SEric Anholt struct drm_file *file_priv); 73521461365SEric Anholt int vc4_get_hang_state_ioctl(struct drm_device *dev, void *data, 73621461365SEric Anholt struct drm_file *file_priv); 737f3099462SEric Anholt int vc4_label_bo_ioctl(struct drm_device *dev, void *data, 738f3099462SEric Anholt struct drm_file *file_priv); 739abd7dbe9SSouptick Joarder vm_fault_t vc4_fault(struct vm_fault *vmf); 740463873d5SEric Anholt int vc4_mmap(struct file *filp, struct vm_area_struct *vma); 741463873d5SEric Anholt int vc4_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma); 742cdec4d36SEric Anholt struct drm_gem_object *vc4_prime_import_sg_table(struct drm_device *dev, 743cdec4d36SEric Anholt struct dma_buf_attachment *attach, 744cdec4d36SEric Anholt struct sg_table *sgt); 745463873d5SEric Anholt void *vc4_prime_vmap(struct drm_gem_object *obj); 746f3099462SEric Anholt int vc4_bo_cache_init(struct drm_device *dev); 747c826a6e1SEric Anholt void vc4_bo_cache_destroy(struct drm_device *dev); 748b9f19259SBoris Brezillon int vc4_bo_inc_usecnt(struct vc4_bo *bo); 749b9f19259SBoris Brezillon void vc4_bo_dec_usecnt(struct vc4_bo *bo); 750b9f19259SBoris Brezillon void vc4_bo_add_to_purgeable_pool(struct vc4_bo *bo); 751b9f19259SBoris Brezillon void vc4_bo_remove_from_purgeable_pool(struct vc4_bo *bo); 752c8b75bcaSEric Anholt 753c8b75bcaSEric Anholt /* vc4_crtc.c */ 754c8b75bcaSEric Anholt extern struct platform_driver vc4_crtc_driver; 755008095e0SBoris Brezillon void vc4_crtc_handle_vblank(struct vc4_crtc *crtc); 756008095e0SBoris Brezillon void vc4_crtc_txp_armed(struct drm_crtc_state *state); 757666e7358SBoris Brezillon void vc4_crtc_get_margins(struct drm_crtc_state *state, 758666e7358SBoris Brezillon unsigned int *right, unsigned int *left, 759666e7358SBoris Brezillon unsigned int *top, unsigned int *bottom); 760c8b75bcaSEric Anholt 761c8b75bcaSEric Anholt /* vc4_debugfs.c */ 762c8b75bcaSEric Anholt int vc4_debugfs_init(struct drm_minor *minor); 763c9be804cSEric Anholt #ifdef CONFIG_DEBUG_FS 764c9be804cSEric Anholt void vc4_debugfs_add_file(struct drm_device *drm, 765c9be804cSEric Anholt const char *filename, 766c9be804cSEric Anholt int (*show)(struct seq_file*, void*), 767c9be804cSEric Anholt void *data); 768c9be804cSEric Anholt void vc4_debugfs_add_regset32(struct drm_device *drm, 769c9be804cSEric Anholt const char *filename, 770c9be804cSEric Anholt struct debugfs_regset32 *regset); 771c9be804cSEric Anholt #else 772c9be804cSEric Anholt static inline void vc4_debugfs_add_file(struct drm_device *drm, 773c9be804cSEric Anholt const char *filename, 774c9be804cSEric Anholt int (*show)(struct seq_file*, void*), 775c9be804cSEric Anholt void *data) 776c9be804cSEric Anholt { 777c9be804cSEric Anholt } 778c9be804cSEric Anholt 779c9be804cSEric Anholt static inline void vc4_debugfs_add_regset32(struct drm_device *drm, 780c9be804cSEric Anholt const char *filename, 781c9be804cSEric Anholt struct debugfs_regset32 *regset) 782c9be804cSEric Anholt { 783c9be804cSEric Anholt } 784c9be804cSEric Anholt #endif 785c8b75bcaSEric Anholt 786c8b75bcaSEric Anholt /* vc4_drv.c */ 787c8b75bcaSEric Anholt void __iomem *vc4_ioremap_regs(struct platform_device *dev, int index); 788c8b75bcaSEric Anholt 78908302c35SEric Anholt /* vc4_dpi.c */ 79008302c35SEric Anholt extern struct platform_driver vc4_dpi_driver; 79108302c35SEric Anholt 7924078f575SEric Anholt /* vc4_dsi.c */ 7934078f575SEric Anholt extern struct platform_driver vc4_dsi_driver; 7944078f575SEric Anholt 795cdec4d36SEric Anholt /* vc4_fence.c */ 796cdec4d36SEric Anholt extern const struct dma_fence_ops vc4_fence_ops; 797cdec4d36SEric Anholt 798d5b1a78aSEric Anholt /* vc4_gem.c */ 799d5b1a78aSEric Anholt void vc4_gem_init(struct drm_device *dev); 800d5b1a78aSEric Anholt void vc4_gem_destroy(struct drm_device *dev); 801d5b1a78aSEric Anholt int vc4_submit_cl_ioctl(struct drm_device *dev, void *data, 802d5b1a78aSEric Anholt struct drm_file *file_priv); 803d5b1a78aSEric Anholt int vc4_wait_seqno_ioctl(struct drm_device *dev, void *data, 804d5b1a78aSEric Anholt struct drm_file *file_priv); 805d5b1a78aSEric Anholt int vc4_wait_bo_ioctl(struct drm_device *dev, void *data, 806d5b1a78aSEric Anholt struct drm_file *file_priv); 807ca26d28bSVarad Gautam void vc4_submit_next_bin_job(struct drm_device *dev); 808ca26d28bSVarad Gautam void vc4_submit_next_render_job(struct drm_device *dev); 809ca26d28bSVarad Gautam void vc4_move_job_to_render(struct drm_device *dev, struct vc4_exec_info *exec); 810d5b1a78aSEric Anholt int vc4_wait_for_seqno(struct drm_device *dev, uint64_t seqno, 811d5b1a78aSEric Anholt uint64_t timeout_ns, bool interruptible); 812d5b1a78aSEric Anholt void vc4_job_handle_completed(struct vc4_dev *vc4); 813b501baccSEric Anholt int vc4_queue_seqno_cb(struct drm_device *dev, 814b501baccSEric Anholt struct vc4_seqno_cb *cb, uint64_t seqno, 815b501baccSEric Anholt void (*func)(struct vc4_seqno_cb *cb)); 816b9f19259SBoris Brezillon int vc4_gem_madvise_ioctl(struct drm_device *dev, void *data, 817b9f19259SBoris Brezillon struct drm_file *file_priv); 818d5b1a78aSEric Anholt 819c8b75bcaSEric Anholt /* vc4_hdmi.c */ 820c8b75bcaSEric Anholt extern struct platform_driver vc4_hdmi_driver; 821c8b75bcaSEric Anholt 8229a8d5e4aSBoris Brezillon /* vc4_vec.c */ 823e4b81f8cSBoris Brezillon extern struct platform_driver vc4_vec_driver; 824e4b81f8cSBoris Brezillon 825008095e0SBoris Brezillon /* vc4_txp.c */ 826008095e0SBoris Brezillon extern struct platform_driver vc4_txp_driver; 827008095e0SBoris Brezillon 828d5b1a78aSEric Anholt /* vc4_irq.c */ 829d5b1a78aSEric Anholt irqreturn_t vc4_irq(int irq, void *arg); 830d5b1a78aSEric Anholt void vc4_irq_preinstall(struct drm_device *dev); 831d5b1a78aSEric Anholt int vc4_irq_postinstall(struct drm_device *dev); 832d5b1a78aSEric Anholt void vc4_irq_uninstall(struct drm_device *dev); 833d5b1a78aSEric Anholt void vc4_irq_reset(struct drm_device *dev); 834d5b1a78aSEric Anholt 835c8b75bcaSEric Anholt /* vc4_hvs.c */ 836c8b75bcaSEric Anholt extern struct platform_driver vc4_hvs_driver; 837c8b75bcaSEric Anholt void vc4_hvs_dump_state(struct drm_device *dev); 838531a1b62SBoris Brezillon void vc4_hvs_unmask_underrun(struct drm_device *dev, int channel); 839531a1b62SBoris Brezillon void vc4_hvs_mask_underrun(struct drm_device *dev, int channel); 840c8b75bcaSEric Anholt 841c8b75bcaSEric Anholt /* vc4_kms.c */ 842c8b75bcaSEric Anholt int vc4_kms_load(struct drm_device *dev); 843c8b75bcaSEric Anholt 844c8b75bcaSEric Anholt /* vc4_plane.c */ 845c8b75bcaSEric Anholt struct drm_plane *vc4_plane_init(struct drm_device *dev, 846c8b75bcaSEric Anholt enum drm_plane_type type); 847c8b75bcaSEric Anholt u32 vc4_plane_write_dlist(struct drm_plane *plane, u32 __iomem *dlist); 8482f196b7cSDaniel Vetter u32 vc4_plane_dlist_size(const struct drm_plane_state *state); 849b501baccSEric Anholt void vc4_plane_async_set_fb(struct drm_plane *plane, 850b501baccSEric Anholt struct drm_framebuffer *fb); 851463873d5SEric Anholt 852d3f5168aSEric Anholt /* vc4_v3d.c */ 853d3f5168aSEric Anholt extern struct platform_driver vc4_v3d_driver; 854ffc26740SEric Anholt extern const struct of_device_id vc4_v3d_dt_match[]; 855553c942fSEric Anholt int vc4_v3d_get_bin_slot(struct vc4_dev *vc4); 85635c8b4b2SPaul Kocialkowski int vc4_v3d_bin_bo_get(struct vc4_dev *vc4, bool *used); 85735c8b4b2SPaul Kocialkowski void vc4_v3d_bin_bo_put(struct vc4_dev *vc4); 858cb74f6eeSEric Anholt int vc4_v3d_pm_get(struct vc4_dev *vc4); 859cb74f6eeSEric Anholt void vc4_v3d_pm_put(struct vc4_dev *vc4); 860d5b1a78aSEric Anholt 861d5b1a78aSEric Anholt /* vc4_validate.c */ 862d5b1a78aSEric Anholt int 863d5b1a78aSEric Anholt vc4_validate_bin_cl(struct drm_device *dev, 864d5b1a78aSEric Anholt void *validated, 865d5b1a78aSEric Anholt void *unvalidated, 866d5b1a78aSEric Anholt struct vc4_exec_info *exec); 867d5b1a78aSEric Anholt 868d5b1a78aSEric Anholt int 869d5b1a78aSEric Anholt vc4_validate_shader_recs(struct drm_device *dev, struct vc4_exec_info *exec); 870d5b1a78aSEric Anholt 871d5b1a78aSEric Anholt struct drm_gem_cma_object *vc4_use_bo(struct vc4_exec_info *exec, 872d5b1a78aSEric Anholt uint32_t hindex); 873d5b1a78aSEric Anholt 874d5b1a78aSEric Anholt int vc4_get_rcl(struct drm_device *dev, struct vc4_exec_info *exec); 875d5b1a78aSEric Anholt 876d5b1a78aSEric Anholt bool vc4_check_tex_size(struct vc4_exec_info *exec, 877d5b1a78aSEric Anholt struct drm_gem_cma_object *fbo, 878d5b1a78aSEric Anholt uint32_t offset, uint8_t tiling_format, 879d5b1a78aSEric Anholt uint32_t width, uint32_t height, uint8_t cpp); 880d3f5168aSEric Anholt 881463873d5SEric Anholt /* vc4_validate_shader.c */ 882463873d5SEric Anholt struct vc4_validated_shader_info * 883463873d5SEric Anholt vc4_validate_shader(struct drm_gem_cma_object *shader_obj); 88465101d8cSBoris Brezillon 88565101d8cSBoris Brezillon /* vc4_perfmon.c */ 88665101d8cSBoris Brezillon void vc4_perfmon_get(struct vc4_perfmon *perfmon); 88765101d8cSBoris Brezillon void vc4_perfmon_put(struct vc4_perfmon *perfmon); 88865101d8cSBoris Brezillon void vc4_perfmon_start(struct vc4_dev *vc4, struct vc4_perfmon *perfmon); 88965101d8cSBoris Brezillon void vc4_perfmon_stop(struct vc4_dev *vc4, struct vc4_perfmon *perfmon, 89065101d8cSBoris Brezillon bool capture); 89165101d8cSBoris Brezillon struct vc4_perfmon *vc4_perfmon_find(struct vc4_file *vc4file, int id); 89265101d8cSBoris Brezillon void vc4_perfmon_open_file(struct vc4_file *vc4file); 89365101d8cSBoris Brezillon void vc4_perfmon_close_file(struct vc4_file *vc4file); 89465101d8cSBoris Brezillon int vc4_perfmon_create_ioctl(struct drm_device *dev, void *data, 89565101d8cSBoris Brezillon struct drm_file *file_priv); 89665101d8cSBoris Brezillon int vc4_perfmon_destroy_ioctl(struct drm_device *dev, void *data, 89765101d8cSBoris Brezillon struct drm_file *file_priv); 89865101d8cSBoris Brezillon int vc4_perfmon_get_values_ioctl(struct drm_device *dev, void *data, 89965101d8cSBoris Brezillon struct drm_file *file_priv); 900