Lines Matching refs:entry
166 static inline void dump_entry_trace(struct dma_debug_entry *entry) in dump_entry_trace() argument
169 if (entry) { in dump_entry_trace()
171 stack_trace_print(entry->stack_entries, entry->stack_len, 0); in dump_entry_trace()
217 #define err_printk(dev, entry, format, arg...) do { \ argument
224 dump_entry_trace(entry); \
236 static int hash_fn(struct dma_debug_entry *entry) in hash_fn() argument
242 return (entry->dev_addr >> HASH_FN_SHIFT) & HASH_FN_MASK; in hash_fn()
248 static struct hash_bucket *get_hash_bucket(struct dma_debug_entry *entry, in get_hash_bucket() argument
252 int idx = hash_fn(entry); in get_hash_bucket()
296 struct dma_debug_entry *entry, *ret = NULL; in __hash_bucket_find() local
299 list_for_each_entry(entry, &bucket->list, list) { in __hash_bucket_find()
300 if (!match(ref, entry)) in __hash_bucket_find()
315 entry->size == ref->size ? ++match_lvl : 0; in __hash_bucket_find()
316 entry->type == ref->type ? ++match_lvl : 0; in __hash_bucket_find()
317 entry->direction == ref->direction ? ++match_lvl : 0; in __hash_bucket_find()
318 entry->sg_call_ents == ref->sg_call_ents ? ++match_lvl : 0; in __hash_bucket_find()
322 return entry; in __hash_bucket_find()
329 ret = entry; in __hash_bucket_find()
354 struct dma_debug_entry *entry, index = *ref; in bucket_find_contain() local
358 entry = __hash_bucket_find(*bucket, ref, containing_match); in bucket_find_contain()
360 if (entry) in bucket_find_contain()
361 return entry; in bucket_find_contain()
379 struct dma_debug_entry *entry) in hash_bucket_add() argument
381 list_add_tail(&entry->list, &bucket->list); in hash_bucket_add()
387 static void hash_bucket_del(struct dma_debug_entry *entry) in hash_bucket_del() argument
389 list_del(&entry->list); in hash_bucket_del()
392 static unsigned long long phys_addr(struct dma_debug_entry *entry) in phys_addr() argument
394 if (entry->type == dma_debug_resource) in phys_addr()
395 return __pfn_to_phys(entry->pfn) + entry->offset; in phys_addr()
397 return page_to_phys(pfn_to_page(entry->pfn)) + entry->offset; in phys_addr()
409 struct dma_debug_entry *entry; in debug_dma_dump_mappings() local
414 list_for_each_entry(entry, &bucket->list, list) { in debug_dma_dump_mappings()
415 if (!dev || dev == entry->dev) { in debug_dma_dump_mappings()
416 dev_info(entry->dev, in debug_dma_dump_mappings()
418 type2name[entry->type], idx, in debug_dma_dump_mappings()
419 phys_addr(entry), entry->pfn, in debug_dma_dump_mappings()
420 entry->dev_addr, entry->size, in debug_dma_dump_mappings()
421 dir2name[entry->direction], in debug_dma_dump_mappings()
422 maperr2str[entry->map_err_type]); in debug_dma_dump_mappings()
457 static phys_addr_t to_cacheline_number(struct dma_debug_entry *entry) in to_cacheline_number() argument
459 return (entry->pfn << CACHELINE_PER_PAGE_SHIFT) + in to_cacheline_number()
460 (entry->offset >> L1_CACHE_SHIFT); in to_cacheline_number()
510 static int active_cacheline_insert(struct dma_debug_entry *entry) in active_cacheline_insert() argument
512 phys_addr_t cln = to_cacheline_number(entry); in active_cacheline_insert()
520 if (entry->direction == DMA_TO_DEVICE) in active_cacheline_insert()
524 rc = radix_tree_insert(&dma_active_cacheline, cln, entry); in active_cacheline_insert()
532 static void active_cacheline_remove(struct dma_debug_entry *entry) in active_cacheline_remove() argument
534 phys_addr_t cln = to_cacheline_number(entry); in active_cacheline_remove()
538 if (entry->direction == DMA_TO_DEVICE) in active_cacheline_remove()
555 static void add_dma_entry(struct dma_debug_entry *entry) in add_dma_entry() argument
561 bucket = get_hash_bucket(entry, &flags); in add_dma_entry()
562 hash_bucket_add(bucket, entry); in add_dma_entry()
565 rc = active_cacheline_insert(entry); in add_dma_entry()
578 struct dma_debug_entry *entry; in dma_debug_create_entries() local
581 entry = (void *)get_zeroed_page(gfp); in dma_debug_create_entries()
582 if (!entry) in dma_debug_create_entries()
586 list_add_tail(&entry[i].list, &free_entries); in dma_debug_create_entries()
596 struct dma_debug_entry *entry; in __dma_entry_alloc() local
598 entry = list_entry(free_entries.next, struct dma_debug_entry, list); in __dma_entry_alloc()
599 list_del(&entry->list); in __dma_entry_alloc()
600 memset(entry, 0, sizeof(*entry)); in __dma_entry_alloc()
606 return entry; in __dma_entry_alloc()
633 struct dma_debug_entry *entry; in dma_entry_alloc() local
649 entry = __dma_entry_alloc(); in dma_entry_alloc()
657 entry->stack_len = stack_trace_save(entry->stack_entries, in dma_entry_alloc()
658 ARRAY_SIZE(entry->stack_entries), in dma_entry_alloc()
661 return entry; in dma_entry_alloc()
664 static void dma_entry_free(struct dma_debug_entry *entry) in dma_entry_free() argument
668 active_cacheline_remove(entry); in dma_entry_free()
675 list_add(&entry->list, &free_entries); in dma_entry_free()
786 struct dma_debug_entry *entry; in dump_show() local
790 list_for_each_entry(entry, &bucket->list, list) { in dump_show()
793 dev_name(entry->dev), in dump_show()
794 dev_driver_string(entry->dev), in dump_show()
795 type2name[entry->type], idx, in dump_show()
796 phys_addr(entry), entry->pfn, in dump_show()
797 entry->dev_addr, entry->size, in dump_show()
798 dir2name[entry->direction], in dump_show()
799 maperr2str[entry->map_err_type]); in dump_show()
827 struct dma_debug_entry *entry; in device_dma_allocations() local
833 list_for_each_entry(entry, &dma_entry_hash[i].list, list) { in device_dma_allocations()
834 if (entry->dev == dev) { in device_dma_allocations()
836 *out_entry = entry; in device_dma_allocations()
848 struct dma_debug_entry *entry; in dma_debug_device_change() local
856 count = device_dma_allocations(dev, &entry); in dma_debug_device_change()
859 err_printk(dev, entry, "device driver has pending " in dma_debug_device_change()
865 count, entry->dev_addr, entry->size, in dma_debug_device_change()
866 dir2name[entry->direction], type2name[entry->type]); in dma_debug_device_change()
958 struct dma_debug_entry *entry; in check_unmap() local
963 entry = bucket_find_exact(bucket, ref); in check_unmap()
965 if (!entry) { in check_unmap()
983 if (ref->size != entry->size) { in check_unmap()
984 err_printk(ref->dev, entry, "device driver frees " in check_unmap()
988 ref->dev_addr, entry->size, ref->size); in check_unmap()
991 if (ref->type != entry->type) { in check_unmap()
992 err_printk(ref->dev, entry, "device driver frees " in check_unmap()
997 type2name[entry->type], type2name[ref->type]); in check_unmap()
998 } else if ((entry->type == dma_debug_coherent) && in check_unmap()
999 (phys_addr(ref) != phys_addr(entry))) { in check_unmap()
1000 err_printk(ref->dev, entry, "device driver frees " in check_unmap()
1006 phys_addr(entry), in check_unmap()
1011 ref->sg_call_ents != entry->sg_call_ents) { in check_unmap()
1012 err_printk(ref->dev, entry, "device driver frees " in check_unmap()
1015 entry->sg_call_ents, ref->sg_call_ents); in check_unmap()
1022 if (ref->direction != entry->direction) { in check_unmap()
1023 err_printk(ref->dev, entry, "device driver frees " in check_unmap()
1028 dir2name[entry->direction], in check_unmap()
1037 if (entry->map_err_type == MAP_ERR_NOT_CHECKED) { in check_unmap()
1038 err_printk(ref->dev, entry, in check_unmap()
1043 type2name[entry->type]); in check_unmap()
1046 hash_bucket_del(entry); in check_unmap()
1047 dma_entry_free(entry); in check_unmap()
1101 struct dma_debug_entry *entry; in check_sync() local
1107 entry = bucket_find_contain(&bucket, ref, &flags); in check_sync()
1109 if (!entry) { in check_sync()
1117 if (ref->size > entry->size) { in check_sync()
1118 err_printk(dev, entry, "device driver syncs" in check_sync()
1123 entry->dev_addr, entry->size, in check_sync()
1127 if (entry->direction == DMA_BIDIRECTIONAL) in check_sync()
1130 if (ref->direction != entry->direction) { in check_sync()
1131 err_printk(dev, entry, "device driver syncs " in check_sync()
1135 (unsigned long long)ref->dev_addr, entry->size, in check_sync()
1136 dir2name[entry->direction], in check_sync()
1140 if (to_cpu && !(entry->direction == DMA_FROM_DEVICE) && in check_sync()
1142 err_printk(dev, entry, "device driver syncs " in check_sync()
1146 (unsigned long long)ref->dev_addr, entry->size, in check_sync()
1147 dir2name[entry->direction], in check_sync()
1150 if (!to_cpu && !(entry->direction == DMA_TO_DEVICE) && in check_sync()
1152 err_printk(dev, entry, "device driver syncs " in check_sync()
1156 (unsigned long long)ref->dev_addr, entry->size, in check_sync()
1157 dir2name[entry->direction], in check_sync()
1162 ref->sg_call_ents > entry->sg_call_ents) { in check_sync()
1163 err_printk(ref->dev, entry, "device driver syncs " in check_sync()
1166 entry->sg_call_ents, ref->sg_call_ents); in check_sync()
1218 struct dma_debug_entry *entry; in debug_dma_map_page() local
1226 entry = dma_entry_alloc(); in debug_dma_map_page()
1227 if (!entry) in debug_dma_map_page()
1230 entry->dev = dev; in debug_dma_map_page()
1231 entry->type = dma_debug_single; in debug_dma_map_page()
1232 entry->pfn = page_to_pfn(page); in debug_dma_map_page()
1233 entry->offset = offset; in debug_dma_map_page()
1234 entry->dev_addr = dma_addr; in debug_dma_map_page()
1235 entry->size = size; in debug_dma_map_page()
1236 entry->direction = direction; in debug_dma_map_page()
1237 entry->map_err_type = MAP_ERR_NOT_CHECKED; in debug_dma_map_page()
1247 add_dma_entry(entry); in debug_dma_map_page()
1253 struct dma_debug_entry *entry; in debug_dma_mapping_error() local
1264 list_for_each_entry(entry, &bucket->list, list) { in debug_dma_mapping_error()
1265 if (!exact_match(&ref, entry)) in debug_dma_mapping_error()
1278 if (entry->map_err_type == MAP_ERR_NOT_CHECKED) { in debug_dma_mapping_error()
1279 entry->map_err_type = MAP_ERR_CHECKED; in debug_dma_mapping_error()
1307 struct dma_debug_entry *entry; in debug_dma_map_sg() local
1321 entry = dma_entry_alloc(); in debug_dma_map_sg()
1322 if (!entry) in debug_dma_map_sg()
1325 entry->type = dma_debug_sg; in debug_dma_map_sg()
1326 entry->dev = dev; in debug_dma_map_sg()
1327 entry->pfn = page_to_pfn(sg_page(s)); in debug_dma_map_sg()
1328 entry->offset = s->offset; in debug_dma_map_sg()
1329 entry->size = sg_dma_len(s); in debug_dma_map_sg()
1330 entry->dev_addr = sg_dma_address(s); in debug_dma_map_sg()
1331 entry->direction = direction; in debug_dma_map_sg()
1332 entry->sg_call_ents = nents; in debug_dma_map_sg()
1333 entry->sg_mapped_ents = mapped_ents; in debug_dma_map_sg()
1337 add_dma_entry(entry); in debug_dma_map_sg()
1344 struct dma_debug_entry *entry; in get_nr_mapped_entries() local
1350 entry = bucket_find_exact(bucket, ref); in get_nr_mapped_entries()
1353 if (entry) in get_nr_mapped_entries()
1354 mapped_ents = entry->sg_mapped_ents; in get_nr_mapped_entries()
1395 struct dma_debug_entry *entry; in debug_dma_alloc_coherent() local
1407 entry = dma_entry_alloc(); in debug_dma_alloc_coherent()
1408 if (!entry) in debug_dma_alloc_coherent()
1411 entry->type = dma_debug_coherent; in debug_dma_alloc_coherent()
1412 entry->dev = dev; in debug_dma_alloc_coherent()
1413 entry->offset = offset_in_page(virt); in debug_dma_alloc_coherent()
1414 entry->size = size; in debug_dma_alloc_coherent()
1415 entry->dev_addr = dma_addr; in debug_dma_alloc_coherent()
1416 entry->direction = DMA_BIDIRECTIONAL; in debug_dma_alloc_coherent()
1419 entry->pfn = vmalloc_to_pfn(virt); in debug_dma_alloc_coherent()
1421 entry->pfn = page_to_pfn(virt_to_page(virt)); in debug_dma_alloc_coherent()
1423 add_dma_entry(entry); in debug_dma_alloc_coherent()
1456 struct dma_debug_entry *entry; in debug_dma_map_resource() local
1461 entry = dma_entry_alloc(); in debug_dma_map_resource()
1462 if (!entry) in debug_dma_map_resource()
1465 entry->type = dma_debug_resource; in debug_dma_map_resource()
1466 entry->dev = dev; in debug_dma_map_resource()
1467 entry->pfn = PHYS_PFN(addr); in debug_dma_map_resource()
1468 entry->offset = offset_in_page(addr); in debug_dma_map_resource()
1469 entry->size = size; in debug_dma_map_resource()
1470 entry->dev_addr = dma_addr; in debug_dma_map_resource()
1471 entry->direction = direction; in debug_dma_map_resource()
1472 entry->map_err_type = MAP_ERR_NOT_CHECKED; in debug_dma_map_resource()
1474 add_dma_entry(entry); in debug_dma_map_resource()