From owner-freebsd-arch@FreeBSD.ORG Sat Jan 31 12:58:36 2015 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1FAFDD35 for ; Sat, 31 Jan 2015 12:58:36 +0000 (UTC) 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 EAFE298A for ; Sat, 31 Jan 2015 12:58:35 +0000 (UTC) Received: from ralph.baldwin.cx (pool-173-54-116-245.nwrknj.fios.verizon.net [173.54.116.245]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 6361AB94B; Sat, 31 Jan 2015 07:58:34 -0500 (EST) From: John Baldwin To: Warner Losh Subject: Re: Wrapper API for static bus_dma allocations Date: Sat, 31 Jan 2015 07:57:35 -0500 Message-ID: <1740117.2W2DTbza1h@ralph.baldwin.cx> User-Agent: KMail/4.14.2 (FreeBSD/10.1-STABLE; KDE/4.14.2; amd64; ; ) In-Reply-To: <21F3F28E-DAB8-4809-A9ED-1095F6BECCFC@bsdimp.com> References: <2800970.jY4xzTy9Hz@ralph.baldwin.cx> <1440008.gcoNUU8dV6@ralph.baldwin.cx> <21F3F28E-DAB8-4809-A9ED-1095F6BECCFC@bsdimp.com> 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); Sat, 31 Jan 2015 07:58:34 -0500 (EST) Cc: Konstantin Belousov , Poul-Henning Kamp , freebsd-arch X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Jan 2015 12:58:36 -0000 On Friday, January 30, 2015 09:07:52 PM Warner Losh wrote: > > On Jan 30, 2015, at 2:31 PM, John Baldwin wrote: > >=20 > > On Friday, January 30, 2015 05:21:50 PM Konstantin Belousov wrote: > >> On Fri, Jan 30, 2015 at 09:56:31AM -0500, John Baldwin wrote: > >>> On 1/29/15 4:54 PM, Poul-Henning Kamp wrote: > >>>> -------- > >>>>=20 > >>>> In message <2800970.jY4xzTy9Hz@ralph.baldwin.cx>, John Baldwin w= rites: > >>>>> The bus_dma API to allocate a chunk of static DMA'able memory (= e.g. > >>>>> for > >>>>> descriptor rings) can be a bit obtuse [...] > >>>>=20 > >>>> Isn't it time we take a good hard stare at all of the bus_dma AP= I, > >>>> and refactor it into something a lot more compact ? > >>>=20 > >>> Given the amount of oddball hardware out there I don't think ther= e is a > >>> lot you can cut out. The filter function might be something we c= an lose > >>> (and losing it would simplify the implementation), but all the ot= her > >>> weird constraints are actually used by something AFAIK. I do thi= nk we > >>> can provide some simpler wrappers for some of the more common cas= es, but > >>> there will be some hardware for which those wrappers do not work.= > >>>=20 > >>> One suggestion Scott has had is to at least make it easier to ext= end the > >>> API by using getter/setter routines on the tag to work with tag > >>> attributes instead of passing them all in bus_dma_tag_create(). > >>=20 > >> BTW, filter function is useless. It can deny specific bus address= from > >> being used, but it does not provide the busdma implementation even= a hint > >> what other address should be (tried to) used. In dmar busdma, I s= imply > >> ignored it. And there is no real users of filter in the tree. > >=20 > > Yes, it is very annoying. I think some old ISA SCSI HBA driver mig= ht have > > used it to skip over some low-memory hole (i.e. there were two vali= d DMA > > ranges and this was the kludge instead of having two sets of > > lowaddr/highaddr exclusions). (That is one part of the API we coul= d > > rototill is to just remove the highaddr arg just use a single arg w= hich > > is effectively lowaddr. I think all drivers always set highaddr to= > > BUS_SPACE_MAXADDR.) >=20 > Not all. There=E2=80=99s some PCI cards that can=E2=80=99t do 64-bit = cycles that pass in the > 32-bit value on 64-bit systems. There=E2=80=99s 386 instances of this= in the tree. > But that may be lowaddr only. It=E2=80=99s hard to grep for this to b= e sure. That is lowaddr only, not the filter callback. However, even if we remove the filter and highaddr arguments from tags,= you=20 are still stuck with creating a tag, allocating memory, and loading it = to get=20 a bus address (and tracking the associated pointers, etc.). I still th= ink a=20 wrapper API for the common case (static DMA allocations) would be usefu= l. Orthogonally I can explore removing the filter along with highaddr (it = is=20 always BUS_SPACE_MAXADDR). --=20 John Baldwin