1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright 2019 Linaro, Ltd, Rob Herring <robh@kernel.org> */
4 #ifndef __PANFROST_GEM_H__
5 #define __PANFROST_GEM_H__
7 #include <drm/drm_gem_shmem_helper.h>
8 #include <drm/drm_mm.h>
12 struct panfrost_gem_object
{
13 struct drm_gem_shmem_object base
;
14 struct sg_table
*sgts
;
17 * Use a list for now. If searching a mapping ever becomes the
18 * bottleneck, we should consider using an RB-tree, or even better,
19 * let the core store drm_gem_object_mapping entries (where we
20 * could place driver specific data) instead of drm_gem_object ones
21 * in its drm_file->object_idr table.
23 * struct drm_gem_object_mapping {
24 * struct drm_gem_object *obj;
29 struct list_head list
;
37 struct panfrost_gem_mapping
{
38 struct list_head node
;
40 struct panfrost_gem_object
*obj
;
41 struct drm_mm_node mmnode
;
42 struct panfrost_mmu
*mmu
;
47 struct panfrost_gem_object
*to_panfrost_bo(struct drm_gem_object
*obj
)
49 return container_of(to_drm_gem_shmem_obj(obj
), struct panfrost_gem_object
, base
);
52 static inline struct panfrost_gem_mapping
*
53 drm_mm_node_to_panfrost_mapping(struct drm_mm_node
*node
)
55 return container_of(node
, struct panfrost_gem_mapping
, mmnode
);
58 struct drm_gem_object
*panfrost_gem_create_object(struct drm_device
*dev
, size_t size
);
60 struct drm_gem_object
*
61 panfrost_gem_prime_import_sg_table(struct drm_device
*dev
,
62 struct dma_buf_attachment
*attach
,
63 struct sg_table
*sgt
);
65 struct panfrost_gem_object
*
66 panfrost_gem_create_with_handle(struct drm_file
*file_priv
,
67 struct drm_device
*dev
, size_t size
,
71 int panfrost_gem_open(struct drm_gem_object
*obj
, struct drm_file
*file_priv
);
72 void panfrost_gem_close(struct drm_gem_object
*obj
,
73 struct drm_file
*file_priv
);
75 struct panfrost_gem_mapping
*
76 panfrost_gem_mapping_get(struct panfrost_gem_object
*bo
,
77 struct panfrost_file_priv
*priv
);
78 void panfrost_gem_mapping_put(struct panfrost_gem_mapping
*mapping
);
79 void panfrost_gem_teardown_mappings(struct panfrost_gem_object
*bo
);
81 void panfrost_gem_shrinker_init(struct drm_device
*dev
);
82 void panfrost_gem_shrinker_cleanup(struct drm_device
*dev
);
84 #endif /* __PANFROST_GEM_H__ */