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 10 struct panfrost_mmu; 11 12 struct panfrost_gem_object { 13 struct drm_gem_shmem_object base; 14 struct sg_table *sgts; 15 16 struct panfrost_mmu *mmu; 17 struct drm_mm_node node; 18 bool is_mapped :1; 19 bool noexec :1; 20 bool is_heap :1; 21 }; 22 23 static inline 24 struct panfrost_gem_object *to_panfrost_bo(struct drm_gem_object *obj) 25 { 26 return container_of(to_drm_gem_shmem_obj(obj), struct panfrost_gem_object, base); 27 } 28 29 static inline 30 struct panfrost_gem_object *drm_mm_node_to_panfrost_bo(struct drm_mm_node *node) 31 { 32 return container_of(node, struct panfrost_gem_object, node); 33 } 34 35 struct drm_gem_object *panfrost_gem_create_object(struct drm_device *dev, size_t size); 36 37 struct drm_gem_object * 38 panfrost_gem_prime_import_sg_table(struct drm_device *dev, 39 struct dma_buf_attachment *attach, 40 struct sg_table *sgt); 41 42 struct panfrost_gem_object * 43 panfrost_gem_create_with_handle(struct drm_file *file_priv, 44 struct drm_device *dev, size_t size, 45 u32 flags, 46 uint32_t *handle); 47 48 void panfrost_gem_shrinker_init(struct drm_device *dev); 49 void panfrost_gem_shrinker_cleanup(struct drm_device *dev); 50 51 #endif /* __PANFROST_GEM_H__ */ 52