cq->queue.direct.buf = pci_alloc_consistent(dev->pdev, size, &t); 
cq->queue.direct.buf = dma_alloc_coherent(&dev->pdev->dev, size, &t, GFP_KERNEL); 
static int mthca_alloc_cq_buf(struct mthca_dev *dev, int size,			      struct mthca_cq *cq){	int err = -ENOMEM;	int npages, shift;	u64 *dma_list = NULL;	dma_addr_t t;	int i;	if (size <= MTHCA_MAX_DIRECT_CQ_SIZE) {		cq->is_direct = 1;		npages        = 1;		shift         = get_order(size) + PAGE_SHIFT;		cq->queue.direct.buf = pci_alloc_consistent(dev->pdev,							    size, &t);		if (!cq->queue.direct.buf)			return -ENOMEM;		pci_unmap_addr_set(&cq->queue.direct, mapping, t);		memset(cq->queue.direct.buf, 0, size);		while (t & ((1 << shift) - 1)) {			--shift;			npages *= 2;		}		dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);		if (!dma_list)			goto err_free;		for (i = 0; i < npages; ++i)			dma_list[i] = t + i * (1 << shift);	} else {		cq->is_direct = 0;		npages        = (size + PAGE_SIZE - 1) / PAGE_SIZE;		shift         = PAGE_SHIFT;		dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);		if (!dma_list)			return -ENOMEM;		cq->queue.page_list = kmalloc(npages * sizeof *cq->queue.page_list,					      GFP_KERNEL);		if (!cq->queue.page_list)			goto err_out;		for (i = 0; i < npages; ++i)			cq->queue.page_list[i].buf = NULL;		for (i = 0; i < npages; ++i) {			cq->queue.page_list[i].buf =				pci_alloc_consistent(dev->pdev, PAGE_SIZE, &t);			if (!cq->queue.page_list[i].buf)				goto err_free;			dma_list[i] = t;			pci_unmap_addr_set(&cq->queue.page_list[i], mapping, t);			memset(cq->queue.page_list[i].buf, 0, PAGE_SIZE);		}	}	err = mthca_mr_alloc_phys(dev, dev->driver_pd.pd_num,				  dma_list, shift, npages,				  0, size,				  MTHCA_MPT_FLAG_LOCAL_WRITE |				  MTHCA_MPT_FLAG_LOCAL_READ,				  &cq->mr);	if (err)		goto err_free;	kfree(dma_list);	return 0;err_free:	mthca_free_cq_buf(dev, cq);err_out:	kfree(dma_list);	return err;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/64dc81fca7f6d5c51e50ffa850640ad8358acd1f/mthca_cq.c/clean/drivers/infiniband/hw/mthca/mthca_cq.c