From owner-freebsd-arch@freebsd.org Fri Aug 28 19:59:38 2015 Return-Path: Delivered-To: freebsd-arch@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 517C49C56D7 for ; Fri, 28 Aug 2015 19:59:38 +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 2E207913 for ; Fri, 28 Aug 2015 19:59:38 +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 44438B94B; Fri, 28 Aug 2015 15:59:37 -0400 (EDT) From: John Baldwin To: freebsd-arch@freebsd.org Cc: Marcel Moolenaar , Justin Hibbits Subject: Re: Devices with 36-bit paddr on 32-bit system Date: Fri, 28 Aug 2015 10:35:50 -0700 Message-ID: <1568331.OrSoeYfXsf@ralph.baldwin.cx> User-Agent: KMail/4.14.3 (FreeBSD/10.2-PRERELEASE; KDE/4.14.3; amd64; ; ) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 28 Aug 2015 15:59:37 -0400 (EDT) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2015 19:59:38 -0000 On Tuesday, August 25, 2015 08:55:45 AM Marcel Moolenaar wrote: >=20 > > On Aug 24, 2015, at 11:44 PM, Justin Hibbits wrote: > >=20 > > With my work porting FreeBSD to PowerPC e500mc and e5500, I have > > devices in my device tree mapped well above the 4GB mark > > (0xffexxxxxx), and have no idea how to properly address them for > > resources in rman. Do we already have a solution to support this? > > Part of the problem is the powerpc nexus does a straight convert to= > > vm_offset_t of rman_get_start() (itself returning a u_long), and > > vm_offset_t is not necessarily equal to vm_paddr_t (on Book-E power= pc > > vm_offset_t is 32-bits, vm_paddr_t is 64-bits). >=20 > I think the best solution is to represent a resource address > space with a type other than u_long. It makes sense to have > it use bus_addr_t or vm_paddr_t for example. Such a change > comes at a high price for sure, but you=E2=80=99ll fix it once and > for all. I don=E2=80=99t think you should kluge your way out of this.= .. Expanding beyond u_long is the right solution. PAE doesn't generally s= uffer from this on i386 (though the ram0 device "punts" and ignores RAM range= s above 4G as a workaround). However, u_long is baked into the bus resource API quite a bit. Specif= ically, the values 0ul and ~0ul are used as magic numbers in lots of places to = request "anywhere" locations. Some of this has been mitigated by bus_alloc_resource_any(), but that doesn't cover all cases. You will p= robably want to add some explicit constants and do a sweep replacing the magic = numbers with those first (and MFC the constants at least to make it easier to p= ort drivers across branches). Then you can change the type. As far as the best type: rman's are in theory generic and not just for = bus addresses. I'd be tempted to let each platform define an rman_addr_t a= long with RMAN_ADDR_MAX constants, but in practice it is probably fine to us= e bus_addr_t and BUS_SPACE_MAXADDR. If you do that it also means you can= skip the step of having to MFC new constants. Note that various bus APIs will have to change to use bus_addr_t instea= d of u_long as well. --=20 John Baldwin