int pass = 0;
unsigned long align_mask;
unsigned long boundary_size;
+ unsigned long flags;
align_mask = 0xffffffffffffffffl >> (64 - align_order);
return DMA_ERROR_CODE;
}
+ spin_lock_irqsave(&(tbl->it_lock), flags);
+
if (handle && *handle)
start = *handle;
else
goto again;
} else {
/* Third failure, give up */
+ spin_unlock_irqrestore(&(tbl->it_lock), flags);
return DMA_ERROR_CODE;
}
}
if (handle)
*handle = end;
+ spin_unlock_irqrestore(&(tbl->it_lock), flags);
return n;
}
unsigned long mask, unsigned int align_order,
struct dma_attrs *attrs)
{
- unsigned long entry, flags;
+ unsigned long entry;
dma_addr_t ret = DMA_ERROR_CODE;
int build_fail;
- spin_lock_irqsave(&(tbl->it_lock), flags);
entry = iommu_range_alloc(dev, tbl, npages, NULL, mask, align_order);
- spin_unlock_irqrestore(&(tbl->it_lock), flags);
if (unlikely(entry == DMA_ERROR_CODE))
return DMA_ERROR_CODE;
return true;
}
-static void __iommu_free_locked(struct iommu_table *tbl, dma_addr_t dma_addr,
- unsigned int npages)
-{
- unsigned long entry, free_entry;
-
- BUG_ON(!spin_is_locked(&tbl->it_lock));
-
- entry = dma_addr >> IOMMU_PAGE_SHIFT;
- free_entry = entry - tbl->it_offset;
-
- if (!iommu_free_check(tbl, dma_addr, npages))
- return;
-
- ppc_md.tce_free(tbl, entry, npages);
- bitmap_clear(tbl->it_map, free_entry, npages);
-}
-
static void __iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
unsigned int npages)
{
struct dma_attrs *attrs)
{
dma_addr_t dma_next = 0, dma_addr;
- unsigned long flags;
struct scatterlist *s, *outs, *segstart;
int outcount, incount, i, build_fail = 0;
unsigned int align;
DBG("sg mapping %d elements:\n", nelems);
- spin_lock_irqsave(&(tbl->it_lock), flags);
-
max_seg_size = dma_get_max_seg_size(dev);
for_each_sg(sglist, s, nelems, i) {
unsigned long vaddr, npages, entry, slen;
if (ppc_md.tce_flush)
ppc_md.tce_flush(tbl);
- spin_unlock_irqrestore(&(tbl->it_lock), flags);
-
DBG("mapped %d elements:\n", outcount);
/* For the sake of iommu_unmap_sg, we clear out the length in the
vaddr = s->dma_address & IOMMU_PAGE_MASK;
npages = iommu_num_pages(s->dma_address, s->dma_length,
IOMMU_PAGE_SIZE);
- __iommu_free_locked(tbl, vaddr, npages);
+ __iommu_free(tbl, vaddr, npages);
s->dma_address = DMA_ERROR_CODE;
s->dma_length = 0;
}
if (s == outs)
break;
}
- spin_unlock_irqrestore(&(tbl->it_lock), flags);
return 0;
}
struct dma_attrs *attrs)
{
struct scatterlist *sg;
- unsigned long flags;
BUG_ON(direction == DMA_NONE);
if (!tbl)
return;
- spin_lock_irqsave(&(tbl->it_lock), flags);
-
sg = sglist;
while (nelems--) {
unsigned int npages;
break;
npages = iommu_num_pages(dma_handle, sg->dma_length,
IOMMU_PAGE_SIZE);
- __iommu_free_locked(tbl, dma_handle, npages);
+ __iommu_free(tbl, dma_handle, npages);
sg = sg_next(sg);
}
*/
if (ppc_md.tce_flush)
ppc_md.tce_flush(tbl);
-
- spin_unlock_irqrestore(&(tbl->it_lock), flags);
}
static void iommu_table_clear(struct iommu_table *tbl)