mpt_entry = MAILBOX_ALIGN(mailbox); 
mpt_entry = mailbox->buf; 
int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,		   u64 iova, u64 total_size, u32 access, struct mthca_mr *mr){	void *mailbox;	struct mthca_mpt_entry *mpt_entry;	u32 key;	int i;	int err;	u8 status;	might_sleep();	WARN_ON(buffer_size_shift >= 32);	key = mthca_alloc(&dev->mr_table.mpt_alloc);	if (key == -1)		return -ENOMEM;	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;	}	mailbox = kmalloc(sizeof *mpt_entry + MTHCA_CMD_MAILBOX_EXTRA,			  GFP_KERNEL);	if (!mailbox) {		err = -ENOMEM;		goto err_out_table;	}	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);	if (!mr->mtt)		mpt_entry->flags |= cpu_to_be32(MTHCA_MPT_FLAG_PHYSICAL);	mpt_entry->page_size = cpu_to_be32(buffer_size_shift - 12);	mpt_entry->key       = cpu_to_be32(key);	mpt_entry->pd        = cpu_to_be32(pd);	mpt_entry->start     = cpu_to_be64(iova);	mpt_entry->length    = cpu_to_be64(total_size);	memset(&mpt_entry->lkey, 0,	       sizeof *mpt_entry - offsetof(struct mthca_mpt_entry, lkey));	if (mr->mtt)		mpt_entry->mtt_seg =			cpu_to_be64(dev->mr_table.mtt_base +				    mr->mtt->first_seg * MTHCA_MTT_SEG_SIZE);	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;	} else if (status) {		mthca_warn(dev, "SW2HW_MPT returned status 0x%02x\n",			   status);		err = -EINVAL;		goto err_out_mailbox;	}	kfree(mailbox);	return err;err_out_mailbox:	kfree(mailbox);err_out_table:	mthca_table_put(dev, dev->mr_table.mpt_table, key);err_out_mpt_free:	mthca_free(&dev->mr_table.mpt_alloc, key);	return err;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/ed878458eeff9754d66f1b0325df6ebbfcdce668/mthca_mr.c/buggy/drivers/infiniband/hw/mthca/mthca_mr.c