|
@@ -267,51 +267,3 @@ void __init ld_mmu_iounit(void)
|
|
BTFIXUPSET_CALL(mmu_unmap_dma_area, iounit_unmap_dma_area, BTFIXUPCALL_NORM);
|
|
BTFIXUPSET_CALL(mmu_unmap_dma_area, iounit_unmap_dma_area, BTFIXUPCALL_NORM);
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
-
|
|
|
|
-__u32 iounit_map_dma_init(struct sbus_bus *sbus, int size)
|
|
|
|
-{
|
|
|
|
- int i, j, k, npages;
|
|
|
|
- unsigned long rotor, scan, limit;
|
|
|
|
- unsigned long flags;
|
|
|
|
- __u32 ret;
|
|
|
|
- struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
|
|
|
|
-
|
|
|
|
- npages = (size + (PAGE_SIZE-1)) >> PAGE_SHIFT;
|
|
|
|
- i = 0x0213;
|
|
|
|
- spin_lock_irqsave(&iounit->lock, flags);
|
|
|
|
-next: j = (i & 15);
|
|
|
|
- rotor = iounit->rotor[j - 1];
|
|
|
|
- limit = iounit->limit[j];
|
|
|
|
- scan = rotor;
|
|
|
|
-nexti: scan = find_next_zero_bit(iounit->bmap, limit, scan);
|
|
|
|
- if (scan + npages > limit) {
|
|
|
|
- if (limit != rotor) {
|
|
|
|
- limit = rotor;
|
|
|
|
- scan = iounit->limit[j - 1];
|
|
|
|
- goto nexti;
|
|
|
|
- }
|
|
|
|
- i >>= 4;
|
|
|
|
- if (!(i & 15))
|
|
|
|
- panic("iounit_map_dma_init: Couldn't find free iopte slots for %d bytes\n", size);
|
|
|
|
- goto next;
|
|
|
|
- }
|
|
|
|
- for (k = 1, scan++; k < npages; k++)
|
|
|
|
- if (test_bit(scan++, iounit->bmap))
|
|
|
|
- goto nexti;
|
|
|
|
- iounit->rotor[j - 1] = (scan < limit) ? scan : iounit->limit[j - 1];
|
|
|
|
- scan -= npages;
|
|
|
|
- ret = IOUNIT_DMA_BASE + (scan << PAGE_SHIFT);
|
|
|
|
- for (k = 0; k < npages; k++, scan++)
|
|
|
|
- set_bit(scan, iounit->bmap);
|
|
|
|
- spin_unlock_irqrestore(&iounit->lock, flags);
|
|
|
|
- return ret;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-__u32 iounit_map_dma_page(__u32 vaddr, void *addr, struct sbus_bus *sbus)
|
|
|
|
-{
|
|
|
|
- int scan = (vaddr - IOUNIT_DMA_BASE) >> PAGE_SHIFT;
|
|
|
|
- struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
|
|
|
|
-
|
|
|
|
- iounit->page_table[scan] = MKIOPTE(__pa(((unsigned long)addr) & PAGE_MASK));
|
|
|
|
- return vaddr + (((unsigned long)addr) & ~PAGE_MASK);
|
|
|
|
-}
|
|
|