aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm
diff options
context:
space:
mode:
authorJerome Glisse <jglisse@redhat.com>2010-04-09 08:39:23 -0400
committerDave Airlie <airlied@redhat.com>2010-04-20 00:12:05 -0400
commit82c5da6bf8b55a931b042fb531083863d26c8020 (patch)
tree88168d32d7060598ac730c30967b2e62dc5da28d /include/drm
parent9d87fa2138d06ff400551800d67d522625033e35 (diff)
drm/ttm: ttm_fault callback to allow driver to handle bo placement V6
On fault the driver is given the opportunity to perform any operation it sees fit in order to place the buffer into a CPU visible area of memory. This patch doesn't break TTM users, nouveau, vmwgfx and radeon should keep working properly. Future patch will take advantage of this infrastructure and remove the old path from TTM once driver are converted. V2 return VM_FAULT_NOPAGE if callback return -EBUSY or -ERESTARTSYS V3 balance io_mem_reserve and io_mem_free call, fault_reserve_notify is responsible to perform any necessary task for mapping to succeed V4 minor cleanup, atomic_t -> bool as member is protected by reserve mecanism from concurent access V5 the callback is now responsible for iomapping the bo and providing a virtual address this simplify TTM and will allow to get rid of TTM_MEMTYPE_FLAG_NEEDS_IOREMAP V6 use the bus addr data to decide to ioremap or this isn't needed but we don't necesarily need to ioremap in the callback but still allow driver to use static mapping Signed-off-by: Jerome Glisse <jglisse@redhat.com> Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'include/drm')
-rw-r--r--include/drm/ttm/ttm_bo_api.h23
-rw-r--r--include/drm/ttm/ttm_bo_driver.h16
2 files changed, 38 insertions, 1 deletions
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 8c8005ec4eaf..3e273e0b9417 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -66,6 +66,26 @@ struct ttm_placement {
66 const uint32_t *busy_placement; 66 const uint32_t *busy_placement;
67}; 67};
68 68
69/**
70 * struct ttm_bus_placement
71 *
72 * @addr: mapped virtual address
73 * @base: bus base address
74 * @is_iomem: is this io memory ?
75 * @size: size in byte
76 * @offset: offset from the base address
77 *
78 * Structure indicating the bus placement of an object.
79 */
80struct ttm_bus_placement {
81 void *addr;
82 unsigned long base;
83 unsigned long size;
84 unsigned long offset;
85 bool is_iomem;
86 bool io_reserved;
87};
88
69 89
70/** 90/**
71 * struct ttm_mem_reg 91 * struct ttm_mem_reg
@@ -75,6 +95,7 @@ struct ttm_placement {
75 * @num_pages: Actual size of memory region in pages. 95 * @num_pages: Actual size of memory region in pages.
76 * @page_alignment: Page alignment. 96 * @page_alignment: Page alignment.
77 * @placement: Placement flags. 97 * @placement: Placement flags.
98 * @bus: Placement on io bus accessible to the CPU
78 * 99 *
79 * Structure indicating the placement and space resources used by a 100 * Structure indicating the placement and space resources used by a
80 * buffer object. 101 * buffer object.
@@ -87,6 +108,7 @@ struct ttm_mem_reg {
87 uint32_t page_alignment; 108 uint32_t page_alignment;
88 uint32_t mem_type; 109 uint32_t mem_type;
89 uint32_t placement; 110 uint32_t placement;
111 struct ttm_bus_placement bus;
90}; 112};
91 113
92/** 114/**
@@ -274,6 +296,7 @@ struct ttm_bo_kmap_obj {
274 ttm_bo_map_kmap = 3, 296 ttm_bo_map_kmap = 3,
275 ttm_bo_map_premapped = 4 | TTM_BO_MAP_IOMEM_MASK, 297 ttm_bo_map_premapped = 4 | TTM_BO_MAP_IOMEM_MASK,
276 } bo_kmap_type; 298 } bo_kmap_type;
299 struct ttm_buffer_object *bo;
277}; 300};
278 301
279/** 302/**
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 69f70e418c2c..da39865d67d8 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -352,12 +352,21 @@ struct ttm_bo_driver {
352 struct ttm_mem_reg *new_mem); 352 struct ttm_mem_reg *new_mem);
353 /* notify the driver we are taking a fault on this BO 353 /* notify the driver we are taking a fault on this BO
354 * and have reserved it */ 354 * and have reserved it */
355 void (*fault_reserve_notify)(struct ttm_buffer_object *bo); 355 int (*fault_reserve_notify)(struct ttm_buffer_object *bo);
356 356
357 /** 357 /**
358 * notify the driver that we're about to swap out this bo 358 * notify the driver that we're about to swap out this bo
359 */ 359 */
360 void (*swap_notify) (struct ttm_buffer_object *bo); 360 void (*swap_notify) (struct ttm_buffer_object *bo);
361
362 /**
363 * Driver callback on when mapping io memory (for bo_move_memcpy
364 * for instance). TTM will take care to call io_mem_free whenever
365 * the mapping is not use anymore. io_mem_reserve & io_mem_free
366 * are balanced.
367 */
368 int (*io_mem_reserve)(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem);
369 void (*io_mem_free)(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem);
361}; 370};
362 371
363/** 372/**
@@ -685,6 +694,11 @@ extern int ttm_bo_pci_offset(struct ttm_bo_device *bdev,
685 unsigned long *bus_offset, 694 unsigned long *bus_offset,
686 unsigned long *bus_size); 695 unsigned long *bus_size);
687 696
697extern int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
698 struct ttm_mem_reg *mem);
699extern void ttm_mem_io_free(struct ttm_bo_device *bdev,
700 struct ttm_mem_reg *mem);
701
688extern void ttm_bo_global_release(struct ttm_global_reference *ref); 702extern void ttm_bo_global_release(struct ttm_global_reference *ref);
689extern int ttm_bo_global_init(struct ttm_global_reference *ref); 703extern int ttm_bo_global_init(struct ttm_global_reference *ref);
690 704