inbox = pci_alloc_consistent(dev->pdev, PAGE_SIZE, &indma); if (!inbox) return -ENOMEM;  memset(inbox, 0, PAGE_SIZE); 
mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); if (IS_ERR(mailbox)) return PTR_ERR(mailbox); memset(mailbox->buf, 0, MTHCA_MAILBOX_SIZE); pages = mailbox->buf; 
static int mthca_map_cmd(struct mthca_dev *dev, u16 op, struct mthca_icm *icm,			 u64 virt, u8 *status){	u32 *inbox;	dma_addr_t indma;	struct mthca_icm_iter iter;	int lg;	int nent = 0;	int i;	int err = 0;	int ts = 0, tc = 0;	inbox = pci_alloc_consistent(dev->pdev, PAGE_SIZE, &indma);	if (!inbox)		return -ENOMEM;	memset(inbox, 0, PAGE_SIZE);	for (mthca_icm_first(icm, &iter);	     !mthca_icm_last(&iter);	     mthca_icm_next(&iter)) {		/*		 * We have to pass pages that are aligned to their		 * size, so find the least significant 1 in the		 * address or size and use that as our log2 size.		 */		lg = ffs(mthca_icm_addr(&iter) | mthca_icm_size(&iter)) - 1;		if (lg < 12) {			mthca_warn(dev, "Got FW area not aligned to 4K (%llx/%lx).\n",				   (unsigned long long) mthca_icm_addr(&iter),				   mthca_icm_size(&iter));			err = -EINVAL;			goto out;		}		for (i = 0; i < mthca_icm_size(&iter) / (1 << lg); ++i, ++nent) {			if (virt != -1) {				*((__be64 *) (inbox + nent * 4)) =					cpu_to_be64(virt);				virt += 1 << lg;			}			*((__be64 *) (inbox + nent * 4 + 2)) =				cpu_to_be64((mthca_icm_addr(&iter) +					     (i << lg)) | (lg - 12));			ts += 1 << (lg - 10);			++tc;			if (nent == PAGE_SIZE / 16) {				err = mthca_cmd(dev, indma, nent, 0, op,						CMD_TIME_CLASS_B, status);				if (err || *status)					goto out;				nent = 0;			}		}	}	if (nent)		err = mthca_cmd(dev, indma, nent, 0, op,				CMD_TIME_CLASS_B, status);	switch (op) {	case CMD_MAP_FA:		mthca_dbg(dev, "Mapped %d chunks/%d KB for FW.\n", tc, ts);		break;	case CMD_MAP_ICM_AUX:		mthca_dbg(dev, "Mapped %d chunks/%d KB for ICM aux.\n", tc, ts);		break;	case CMD_MAP_ICM:		mthca_dbg(dev, "Mapped %d chunks/%d KB at %llx for ICM.\n",			  tc, ts, (unsigned long long) virt - (ts << 10));		break;	}out:	pci_free_consistent(dev->pdev, PAGE_SIZE, inbox, indma);	return err;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/ed878458eeff9754d66f1b0325df6ebbfcdce668/mthca_cmd.c/clean/drivers/infiniband/hw/mthca/mthca_cmd.c