Lines Matching refs:ioc

225 struct ioc {  struct
253 struct ioc *next; /* Linked list of discovered iocs */ argument
260 static struct ioc *ioc_list; argument
295 #define CCIO_SEARCH_LOOP(ioc, res_idx, mask, size) \ argument
299 idx = (unsigned int)((unsigned long)res_ptr - (unsigned long)ioc->res_map); \
304 ioc->res_hint = res_idx + (size >> 3); \
310 u##size *res_ptr = (u##size *)&((ioc)->res_map[ioa->res_hint & ~((size >> 3) - 1)]); \
311 u##size *res_end = (u##size *)&(ioc)->res_map[ioa->res_size]; \
312 CCIO_SEARCH_LOOP(ioc, res_idx, mask, size); \
313 res_ptr = (u##size *)&(ioc)->res_map[0]; \
340 ccio_alloc_range(struct ioc *ioc, struct device *dev, size_t size) in ccio_alloc_range() argument
374 CCIO_FIND_FREE_MAPPING(ioc, res_idx, mask, 8); in ccio_alloc_range()
376 CCIO_FIND_FREE_MAPPING(ioc, res_idx, 0xff, 8); in ccio_alloc_range()
379 CCIO_FIND_FREE_MAPPING(ioc, res_idx, 0xffff, 16); in ccio_alloc_range()
381 CCIO_FIND_FREE_MAPPING(ioc, res_idx, ~(unsigned int)0, 32); in ccio_alloc_range()
384 CCIO_FIND_FREE_MAPPING(ioc, res_idx, ~0UL, 64); in ccio_alloc_range()
397 __func__, res_idx, ioc->res_hint); in ccio_alloc_range()
406 ioc->avg_search[ioc->avg_idx++] = cr_start; in ccio_alloc_range()
407 ioc->avg_idx &= CCIO_SEARCH_SAMPLE - 1; in ccio_alloc_range()
408 ioc->used_pages += pages_needed; in ccio_alloc_range()
416 #define CCIO_FREE_MAPPINGS(ioc, res_idx, mask, size) \ argument
417 u##size *res_ptr = (u##size *)&((ioc)->res_map[res_idx]); \
431 ccio_free_range(struct ioc *ioc, dma_addr_t iova, unsigned long pages_mapped) in ccio_free_range() argument
444 ioc->used_pages -= pages_mapped; in ccio_free_range()
451 CCIO_FREE_MAPPINGS(ioc, res_idx, mask, 8); in ccio_free_range()
453 CCIO_FREE_MAPPINGS(ioc, res_idx, 0xffUL, 8); in ccio_free_range()
456 CCIO_FREE_MAPPINGS(ioc, res_idx, 0xffffUL, 16); in ccio_free_range()
458 CCIO_FREE_MAPPINGS(ioc, res_idx, ~(unsigned int)0, 32); in ccio_free_range()
461 CCIO_FREE_MAPPINGS(ioc, res_idx, ~0UL, 64); in ccio_free_range()
627 ccio_clear_io_tlb(struct ioc *ioc, dma_addr_t iovp, size_t byte_cnt) in ccio_clear_io_tlb() argument
629 u32 chain_size = 1 << ioc->chainid_shift; in ccio_clear_io_tlb()
635 WRITE_U32(CMD_TLB_PURGE | iovp, &ioc->ioc_regs->io_command); in ccio_clear_io_tlb()
660 ccio_mark_invalid(struct ioc *ioc, dma_addr_t iova, size_t byte_cnt) in ccio_mark_invalid() argument
671 char *pdir_ptr = (char *) &(ioc->pdir_base[idx]); in ccio_mark_invalid()
673 BUG_ON(idx >= (ioc->pdir_size / sizeof(u64))); in ccio_mark_invalid()
687 ccio_clear_io_tlb(ioc, CCIO_IOVP(iova), saved_byte_cnt); in ccio_mark_invalid()
728 struct ioc *ioc; in ccio_map_single() local
736 ioc = GET_IOC(dev); in ccio_map_single()
737 if (!ioc) in ccio_map_single()
747 spin_lock_irqsave(&ioc->res_lock, flags); in ccio_map_single()
750 ioc->msingle_calls++; in ccio_map_single()
751 ioc->msingle_pages += size >> IOVP_SHIFT; in ccio_map_single()
754 idx = ccio_alloc_range(ioc, dev, size); in ccio_map_single()
757 pdir_start = &(ioc->pdir_base[idx]); in ccio_map_single()
778 spin_unlock_irqrestore(&ioc->res_lock, flags); in ccio_map_single()
806 struct ioc *ioc; in ccio_unmap_page() local
811 ioc = GET_IOC(dev); in ccio_unmap_page()
812 if (!ioc) { in ccio_unmap_page()
813 WARN_ON(!ioc); in ccio_unmap_page()
824 spin_lock_irqsave(&ioc->res_lock, flags); in ccio_unmap_page()
827 ioc->usingle_calls++; in ccio_unmap_page()
828 ioc->usingle_pages += size >> IOVP_SHIFT; in ccio_unmap_page()
831 ccio_mark_invalid(ioc, iova, size); in ccio_unmap_page()
832 ccio_free_range(ioc, iova, (size >> IOVP_SHIFT)); in ccio_unmap_page()
833 spin_unlock_irqrestore(&ioc->res_lock, flags); in ccio_unmap_page()
911 struct ioc *ioc; in ccio_map_sg() local
919 ioc = GET_IOC(dev); in ccio_map_sg()
920 if (!ioc) in ccio_map_sg()
937 spin_lock_irqsave(&ioc->res_lock, flags); in ccio_map_sg()
940 ioc->msg_calls++; in ccio_map_sg()
951 coalesced = iommu_coalesce_chunks(ioc, dev, sglist, nents, ccio_alloc_range); in ccio_map_sg()
961 filled = iommu_fill_pdir(ioc, sglist, nents, hint, ccio_io_pdir_entry); in ccio_map_sg()
963 spin_unlock_irqrestore(&ioc->res_lock, flags); in ccio_map_sg()
990 struct ioc *ioc; in ccio_unmap_sg() local
993 ioc = GET_IOC(dev); in ccio_unmap_sg()
994 if (!ioc) { in ccio_unmap_sg()
995 WARN_ON(!ioc); in ccio_unmap_sg()
1003 ioc->usg_calls++; in ccio_unmap_sg()
1009 ioc->usg_pages += sg_dma_len(sglist) >> PAGE_SHIFT; in ccio_unmap_sg()
1035 struct ioc *ioc = ioc_list; in ccio_proc_info() local
1037 while (ioc != NULL) { in ccio_proc_info()
1038 unsigned int total_pages = ioc->res_size << 3; in ccio_proc_info()
1044 seq_printf(m, "%s\n", ioc->name); in ccio_proc_info()
1047 (ioc->cujo20_bug ? "yes" : "no")); in ccio_proc_info()
1054 total_pages - ioc->used_pages, ioc->used_pages, in ccio_proc_info()
1055 (int)(ioc->used_pages * 100 / total_pages)); in ccio_proc_info()
1059 ioc->res_size, total_pages); in ccio_proc_info()
1062 min = max = ioc->avg_search[0]; in ccio_proc_info()
1064 avg += ioc->avg_search[j]; in ccio_proc_info()
1065 if(ioc->avg_search[j] > max) in ccio_proc_info()
1066 max = ioc->avg_search[j]; in ccio_proc_info()
1067 if(ioc->avg_search[j] < min) in ccio_proc_info()
1068 min = ioc->avg_search[j]; in ccio_proc_info()
1075 ioc->msingle_calls, ioc->msingle_pages, in ccio_proc_info()
1076 (int)((ioc->msingle_pages * 1000)/ioc->msingle_calls)); in ccio_proc_info()
1079 min = ioc->usingle_calls - ioc->usg_calls; in ccio_proc_info()
1080 max = ioc->usingle_pages - ioc->usg_pages; in ccio_proc_info()
1085 ioc->msg_calls, ioc->msg_pages, in ccio_proc_info()
1086 (int)((ioc->msg_pages * 1000)/ioc->msg_calls)); in ccio_proc_info()
1089 ioc->usg_calls, ioc->usg_pages, in ccio_proc_info()
1090 (int)((ioc->usg_pages * 1000)/ioc->usg_calls)); in ccio_proc_info()
1093 ioc = ioc->next; in ccio_proc_info()
1101 struct ioc *ioc = ioc_list; in ccio_proc_bitmap_info() local
1103 while (ioc != NULL) { in ccio_proc_bitmap_info()
1104 seq_hex_dump(m, " ", DUMP_PREFIX_NONE, 32, 4, ioc->res_map, in ccio_proc_bitmap_info()
1105 ioc->res_size, false); in ccio_proc_bitmap_info()
1107 ioc = ioc->next; in ccio_proc_bitmap_info()
1122 static struct ioc * ccio_find_ioc(int hw_path) in ccio_find_ioc()
1125 struct ioc *ioc; in ccio_find_ioc() local
1127 ioc = ioc_list; in ccio_find_ioc()
1129 if (ioc->hw_path == hw_path) in ccio_find_ioc()
1130 return ioc; in ccio_find_ioc()
1132 ioc = ioc->next; in ccio_find_ioc()
1164 struct ioc *ioc = ccio_get_iommu(dev); in ccio_cujo20_fixup() local
1167 ioc->cujo20_bug = 1; in ccio_cujo20_fixup()
1168 res_ptr = ioc->res_map; in ccio_cujo20_fixup()
1171 while (idx < ioc->res_size) { in ccio_cujo20_fixup()
1229 ccio_ioc_init(struct ioc *ioc) in ccio_ioc_init() argument
1276 ioc->pdir_size = (iova_space_size / IOVP_SIZE) * sizeof(u64); in ccio_ioc_init()
1278 BUG_ON(ioc->pdir_size > 8 * 1024 * 1024); /* max pdir size <= 8MB */ in ccio_ioc_init()
1281 BUG_ON((1 << get_order(ioc->pdir_size)) != (ioc->pdir_size >> PAGE_SHIFT)); in ccio_ioc_init()
1284 __func__, ioc->ioc_regs, in ccio_ioc_init()
1289 ioc->pdir_base = (u64 *)__get_free_pages(GFP_KERNEL, in ccio_ioc_init()
1290 get_order(ioc->pdir_size)); in ccio_ioc_init()
1291 if(NULL == ioc->pdir_base) { in ccio_ioc_init()
1294 memset(ioc->pdir_base, 0, ioc->pdir_size); in ccio_ioc_init()
1296 BUG_ON((((unsigned long)ioc->pdir_base) & PAGE_MASK) != (unsigned long)ioc->pdir_base); in ccio_ioc_init()
1297 DBG_INIT(" base %p\n", ioc->pdir_base); in ccio_ioc_init()
1300 ioc->res_size = (ioc->pdir_size / sizeof(u64)) >> 3; in ccio_ioc_init()
1301 DBG_INIT("%s() res_size 0x%x\n", __func__, ioc->res_size); in ccio_ioc_init()
1303 ioc->res_map = (u8 *)__get_free_pages(GFP_KERNEL, in ccio_ioc_init()
1304 get_order(ioc->res_size)); in ccio_ioc_init()
1305 if(NULL == ioc->res_map) { in ccio_ioc_init()
1308 memset(ioc->res_map, 0, ioc->res_size); in ccio_ioc_init()
1311 ioc->res_hint = 16; in ccio_ioc_init()
1314 spin_lock_init(&ioc->res_lock); in ccio_ioc_init()
1320 ioc->chainid_shift = get_order(iova_space_size) + PAGE_SHIFT - CCIO_CHAINID_SHIFT; in ccio_ioc_init()
1321 DBG_INIT(" chainid_shift 0x%x\n", ioc->chainid_shift); in ccio_ioc_init()
1326 WRITE_U32(CCIO_CHAINID_MASK << ioc->chainid_shift, in ccio_ioc_init()
1327 &ioc->ioc_regs->io_chain_id_mask); in ccio_ioc_init()
1329 WRITE_U32(virt_to_phys(ioc->pdir_base), in ccio_ioc_init()
1330 &ioc->ioc_regs->io_pdir_base); in ccio_ioc_init()
1335 WRITE_U32(IOA_NORMAL_MODE, &ioc->ioc_regs->io_control); in ccio_ioc_init()
1340 WRITE_U32(0, &ioc->ioc_regs->io_tlb_entry_m); in ccio_ioc_init()
1341 WRITE_U32(0, &ioc->ioc_regs->io_tlb_entry_l); in ccio_ioc_init()
1344 WRITE_U32((CMD_TLB_DIRECT_WRITE | (i << ioc->chainid_shift)), in ccio_ioc_init()
1345 &ioc->ioc_regs->io_command); in ccio_ioc_init()
1382 static void __init ccio_init_resources(struct ioc *ioc) in ccio_init_resources() argument
1384 struct resource *res = ioc->mmio_region; in ccio_init_resources()
1387 snprintf(name, 14, "GSC Bus [%d/]", ioc->hw_path); in ccio_init_resources()
1389 ccio_init_resource(res, name, &ioc->ioc_regs->io_io_low); in ccio_init_resources()
1390 ccio_init_resource(res + 1, name, &ioc->ioc_regs->io_io_low_hv); in ccio_init_resources()
1449 struct ioc *ioc = ccio_get_iommu(dev); in ccio_allocate_resource() local
1450 if (!ioc) in ccio_allocate_resource()
1453 parent = ioc->mmio_region; in ccio_allocate_resource()
1465 &ioc->ioc_regs->io_io_low); in ccio_allocate_resource()
1467 &ioc->ioc_regs->io_io_high); in ccio_allocate_resource()
1471 &ioc->ioc_regs->io_io_low_hv); in ccio_allocate_resource()
1473 &ioc->ioc_regs->io_io_high_hv); in ccio_allocate_resource()
1486 struct ioc *ioc = ccio_get_iommu(dev); in ccio_request_resource() local
1488 if (!ioc) { in ccio_request_resource()
1490 } else if ((ioc->mmio_region->start <= res->start) && in ccio_request_resource()
1491 (res->end <= ioc->mmio_region->end)) { in ccio_request_resource()
1492 parent = ioc->mmio_region; in ccio_request_resource()
1493 } else if (((ioc->mmio_region + 1)->start <= res->start) && in ccio_request_resource()
1494 (res->end <= (ioc->mmio_region + 1)->end)) { in ccio_request_resource()
1495 parent = ioc->mmio_region + 1; in ccio_request_resource()
1519 struct ioc *ioc, **ioc_p = &ioc_list; in ccio_probe() local
1522 ioc = kzalloc(sizeof(struct ioc), GFP_KERNEL); in ccio_probe()
1523 if (ioc == NULL) { in ccio_probe()
1528 ioc->name = dev->id.hversion == U2_IOA_RUNWAY ? "U2" : "UTurn"; in ccio_probe()
1530 printk(KERN_INFO "Found %s at 0x%lx\n", ioc->name, in ccio_probe()
1536 *ioc_p = ioc; in ccio_probe()
1538 ioc->hw_path = dev->hw_path; in ccio_probe()
1539 ioc->ioc_regs = ioremap(dev->hpa.start, 4096); in ccio_probe()
1540 if (!ioc->ioc_regs) { in ccio_probe()
1541 kfree(ioc); in ccio_probe()
1544 ccio_ioc_init(ioc); in ccio_probe()
1545 ccio_init_resources(ioc); in ccio_probe()
1552 hba->iommu = ioc; in ccio_probe()