Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 170 lines 4.9 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2/* Copyright 2019 Linaro, Ltd, Rob Herring <robh@kernel.org> */ 3 4#ifndef __PANFROST_GEM_H__ 5#define __PANFROST_GEM_H__ 6 7#include <drm/drm_gem_shmem_helper.h> 8#include <drm/drm_mm.h> 9 10struct panfrost_mmu; 11struct panfrost_device; 12 13#define PANFROST_BO_LABEL_MAXLEN 4096 14 15enum panfrost_debugfs_gem_state_flags { 16 /** @PANFROST_DEBUGFS_GEM_STATE_FLAG_IMPORTED: GEM BO is PRIME imported. */ 17 PANFROST_DEBUGFS_GEM_STATE_FLAG_IMPORTED = BIT(0), 18 19 /** @PANFROST_DEBUGFS_GEM_STATE_FLAG_EXPORTED: GEM BO is PRIME exported. */ 20 PANFROST_DEBUGFS_GEM_STATE_FLAG_EXPORTED = BIT(1), 21 22 /** @PANFROST_DEBUGFS_GEM_STATE_FLAG_PURGED: GEM BO was reclaimed by the shrinker. */ 23 PANFROST_DEBUGFS_GEM_STATE_FLAG_PURGED = BIT(2), 24 25 /** 26 * @PANFROST_DEBUGFS_GEM_STATE_FLAG_PURGEABLE: GEM BO pages were marked as no longer 27 * needed by UM and can be reclaimed by the shrinker. 28 */ 29 PANFROST_DEBUGFS_GEM_STATE_FLAG_PURGEABLE = BIT(3), 30}; 31 32/** 33 * struct panfrost_gem_debugfs - GEM object's DebugFS list information 34 */ 35struct panfrost_gem_debugfs { 36 /** 37 * @node: Node used to insert the object in the device-wide list of 38 * GEM objects, to display information about it through a DebugFS file. 39 */ 40 struct list_head node; 41 42 /** @creator: Information about the UM process which created the GEM. */ 43 struct { 44 /** @creator.process_name: Group leader name in owning thread's process */ 45 char process_name[TASK_COMM_LEN]; 46 47 /** @creator.tgid: PID of the thread's group leader within its process */ 48 pid_t tgid; 49 } creator; 50}; 51 52struct panfrost_gem_object { 53 struct drm_gem_shmem_object base; 54 struct sg_table *sgts; 55 56 /* 57 * Use a list for now. If searching a mapping ever becomes the 58 * bottleneck, we should consider using an RB-tree, or even better, 59 * let the core store drm_gem_object_mapping entries (where we 60 * could place driver specific data) instead of drm_gem_object ones 61 * in its drm_file->object_idr table. 62 * 63 * struct drm_gem_object_mapping { 64 * struct drm_gem_object *obj; 65 * void *driver_priv; 66 * }; 67 */ 68 struct { 69 struct list_head list; 70 struct mutex lock; 71 } mappings; 72 73 /* 74 * Count the number of jobs referencing this BO so we don't let the 75 * shrinker reclaim this object prematurely. 76 */ 77 atomic_t gpu_usecount; 78 79 /* 80 * Object chunk size currently mapped onto physical memory 81 */ 82 size_t heap_rss_size; 83 84 /** 85 * @label: BO tagging fields. The label can be assigned within the 86 * driver itself or through a specific IOCTL. 87 */ 88 struct { 89 /** 90 * @label.str: Pointer to NULL-terminated string, 91 */ 92 const char *str; 93 94 /** @lock.str: Protects access to the @label.str field. */ 95 struct mutex lock; 96 } label; 97 98 bool noexec :1; 99 bool is_heap :1; 100 101 /* On coherent devices, this reflects the creation flags, not the true 102 * cacheability attribute of the mapping. 103 */ 104 bool wb_mmap :1; 105 106#ifdef CONFIG_DEBUG_FS 107 struct panfrost_gem_debugfs debugfs; 108#endif 109}; 110 111struct panfrost_gem_mapping { 112 struct list_head node; 113 struct kref refcount; 114 struct panfrost_gem_object *obj; 115 struct drm_mm_node mmnode; 116 struct panfrost_mmu *mmu; 117 bool active :1; 118}; 119 120static inline 121struct panfrost_gem_object *to_panfrost_bo(struct drm_gem_object *obj) 122{ 123 return container_of(to_drm_gem_shmem_obj(obj), struct panfrost_gem_object, base); 124} 125 126static inline struct panfrost_gem_mapping * 127drm_mm_node_to_panfrost_mapping(struct drm_mm_node *node) 128{ 129 return container_of(node, struct panfrost_gem_mapping, mmnode); 130} 131 132void panfrost_gem_init(struct panfrost_device *pfdev); 133 134struct drm_gem_object *panfrost_gem_create_object(struct drm_device *dev, size_t size); 135 136struct drm_gem_object * 137panfrost_gem_prime_import_sg_table(struct drm_device *dev, 138 struct dma_buf_attachment *attach, 139 struct sg_table *sgt); 140struct drm_gem_object * 141panfrost_gem_prime_import(struct drm_device *dev, 142 struct dma_buf *dma_buf); 143 144struct panfrost_gem_object * 145panfrost_gem_create(struct drm_device *dev, size_t size, u32 flags); 146 147int panfrost_gem_open(struct drm_gem_object *obj, struct drm_file *file_priv); 148void panfrost_gem_close(struct drm_gem_object *obj, 149 struct drm_file *file_priv); 150 151struct panfrost_gem_mapping * 152panfrost_gem_mapping_get(struct panfrost_gem_object *bo, 153 struct panfrost_file_priv *priv); 154void panfrost_gem_mapping_put(struct panfrost_gem_mapping *mapping); 155void panfrost_gem_teardown_mappings_locked(struct panfrost_gem_object *bo); 156 157int panfrost_gem_shrinker_init(struct drm_device *dev); 158void panfrost_gem_shrinker_cleanup(struct drm_device *dev); 159 160void panfrost_gem_set_label(struct drm_gem_object *obj, const char *label); 161int panfrost_gem_sync(struct drm_gem_object *obj, u32 type, 162 u32 offset, u32 size); 163void panfrost_gem_internal_set_label(struct drm_gem_object *obj, const char *label); 164 165#ifdef CONFIG_DEBUG_FS 166void panfrost_gem_debugfs_print_bos(struct panfrost_device *pfdev, 167 struct seq_file *m); 168#endif 169 170#endif /* __PANFROST_GEM_H__ */