kfree(mailbox); 
mthca_free_mailbox(dev, mailbox); 
int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd,		    u32 access, struct mthca_fmr *mr){	struct mthca_mpt_entry *mpt_entry;	void *mailbox;	u64 mtt_seg;	u32 key, idx;	u8 status;	int list_len = mr->attr.max_pages;	int err = -ENOMEM;	int i;	might_sleep();	if (mr->attr.page_size < 12 || mr->attr.page_size >= 32)		return -EINVAL;	/* For Arbel, all MTTs must fit in the same page. */	if (mthca_is_memfree(dev) &&	    mr->attr.max_pages * sizeof *mr->mem.arbel.mtts > PAGE_SIZE)		return -EINVAL;	mr->maps = 0;	key = mthca_alloc(&dev->mr_table.mpt_alloc);	if (key == -1)		return -ENOMEM;	idx = key & (dev->limits.num_mpts - 1);	mr->ibmr.rkey = mr->ibmr.lkey = hw_index_to_key(dev, key);	if (mthca_is_memfree(dev)) {		err = mthca_table_get(dev, dev->mr_table.mpt_table, key);		if (err)			goto err_out_mpt_free;		mr->mem.arbel.mpt = mthca_table_find(dev->mr_table.mpt_table, key);		BUG_ON(!mr->mem.arbel.mpt);	} else		mr->mem.tavor.mpt = dev->mr_table.tavor_fmr.mpt_base +		       	sizeof *(mr->mem.tavor.mpt) * idx;	mr->mtt = __mthca_alloc_mtt(dev, list_len, dev->mr_table.fmr_mtt_buddy);	if (IS_ERR(mr->mtt))		goto err_out_table;	mtt_seg = mr->mtt->first_seg * MTHCA_MTT_SEG_SIZE;	if (mthca_is_memfree(dev)) {		mr->mem.arbel.mtts = mthca_table_find(dev->mr_table.mtt_table,						      mr->mtt->first_seg);		BUG_ON(!mr->mem.arbel.mtts);	} else		mr->mem.tavor.mtts = dev->mr_table.tavor_fmr.mtt_base + mtt_seg;	mailbox = kmalloc(sizeof *mpt_entry + MTHCA_CMD_MAILBOX_EXTRA,			  GFP_KERNEL);	if (!mailbox)		goto err_out_free_mtt;	mpt_entry = MAILBOX_ALIGN(mailbox);	mpt_entry->flags = cpu_to_be32(MTHCA_MPT_FLAG_SW_OWNS     |				       MTHCA_MPT_FLAG_MIO         |				       MTHCA_MPT_FLAG_REGION      |				       access);	mpt_entry->page_size = cpu_to_be32(mr->attr.page_size - 12);	mpt_entry->key       = cpu_to_be32(key);	mpt_entry->pd        = cpu_to_be32(pd);	memset(&mpt_entry->start, 0,	       sizeof *mpt_entry - offsetof(struct mthca_mpt_entry, start));	mpt_entry->mtt_seg   = cpu_to_be64(dev->mr_table.mtt_base + mtt_seg);	if (0) {		mthca_dbg(dev, "Dumping MPT entry %08x:\n", mr->ibmr.lkey);		for (i = 0; i < sizeof (struct mthca_mpt_entry) / 4; ++i) {			if (i % 4 == 0)				printk("[%02x] ", i * 4);			printk(" %08x", be32_to_cpu(((u32 *) mpt_entry)[i]));			if ((i + 1) % 4 == 0)				printk("\n");		}	}	err = mthca_SW2HW_MPT(dev, mpt_entry,			      key & (dev->limits.num_mpts - 1),			      &status);	if (err) {		mthca_warn(dev, "SW2HW_MPT failed (%d)\n", err);		goto err_out_mailbox_free;	}	if (status) {		mthca_warn(dev, "SW2HW_MPT returned status 0x%02x\n",			   status);		err = -EINVAL;		goto err_out_mailbox_free;	}	kfree(mailbox);	return 0;err_out_mailbox_free:	kfree(mailbox);err_out_free_mtt:	mthca_free_mtt(dev, mr->mtt);err_out_table:	mthca_table_put(dev, dev->mr_table.mpt_table, key);err_out_mpt_free:	mthca_free(&dev->mr_table.mpt_alloc, mr->ibmr.lkey);	return err;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/ed878458eeff9754d66f1b0325df6ebbfcdce668/mthca_mr.c/clean/drivers/infiniband/hw/mthca/mthca_mr.c