if (buffer_list[i].addr & ~PAGE_MASK) 
if (i != 0 && buffer_list[i].addr & ~PAGE_MASK) 
static struct ib_mr *mthca_reg_phys_mr(struct ib_pd       *pd,				       struct ib_phys_buf *buffer_list,				       int                 num_phys_buf,				       int                 acc,				       u64                *iova_start){	struct mthca_mr *mr;	u64 *page_list;	u64 total_size;	u64 mask;	int shift;	int npages;	int err;	int i, j, n;	/* First check that we have enough alignment */	if ((*iova_start & ~PAGE_MASK) != (buffer_list[0].addr & ~PAGE_MASK))		return ERR_PTR(-EINVAL);	if (num_phys_buf > 1 &&	    ((buffer_list[0].addr + buffer_list[0].size) & ~PAGE_MASK))		return ERR_PTR(-EINVAL);	mask = 0;	total_size = 0;	for (i = 0; i < num_phys_buf; ++i) {		if (buffer_list[i].addr & ~PAGE_MASK)			return ERR_PTR(-EINVAL);		if (i != 0 && i != num_phys_buf - 1 &&		    (buffer_list[i].size & ~PAGE_MASK))			return ERR_PTR(-EINVAL);		total_size += buffer_list[i].size;		if (i > 0)			mask |= buffer_list[i].addr;	}	/* Find largest page shift we can use to cover buffers */	for (shift = PAGE_SHIFT; shift < 31; ++shift)		if (num_phys_buf > 1) {			if ((1ULL << shift) & mask)				break;		} else {			if (1ULL << shift >=			    buffer_list[0].size +			    (buffer_list[0].addr & ((1ULL << shift) - 1)))				break;		}	buffer_list[0].size += buffer_list[0].addr & ((1ULL << shift) - 1);	buffer_list[0].addr &= ~0ull << shift;	mr = kmalloc(sizeof *mr, GFP_KERNEL);	if (!mr)		return ERR_PTR(-ENOMEM);	npages = 0;	for (i = 0; i < num_phys_buf; ++i)		npages += (buffer_list[i].size + (1ULL << shift) - 1) >> shift;	if (!npages)		return &mr->ibmr;	page_list = kmalloc(npages * sizeof *page_list, GFP_KERNEL);	if (!page_list) {		kfree(mr);		return ERR_PTR(-ENOMEM);	}	n = 0;	for (i = 0; i < num_phys_buf; ++i)		for (j = 0;		     j < (buffer_list[i].size + (1ULL << shift) - 1) >> shift;		     ++j)			page_list[n++] = buffer_list[i].addr + ((u64) j << shift);	mthca_dbg(to_mdev(pd->device), "Registering memory at %llx (iova %llx) "		  "in PD %x; shift %d, npages %d.\n",		  (unsigned long long) buffer_list[0].addr,		  (unsigned long long) *iova_start,		  to_mpd(pd)->pd_num,		  shift, npages);	err = mthca_mr_alloc_phys(to_mdev(pd->device),				  to_mpd(pd)->pd_num,				  page_list, shift, npages,				  *iova_start, total_size,				  convert_access(acc), mr);	if (err) {		kfree(mr);		return ERR_PTR(err);	}	kfree(page_list);	return &mr->ibmr;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/72c30290bea3a24e2ab56c7a51af47012f7465a4/mthca_provider.c/clean/drivers/infiniband/hw/mthca/mthca_provider.c