kernels/linux-2.4.0/arch/ia64/lib/swiotlb.c
/*
 * dma_addr is the kernel virtual address of the bounce buffer to unmap.
 */
dma_addr is the kernel virtual address of the bounce buffer to unmap.
dma_addr is the kernel virtual address of the bounce buffer to unmap .
static void
unmap_single (struct pci_dev *hwdev, char *dma_addr, size_t size, int direction)
{
	unsigned long flags;
	int i, nslots = ALIGN(size, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT;
	int index = (dma_addr - io_tlb_start) >> IO_TLB_SHIFT;
	char *buffer = io_tlb_orig_addr[index];
	if ((direction == PCI_DMA_FROMDEVICE) || (direction == PCI_DMA_BIDIRECTIONAL))
		memcpy(buffer, dma_addr, size);
	spin_lock_irqsave(&io_tlb_lock, flags);
	{
		int count = ((index + nslots) < io_tlb_nslabs ? io_tlb_list[index + nslots] : 0);
		for (i = index + nslots - 1; i >= index; i--)
			io_tlb_list[i] = ++count;
		for (i = index - 1; (i >= 0) && io_tlb_list[i]; i--)
			io_tlb_list[i] = ++count;
	}
	spin_unlock_irqrestore(&io_tlb_lock, flags);
}
static void unmap_single ( struct pci_dev * hwdev , char * dma_addr , size_t size , int direction ) { unsigned long flags ; int i , nslots = ALIGN ( size , 1 << IO_TLB_SHIFT ) >> IO_TLB_SHIFT ; int index = ( dma_addr - io_tlb_start ) >> IO_TLB_SHIFT ; char * buffer = io_tlb_orig_addr [ index ] ; if ( ( direction == PCI_DMA_FROMDEVICE ) || ( direction == PCI_DMA_BIDIRECTIONAL ) ) memcpy ( buffer , dma_addr , size ) ; spin_lock_irqsave ( & io_tlb_lock , flags ) ; { int count = ( ( index + nslots ) < io_tlb_nslabs ? io_tlb_list [ index + nslots ] : 0 ) ; for ( i = index + nslots - 1 ; i >= index ; i -- ) io_tlb_list [ i ] = ++ count ; for ( i = index - 1 ; ( i >= 0 ) && io_tlb_list [ i ] ; i -- ) io_tlb_list [ i ] = ++ count ; } spin_unlock_irqrestore ( & io_tlb_lock , flags ) ; }
dma_addr is the kernel virtual address of the bounce buffer to unmap.
dma_addr is the kernel virtual address of the bounce buffer to unmap .
/*
	 * First, sync the memory before unmapping the entry
	 */ /*
 	 	 * bounce... copy the data back into the original buffer * and delete the
 	 	 * bounce buffer.
 	 	 */ /*
	 * Return the buffer to the free list by setting the corresponding entries to
	 * indicate the number of contigous entries available.  While returning the
	 * entries to the free list, we merge the entries with slots below and above the
	 * pool being returned.
	 */ /*
		 * Step 1: return the slots to the free list, merging the slots with
		 * superceeding slots
		 */ /*
		 * Step 2: merge the returned slots with the preceeding slots, if
		 * available (non zero)
		 */