⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mptbase.c

📁 Linux Kernel 2.6.9 for OMAP1710
💻 C
📖 第 1 页 / 共 5 页
字号:
		if ((int)ioc->chip_type <= (int)FC929) {			/*			 *  Pre-fetch FC port WWN and stuff...			 *  (FCPortPage0_t stuff)			 */			for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) {				(void) GetFcPortPage0(ioc, ii);			}			if ((ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN) &&			    (ioc->lan_cnfg_page0.Header.PageLength == 0)) {				/*				 *  Pre-fetch the ports LAN MAC address!				 *  (LANPage1_t stuff)				 */				(void) GetLanConfigPages(ioc);#ifdef MPT_DEBUG				{					u8 *a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow;					dprintk((MYIOC_s_INFO_FMT "LanAddr = %02X:%02X:%02X:%02X:%02X:%02X\n",							ioc->name, a[5], a[4], a[3], a[2], a[1], a[0] ));				}#endif			}		} else {			/* Get NVRAM and adapter maximums from SPP 0 and 2			 */			mpt_GetScsiPortSettings(ioc, 0);			/* Get version and length of SDP 1			 */			mpt_readScsiDevicePageHeaders(ioc, 0);			/* Find IM volumes			 */			if (ioc->facts.MsgVersion >= 0x0102)				mpt_findImVolumes(ioc);			/* Check, and possibly reset, the coalescing value			 */			mpt_read_ioc_pg_1(ioc);			mpt_read_ioc_pg_4(ioc);		}		GetIoUnitPage2(ioc);	}	/*	 * Call each currently registered protocol IOC reset handler	 * with post-reset indication.	 * NOTE: If we're doing _IOC_BRINGUP, there can be no	 * MptResetHandlers[] registered yet.	 */	if (hard_reset_done) {		rc = handlers = 0;		for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) {			if ((ret == 0) && MptResetHandlers[ii]) {				dprintk((MYIOC_s_INFO_FMT "Calling IOC post_reset handler #%d\n",						ioc->name, ii));				rc += (*(MptResetHandlers[ii]))(ioc, MPT_IOC_POST_RESET);				handlers++;			}			if (alt_ioc_ready && MptResetHandlers[ii]) {				dprintk((MYIOC_s_INFO_FMT "Calling alt-%s post_reset handler #%d\n",						ioc->name, ioc->alt_ioc->name, ii));				rc += (*(MptResetHandlers[ii]))(ioc->alt_ioc, MPT_IOC_POST_RESET);				handlers++;			}		}		/* FIXME?  Examine results here? */	}	return ret;}/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*//* *	mpt_detect_bound_ports - Search for PCI bus/dev_function *	which matches PCI bus/dev_function (+/-1) for newly discovered 929, *	929X, 1030 or 1035. *	@ioc: Pointer to MPT adapter structure *	@pdev: Pointer to (struct pci_dev) structure * *	If match on PCI dev_function +/-1 is found, bind the two MPT adapters *	using alt_ioc pointer fields in their %MPT_ADAPTER structures. */static voidmpt_detect_bound_ports(MPT_ADAPTER *ioc, struct pci_dev *pdev){	unsigned int match_lo, match_hi;	MPT_ADAPTER *ioc_srch;	match_lo = pdev->devfn-1;	match_hi = pdev->devfn+1;	dprintk((MYIOC_s_INFO_FMT "PCI bus/devfn=%x/%x, searching for devfn match on %x or %x\n",			ioc->name, pdev->bus->number, pdev->devfn, match_lo, match_hi));	list_for_each_entry(ioc_srch, &ioc_list, list) {		struct pci_dev *_pcidev = ioc_srch->pcidev;		if ((_pcidev->device == pdev->device) &&		    (_pcidev->bus->number == pdev->bus->number) &&		    (_pcidev->devfn == match_lo || _pcidev->devfn == match_hi) ) {			/* Paranoia checks */			if (ioc->alt_ioc != NULL) {				printk(KERN_WARNING MYNAM ": Oops, already bound (%s <==> %s)!\n",						ioc->name, ioc->alt_ioc->name);				break;			} else if (ioc_srch->alt_ioc != NULL) {				printk(KERN_WARNING MYNAM ": Oops, already bound (%s <==> %s)!\n",						ioc_srch->name, ioc_srch->alt_ioc->name);				break;			}			dprintk((KERN_INFO MYNAM ": FOUND! binding %s <==> %s\n",					ioc->name, ioc_srch->name));			ioc_srch->alt_ioc = ioc;			ioc->alt_ioc = ioc_srch;			break;		}	}}/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*//* *	mpt_adapter_disable - Disable misbehaving MPT adapter. *	@this: Pointer to MPT adapter structure */static voidmpt_adapter_disable(MPT_ADAPTER *ioc){	int sz;	int ret;	if (ioc->cached_fw != NULL) {		ddlprintk((KERN_INFO MYNAM ": mpt_adapter_disable: Pushing FW onto adapter\n"));		if ((ret = mpt_downloadboot(ioc, NO_SLEEP)) < 0) {			printk(KERN_WARNING MYNAM				": firmware downloadboot failure (%d)!\n", ret);		}	}	/* Disable adapter interrupts! */	CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF);	ioc->active = 0;	/* Clear any lingering interrupt */	CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);	if (ioc->alloc != NULL) {		sz = ioc->alloc_sz;		dexitprintk((KERN_INFO MYNAM ": %s.free  @ %p, sz=%d bytes\n",		 	ioc->name, ioc->alloc, ioc->alloc_sz));		pci_free_consistent(ioc->pcidev, sz,				ioc->alloc, ioc->alloc_dma);		ioc->reply_frames = NULL;		ioc->req_frames = NULL;		ioc->alloc = NULL;		ioc->alloc_total -= sz;	}	if (ioc->sense_buf_pool != NULL) {		sz = (ioc->req_depth * MPT_SENSE_BUFFER_ALLOC);		pci_free_consistent(ioc->pcidev, sz,				ioc->sense_buf_pool, ioc->sense_buf_pool_dma);		ioc->sense_buf_pool = NULL;		ioc->alloc_total -= sz;	}	if (ioc->events != NULL){		sz = MPTCTL_EVENT_LOG_SIZE * sizeof(MPT_IOCTL_EVENTS);		kfree(ioc->events);		ioc->events = NULL;		ioc->alloc_total -= sz;	}	if (ioc->cached_fw != NULL) {		sz = ioc->facts.FWImageSize;		pci_free_consistent(ioc->pcidev, sz,			ioc->cached_fw, ioc->cached_fw_dma);		ioc->cached_fw = NULL;		ioc->alloc_total -= sz;	}	if (ioc->spi_data.nvram != NULL) {		kfree(ioc->spi_data.nvram);		ioc->spi_data.nvram = NULL;	}	if (ioc->spi_data.pIocPg3 != NULL) {		kfree(ioc->spi_data.pIocPg3);		ioc->spi_data.pIocPg3 = NULL;	}	if (ioc->spi_data.pIocPg4 != NULL) {		sz = ioc->spi_data.IocPg4Sz;		pci_free_consistent(ioc->pcidev, sz, 			ioc->spi_data.pIocPg4,			ioc->spi_data.IocPg4_dma);		ioc->spi_data.pIocPg4 = NULL;		ioc->alloc_total -= sz;	}	if (ioc->ReqToChain != NULL) {		kfree(ioc->ReqToChain);		kfree(ioc->RequestNB);		ioc->ReqToChain = NULL;	}	if (ioc->ChainToChain != NULL) {		kfree(ioc->ChainToChain);		ioc->ChainToChain = NULL;	}}/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*//* *	mpt_adapter_dispose - Free all resources associated with a MPT *	adapter. *	@ioc: Pointer to MPT adapter structure * *	This routine unregisters h/w resources and frees all alloc'd memory *	associated with a MPT adapter structure. */static voidmpt_adapter_dispose(MPT_ADAPTER *ioc){	if (ioc != NULL) {		int sz_first, sz_last;		sz_first = ioc->alloc_total;		mpt_adapter_disable(ioc);		if (ioc->pci_irq != -1) {			free_irq(ioc->pci_irq, ioc);			ioc->pci_irq = -1;		}		if (ioc->memmap != NULL)			iounmap((u8 *) ioc->memmap);#if defined(CONFIG_MTRR) && 0		if (ioc->mtrr_reg > 0) {			mtrr_del(ioc->mtrr_reg, 0, 0);			dprintk((KERN_INFO MYNAM ": %s: MTRR region de-registered\n", ioc->name));		}#endif		/*  Zap the adapter lookup ptr!  */		list_del(&ioc->list);		sz_last = ioc->alloc_total;		dprintk((KERN_INFO MYNAM ": %s: free'd %d of %d bytes\n",				ioc->name, sz_first-sz_last+(int)sizeof(*ioc), sz_first));		kfree(ioc);	}}/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*//* *	MptDisplayIocCapabilities - Disply IOC's capacilities. *	@ioc: Pointer to MPT adapter structure */static voidMptDisplayIocCapabilities(MPT_ADAPTER *ioc){	int i = 0;	printk(KERN_INFO "%s: ", ioc->name);	if (ioc->prod_name && strlen(ioc->prod_name) > 3)		printk("%s: ", ioc->prod_name+3);	printk("Capabilities={");	if (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_INITIATOR) {		printk("Initiator");		i++;	}	if (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_TARGET) {		printk("%sTarget", i ? "," : "");		i++;	}	if (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN) {		printk("%sLAN", i ? "," : "");		i++;	}#if 0	/*	 *  This would probably evoke more questions than it's worth	 */	if (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_TARGET) {		printk("%sLogBusAddr", i ? "," : "");		i++;	}#endif	printk("}\n");}/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*//* *	MakeIocReady - Get IOC to a READY state, using KickStart if needed. *	@ioc: Pointer to MPT_ADAPTER structure *	@force: Force hard KickStart of IOC *	@sleepFlag: Specifies whether the process can sleep * *	Returns: *		 1 - DIAG reset and READY *		 0 - READY initially OR soft reset and READY *		-1 - Any failure on KickStart *		-2 - Msg Unit Reset Failed *		-3 - IO Unit Reset Failed *		-4 - IOC owned by a PEER */static intMakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag){	u32	 ioc_state;	int	 statefault = 0;	int	 cntdn;	int	 hard_reset_done = 0;	int	 r;	int	 ii;	int	 whoinit;	/* Get current [raw] IOC state  */	ioc_state = mpt_GetIocState(ioc, 0);	dhsprintk((KERN_INFO MYNAM "::MakeIocReady, %s [raw] state=%08x\n", ioc->name, ioc_state));	/*	 *	Check to see if IOC got left/stuck in doorbell handshake	 *	grip of death.  If so, hard reset the IOC.	 */	if (ioc_state & MPI_DOORBELL_ACTIVE) {		statefault = 1;		printk(MYIOC_s_WARN_FMT "Unexpected doorbell active!\n",				ioc->name);	}	/* Is it already READY? */	if (!statefault && (ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_READY) {		if ((int)ioc->chip_type <= (int)FC929)			return 0;		else {			return 0;			/* Workaround from broken 1030 FW.			 * Force a diagnostic reset if fails.			 *//*			if ((r = SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, sleepFlag)) == 0)				return 0;			else				statefault = 4; */		}	}	/*	 *	Check to see if IOC is in FAULT state.	 */	if ((ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_FAULT) {		statefault = 2;		printk(MYIOC_s_WARN_FMT "IOC is in FAULT state!!!\n",				ioc->name);		printk(KERN_WARNING "           FAULT code = %04xh\n",				ioc_state & MPI_DOORBELL_DATA_MASK);	}	/*	 *	Hmmm...  Did it get left operational?	 */	if ((ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_OPERATIONAL) {		dinitprintk((MYIOC_s_WARN_FMT "IOC operational unexpected\n",				ioc->name));		/* Check WhoInit.		 * If PCI Peer, exit.		 * Else, if no fault conditions are present, issue a MessageUnitReset		 * Else, fall through to KickStart case		 */		whoinit = (ioc_state & MPI_DOORBELL_WHO_INIT_MASK) >> MPI_DOORBELL_WHO_INIT_SHIFT;		dprintk((KERN_WARNING MYNAM			": whoinit 0x%x\n statefault %d force %d\n",			whoinit, statefault, force));		if (whoinit == MPI_WHOINIT_PCI_PEER)			return -4;		else {			if ((statefault == 0 ) && (force == 0)) {				if ((r = SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, sleepFlag)) == 0)					return 0;			}			statefault = 3;		}	}	hard_reset_done = KickStart(ioc, statefault||force, sleepFlag);	if (hard_reset_done < 0)		return -1;	/*	 *  Loop here waiting for IOC to come READY.	 */	ii = 0;	cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * 15;	/* 15 seconds */	while ((ioc_state = mpt_GetIocState(ioc, 1)) != MPI_IOC_STATE_READY) {		if (ioc_state == MPI_IOC_STATE_OPERATIONAL) {			/*			 *  BIOS or previous driver load left IOC in OP state.			 *  Reset messaging FIFOs.			 */			if ((r = SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, sleepFlag)) != 0) {				printk(MYIOC_s_ERR_FMT "IOC msg unit reset failed!\n", ioc->name);				return -2;			}		} else if (ioc_state == MPI_IOC_STATE_RESET) {			/*			 *  Something is wrong.  Try to get IOC back			 *  to a known state.			 */			if ((r = SendIocReset(ioc, MPI_FUNCTION_IO_UNIT_RESET, sleepFlag)) != 0) {				printk(MYIOC_s_ERR_FMT "IO unit reset failed!\n", ioc->name);				return -3;			}		}		ii++; cntdn--;		if (!cntdn) {			printk(MYIOC_s_ERR_FMT "Wait IOC_READY state timeout(%d)!\n",					ioc->name, (int)((ii+5)/HZ));			return -ETIME;		}		if (sleepFlag == CAN_SLEEP) {			set_current_state(TASK_INTERRUPTIBLE);			schedule_timeout(1 * HZ / 1000);		} else {			mdelay (1);	/* 1 msec delay */		}	}	if (statefault < 3) {		printk(MYIOC_s_INFO_FMT "Recovered from %s\n",				ioc->name,				statefault==1 ? "stuck handshake" : "IOC FAULT"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -