Lines Matching full:mapping

8 #include <linux/dma-mapping.h>
891 * host1x_bo_pin() - Create a DMA mapping for the buffer object
895 * @cache: Cache in which to store mapping, or NULL
897 * Creates a DMA mapping pointing to @bo for @dev. The refcount of @bo is incremented
900 * If @cache is specified, the mapping is also stored in the cache and not released
908 struct host1x_bo_mapping *mapping; in host1x_bo_pin() local
913 list_for_each_entry(mapping, &cache->mappings, entry) { in host1x_bo_pin()
914 if (mapping->bo == bo && mapping->direction == dir) { in host1x_bo_pin()
915 kref_get(&mapping->ref); in host1x_bo_pin()
922 mapping = bo->ops->pin(dev, bo, dir); in host1x_bo_pin()
923 if (IS_ERR(mapping)) in host1x_bo_pin()
928 spin_lock(&mapping->bo->lock); in host1x_bo_pin()
929 list_add_tail(&mapping->list, &bo->mappings); in host1x_bo_pin()
930 spin_unlock(&mapping->bo->lock); in host1x_bo_pin()
933 INIT_LIST_HEAD(&mapping->entry); in host1x_bo_pin()
934 mapping->cache = cache; in host1x_bo_pin()
936 list_add_tail(&mapping->entry, &cache->mappings); in host1x_bo_pin()
939 * Bump the mapping reference count to track the mapping in the cache, in host1x_bo_pin()
941 * triggering the release of the cache mapping through in host1x_bo_pin()
944 kref_get(&mapping->ref); in host1x_bo_pin()
951 return mapping; in host1x_bo_pin()
957 struct host1x_bo_mapping *mapping = to_host1x_bo_mapping(ref); in __host1x_bo_unpin() local
960 * When the last reference of the mapping goes away, make sure to remove the mapping from in __host1x_bo_unpin()
963 if (mapping->cache) in __host1x_bo_unpin()
964 list_del(&mapping->entry); in __host1x_bo_unpin()
966 spin_lock(&mapping->bo->lock); in __host1x_bo_unpin()
967 list_del(&mapping->list); in __host1x_bo_unpin()
968 spin_unlock(&mapping->bo->lock); in __host1x_bo_unpin()
970 mapping->bo->ops->unpin(mapping); in __host1x_bo_unpin()
974 * host1x_bo_unpin() - Release an established DMA mapping of a buffer object
975 * @mapping: Mapping to release
977 * Unmaps the given @mapping, unless it is cached. Decreases the refcount on
980 void host1x_bo_unpin(struct host1x_bo_mapping *mapping) in host1x_bo_unpin() argument
982 struct host1x_bo_cache *cache = mapping->cache; in host1x_bo_unpin()
983 struct host1x_bo *bo = mapping->bo; in host1x_bo_unpin()
988 kref_put(&mapping->ref, __host1x_bo_unpin); in host1x_bo_unpin()
1007 struct host1x_bo_mapping *mapping, *tmp; in host1x_bo_clear_cached_mappings() local
1010 list_for_each_entry_safe(mapping, tmp, &bo->mappings, list) { in host1x_bo_clear_cached_mappings()
1011 cache = mapping->cache; in host1x_bo_clear_cached_mappings()
1016 WARN_ON(kref_read(&mapping->ref) != 1); in host1x_bo_clear_cached_mappings()
1017 __host1x_bo_unpin(&mapping->ref); in host1x_bo_clear_cached_mappings()