Subversion Repositories Kolibri OS

Rev

Rev 4568 | Rev 5270 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4568 Rev 5056
Line 35... Line 35...
35
#include 
35
#include 
36
#include 
36
#include 
37
#include 
37
#include 
38
#include 
38
#include 
39
#include 
39
#include 
40
//#include 
40
#include 
41
#include 
41
#include 
42
#include 
42
#include 
43
 
-
 
44
struct ww_acquire_ctx;
43
#include 
Line 45... Line 44...
45
 
44
 
46
struct ttm_backend_func {
45
struct ttm_backend_func {
47
	/**
46
	/**
48
	 * struct ttm_backend_func member bind
47
	 * struct ttm_backend_func member bind
Line 132... Line 131...
132
 
131
 
133
/**
132
/**
134
 * struct ttm_dma_tt
133
 * struct ttm_dma_tt
135
 *
134
 *
-
 
135
 * @ttm: Base ttm_tt struct.
136
 * @ttm: Base ttm_tt struct.
136
 * @cpu_address: The CPU address of the pages
137
 * @dma_address: The DMA (bus) addresses of the pages
137
 * @dma_address: The DMA (bus) addresses of the pages
138
 * @pages_list: used by some page allocation backend
138
 * @pages_list: used by some page allocation backend
139
 *
139
 *
140
 * This is a structure holding the pages, caching- and aperture binding
140
 * This is a structure holding the pages, caching- and aperture binding
141
 * status for a buffer object that isn't backed by fixed (VRAM / AGP)
141
 * status for a buffer object that isn't backed by fixed (VRAM / AGP)
142
 * memory.
142
 * memory.
143
 */
143
 */
144
struct ttm_dma_tt {
144
struct ttm_dma_tt {
-
 
145
	struct ttm_tt ttm;
145
	struct ttm_tt ttm;
146
	void **cpu_address;
146
	dma_addr_t *dma_address;
147
	dma_addr_t *dma_address;
147
	struct list_head pages_list;
148
	struct list_head pages_list;
Line 148... Line 149...
148
};
149
};
Line 181... Line 182...
181
	 * struct ttm_mem_type_manager member get_node
182
	 * struct ttm_mem_type_manager member get_node
182
	 *
183
	 *
183
	 * @man: Pointer to a memory type manager.
184
	 * @man: Pointer to a memory type manager.
184
	 * @bo: Pointer to the buffer object we're allocating space for.
185
	 * @bo: Pointer to the buffer object we're allocating space for.
185
	 * @placement: Placement details.
186
	 * @placement: Placement details.
-
 
187
	 * @flags: Additional placement flags.
186
	 * @mem: Pointer to a struct ttm_mem_reg to be filled in.
188
	 * @mem: Pointer to a struct ttm_mem_reg to be filled in.
187
	 *
189
	 *
188
	 * This function should allocate space in the memory type managed
190
	 * This function should allocate space in the memory type managed
189
	 * by @man. Placement details if
191
	 * by @man. Placement details if
190
	 * applicable are given by @placement. If successful,
192
	 * applicable are given by @placement. If successful,
Line 205... Line 207...
205
	 * protect any data structures managing the space.
207
	 * protect any data structures managing the space.
206
	 */
208
	 */
207
	int  (*get_node)(struct ttm_mem_type_manager *man,
209
	int  (*get_node)(struct ttm_mem_type_manager *man,
208
			 struct ttm_buffer_object *bo,
210
			 struct ttm_buffer_object *bo,
209
			 struct ttm_placement *placement,
211
			 struct ttm_placement *placement,
-
 
212
			 uint32_t flags,
210
			 struct ttm_mem_reg *mem);
213
			 struct ttm_mem_reg *mem);
Line 211... Line 214...
211
 
214
 
212
	/**
215
	/**
213
	 * struct ttm_mem_type_manager member put_node
216
	 * struct ttm_mem_type_manager member put_node
Line 652... Line 655...
652
 * Swap in a previously swap out ttm_tt.
655
 * Swap in a previously swap out ttm_tt.
653
 */
656
 */
654
extern int ttm_tt_swapin(struct ttm_tt *ttm);
657
extern int ttm_tt_swapin(struct ttm_tt *ttm);
Line 655... Line 658...
655
 
658
 
656
/**
-
 
657
 * ttm_tt_cache_flush:
-
 
658
 *
-
 
659
 * @pages: An array of pointers to struct page:s to flush.
-
 
660
 * @num_pages: Number of pages to flush.
-
 
661
 *
-
 
662
 * Flush the data of the indicated pages from the cpu caches.
-
 
663
 * This is used when changing caching attributes of the pages from
-
 
664
 * cache-coherent.
-
 
665
 */
-
 
666
extern void ttm_tt_cache_flush(struct page *pages[], unsigned long num_pages);
-
 
667
 
-
 
668
/**
659
/**
669
 * ttm_tt_set_placement_caching:
660
 * ttm_tt_set_placement_caching:
670
 *
661
 *
671
 * @ttm A struct ttm_tt the backing pages of which will change caching policy.
662
 * @ttm A struct ttm_tt the backing pages of which will change caching policy.
672
 * @placement: Flag indicating the desired caching policy.
663
 * @placement: Flag indicating the desired caching policy.
Line 746... Line 737...
746
 * ttm_bo_device_init
737
 * ttm_bo_device_init
747
 *
738
 *
748
 * @bdev: A pointer to a struct ttm_bo_device to initialize.
739
 * @bdev: A pointer to a struct ttm_bo_device to initialize.
749
 * @glob: A pointer to an initialized struct ttm_bo_global.
740
 * @glob: A pointer to an initialized struct ttm_bo_global.
750
 * @driver: A pointer to a struct ttm_bo_driver set up by the caller.
741
 * @driver: A pointer to a struct ttm_bo_driver set up by the caller.
-
 
742
 * @mapping: The address space to use for this bo.
751
 * @file_page_offset: Offset into the device address space that is available
743
 * @file_page_offset: Offset into the device address space that is available
752
 * for buffer data. This ensures compatibility with other users of the
744
 * for buffer data. This ensures compatibility with other users of the
753
 * address space.
745
 * address space.
754
 *
746
 *
755
 * Initializes a struct ttm_bo_device:
747
 * Initializes a struct ttm_bo_device:
Line 757... Line 749...
757
 * !0: Failure.
749
 * !0: Failure.
758
 */
750
 */
759
extern int ttm_bo_device_init(struct ttm_bo_device *bdev,
751
extern int ttm_bo_device_init(struct ttm_bo_device *bdev,
760
			      struct ttm_bo_global *glob,
752
			      struct ttm_bo_global *glob,
761
			      struct ttm_bo_driver *driver,
753
			      struct ttm_bo_driver *driver,
-
 
754
			      struct address_space *mapping,
762
			      uint64_t file_page_offset, bool need_dma32);
755
			      uint64_t file_page_offset, bool need_dma32);
Line 763... Line 756...
763
 
756
 
764
/**
757
/**
765
 * ttm_bo_unmap_virtual
758
 * ttm_bo_unmap_virtual
Line 785... Line 778...
785
 
778
 
786
extern void ttm_bo_del_sub_from_lru(struct ttm_buffer_object *bo);
779
extern void ttm_bo_del_sub_from_lru(struct ttm_buffer_object *bo);
Line 787... Line 780...
787
extern void ttm_bo_add_to_lru(struct ttm_buffer_object *bo);
780
extern void ttm_bo_add_to_lru(struct ttm_buffer_object *bo);
788
 
781
 
789
/**
782
/**
790
 * ttm_bo_reserve_nolru:
783
 * __ttm_bo_reserve:
791
 *
784
 *
792
 * @bo: A pointer to a struct ttm_buffer_object.
785
 * @bo: A pointer to a struct ttm_buffer_object.
793
 * @interruptible: Sleep interruptible if waiting.
786
 * @interruptible: Sleep interruptible if waiting.
Line 806... Line 799...
806
 * a signal. Release all buffer reservations and return to user-space.
799
 * a signal. Release all buffer reservations and return to user-space.
807
 * -EBUSY: The function needed to sleep, but @no_wait was true
800
 * -EBUSY: The function needed to sleep, but @no_wait was true
808
 * -EALREADY: Bo already reserved using @ticket. This error code will only
801
 * -EALREADY: Bo already reserved using @ticket. This error code will only
809
 * be returned if @use_ticket is set to true.
802
 * be returned if @use_ticket is set to true.
810
 */
803
 */
811
static inline int ttm_bo_reserve_nolru(struct ttm_buffer_object *bo,
804
static inline int __ttm_bo_reserve(struct ttm_buffer_object *bo,
812
				       bool interruptible,
805
				       bool interruptible,
813
				       bool no_wait, bool use_ticket,
806
				       bool no_wait, bool use_ticket,
814
				       struct ww_acquire_ctx *ticket)
807
				       struct ww_acquire_ctx *ticket)
815
{
808
{
816
	int ret = 0;
809
	int ret = 0;
817
/*
810
 
818
	if (no_wait) {
811
	if (no_wait) {
819
		bool success;
812
		bool success;
820
		if (WARN_ON(ticket))
813
		if (WARN_ON(ticket))
821
			return -EBUSY;
814
			return -EBUSY;
Line 828... Line 821...
828
		ret = ww_mutex_lock_interruptible(&bo->resv->lock, ticket);
821
		ret = ww_mutex_lock_interruptible(&bo->resv->lock, ticket);
829
	else
822
	else
830
		ret = ww_mutex_lock(&bo->resv->lock, ticket);
823
		ret = ww_mutex_lock(&bo->resv->lock, ticket);
831
	if (ret == -EINTR)
824
	if (ret == -EINTR)
832
		return -ERESTARTSYS;
825
		return -ERESTARTSYS;
833
*/
-
 
834
	return ret;
826
	return ret;
835
}
827
}
Line 836... Line 828...
836
 
828
 
837
/**
829
/**
Line 886... Line 878...
886
{
878
{
887
	int ret;
879
	int ret;
Line 888... Line 880...
888
 
880
 
Line 889... Line 881...
889
	WARN_ON(!atomic_read(&bo->kref.refcount));
881
	WARN_ON(!atomic_read(&bo->kref.refcount));
890
 
-
 
891
	ret = ttm_bo_reserve_nolru(bo, interruptible, no_wait, use_ticket,
882
 
892
				    ticket);
883
	ret = __ttm_bo_reserve(bo, interruptible, no_wait, use_ticket, ticket);
Line 893... Line 884...
893
	if (likely(ret == 0))
884
	if (likely(ret == 0))
894
		ttm_bo_del_sub_from_lru(bo);
885
		ttm_bo_del_sub_from_lru(bo);
Line 912... Line 903...
912
{
903
{
913
	int ret = 0;
904
	int ret = 0;
Line 914... Line 905...
914
 
905
 
Line 915... Line -...
915
	WARN_ON(!atomic_read(&bo->kref.refcount));
-
 
916
 
-
 
917
	if (interruptible)
-
 
918
		ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock,
-
 
919
						       ticket);
906
	WARN_ON(!atomic_read(&bo->kref.refcount));
Line 920... Line 907...
920
	else
907
 
921
		ww_mutex_lock_slow(&bo->resv->lock, ticket);
908
	ww_mutex_lock_slow(&bo->resv->lock, ticket);
922
 
909
 
Line 927... Line 914...
927
 
914
 
928
	return ret;
915
	return ret;
Line 929... Line 916...
929
}
916
}
930
 
917
 
931
/**
918
/**
932
 * ttm_bo_unreserve_ticket
-
 
933
 * @bo: A pointer to a struct ttm_buffer_object.
919
 * __ttm_bo_unreserve
934
 * @ticket: ww_acquire_ctx used for reserving
920
 * @bo: A pointer to a struct ttm_buffer_object.
-
 
921
 *
935
 *
922
 * Unreserve a previous reservation of @bo where the buffer object is
936
 * Unreserve a previous reservation of @bo made with @ticket.
923
 * already on lru lists.
-
 
924
 */
-
 
925
static inline void __ttm_bo_unreserve(struct ttm_buffer_object *bo)
-
 
926
{
-
 
927
	ww_mutex_unlock(&bo->resv->lock);
-
 
928
}
-
 
929
 
-
 
930
/**
937
 */
931
 * ttm_bo_unreserve
-
 
932
 *
-
 
933
 * @bo: A pointer to a struct ttm_buffer_object.
-
 
934
 *
-
 
935
 * Unreserve a previous reservation of @bo.
938
static inline void ttm_bo_unreserve_ticket(struct ttm_buffer_object *bo,
936
 */
939
					   struct ww_acquire_ctx *t)
937
static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
940
{
938
{
941
	if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {
939
	if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {
942
		spin_lock(&bo->glob->lru_lock);
940
		spin_lock(&bo->glob->lru_lock);
943
		ttm_bo_add_to_lru(bo);
941
		ttm_bo_add_to_lru(bo);
944
		spin_unlock(&bo->glob->lru_lock);
942
		spin_unlock(&bo->glob->lru_lock);
945
	}
943
	}
Line 946... Line 944...
946
//   ww_mutex_unlock(&bo->resv->lock);
944
	__ttm_bo_unreserve(bo);
947
}
945
}
948
 
-
 
949
/**
946
 
-
 
947
/**
950
 * ttm_bo_unreserve
948
 * ttm_bo_unreserve_ticket
951
 *
949
 * @bo: A pointer to a struct ttm_buffer_object.
952
 * @bo: A pointer to a struct ttm_buffer_object.
950
 * @ticket: ww_acquire_ctx used for reserving
953
 *
951
 *
-
 
952
 * Unreserve a previous reservation of @bo made with @ticket.
954
 * Unreserve a previous reservation of @bo.
953
 */
955
 */
954
static inline void ttm_bo_unreserve_ticket(struct ttm_buffer_object *bo,
956
static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
955
					   struct ww_acquire_ctx *t)
Line 957... Line 956...
957
{
956
{
958
	ttm_bo_unreserve_ticket(bo, NULL);
957
	ttm_bo_unreserve(bo);
959
}
958
}