aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm/drmP.h
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2008-07-30 15:06:12 -0400
committerDave Airlie <airlied@linux.ie>2008-10-17 17:10:12 -0400
commit673a394b1e3b69be886ff24abfd6df97c52e8d08 (patch)
tree61ca8299333ab50ffc46cf328b20eb25133392ff /include/drm/drmP.h
parentd1d8c925b71dd6753bf438f9e14a9e5c5183bcc6 (diff)
drm: Add GEM ("graphics execution manager") to i915 driver.
GEM allows the creation of persistent buffer objects accessible by the graphics device through new ioctls for managing execution of commands on the device. The userland API is almost entirely driver-specific to ensure that any driver building on this model can easily map the interface to individual driver requirements. GEM is used by the 2d driver for managing its internal state allocations and will be used for pixmap storage to reduce memory consumption and enable zero-copy GLX_EXT_texture_from_pixmap, and in the 3d driver is used to enable GL_EXT_framebuffer_object and GL_ARB_pixel_buffer_object. Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'include/drm/drmP.h')
-rw-r--r--include/drm/drmP.h151
1 files changed, 151 insertions, 0 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index e79ce0781f0b..1469a1bd8821 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -104,6 +104,7 @@ struct drm_device;
104#define DRIVER_DMA_QUEUE 0x200 104#define DRIVER_DMA_QUEUE 0x200
105#define DRIVER_FB_DMA 0x400 105#define DRIVER_FB_DMA 0x400
106#define DRIVER_IRQ_VBL2 0x800 106#define DRIVER_IRQ_VBL2 0x800
107#define DRIVER_GEM 0x1000
107 108
108/***********************************************************************/ 109/***********************************************************************/
109/** \name Begin the DRM... */ 110/** \name Begin the DRM... */
@@ -387,6 +388,10 @@ struct drm_file {
387 struct drm_minor *minor; 388 struct drm_minor *minor;
388 int remove_auth_on_close; 389 int remove_auth_on_close;
389 unsigned long lock_count; 390 unsigned long lock_count;
391 /** Mapping of mm object handles to object pointers. */
392 struct idr object_idr;
393 /** Lock for synchronization of access to object_idr. */
394 spinlock_t table_lock;
390 struct file *filp; 395 struct file *filp;
391 void *driver_priv; 396 void *driver_priv;
392}; 397};
@@ -558,6 +563,56 @@ struct drm_ati_pcigart_info {
558}; 563};
559 564
560/** 565/**
566 * This structure defines the drm_mm memory object, which will be used by the
567 * DRM for its buffer objects.
568 */
569struct drm_gem_object {
570 /** Reference count of this object */
571 struct kref refcount;
572
573 /** Handle count of this object. Each handle also holds a reference */
574 struct kref handlecount;
575
576 /** Related drm device */
577 struct drm_device *dev;
578
579 /** File representing the shmem storage */
580 struct file *filp;
581
582 /**
583 * Size of the object, in bytes. Immutable over the object's
584 * lifetime.
585 */
586 size_t size;
587
588 /**
589 * Global name for this object, starts at 1. 0 means unnamed.
590 * Access is covered by the object_name_lock in the related drm_device
591 */
592 int name;
593
594 /**
595 * Memory domains. These monitor which caches contain read/write data
596 * related to the object. When transitioning from one set of domains
597 * to another, the driver is called to ensure that caches are suitably
598 * flushed and invalidated
599 */
600 uint32_t read_domains;
601 uint32_t write_domain;
602
603 /**
604 * While validating an exec operation, the
605 * new read/write domain values are computed here.
606 * They will be transferred to the above values
607 * at the point that any cache flushing occurs
608 */
609 uint32_t pending_read_domains;
610 uint32_t pending_write_domain;
611
612 void *driver_private;
613};
614
615/**
561 * DRM driver structure. This structure represent the common code for 616 * DRM driver structure. This structure represent the common code for
562 * a family of cards. There will one drm_device for each card present 617 * a family of cards. There will one drm_device for each card present
563 * in this family 618 * in this family
@@ -657,6 +712,18 @@ struct drm_driver {
657 void (*set_version) (struct drm_device *dev, 712 void (*set_version) (struct drm_device *dev,
658 struct drm_set_version *sv); 713 struct drm_set_version *sv);
659 714
715 int (*proc_init)(struct drm_minor *minor);
716 void (*proc_cleanup)(struct drm_minor *minor);
717
718 /**
719 * Driver-specific constructor for drm_gem_objects, to set up
720 * obj->driver_private.
721 *
722 * Returns 0 on success.
723 */
724 int (*gem_init_object) (struct drm_gem_object *obj);
725 void (*gem_free_object) (struct drm_gem_object *obj);
726
660 int major; 727 int major;
661 int minor; 728 int minor;
662 int patchlevel; 729 int patchlevel;
@@ -830,6 +897,22 @@ struct drm_device {
830 spinlock_t drw_lock; 897 spinlock_t drw_lock;
831 struct idr drw_idr; 898 struct idr drw_idr;
832 /*@} */ 899 /*@} */
900
901 /** \name GEM information */
902 /*@{ */
903 spinlock_t object_name_lock;
904 struct idr object_name_idr;
905 atomic_t object_count;
906 atomic_t object_memory;
907 atomic_t pin_count;
908 atomic_t pin_memory;
909 atomic_t gtt_count;
910 atomic_t gtt_memory;
911 uint32_t gtt_total;
912 uint32_t invalidate_domains; /* domains pending invalidation */
913 uint32_t flush_domains; /* domains pending flush */
914 /*@} */
915
833}; 916};
834 917
835static __inline__ int drm_core_check_feature(struct drm_device *dev, 918static __inline__ int drm_core_check_feature(struct drm_device *dev,
@@ -926,6 +1009,10 @@ extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area);
926extern DRM_AGP_MEM *drm_alloc_agp(struct drm_device *dev, int pages, u32 type); 1009extern DRM_AGP_MEM *drm_alloc_agp(struct drm_device *dev, int pages, u32 type);
927extern int drm_free_agp(DRM_AGP_MEM * handle, int pages); 1010extern int drm_free_agp(DRM_AGP_MEM * handle, int pages);
928extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start); 1011extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start);
1012extern DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev,
1013 struct page **pages,
1014 unsigned long num_pages,
1015 uint32_t gtt_offset);
929extern int drm_unbind_agp(DRM_AGP_MEM * handle); 1016extern int drm_unbind_agp(DRM_AGP_MEM * handle);
930 1017
931 /* Misc. IOCTL support (drm_ioctl.h) */ 1018 /* Misc. IOCTL support (drm_ioctl.h) */
@@ -988,6 +1075,9 @@ extern int drm_getmagic(struct drm_device *dev, void *data,
988extern int drm_authmagic(struct drm_device *dev, void *data, 1075extern int drm_authmagic(struct drm_device *dev, void *data,
989 struct drm_file *file_priv); 1076 struct drm_file *file_priv);
990 1077
1078/* Cache management (drm_cache.c) */
1079void drm_clflush_pages(struct page *pages[], unsigned long num_pages);
1080
991 /* Locking IOCTL support (drm_lock.h) */ 1081 /* Locking IOCTL support (drm_lock.h) */
992extern int drm_lock(struct drm_device *dev, void *data, 1082extern int drm_lock(struct drm_device *dev, void *data,
993 struct drm_file *file_priv); 1083 struct drm_file *file_priv);
@@ -1094,6 +1184,7 @@ extern DRM_AGP_MEM *drm_agp_allocate_memory(struct agp_bridge_data *bridge, size
1094extern int drm_agp_free_memory(DRM_AGP_MEM * handle); 1184extern int drm_agp_free_memory(DRM_AGP_MEM * handle);
1095extern int drm_agp_bind_memory(DRM_AGP_MEM * handle, off_t start); 1185extern int drm_agp_bind_memory(DRM_AGP_MEM * handle, off_t start);
1096extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle); 1186extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle);
1187extern void drm_agp_chipset_flush(struct drm_device *dev);
1097 1188
1098 /* Stub support (drm_stub.h) */ 1189 /* Stub support (drm_stub.h) */
1099extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent, 1190extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
@@ -1156,6 +1247,66 @@ extern unsigned long drm_mm_tail_space(struct drm_mm *mm);
1156extern int drm_mm_remove_space_from_tail(struct drm_mm *mm, unsigned long size); 1247extern int drm_mm_remove_space_from_tail(struct drm_mm *mm, unsigned long size);
1157extern int drm_mm_add_space_to_tail(struct drm_mm *mm, unsigned long size); 1248extern int drm_mm_add_space_to_tail(struct drm_mm *mm, unsigned long size);
1158 1249
1250/* Graphics Execution Manager library functions (drm_gem.c) */
1251int drm_gem_init(struct drm_device *dev);
1252void drm_gem_object_free(struct kref *kref);
1253struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev,
1254 size_t size);
1255void drm_gem_object_handle_free(struct kref *kref);
1256
1257static inline void
1258drm_gem_object_reference(struct drm_gem_object *obj)
1259{
1260 kref_get(&obj->refcount);
1261}
1262
1263static inline void
1264drm_gem_object_unreference(struct drm_gem_object *obj)
1265{
1266 if (obj == NULL)
1267 return;
1268
1269 kref_put(&obj->refcount, drm_gem_object_free);
1270}
1271
1272int drm_gem_handle_create(struct drm_file *file_priv,
1273 struct drm_gem_object *obj,
1274 int *handlep);
1275
1276static inline void
1277drm_gem_object_handle_reference(struct drm_gem_object *obj)
1278{
1279 drm_gem_object_reference(obj);
1280 kref_get(&obj->handlecount);
1281}
1282
1283static inline void
1284drm_gem_object_handle_unreference(struct drm_gem_object *obj)
1285{
1286 if (obj == NULL)
1287 return;
1288
1289 /*
1290 * Must bump handle count first as this may be the last
1291 * ref, in which case the object would disappear before we
1292 * checked for a name
1293 */
1294 kref_put(&obj->handlecount, drm_gem_object_handle_free);
1295 drm_gem_object_unreference(obj);
1296}
1297
1298struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev,
1299 struct drm_file *filp,
1300 int handle);
1301int drm_gem_close_ioctl(struct drm_device *dev, void *data,
1302 struct drm_file *file_priv);
1303int drm_gem_flink_ioctl(struct drm_device *dev, void *data,
1304 struct drm_file *file_priv);
1305int drm_gem_open_ioctl(struct drm_device *dev, void *data,
1306 struct drm_file *file_priv);
1307void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
1308void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
1309
1159extern void drm_core_ioremap(struct drm_map *map, struct drm_device *dev); 1310extern void drm_core_ioremap(struct drm_map *map, struct drm_device *dev);
1160extern void drm_core_ioremap_wc(struct drm_map *map, struct drm_device *dev); 1311extern void drm_core_ioremap_wc(struct drm_map *map, struct drm_device *dev);
1161extern void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev); 1312extern void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev);