ctx = iommu->iommu_cur_ctx++; 
ctx = iommu_alloc_ctx(iommu); 
int pci_map_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, int direction){	struct pcidev_cookie *pcp;	struct pci_iommu *iommu;	struct pci_strbuf *strbuf;	unsigned long flags, ctx, npages, iopte_protection;	iopte_t *base;	u32 dma_base;	struct scatterlist *sgtmp;	int used;	/* Fast path single entry scatterlists. */	if (nelems == 1) {		sglist->dma_address =			pci_map_single(pdev,				       (page_address(sglist->page) + sglist->offset),				       sglist->length, direction);		sglist->dma_length = sglist->length;		return 1;	}	pcp = pdev->sysdata;	iommu = pcp->pbm->iommu;	strbuf = &pcp->pbm->stc;		if (direction == PCI_DMA_NONE)		BUG();	/* Step 1: Prepare scatter list. */	npages = prepare_sg(sglist, nelems);	/* Step 2: Allocate a cluster. */	spin_lock_irqsave(&iommu->lock, flags);	base = alloc_streaming_cluster(iommu, npages);	if (base == NULL)		goto bad;	dma_base = iommu->page_table_map_base + ((base - iommu->page_table) << IO_PAGE_SHIFT);	/* Step 3: Normalize DMA addresses. */	used = nelems;	sgtmp = sglist;	while (used && sgtmp->dma_length) {		sgtmp->dma_address += dma_base;		sgtmp++;		used--;	}	used = nelems - used;	/* Step 4: Choose a context if necessary. */	ctx = 0;	if (iommu->iommu_ctxflush)		ctx = iommu->iommu_cur_ctx++;	/* Step 5: Create the mappings. */	if (strbuf->strbuf_enabled)		iopte_protection = IOPTE_STREAMING(ctx);	else		iopte_protection = IOPTE_CONSISTENT(ctx);	if (direction != PCI_DMA_TODEVICE)		iopte_protection |= IOPTE_WRITE;	fill_sg (base, sglist, used, nelems, iopte_protection);#ifdef VERIFY_SG	verify_sglist(sglist, nelems, base, npages);#endif	spin_unlock_irqrestore(&iommu->lock, flags);	return used;bad:	spin_unlock_irqrestore(&iommu->lock, flags);	return PCI_DMA_ERROR_CODE;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/7c963ad1d113790a8c723a178988b675868f3abe/pci_iommu.c/clean/arch/sparc64/kernel/pci_iommu.c