From owner-svn-src-all@FreeBSD.ORG Sat Mar 14 14:08:54 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8F0EB106566B; Sat, 14 Mar 2009 14:08:54 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7D8408FC34; Sat, 14 Mar 2009 14:08:54 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2EE8sPP095290; Sat, 14 Mar 2009 14:08:54 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2EE8sHW095288; Sat, 14 Mar 2009 14:08:54 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200903141408.n2EE8sHW095288@svn.freebsd.org> From: Warner Losh Date: Sat, 14 Mar 2009 14:08:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189792 - head/sys/dev/pci X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Mar 2009 14:08:55 -0000 Author: imp Date: Sat Mar 14 14:08:53 2009 New Revision: 189792 URL: http://svn.freebsd.org/changeset/base/189792 Log: Two fixes: (1) Fix pcib_read/write_config prototypes. (2) When contrainting a resource request for a 'subtractive' bridge, it is important to select a range outside the base/limit registers, since those are the only values known to not possibly work. On my HP laptop, the base bridge excludes I/O ports 0xa000-0xafff, however that was the range we were passing up the tree. Instead, when a range spans the "hole" we now arbitrarily pick the range just above the hole to allocate from. All of my rl and xl cards, at a minimum, started working again on this laptop with those fixes. Modified: head/sys/dev/pci/pci_pci.c head/sys/dev/pci/pcib_private.h Modified: head/sys/dev/pci/pci_pci.c ============================================================================== --- head/sys/dev/pci/pci_pci.c Sat Mar 14 14:02:53 2009 (r189791) +++ head/sys/dev/pci/pci_pci.c Sat Mar 14 14:08:53 2009 (r189792) @@ -413,12 +413,12 @@ pcib_alloc_resource(device_t dev, device } } else { ok = 1; -#if 1 - if (start < sc->iobase && end > sc->iolimit) { - start = sc->iobase; - end = sc->iolimit; - } -#endif + /* + * If we overlap with the subtractive range, then + * pick the upper range to use. + */ + if (start < sc->iolimit && end > sc->iobase) + start = sc->iolimit + 1; } if (end < start) { device_printf(dev, "ioport: end (%lx) < start (%lx)\n", @@ -479,16 +479,12 @@ pcib_alloc_resource(device_t dev, device } else if (!ok) { ok = 1; /* subtractive bridge: always ok */ if (pcib_is_nonprefetch_open(sc)) { - if (start < sc->membase && end > sc->memlimit) { - start = sc->membase; - end = sc->memlimit; - } + if (start < sc->memlimit && end > sc->membase) + start = sc->memlimit + 1; } if (pcib_is_prefetch_open(sc)) { - if (start < sc->pmembase && end > sc->pmemlimit) { - start = sc->pmembase; - end = sc->pmemlimit; - } + if (start < sc->pmemlimit && end > sc->pmembase) + start = sc->pmemlimit + 1; } } if (end < start) { @@ -536,13 +532,13 @@ pcib_maxslots(device_t dev) * Since we are a child of a PCI bus, its parent must support the pcib interface. */ uint32_t -pcib_read_config(device_t dev, int b, int s, int f, int reg, int width) +pcib_read_config(device_t dev, u_int b, u_int s, u_int f, u_int reg, int width) { return(PCIB_READ_CONFIG(device_get_parent(device_get_parent(dev)), b, s, f, reg, width)); } void -pcib_write_config(device_t dev, int b, int s, int f, int reg, uint32_t val, int width) +pcib_write_config(device_t dev, u_int b, u_int s, u_int f, u_int reg, uint32_t val, int width) { PCIB_WRITE_CONFIG(device_get_parent(device_get_parent(dev)), b, s, f, reg, val, width); } Modified: head/sys/dev/pci/pcib_private.h ============================================================================== --- head/sys/dev/pci/pcib_private.h Sat Mar 14 14:02:53 2009 (r189791) +++ head/sys/dev/pci/pcib_private.h Sat Mar 14 14:08:53 2009 (r189792) @@ -74,8 +74,8 @@ int pcib_write_ivar(device_t dev, devic struct resource *pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags); int pcib_maxslots(device_t dev); -uint32_t pcib_read_config(device_t dev, int b, int s, int f, int reg, int width); -void pcib_write_config(device_t dev, int b, int s, int f, int reg, uint32_t val, int width); +uint32_t pcib_read_config(device_t dev, u_int b, u_int s, u_int f, u_int reg, int width); +void pcib_write_config(device_t dev, u_int b, u_int s, u_int f, u_int reg, uint32_t val, int width); int pcib_route_interrupt(device_t pcib, device_t dev, int pin); int pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, int *irqs); int pcib_release_msi(device_t pcib, device_t dev, int count, int *irqs);