From owner-svn-src-head@FreeBSD.ORG Fri Sep 12 20:34:20 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EB505506; Fri, 12 Sep 2014 20:34:19 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D695D626; Fri, 12 Sep 2014 20:34:19 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s8CKYJcQ046536; Fri, 12 Sep 2014 20:34:19 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s8CKYJSv046534; Fri, 12 Sep 2014 20:34:19 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201409122034.s8CKYJSv046534@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 12 Sep 2014 20:34:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r271484 - in head/sys/arm: arm xscale/ixp425 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Sep 2014 20:34:20 -0000 Author: jhb Date: Fri Sep 12 20:34:19 2014 New Revision: 271484 URL: http://svnweb.freebsd.org/changeset/base/271484 Log: - Don't let rman_reserve_resource() activate the resource in nexus_alloc_resource() and don't set a bushandle. nexus_activate_resource() will set a proper bushandle. - Implement a proper nexus_release_resource(). - Fix ixppcib_activate_resource() to call rman_activate_resource() before creating a mapping for the resource. Tested by: jmg Modified: head/sys/arm/arm/nexus.c head/sys/arm/xscale/ixp425/ixp425_pci.c Modified: head/sys/arm/arm/nexus.c ============================================================================== --- head/sys/arm/arm/nexus.c Fri Sep 12 20:16:55 2014 (r271483) +++ head/sys/arm/arm/nexus.c Fri Sep 12 20:34:19 2014 (r271484) @@ -90,6 +90,8 @@ static int nexus_config_intr(device_t de enum intr_polarity pol); static int nexus_deactivate_resource(device_t, device_t, int, int, struct resource *); +static int nexus_release_resource(device_t, device_t, int, int, + struct resource *); static int nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep); @@ -111,6 +113,7 @@ static device_method_t nexus_methods[] = DEVMETHOD(bus_activate_resource, nexus_activate_resource), DEVMETHOD(bus_config_intr, nexus_config_intr), DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource), + DEVMETHOD(bus_release_resource, nexus_release_resource), DEVMETHOD(bus_setup_intr, nexus_setup_intr), DEVMETHOD(bus_teardown_intr, nexus_teardown_intr), #ifdef FDT @@ -205,6 +208,8 @@ nexus_alloc_resource(device_t bus, devic struct rman *rm; int needactivate = flags & RF_ACTIVE; + flags &= ~RF_ACTIVE; + switch (type) { case SYS_RES_MEMORY: case SYS_RES_IOPORT: @@ -212,15 +217,14 @@ nexus_alloc_resource(device_t bus, devic break; default: - return (0); + return (NULL); } rv = rman_reserve_resource(rm, start, end, count, flags, child); if (rv == 0) - return (0); + return (NULL); rman_set_rid(rv, *rid); - rman_set_bushandle(rv, rman_get_start(rv)); if (needactivate) { if (bus_activate_resource(child, type, *rid, rv)) { @@ -233,6 +237,20 @@ nexus_alloc_resource(device_t bus, devic } static int +nexus_release_resource(device_t bus, device_t child, int type, int rid, + struct resource *res) +{ + int error; + + if (rman_get_flags(res) & RF_ACTIVE) { + error = bus_deactivate_resource(child, type, rid, res); + if (error) + return (error); + } + return (rman_release_resource(res)); +} + +static int nexus_config_intr(device_t dev, int irq, enum intr_trigger trig, enum intr_polarity pol) { Modified: head/sys/arm/xscale/ixp425/ixp425_pci.c ============================================================================== --- head/sys/arm/xscale/ixp425/ixp425_pci.c Fri Sep 12 20:16:55 2014 (r271483) +++ head/sys/arm/xscale/ixp425/ixp425_pci.c Fri Sep 12 20:34:19 2014 (r271484) @@ -320,9 +320,12 @@ static int ixppcib_activate_resource(device_t bus, device_t child, int type, int rid, struct resource *r) { - struct ixppcib_softc *sc = device_get_softc(bus); + int error; + error = rman_activate_resource(r); + if (error) + return (error); switch (type) { case SYS_RES_IOPORT: rman_set_bustag(r, &sc->sc_pci_iot); @@ -335,7 +338,7 @@ ixppcib_activate_resource(device_t bus, break; } - return (rman_activate_resource(r)); + return (0); } static int