From owner-svn-src-head@freebsd.org Tue May 24 03:21:47 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AA5D2B4897D; Tue, 24 May 2016 03:21:47 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8A50D1C2E; Tue, 24 May 2016 03:21:47 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 6985EB94C; Mon, 23 May 2016 23:21:46 -0400 (EDT) From: John Baldwin To: Adrian Chadd Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r300548 - in head/sys: conf dev/bhnd dev/bhnd/bhndb dev/bhnd/cores/chipc dev/bhnd/nvram dev/bhnd/siba modules/bhnd modules/bhnd/cores/bhnd_chipc Date: Mon, 23 May 2016 20:18:26 -0700 Message-ID: <2018441.udrSCt4JcK@ralph.baldwin.cx> User-Agent: KMail/4.14.3 (FreeBSD/10.2-STABLE; KDE/4.14.3; amd64; ; ) In-Reply-To: <201605240112.u4O1CJOt063645@repo.freebsd.org> References: <201605240112.u4O1CJOt063645@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 23 May 2016 23:21:46 -0400 (EDT) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Tue, 24 May 2016 03:21:47 -0000 On Tuesday, May 24, 2016 01:12:19 AM Adrian Chadd wrote: > Author: adrian > Date: Tue May 24 01:12:19 2016 > New Revision: 300548 > URL: https://svnweb.freebsd.org/changeset/base/300548 > > Log: > [bhnd] Implement pass-through resource management for ChipCommon. > > This patchset adds support to bhnd_chipc for sharing SYS_RES_MEMORY > resources with its children, allowing us to hang devices off of > bhnd_chipc that rely on access to a subset of the device register space > that bhnd_chipc itself must also allocate. > > We could avoid most of this heavy lifting if RF_SHAREABLE+SYS_RES_MEMORY > wasn't limited to use with allocations at the same size/offset. > > As a work-around, I implemented something similar to vga_pci.c, which > implements similar reference counting of of PCI BAR resources for its > children. > > With these changes, chipc will use reference counting of SYS_RES_MEMORY > allocation/activation requests, to decide when to allocate/activate/ > deactivate/release resources from the parent bhnd(4) bus. > > The requesting child device is allocated a new resource from chipc's > rman, pointing to (possibly a subregion of) the refcounted bhnd resources > allocated by chipc. > > Other resource types are just passed directly to the parent bhnd bus; > RF_SHAREABLE works just fine with IRQs. > > I also lifted the SPROM device code out into a common driver, since this > now allows me to hang simple subclasses off of a common driver off of both > bhndb_pci and bhnd_chipc. Hmm, what the PCI-PCI bridge driver does with NEW_PCIB is to allocate a single resource from its parent bus for each I/O window it decodes. It then creates a rman that is populated with the addresses in that resource and suballocates from that rman. This allows child devices to allocate non-overlapping resources exclusively (they could also do shareable mappings for subsets if applicable). Right now NEW_PCIB assumes it can pass one of these "child" resources up to the nexus to have it "mapped" via bus_activate_resource(). However, the recently added bus_map_resource() provides a cleaner way to do this where a bridge device can request a mapping for the sub-range of the resource on its "upstream" side that corresponds to the range used by a resource for a child device. -- John Baldwin