drm/ttm: ttm_fault callback to allow driver to handle bo placement V6
[safe/jmp/linux-2.6] / include / drm / ttm / ttm_bo_api.h
index 99dc521..3e273e0 100644 (file)
@@ -44,6 +44,49 @@ struct ttm_bo_device;
 
 struct drm_mm_node;
 
+
+/**
+ * struct ttm_placement
+ *
+ * @fpfn:              first valid page frame number to put the object
+ * @lpfn:              last valid page frame number to put the object
+ * @num_placement:     number of prefered placements
+ * @placement:         prefered placements
+ * @num_busy_placement:        number of prefered placements when need to evict buffer
+ * @busy_placement:    prefered placements when need to evict buffer
+ *
+ * Structure indicating the placement you request for an object.
+ */
+struct ttm_placement {
+       unsigned        fpfn;
+       unsigned        lpfn;
+       unsigned        num_placement;
+       const uint32_t  *placement;
+       unsigned        num_busy_placement;
+       const uint32_t  *busy_placement;
+};
+
+/**
+ * struct ttm_bus_placement
+ *
+ * @addr:              mapped virtual address
+ * @base:              bus base address
+ * @is_iomem:          is this io memory ?
+ * @size:              size in byte
+ * @offset:            offset from the base address
+ *
+ * Structure indicating the bus placement of an object.
+ */
+struct ttm_bus_placement {
+       void            *addr;
+       unsigned long   base;
+       unsigned long   size;
+       unsigned long   offset;
+       bool            is_iomem;
+       bool            io_reserved;
+};
+
+
 /**
  * struct ttm_mem_reg
  *
@@ -52,6 +95,7 @@ struct drm_mm_node;
  * @num_pages: Actual size of memory region in pages.
  * @page_alignment: Page alignment.
  * @placement: Placement flags.
+ * @bus: Placement on io bus accessible to the CPU
  *
  * Structure indicating the placement and space resources used by a
  * buffer object.
@@ -64,6 +108,7 @@ struct ttm_mem_reg {
        uint32_t page_alignment;
        uint32_t mem_type;
        uint32_t placement;
+       struct ttm_bus_placement bus;
 };
 
 /**
@@ -109,10 +154,6 @@ struct ttm_tt;
  * the object is destroyed.
  * @event_queue: Queue for processes waiting on buffer object status change.
  * @lock: spinlock protecting mostly synchronization members.
- * @proposed_placement: Proposed placement for the buffer. Changed only by the
- * creator prior to validation as opposed to bo->mem.proposed_flags which is
- * changed by the implementation prior to a buffer move if it wants to outsmart
- * the buffer creator / user. This latter happens, for example, at eviction.
  * @mem: structure describing current placement.
  * @persistant_swap_storage: Usually the swap storage is deleted for buffers
  * pinned in physical memory. If this behaviour is not desired, this member
@@ -155,6 +196,7 @@ struct ttm_buffer_object {
         * Members constant at init.
         */
 
+       struct ttm_bo_global *glob;
        struct ttm_bo_device *bdev;
        unsigned long buffer_start;
        enum ttm_bo_type type;
@@ -176,7 +218,6 @@ struct ttm_buffer_object {
         * Members protected by the bo::reserved lock.
         */
 
-       uint32_t proposed_placement;
        struct ttm_mem_reg mem;
        struct file *persistant_swap_storage;
        struct ttm_tt *ttm;
@@ -255,6 +296,7 @@ struct ttm_bo_kmap_obj {
                ttm_bo_map_kmap         = 3,
                ttm_bo_map_premapped    = 4 | TTM_BO_MAP_IOMEM_MASK,
        } bo_kmap_type;
+       struct ttm_buffer_object *bo;
 };
 
 /**
@@ -284,29 +326,32 @@ ttm_bo_reference(struct ttm_buffer_object *bo)
  * Note: It might be necessary to block validations before the
  * wait by reserving the buffer.
  * Returns -EBUSY if no_wait is true and the buffer is busy.
- * Returns -ERESTART if interrupted by a signal.
+ * Returns -ERESTARTSYS if interrupted by a signal.
  */
 extern int ttm_bo_wait(struct ttm_buffer_object *bo, bool lazy,
                       bool interruptible, bool no_wait);
 /**
- * ttm_buffer_object_validate
+ * ttm_bo_validate
  *
  * @bo: The buffer object.
- * @proposed_placement: Proposed_placement for the buffer object.
+ * @placement: Proposed placement for the buffer object.
  * @interruptible: Sleep interruptible if sleeping.
- * @no_wait: Return immediately if the buffer is busy.
+ * @no_wait_reserve: Return immediately if other buffers are busy.
+ * @no_wait_gpu: Return immediately if the GPU is busy.
  *
  * Changes placement and caching policy of the buffer object
- * according to bo::proposed_flags.
+ * according proposed placement.
  * Returns
- * -EINVAL on invalid proposed_flags.
+ * -EINVAL on invalid proposed placement.
  * -ENOMEM on out-of-memory condition.
  * -EBUSY if no_wait is true and buffer busy.
- * -ERESTART if interrupted by a signal.
+ * -ERESTARTSYS if interrupted by a signal.
  */
-extern int ttm_buffer_object_validate(struct ttm_buffer_object *bo,
-                                     uint32_t proposed_placement,
-                                     bool interruptible, bool no_wait);
+extern int ttm_bo_validate(struct ttm_buffer_object *bo,
+                               struct ttm_placement *placement,
+                               bool interruptible, bool no_wait_reserve,
+                               bool no_wait_gpu);
+
 /**
  * ttm_bo_unref
  *
@@ -327,7 +372,7 @@ extern void ttm_bo_unref(struct ttm_buffer_object **bo);
  * waiting for buffer idle. This lock is recursive.
  * Returns
  * -EBUSY if the buffer is busy and no_wait is true.
- * -ERESTART if interrupted by a signal.
+ * -ERESTARTSYS if interrupted by a signal.
  */
 
 extern int
@@ -342,7 +387,7 @@ ttm_bo_synccpu_write_grab(struct ttm_buffer_object *bo, bool no_wait);
 extern void ttm_bo_synccpu_write_release(struct ttm_buffer_object *bo);
 
 /**
- * ttm_buffer_object_init
+ * ttm_bo_init
  *
  * @bdev: Pointer to a ttm_bo_device struct.
  * @bo: Pointer to a ttm_buffer_object to be initialized.
@@ -370,20 +415,20 @@ extern void ttm_bo_synccpu_write_release(struct ttm_buffer_object *bo);
  * Returns
  * -ENOMEM: Out of memory.
  * -EINVAL: Invalid placement flags.
- * -ERESTART: Interrupted by signal while sleeping waiting for resources.
+ * -ERESTARTSYS: Interrupted by signal while sleeping waiting for resources.
  */
 
-extern int ttm_buffer_object_init(struct ttm_bo_device *bdev,
-                                 struct ttm_buffer_object *bo,
-                                 unsigned long size,
-                                 enum ttm_bo_type type,
-                                 uint32_t flags,
-                                 uint32_t page_alignment,
-                                 unsigned long buffer_start,
-                                 bool interrubtible,
-                                 struct file *persistant_swap_storage,
-                                 size_t acc_size,
-                                 void (*destroy) (struct ttm_buffer_object *));
+extern int ttm_bo_init(struct ttm_bo_device *bdev,
+                       struct ttm_buffer_object *bo,
+                       unsigned long size,
+                       enum ttm_bo_type type,
+                       struct ttm_placement *placement,
+                       uint32_t page_alignment,
+                       unsigned long buffer_start,
+                       bool interrubtible,
+                       struct file *persistant_swap_storage,
+                       size_t acc_size,
+                       void (*destroy) (struct ttm_buffer_object *));
 /**
  * ttm_bo_synccpu_object_init
  *
@@ -404,47 +449,43 @@ extern int ttm_buffer_object_init(struct ttm_bo_device *bdev,
  * GEM user interface.
  * @p_bo: On successful completion *p_bo points to the created object.
  *
- * This function allocates a ttm_buffer_object, and then calls
- * ttm_buffer_object_init on that object.
- * The destroy function is set to kfree().
+ * This function allocates a ttm_buffer_object, and then calls ttm_bo_init
+ * on that object. The destroy function is set to kfree().
  * Returns
  * -ENOMEM: Out of memory.
  * -EINVAL: Invalid placement flags.
- * -ERESTART: Interrupted by signal while waiting for resources.
+ * -ERESTARTSYS: Interrupted by signal while waiting for resources.
  */
 
-extern int ttm_buffer_object_create(struct ttm_bo_device *bdev,
-                                   unsigned long size,
-                                   enum ttm_bo_type type,
-                                   uint32_t flags,
-                                   uint32_t page_alignment,
-                                   unsigned long buffer_start,
-                                   bool interruptible,
-                                   struct file *persistant_swap_storage,
-                                   struct ttm_buffer_object **p_bo);
+extern int ttm_bo_create(struct ttm_bo_device *bdev,
+                               unsigned long size,
+                               enum ttm_bo_type type,
+                               struct ttm_placement *placement,
+                               uint32_t page_alignment,
+                               unsigned long buffer_start,
+                               bool interruptible,
+                               struct file *persistant_swap_storage,
+                               struct ttm_buffer_object **p_bo);
 
 /**
  * ttm_bo_check_placement
  *
- * @bo: the buffer object.
- * @set_flags: placement flags to set.
- * @clr_flags: placement flags to clear.
+ * @bo:                the buffer object.
+ * @placement: placements
  *
  * Performs minimal validity checking on an intended change of
  * placement flags.
  * Returns
  * -EINVAL: Intended change is invalid or not allowed.
  */
-
 extern int ttm_bo_check_placement(struct ttm_buffer_object *bo,
-                                 uint32_t set_flags, uint32_t clr_flags);
+                                       struct ttm_placement *placement);
 
 /**
  * ttm_bo_init_mm
  *
  * @bdev: Pointer to a ttm_bo_device struct.
  * @mem_type: The memory type.
- * @p_offset: offset for managed area in pages.
  * @p_size: size managed area in pages.
  *
  * Initialize a manager for a given memory type.
@@ -457,7 +498,7 @@ extern int ttm_bo_check_placement(struct ttm_buffer_object *bo,
  */
 
 extern int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,
-                         unsigned long p_offset, unsigned long p_size);
+                               unsigned long p_size);
 /**
  * ttm_bo_clean_mm
  *
@@ -502,7 +543,7 @@ extern int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type);
  *
  * Returns:
  * -EINVAL: Invalid or uninitialized memory type.
- * -ERESTART: The call was interrupted by a signal while waiting to
+ * -ERESTARTSYS: The call was interrupted by a signal while waiting to
  * evict a buffer.
  */
 
@@ -605,7 +646,7 @@ extern int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma,
  * be called from the fops::read and fops::write method.
  * Returns:
  * See man (2) write, man(2) read. In particular,
- * the function may return -EINTR if
+ * the function may return -ERESTARTSYS if
  * interrupted by a signal.
  */