void *mailbox = NULL; struct mthca_mpt_entry *mpt_entry; u32 key; int err; u8 status;  might_sleep();  mr->order = -1; 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_PHYSICAL    | MTHCA_MPT_FLAG_REGION      | access); mpt_entry->page_size = 0; mpt_entry->key       = cpu_to_be32(key); mpt_entry->pd        = cpu_to_be32(pd); mpt_entry->start     = 0; mpt_entry->length    = ~0ULL;  memset(&mpt_entry->lkey, 0, sizeof *mpt_entry - offsetof(struct mthca_mpt_entry, lkey));  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_table; } else if (status) { mthca_warn(dev, "SW2HW_MPT returned status 0x%02x\n", status); err = -EINVAL; goto err_out_table; }  kfree(mailbox); return err;  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); kfree(mailbox); return err;
mr->mtt = NULL; return mthca_mr_alloc(dev, pd, 12, 0, ~0ULL, access, mr);
int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,			   u32 access, struct mthca_mr *mr){	void *mailbox = NULL;	struct mthca_mpt_entry *mpt_entry;	u32 key;	int err;	u8 status;	might_sleep();	mr->order = -1;	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_PHYSICAL    |				       MTHCA_MPT_FLAG_REGION      |				       access);	mpt_entry->page_size = 0;	mpt_entry->key       = cpu_to_be32(key);	mpt_entry->pd        = cpu_to_be32(pd);	mpt_entry->start     = 0;	mpt_entry->length    = ~0ULL;	memset(&mpt_entry->lkey, 0,	       sizeof *mpt_entry - offsetof(struct mthca_mpt_entry, lkey));	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_table;	} else if (status) {		mthca_warn(dev, "SW2HW_MPT returned status 0x%02x\n",			   status);		err = -EINVAL;		goto err_out_table;	}	kfree(mailbox);	return err;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);	kfree(mailbox);	return err;}