diff options
author | Jesse Barnes <jbarnes@virtuousgeek.org> | 2008-11-05 13:31:53 -0500 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2008-12-29 02:47:22 -0500 |
commit | a2c0a97b784f837300f7b0869c82ab712c600952 (patch) | |
tree | aca1cdf3d32e1cfa7387350483f6a70c74a24ffd /include/drm | |
parent | a9587470f753d670d910293ecbf1c7b66c99de50 (diff) |
drm: GEM mmap support
Add core support for mapping of GEM objects. Drivers should provide a
vm_operations_struct if they want to support page faulting of objects.
The code for handling GEM object offsets was taken from TTM, which was
written by Thomas Hellström.
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'include/drm')
-rw-r--r-- | include/drm/drm.h | 1 | ||||
-rw-r--r-- | include/drm/drmP.h | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/include/drm/drm.h b/include/drm/drm.h index 3fb173c5af3e..3a66252456ba 100644 --- a/include/drm/drm.h +++ b/include/drm/drm.h | |||
@@ -173,6 +173,7 @@ enum drm_map_type { | |||
173 | _DRM_AGP = 3, /**< AGP/GART */ | 173 | _DRM_AGP = 3, /**< AGP/GART */ |
174 | _DRM_SCATTER_GATHER = 4, /**< Scatter/gather memory for PCI DMA */ | 174 | _DRM_SCATTER_GATHER = 4, /**< Scatter/gather memory for PCI DMA */ |
175 | _DRM_CONSISTENT = 5, /**< Consistent memory for PCI DMA */ | 175 | _DRM_CONSISTENT = 5, /**< Consistent memory for PCI DMA */ |
176 | _DRM_GEM = 6, /**< GEM object */ | ||
176 | }; | 177 | }; |
177 | 178 | ||
178 | /** | 179 | /** |
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index c9cc618dbcfc..ae42a6a5c24e 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h | |||
@@ -528,6 +528,7 @@ struct drm_map_list { | |||
528 | struct drm_map *map; /**< mapping */ | 528 | struct drm_map *map; /**< mapping */ |
529 | uint64_t user_token; | 529 | uint64_t user_token; |
530 | struct drm_master *master; | 530 | struct drm_master *master; |
531 | struct drm_mm_node *file_offset_node; /**< fake offset */ | ||
531 | }; | 532 | }; |
532 | 533 | ||
533 | typedef struct drm_map drm_local_map_t; | 534 | typedef struct drm_map drm_local_map_t; |
@@ -568,6 +569,14 @@ struct drm_ati_pcigart_info { | |||
568 | }; | 569 | }; |
569 | 570 | ||
570 | /** | 571 | /** |
572 | * GEM specific mm private for tracking GEM objects | ||
573 | */ | ||
574 | struct drm_gem_mm { | ||
575 | struct drm_mm offset_manager; /**< Offset mgmt for buffer objects */ | ||
576 | struct drm_open_hash offset_hash; /**< User token hash table for maps */ | ||
577 | }; | ||
578 | |||
579 | /** | ||
571 | * This structure defines the drm_mm memory object, which will be used by the | 580 | * This structure defines the drm_mm memory object, which will be used by the |
572 | * DRM for its buffer objects. | 581 | * DRM for its buffer objects. |
573 | */ | 582 | */ |
@@ -584,6 +593,9 @@ struct drm_gem_object { | |||
584 | /** File representing the shmem storage */ | 593 | /** File representing the shmem storage */ |
585 | struct file *filp; | 594 | struct file *filp; |
586 | 595 | ||
596 | /* Mapping info for this object */ | ||
597 | struct drm_map_list map_list; | ||
598 | |||
587 | /** | 599 | /** |
588 | * Size of the object, in bytes. Immutable over the object's | 600 | * Size of the object, in bytes. Immutable over the object's |
589 | * lifetime. | 601 | * lifetime. |
@@ -758,6 +770,9 @@ struct drm_driver { | |||
758 | int (*gem_init_object) (struct drm_gem_object *obj); | 770 | int (*gem_init_object) (struct drm_gem_object *obj); |
759 | void (*gem_free_object) (struct drm_gem_object *obj); | 771 | void (*gem_free_object) (struct drm_gem_object *obj); |
760 | 772 | ||
773 | /* Driver private ops for this object */ | ||
774 | struct vm_operations_struct *gem_vm_ops; | ||
775 | |||
761 | int major; | 776 | int major; |
762 | int minor; | 777 | int minor; |
763 | int patchlevel; | 778 | int patchlevel; |
@@ -910,6 +925,8 @@ struct drm_device { | |||
910 | struct drm_sg_mem *sg; /**< Scatter gather memory */ | 925 | struct drm_sg_mem *sg; /**< Scatter gather memory */ |
911 | int num_crtcs; /**< Number of CRTCs on this device */ | 926 | int num_crtcs; /**< Number of CRTCs on this device */ |
912 | void *dev_private; /**< device private data */ | 927 | void *dev_private; /**< device private data */ |
928 | void *mm_private; | ||
929 | struct address_space *dev_mapping; | ||
913 | struct drm_sigdata sigdata; /**< For block_all_signals */ | 930 | struct drm_sigdata sigdata; /**< For block_all_signals */ |
914 | sigset_t sigmask; | 931 | sigset_t sigmask; |
915 | 932 | ||
@@ -1026,6 +1043,8 @@ extern int drm_release(struct inode *inode, struct file *filp); | |||
1026 | 1043 | ||
1027 | /* Mapping support (drm_vm.h) */ | 1044 | /* Mapping support (drm_vm.h) */ |
1028 | extern int drm_mmap(struct file *filp, struct vm_area_struct *vma); | 1045 | extern int drm_mmap(struct file *filp, struct vm_area_struct *vma); |
1046 | extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma); | ||
1047 | extern void drm_vm_open_locked(struct vm_area_struct *vma); | ||
1029 | extern unsigned long drm_core_get_map_ofs(struct drm_map * map); | 1048 | extern unsigned long drm_core_get_map_ofs(struct drm_map * map); |
1030 | extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev); | 1049 | extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev); |
1031 | extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); | 1050 | extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); |
@@ -1287,10 +1306,12 @@ extern int drm_mm_add_space_to_tail(struct drm_mm *mm, unsigned long size); | |||
1287 | 1306 | ||
1288 | /* Graphics Execution Manager library functions (drm_gem.c) */ | 1307 | /* Graphics Execution Manager library functions (drm_gem.c) */ |
1289 | int drm_gem_init(struct drm_device *dev); | 1308 | int drm_gem_init(struct drm_device *dev); |
1309 | void drm_gem_destroy(struct drm_device *dev); | ||
1290 | void drm_gem_object_free(struct kref *kref); | 1310 | void drm_gem_object_free(struct kref *kref); |
1291 | struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev, | 1311 | struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev, |
1292 | size_t size); | 1312 | size_t size); |
1293 | void drm_gem_object_handle_free(struct kref *kref); | 1313 | void drm_gem_object_handle_free(struct kref *kref); |
1314 | int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); | ||
1294 | 1315 | ||
1295 | static inline void | 1316 | static inline void |
1296 | drm_gem_object_reference(struct drm_gem_object *obj) | 1317 | drm_gem_object_reference(struct drm_gem_object *obj) |