pcibr_error.c

来自「Linux Kernel 2.6.9 for OMAP1710」· C语言 代码 · 共 1,874 行 · 第 1/4 页

C
1,874
字号
		printk("\t    Bridge Response Buf Error Addr Reg: 0x%lx\n"		    "\t    dev-num %d buff-num %d addr 0x%lx\n",		    pcireg_resp_err_get(pcibr_soft),		    (int)pcireg_resp_err_dev_get(pcibr_soft),		    (int)pcireg_resp_err_buf_get(pcibr_soft),		    pcireg_resp_err_get(pcibr_soft));		break;	    }	}    }    mult_int = pcireg_intr_multiple_get(pcibr_soft);    if (mult_int & ~BRIDGE_ISR_INT_MSK) {	printk("    %s Multiple Interrupt Register is 0x%lx\n",		pcibr_soft->bs_asic_name, mult_int);	for (i = PCIBR_ISR_ERR_START; i < 64; i++) {	    if (mult_int & (1ull << i))		printk( "\t%s\n", pcibr_isr_errs[i]);	}    }}/* pcibr_pioerr_check(): *	Check to see if this pcibr has a PCI PIO *	TIMEOUT error; if so, bump the timeout-count *	on any piomaps that could cover the address. */static voidpcibr_pioerr_check(pcibr_soft_t soft){    uint64_t		    int_status;    iopaddr_t		    pci_addr;    pciio_slot_t	    slot;    pcibr_piomap_t	    map;    iopaddr_t		    base;    size_t		    size;    unsigned		    win;    int			    func;    int_status = pcireg_intr_status_get(soft);    if (int_status & BRIDGE_ISR_PCIBUS_PIOERR) {	pci_addr = pcireg_pci_bus_addr_get(soft);	slot = PCIBR_NUM_SLOTS(soft);	while (slot-- > 0) {	    int 		nfunc = soft->bs_slot[slot].bss_ninfo;	    pcibr_info_h	pcibr_infoh = soft->bs_slot[slot].bss_infos;	    for (func = 0; func < nfunc; func++) {		pcibr_info_t 	pcibr_info = pcibr_infoh[func];		if (!pcibr_info)		    continue;		for (map = pcibr_info->f_piomap;		        map != NULL; map = map->bp_next) {		    base = map->bp_pciaddr;		    size = map->bp_mapsz;		    win = map->bp_space - PCIIO_SPACE_WIN(0);		    if (win < 6)			base += soft->bs_slot[slot].bss_window[win].bssw_base;		    else if (map->bp_space == PCIIO_SPACE_ROM)			base += pcibr_info->f_rbase;		    if ((pci_addr >= base) && (pci_addr < (base + size)))			atomic_inc(&map->bp_toc);		}	    }	}    }}/* * PCI Bridge Error interrupt handler. *      This gets invoked, whenever a PCI bridge sends an error interrupt. *      Primarily this servers two purposes. *              - If an error can be handled (typically a PIO read/write *                error, we try to do it silently. *              - If an error cannot be handled, we die violently. *      Interrupt due to PIO errors: *              - Bridge sends an interrupt, whenever a PCI operation *                done by the bridge as the master fails. Operations could *                be either a PIO read or a PIO write. *                PIO Read operation also triggers a bus error, and it's *                We primarily ignore this interrupt in that context.. *                For PIO write errors, this is the only indication. *                and we have to handle with the info from here. * *                So, there is no way to distinguish if an interrupt is *                due to read or write error!. */irqreturn_tpcibr_error_intr_handler(int irq, void *arg, struct pt_regs *ep){    pcibr_soft_t            pcibr_soft;    void               *bridge;    uint64_t		    int_status;    uint64_t		    err_status;    int                     i;    uint64_t		    disable_errintr_mask = 0;    nasid_t		    nasid;#if PCIBR_SOFT_LIST    /*     * Defensive code for linked pcibr_soft structs     */    {	extern pcibr_list_p	pcibr_list;	pcibr_list_p            entry;	entry = pcibr_list;	while (1) {	    if (entry == NULL) {		printk("pcibr_error_intr_handler: (0x%lx) is not a pcibr_soft!",	 	      (uint64_t)arg);    		return IRQ_NONE;	    }	    if ((intr_arg_t) entry->bl_soft == arg)		break;	    entry = entry->bl_next;	}    }#endif /* PCIBR_SOFT_LIST */    pcibr_soft = (pcibr_soft_t) arg;    bridge = pcibr_soft->bs_base;    /*     * pcibr_error_intr_handler gets invoked whenever bridge encounters     * an error situation, and the interrupt for that error is enabled.     * This routine decides if the error is fatal or not, and takes     * action accordingly.     *     * In the case of PIO read/write timeouts, there is no way     * to know if it was a read or write request that timed out.     * If the error was due to a "read", a bus error will also occur     * and the bus error handling code takes care of it.      * If the error is due to a "write", the error is currently logged      * by this routine. For SN1 and SN0, if fire-and-forget mode is      * disabled, a write error response xtalk packet will be sent to      * the II, which will cause an II error interrupt. No write error      * recovery actions of any kind currently take place at the pcibr      * layer! (e.g., no panic on unrecovered write error)     *     * Prior to reading the Bridge int_status register we need to ensure     * that there are no error bits set in the lower layers (hubii)     * that have disabled PIO access to the widget. If so, there is nothing     * we can do until the bits clear, so we setup a timeout and try again     * later.     */    nasid = NASID_GET(bridge);    if (hubii_check_widget_disabled(nasid, pcibr_soft->bs_xid)) {	DECLARE_WAIT_QUEUE_HEAD(wq);	sleep_on_timeout(&wq, BRIDGE_PIOERR_TIMEOUT*HZ );  /* sleep */	pcibr_soft->bs_errinfo.bserr_toutcnt++;	/* Let's go recursive */	return(pcibr_error_intr_handler(irq, arg, ep));    }    int_status = pcireg_intr_status_get(pcibr_soft);    PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_INTR_ERROR, pcibr_soft->bs_conn,		"pcibr_error_intr_handler: int_status=0x%lx\n", int_status));    /* int_status is which bits we have to clear;     * err_status is the bits we haven't handled yet.     */    err_status = int_status;    if (!(int_status & ~BRIDGE_ISR_INT_MSK)) {	/*	 * No error bit set!!.	 */	return IRQ_HANDLED;    }    /*     * If we have a PCIBUS_PIOERR, hand it to the logger.     */    if (int_status & BRIDGE_ISR_PCIBUS_PIOERR) {	pcibr_pioerr_check(pcibr_soft);    }    if (err_status) {	struct bs_errintr_stat_s *bs_estat ;        bs_estat = &pcibr_soft->bs_errintr_stat[PCIBR_ISR_ERR_START];	for (i = PCIBR_ISR_ERR_START; i < 64; i++, bs_estat++) {	    if (err_status & (1ull << i)) {		uint32_t              errrate = 0;		uint32_t              errcount = 0;		uint32_t              errinterval = 0, current_tick = 0;		int                     llp_tx_retry_errors = 0;		int                     is_llp_tx_retry_intr = 0;		bs_estat->bs_errcount_total++;		current_tick = jiffies;		errinterval = (current_tick - bs_estat->bs_lasterr_timestamp);		errcount = (bs_estat->bs_errcount_total -			    bs_estat->bs_lasterr_snapshot);		/* LLP interrrupt errors are only valid on BUS0 of the PIC */		if (pcibr_soft->bs_busnum == 0)		    is_llp_tx_retry_intr = (BRIDGE_ISR_LLP_TX_RETRY==(1ull << i));		/* Check for the divide by zero condition while		 * calculating the error rates.		 */		if (errinterval) {		    errrate = errcount / errinterval;		    /* If able to calculate error rate		     * on a LLP transmitter retry interrupt, check		     * if the error rate is nonzero and we have seen		     * a certain minimum number of errors.		     *		     * NOTE : errcount is being compared to		     * PCIBR_ERRTIME_THRESHOLD to make sure that we are not		     * seeing cases like x error interrupts per y ticks for		     * very low x ,y (x > y ) which could result in a		     * rate > 100/tick.		     */		    if (is_llp_tx_retry_intr &&			errrate &&			(errcount >= PCIBR_ERRTIME_THRESHOLD)) {			llp_tx_retry_errors = 1;		    }		} else {		    errrate = 0;		    /* Since we are not able to calculate the		     * error rate check if we exceeded a certain		     * minimum number of errors for LLP transmitter		     * retries. Note that this can only happen		     * within the first tick after the last snapshot.		     */		    if (is_llp_tx_retry_intr &&			(errcount >= PCIBR_ERRINTR_DISABLE_LEVEL)) {			llp_tx_retry_errors = 1;		    }		}		/*		 * If a non-zero error rate (which is equivalent to		 * to 100 errors/tick at least) for the LLP transmitter		 * retry interrupt was seen, check if we should print		 * a warning message.		 */		if (llp_tx_retry_errors) {		    static uint32_t       last_printed_rate;		    if (errrate > last_printed_rate) {			last_printed_rate = errrate;			/* Print the warning only if the error rate			 * for the transmitter retry interrupt			 * exceeded the previously printed rate.			 */			printk(KERN_WARNING				"%s: %s, Excessive error interrupts : %d/tick\n",				pcibr_soft->bs_name,				pcibr_isr_errs[i],				errrate);		    }		    /*		     * Update snapshot, and time		     */		    bs_estat->bs_lasterr_timestamp = current_tick;		    bs_estat->bs_lasterr_snapshot =			bs_estat->bs_errcount_total;		}		/*		 * If the error rate is high enough, print the error rate.		 */		if (errinterval > PCIBR_ERRTIME_THRESHOLD) {		    if (errrate > PCIBR_ERRRATE_THRESHOLD) {			printk(KERN_NOTICE "%s: %s, Error rate %d/tick",				pcibr_soft->bs_name,				pcibr_isr_errs[i],				errrate);			/*			 * Update snapshot, and time			 */			bs_estat->bs_lasterr_timestamp = current_tick;			bs_estat->bs_lasterr_snapshot =			    bs_estat->bs_errcount_total;		    }		}		/* PIC BRINGUP WAR (PV# 856155):		 * Dont disable PCI_X_ARB_ERR interrupts, we need the		 * interrupt inorder to clear the DEV_BROKE bits in		 * b_arb register to re-enable the device.		 */		if (!(err_status & PIC_ISR_PCIX_ARB_ERR) &&				PCIBR_WAR_ENABLED(PV856155, pcibr_soft)) {		if (bs_estat->bs_errcount_total > PCIBR_ERRINTR_DISABLE_LEVEL) {		    /*		     * We have seen a fairly large number of errors of		     * this type. Let's disable the interrupt. But flash		     * a message about the interrupt being disabled.		     */		    printk(KERN_NOTICE			    "%s Disabling error interrupt type %s. Error count %d",			    pcibr_soft->bs_name,			    pcibr_isr_errs[i],			    bs_estat->bs_errcount_total);		    disable_errintr_mask |= (1ull << i);		}		} /* PIC: WAR for PV 856155 end-of-if */	    }	}    }    if (disable_errintr_mask) {	unsigned long s;	/*	 * Disable some high frequency errors as they	 * could eat up too much cpu time.	 */	s = pcibr_lock(pcibr_soft);	pcireg_intr_enable_bit_clr(pcibr_soft, disable_errintr_mask);	pcibr_unlock(pcibr_soft, s);    }    /*     * If we leave the PROM cacheable, T5 might     * try to do a cache line sized writeback to it,     * which will cause a BRIDGE_ISR_INVLD_ADDR.     */    if ((err_status & BRIDGE_ISR_INVLD_ADDR) &&	(0x00C00000 == (pcireg_bus_err_get(pcibr_soft) & 0xFFFFFFFFFFC00000)) &&	(0x00402000 == (0x00F07F00 & pcireg_cmdword_err_get(pcibr_soft)))) {	err_status &= ~BRIDGE_ISR_INVLD_ADDR;    }    /*     * pcibr_pioerr_dump is a systune that make be used to not     * print bridge registers for interrupts generated by pio-errors.     * Some customers do early probes and expect a lot of failed     * pios.     */    if (!pcibr_pioerr_dump) {	bridge_errors_to_dump &= ~BRIDGE_ISR_PCIBUS_PIOERR;    } else {	bridge_errors_to_dump |= BRIDGE_ISR_PCIBUS_PIOERR;    }    /* Dump/Log Bridge error interrupt info */    if (err_status & bridge_errors_to_dump) {	printk("BRIDGE ERR_STATUS 0x%lx\n", err_status);	pcibr_error_dump(pcibr_soft);    }    /* PIC BRINGUP WAR (PV# 867308):     * Make BRIDGE_ISR_LLP_REC_SNERR & BRIDGE_ISR_LLP_REC_CBERR fatal errors     * so we know we've hit the problem defined in PV 867308 that we believe     * has only been seen in simulation     */    if (PCIBR_WAR_ENABLED(PV867308, pcibr_soft) &&	(err_status & (BRIDGE_ISR_LLP_REC_SNERR | BRIDGE_ISR_LLP_REC_CBERR))) {	printk("BRIDGE ERR_STATUS 0x%lx\n", err_status);	pcibr_error_dump(pcibr_soft);	/* machine_error_dump(""); */	panic("PCI Bridge Error interrupt killed the system");    }    if (err_status & BRIDGE_ISR_ERROR_FATAL) {	panic("PCI Bridge Error interrupt killed the system");	    /*NOTREACHED */    }    /*     * We can't return without re-enabling the interrupt, since     * it would cause problems for devices like IOC3 (Lost     * interrupts ?.). So, just cleanup the interrupt, and     * use saved values later..     *      * PIC doesn't require groups of interrupts to be cleared...     */    pcireg_intr_reset_set(pcibr_soft, (int_status | BRIDGE_IRR_MULTI_CLR));    /* PIC BRINGUP WAR (PV# 856155):     * On a PCI_X_ARB_ERR error interrupt clear the DEV_BROKE bits from     * the b_arb register to re-enable the device.     */    if ((err_status & PIC_ISR_PCIX_ARB_ERR) &&		PCIBR_WAR_ENABLED(PV856155, pcibr_soft)) {	pcireg_arbitration_bit_set(pcibr_soft, (0xf << 20));    }    /* Zero out bserr_intstat field */    pcibr_soft->bs_errinfo.bserr_intstat = 0;    return IRQ_HANDLED;}/* * pcibr_addr_toslot *      Given the 'pciaddr' find out which slot this address is *      allocated to, and return the slot number. *      While we have the info handy, construct the *      function number, space code and offset as well. * * NOTE: if this routine is called, we don't know whether * the address is in CFG, MEM, or I/O space. We have to guess. * This will be the case on PIO stores, where the only way * we have of getting the address is to check the Bridge, which * stores the PCI address but not the space and not the xtalk * address (from which we could get it). */static intpcibr_addr_toslot(pcibr_soft_t pcibr_soft,		  iopaddr_t pciaddr,		  pciio_space_t *spacep,		  iopaddr_t *offsetp,		  pciio_function_t *funcp){    int                     s, f = 0, w;    iopaddr_t               base;    size_t                  size;    pciio_piospace_t        piosp;    /*     * Check if the address is in config space     */    if ((pciaddr >= BRIDGE_CONFIG_BASE) && (pciaddr < BRIDGE_CONFIG_END)) {	if (pciaddr >= BRIDGE_CONFIG1_BASE)	    pciaddr -= BRIDGE_CONFIG1_BASE;	else	    pciaddr -= BRIDGE_CONFIG_BASE;	s = pciaddr / BRIDGE_CONFIG_SLOT_SIZE;	pciaddr %= BRIDGE_CONFIG_SLOT_SIZE;	if (funcp) {	    f = pciaddr / 0x100;	    pciaddr %= 0x100;	}	if (spacep)	    *spacep = PCIIO_SPACE_CFG;	if (offsetp)	    *offsetp = pciaddr;	if (funcp)	    *funcp = f;	return s;    }    for (s = pcibr_soft->bs_min_slot; s < PCIBR_NUM_SLOTS(pcibr_soft); ++s) {	int                     nf = pcibr_soft->bs_slot[s].bss_ninfo;	pcibr_info_h            pcibr_infoh = pcibr_soft->bs_slot[s].bss_infos;	for (f = 0; f < nf; f++) {	    pcibr_info_t            pcibr_info = pcibr_infoh[f];	    if (!pcibr_info)		continue;	    for (w = 0; w < 6; w++) {		if (pcibr_info->f_window[w].w_space		    == PCIIO_SPACE_NONE) {		    continue;		}		base = pcibr_info->f_window[w].w_base;		size = pcibr_info->f_window[w].w_size;

⌨️ 快捷键说明

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