Lines Matching refs:ioc
201 struct ioc { struct
252 struct ioc ioc[MAX_IOC]; argument
351 sba_dump_pdir_entry(struct ioc *ioc, char *msg, uint pide) in sba_dump_pdir_entry() argument
354 u64 *ptr = &(ioc->pdir_base[pide & (~0U * BITS_PER_LONG)]); in sba_dump_pdir_entry()
355 unsigned long *rptr = (unsigned long *) &(ioc->res_map[(pide >>3) & ~(sizeof(unsigned long) - 1)]); in sba_dump_pdir_entry()
383 sba_check_pdir(struct ioc *ioc, char *msg) in sba_check_pdir() argument
385 u32 *rptr_end = (u32 *) &(ioc->res_map[ioc->res_size]); in sba_check_pdir()
386 u32 *rptr = (u32 *) ioc->res_map; /* resource map ptr */ in sba_check_pdir()
387 u64 *pptr = ioc->pdir_base; /* pdir ptr */ in sba_check_pdir()
403 sba_dump_pdir_entry(ioc, msg, pide); in sba_check_pdir()
427 sba_dump_sg( struct ioc *ioc, struct scatterlist *startsg, int nents) in sba_dump_sg() argument
456 #define SBA_IOVA(ioc,iovp,offset,hint_reg) ((iovp) | (offset) | ((hint_reg)<<(ioc->hint_shift_pdir)… argument
457 #define SBA_IOVP(ioc,iova) ((iova) & ioc->hint_mask_pdir) argument
478 sba_search_bitmap(struct ioc *ioc, unsigned long bits_wanted) in sba_search_bitmap() argument
480 unsigned long *res_ptr = ioc->res_hint; in sba_search_bitmap()
481 unsigned long *res_end = (unsigned long *) &(ioc->res_map[ioc->res_size]); in sba_search_bitmap()
484 ASSERT(((unsigned long) ioc->res_hint & (sizeof(unsigned long) - 1UL)) == 0); in sba_search_bitmap()
491 pide = ((unsigned long)res_ptr - (unsigned long)ioc->res_map); in sba_search_bitmap()
498 ioc->res_bitshift = 0; in sba_search_bitmap()
507 uint bitshiftcnt = ROUNDUP(ioc->res_bitshift, o); in sba_search_bitmap()
523 pide = ((unsigned long)res_ptr - (unsigned long)ioc->res_map); in sba_search_bitmap()
537 ioc->res_bitshift = bitshiftcnt + bits_wanted; in sba_search_bitmap()
542 ioc->res_hint = (unsigned long *) ioc->res_map; in sba_search_bitmap()
543 ioc->res_bitshift = 0; in sba_search_bitmap()
545 ioc->res_hint = res_ptr; in sba_search_bitmap()
560 sba_alloc_range(struct ioc *ioc, size_t size) in sba_alloc_range() argument
578 pide = sba_search_bitmap(ioc, pages_needed); in sba_alloc_range()
579 if (pide >= (ioc->res_size << 3)) { in sba_alloc_range()
580 pide = sba_search_bitmap(ioc, pages_needed); in sba_alloc_range()
581 if (pide >= (ioc->res_size << 3)) in sba_alloc_range()
582 panic(__FILE__ ": I/O MMU @ %lx is out of mapping resources\n", ioc->ioc_hpa); in sba_alloc_range()
587 if(0x00 != ((u8 *) ioc->pdir_base)[pide*sizeof(u64) + 7]) { in sba_alloc_range()
588 sba_dump_pdir_entry(ioc, "sba_search_bitmap() botched it?", pide); in sba_alloc_range()
594 (uint) ((unsigned long) ioc->res_hint - (unsigned long) ioc->res_map), in sba_alloc_range()
595 ioc->res_bitshift ); in sba_alloc_range()
604 ioc->avg_search[ioc->avg_idx++] = cr_start; in sba_alloc_range()
605 ioc->avg_idx &= SBA_SEARCH_SAMPLE - 1; in sba_alloc_range()
607 ioc->used_pages += pages_needed; in sba_alloc_range()
623 sba_free_range(struct ioc *ioc, dma_addr_t iova, size_t size) in sba_free_range() argument
625 unsigned long iovp = SBA_IOVP(ioc, iova); in sba_free_range()
628 unsigned long *res_ptr = (unsigned long *) &((ioc)->res_map[ridx & ~RESMAP_IDX_MASK]); in sba_free_range()
640 ioc->used_pages -= bits_not_wanted; in sba_free_range()
658 #define SBA_DMA_HINT(ioc, val) ((val) << (ioc)->hint_shift_pdir) argument
746 sba_mark_invalid(struct ioc *ioc, dma_addr_t iova, size_t byte_cnt) in sba_mark_invalid() argument
748 u32 iovp = (u32) SBA_IOVP(ioc,iova); in sba_mark_invalid()
762 if (0x80 != (((u8 *) ioc->pdir_base)[off])) { in sba_mark_invalid()
763 sba_dump_pdir_entry(ioc,"sba_mark_invalid()", PDIR_INDEX(iovp)); in sba_mark_invalid()
769 ASSERT( off < ioc->pdir_size); in sba_mark_invalid()
779 ((u8 *)(ioc->pdir_base))[off] = 0; in sba_mark_invalid()
788 ASSERT(0x80 == (((u8 *) ioc->pdir_base)[off] & 0x80)); in sba_mark_invalid()
790 ((u8 *)(ioc->pdir_base))[off] = 0; in sba_mark_invalid()
796 WRITE_REG(iovp, ioc->ioc_hpa+IOC_PCOM); in sba_mark_invalid()
832 struct ioc *ioc; in sba_map_single() local
843 ioc = GET_IOC(dev); in sba_map_single()
844 ASSERT(ioc); in sba_map_single()
852 spin_lock_irqsave(&ioc->res_lock, flags); in sba_map_single()
854 sba_check_pdir(ioc,"Check before sba_map_single()"); in sba_map_single()
858 ioc->msingle_calls++; in sba_map_single()
859 ioc->msingle_pages += size >> IOVP_SHIFT; in sba_map_single()
861 pide = sba_alloc_range(ioc, size); in sba_map_single()
867 pdir_start = &(ioc->pdir_base[pide]); in sba_map_single()
891 sba_check_pdir(ioc,"Check after sba_map_single()"); in sba_map_single()
893 spin_unlock_irqrestore(&ioc->res_lock, flags); in sba_map_single()
894 return SBA_IOVA(ioc, iovp, offset, DEFAULT_DMA_HINT_REG); in sba_map_single()
910 struct ioc *ioc; in sba_unmap_single() local
918 ioc = GET_IOC(dev); in sba_unmap_single()
919 ASSERT(ioc); in sba_unmap_single()
930 spin_lock_irqsave(&ioc->res_lock, flags); in sba_unmap_single()
933 ioc->usingle_calls++; in sba_unmap_single()
934 ioc->usingle_pages += size >> IOVP_SHIFT; in sba_unmap_single()
938 d = &(ioc->saved[ioc->saved_cnt]); in sba_unmap_single()
941 if (++(ioc->saved_cnt) >= DELAYED_RESOURCE_CNT) { in sba_unmap_single()
942 int cnt = ioc->saved_cnt; in sba_unmap_single()
944 sba_mark_invalid(ioc, d->iova, d->size); in sba_unmap_single()
945 sba_free_range(ioc, d->iova, d->size); in sba_unmap_single()
948 ioc->saved_cnt = 0; in sba_unmap_single()
949 READ_REG(ioc->ioc_hpa+IOC_PCOM); /* flush purges */ in sba_unmap_single()
952 sba_mark_invalid(ioc, iova, size); in sba_unmap_single()
953 sba_free_range(ioc, iova, size); in sba_unmap_single()
954 READ_REG(ioc->ioc_hpa+IOC_PCOM); /* flush purges */ in sba_unmap_single()
956 spin_unlock_irqrestore(&ioc->res_lock, flags); in sba_unmap_single()
1040 struct ioc *ioc, in sba_fill_pdir() argument
1077 pdirp = &(ioc->pdir_base[pide >> IOVP_SHIFT]); in sba_fill_pdir()
1096 ioc->msg_pages += cnt >> IOVP_SHIFT; in sba_fill_pdir()
1139 sba_coalesce_chunks( struct ioc *ioc, in sba_coalesce_chunks() argument
1252 | (sba_alloc_range(ioc, dma_len) << IOVP_SHIFT) in sba_coalesce_chunks()
1273 struct ioc *ioc; in sba_map_sg() local
1280 ioc = GET_IOC(dev); in sba_map_sg()
1281 ASSERT(ioc); in sba_map_sg()
1292 spin_lock_irqsave(&ioc->res_lock, flags); in sba_map_sg()
1295 if (sba_check_pdir(ioc,"Check before sba_map_sg()")) in sba_map_sg()
1297 sba_dump_sg(ioc, sglist, nents); in sba_map_sg()
1303 ioc->msg_calls++; in sba_map_sg()
1314 coalesced = sba_coalesce_chunks(ioc, sglist, nents); in sba_map_sg()
1324 filled = sba_fill_pdir(ioc, sglist, nents); in sba_map_sg()
1327 if (sba_check_pdir(ioc,"Check after sba_map_sg()")) in sba_map_sg()
1329 sba_dump_sg(ioc, sglist, nents); in sba_map_sg()
1334 spin_unlock_irqrestore(&ioc->res_lock, flags); in sba_map_sg()
1355 struct ioc *ioc; in sba_unmap_sg() local
1364 ioc = GET_IOC(dev); in sba_unmap_sg()
1365 ASSERT(ioc); in sba_unmap_sg()
1368 ioc->usg_calls++; in sba_unmap_sg()
1372 spin_lock_irqsave(&ioc->res_lock, flags); in sba_unmap_sg()
1373 sba_check_pdir(ioc,"Check before sba_unmap_sg()"); in sba_unmap_sg()
1374 spin_unlock_irqrestore(&ioc->res_lock, flags); in sba_unmap_sg()
1381 …ioc->usg_pages += ((sg_dma_address(sglist) & ~IOVP_MASK) + sg_dma_len(sglist) + IOVP_SIZE - 1) >> … in sba_unmap_sg()
1382 ioc->usingle_calls--; /* kluge since call is unmap_sg() */ in sba_unmap_sg()
1390 spin_lock_irqsave(&ioc->res_lock, flags); in sba_unmap_sg()
1391 sba_check_pdir(ioc,"Check after sba_unmap_sg()"); in sba_unmap_sg()
1392 spin_unlock_irqrestore(&ioc->res_lock, flags); in sba_unmap_sg()
1433 PAT_MOD(mod)->mod_info.ioc = PAT_GET_IOC(temp); in sba_get_pat_resources()
1543 sba_ioc_init(struct parisc_device *sba, struct ioc *ioc, int ioc_num) in sba_ioc_init() argument
1590 ioc->pdir_size = pdir_size = (iova_space_size/IOVP_SIZE) * sizeof(u64); in sba_ioc_init()
1598 __FUNCTION__, ioc->ioc_hpa, (int) (physmem>>20), in sba_ioc_init()
1602 ioc->hint_shift_pdir = iov_order + PAGE_SHIFT; in sba_ioc_init()
1603 ioc->hint_mask_pdir = ~(0x3 << (iov_order + PAGE_SHIFT)); in sba_ioc_init()
1605 ioc->pdir_base = sba_alloc_pdir(pdir_size); in sba_ioc_init()
1608 __FUNCTION__, ioc->pdir_base, pdir_size, in sba_ioc_init()
1609 ioc->hint_shift_pdir, ioc->hint_mask_pdir); in sba_ioc_init()
1611 ASSERT((((unsigned long) ioc->pdir_base) & PAGE_MASK) == (unsigned long) ioc->pdir_base); in sba_ioc_init()
1612 WRITE_REG64(virt_to_phys(ioc->pdir_base), ioc->ioc_hpa + IOC_PDIR_BASE); in sba_ioc_init()
1622 ioc->ibase = IOC_IOVA_SPACE_BASE | 1; /* bit 0 == enable bit */ in sba_ioc_init()
1623 ioc->imask = iova_space_mask; /* save it */ in sba_ioc_init()
1626 __FUNCTION__, ioc->ibase, ioc->imask); in sba_ioc_init()
1640 lba_set_iregs(lba, ioc->ibase, ioc->imask); in sba_ioc_init()
1646 WRITE_REG(ioc->ibase, ioc->ioc_hpa+IOC_IBASE); in sba_ioc_init()
1647 WRITE_REG(ioc->imask, ioc->ioc_hpa+IOC_IMASK); in sba_ioc_init()
1650 WRITE_REG(0, ioc->ioc_hpa+IOC_TCNFG); in sba_ioc_init()
1656 WRITE_REG(0 | 31, ioc->ioc_hpa+IOC_PCOM); in sba_ioc_init()
1696 sba_dev->ioc[0].ioc_hpa = ASTRO_IOC_OFFSET; in sba_hw_init()
1699 sba_dev->ioc[0].ioc_hpa = sba_dev->ioc[1].ioc_hpa = 0; in sba_hw_init()
1705 sba_dev->ioc[i].ioc_hpa += sba_dev->sba_hpa + IKE_IOC_OFFSET(i); in sba_hw_init()
1710 WRITE_REG(HF_ENABLE, sba_dev->ioc[i].ioc_hpa + ROPE0_CTL); in sba_hw_init()
1711 WRITE_REG(HF_ENABLE, sba_dev->ioc[i].ioc_hpa + ROPE1_CTL); in sba_hw_init()
1712 WRITE_REG(HF_ENABLE, sba_dev->ioc[i].ioc_hpa + ROPE2_CTL); in sba_hw_init()
1713 WRITE_REG(HF_ENABLE, sba_dev->ioc[i].ioc_hpa + ROPE3_CTL); in sba_hw_init()
1714 WRITE_REG(HF_ENABLE, sba_dev->ioc[i].ioc_hpa + ROPE4_CTL); in sba_hw_init()
1715 WRITE_REG(HF_ENABLE, sba_dev->ioc[i].ioc_hpa + ROPE5_CTL); in sba_hw_init()
1716 WRITE_REG(HF_ENABLE, sba_dev->ioc[i].ioc_hpa + ROPE6_CTL); in sba_hw_init()
1717 WRITE_REG(HF_ENABLE, sba_dev->ioc[i].ioc_hpa + ROPE7_CTL); in sba_hw_init()
1720 READ_REG(sba_dev->ioc[i].ioc_hpa + ROPE7_CTL); in sba_hw_init()
1722 sba_ioc_init(sba_dev->dev, &(sba_dev->ioc[i]), i); in sba_hw_init()
1746 res_size = sba_dev->ioc[i].pdir_size/sizeof(u64); /* entries */ in sba_common_init()
1757 sba_dev->ioc[i].res_size = res_size; in sba_common_init()
1758 sba_dev->ioc[i].res_map = (char *) __get_free_pages(GFP_KERNEL, get_order(res_size)); in sba_common_init()
1761 iterate_pages( sba_dev->ioc[i].res_map, res_size, in sba_common_init()
1765 if (NULL == sba_dev->ioc[i].res_map) in sba_common_init()
1770 memset(sba_dev->ioc[i].res_map, 0, res_size); in sba_common_init()
1772 sba_dev->ioc[i].res_hint = (unsigned long *) in sba_common_init()
1773 &(sba_dev->ioc[i].res_map[L1_CACHE_BYTES]); in sba_common_init()
1777 sba_dev->ioc[i].res_map[0] = 0x80; in sba_common_init()
1778 sba_dev->ioc[i].pdir_base[0] = 0xeeffc0addbba0080ULL; in sba_common_init()
1787 long *p_start = (long *) &(sba_dev->ioc[i].res_map[idx_start]); in sba_common_init()
1788 long *p_end = (long *) &(sba_dev->ioc[i].res_map[idx_end]); in sba_common_init()
1797 iterate_pages( sba_dev->ioc[i].res_map, res_size, in sba_common_init()
1799 iterate_pages( sba_dev->ioc[i].pdir_base, sba_dev->ioc[i].pdir_size, in sba_common_init()
1804 __FUNCTION__, i, res_size, sba_dev->ioc[i].res_map); in sba_common_init()
1828 struct ioc *ioc = &sba_dev->ioc[0]; /* FIXME: Multi-IOC support! */ in sba_proc_info() local
1829 int total_pages = (int) (ioc->res_size << 3); /* 8 bits per byte */ in sba_proc_info()
1839 (int) ((ioc->res_size << 3) * sizeof(u64)), /* 8 bits/byte */ in sba_proc_info()
1843 total_pages - ioc->used_pages, ioc->used_pages, in sba_proc_info()
1844 (int) (ioc->used_pages * 100 / total_pages)); in sba_proc_info()
1847 buf, ioc->res_size, ioc->res_size << 3); /* 8 bits per byte */ in sba_proc_info()
1849 min = max = ioc->avg_search[0]; in sba_proc_info()
1851 avg += ioc->avg_search[i]; in sba_proc_info()
1852 if (ioc->avg_search[i] > max) max = ioc->avg_search[i]; in sba_proc_info()
1853 if (ioc->avg_search[i] < min) min = ioc->avg_search[i]; in sba_proc_info()
1860 buf, ioc->msingle_calls, ioc->msingle_pages, in sba_proc_info()
1861 (int) ((ioc->msingle_pages * 1000)/ioc->msingle_calls)); in sba_proc_info()
1864 min = ioc->usingle_calls; in sba_proc_info()
1865 max = ioc->usingle_pages - ioc->usg_pages; in sba_proc_info()
1871 buf, ioc->msg_calls, ioc->msg_pages, in sba_proc_info()
1872 (int) ((ioc->msg_pages * 1000)/ioc->msg_calls)); in sba_proc_info()
1875 buf, ioc->usg_calls, ioc->usg_pages, in sba_proc_info()
1876 (int) ((ioc->usg_pages * 1000)/ioc->usg_calls)); in sba_proc_info()
1887 struct ioc *ioc = &sba_dev->ioc[0]; /* FIXME: Mutli-IOC suppoer! */
1888 unsigned int *res_ptr = (unsigned int *)ioc->res_map;
1892 for(i = 0; i < (ioc->res_size / sizeof(unsigned int)); ++i, ++res_ptr) {
1994 spin_lock_init(&(sba_dev->ioc[i].res_lock)); in sba_driver_callback()
2050 return &(sba->ioc[iocnum]); in sba_get_iommu()