From owner-freebsd-current@FreeBSD.ORG Wed Nov 8 21:52:37 2006 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A8DEE16A47B for ; Wed, 8 Nov 2006 21:52:37 +0000 (UTC) (envelope-from iedowse@iedowse.com) Received: from nowhere.iedowse.com (nowhere.iedowse.com [82.195.144.75]) by mx1.FreeBSD.org (Postfix) with SMTP id D528543D75 for ; Wed, 8 Nov 2006 21:52:29 +0000 (GMT) (envelope-from iedowse@iedowse.com) Received: from localhost ([127.0.0.1] helo=iedowse.com) by nowhere.iedowse.com via local-iedowse id ; 8 Nov 2006 21:52:22 +0000 (GMT) To: Vladimir Kushnir In-Reply-To: Your message of "Mon, 06 Nov 2006 01:57:46 +0200." <20061106015245.R1183@kushnir1.kiev.ua> Date: Wed, 08 Nov 2006 21:52:21 +0000 From: Ian Dowse Message-ID: <200611082152.aa94781@nowhere.iedowse.com> Cc: John-Mark Gurney , current@freebsd.org Subject: Re: Asus A8V hangs during pci probe on fresh -CURRENT X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Nov 2006 21:52:37 -0000 In message <20061106015245.R1183@kushnir1.kiev.ua>, Vladimir Kushnir writes: >On Sat, 4 Nov 2006, John-Mark Gurney wrote: >> Ok, then add a couple printfs to the pci_read_vpd_reg line... one before >> the WREG line, and another before the return... I have a feeling that >> your card isn't setting the correct bit, as the printf you enabled w/ > >Your feeling was absolutely right - system hangs exactly here. Maybe something like the following would help? This adds a timeout to pci_read_vpd_reg() so it might prevent the complete hang. Ian Index: pci.c =================================================================== RCS file: /home/ncvs/src/sys/dev/pci/pci.c,v retrieving revision 1.320 diff -u -r1.320 pci.c --- pci.c 7 Nov 2006 18:55:51 -0000 1.320 +++ pci.c 8 Nov 2006 21:48:11 -0000 @@ -495,12 +495,19 @@ pci_read_vpd_reg(device_t pcib, pcicfgregs *cfg, int reg) { #define WREG(n, v, w) PCIB_WRITE_CONFIG(pcib, cfg->bus, cfg->slot, cfg->func, n, v, w) + int timo; KASSERT((reg & 3) == 0, ("VPD register must by 4 byte aligned")); WREG(cfg->vpd.vpd_reg + 2, reg, 2); - while ((REG(cfg->vpd.vpd_reg + 2, 2) & 0x8000) != 0x8000) + timo = 1000000; + while (--timo > 0 && (REG(cfg->vpd.vpd_reg + 2, 2) & 0x8000) != 0x8000) DELAY(1); /* limit looping */ + if (timo == 0) { + printf("pci%d:%d:%d: read VPD reg %d timed out\n", cfg->bus, + cfg->slot, cfg->func, reg); + return 0xffffffff; + } return REG(cfg->vpd.vpd_reg + 4, 4); } @@ -509,12 +516,18 @@ static void pci_write_vpd_reg(device_t pcib, pcicfgregs *cfg, int reg, uint32_t data) { + int timo; + KASSERT((reg & 3) == 0, ("VPD register must by 4 byte aligned")); WREG(cfg->vpd.vpd_reg + 4, data, 4); WREG(cfg->vpd.vpd_reg + 2, reg | 0x8000, 2); - while ((REG(cfg->vpd.vpd_reg + 2, 2) & 0x8000) == 0x8000) + timo = 1000000; + while (--timo > 0 && (REG(cfg->vpd.vpd_reg + 2, 2) & 0x8000) == 0x8000) DELAY(1); /* limit looping */ + if (timo == 0) + printf("pci%d:%d:%d: write VPD reg %d timed out\n", cfg->bus, + cfg->slot, cfg->func, reg); return; } @@ -630,7 +643,8 @@ state = 5; break; default: /* XXX - unimplemented */ - state = 4; + end = 1; + cksumvalid = 0; break; } break;