From owner-freebsd-hackers@FreeBSD.ORG Mon Aug 6 14:40:02 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 83C9E1065670 for ; Mon, 6 Aug 2012 14:40:02 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id 535488FC0C for ; Mon, 6 Aug 2012 14:40:02 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 99D50B941; Mon, 6 Aug 2012 10:40:01 -0400 (EDT) From: John Baldwin To: Peter Jeremy Date: Mon, 6 Aug 2012 10:16:13 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p17; KDE/4.5.5; amd64; ; ) References: <20120703111753.GB72292@server.rulingia.com> <20120708110516.GA38312@server.rulingia.com> <201207120826.05577.jhb@freebsd.org> In-Reply-To: <201207120826.05577.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201208061016.13065.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 06 Aug 2012 10:40:01 -0400 (EDT) Cc: freebsd-hackers@freebsd.org Subject: Re: contigmalloc() breaking Xorg X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Aug 2012 14:40:02 -0000 On Thursday, July 12, 2012 8:26:05 am John Baldwin wrote: > However, rather add a wiredmalloc(), I think you should just have > bus_dmamem_alloc() call kmem_alloc_attr() directly in this case. One of the > things I've been meaning to add to bus_dma is a way to allocate other memory > types (e.g. WC memory), and in that case it would be best to just call > kmem_alloc_attr() directly instead. After my recent changes, I think this would do the above. What do you think of this, and if it looks ok, can you test it? Index: busdma_machdep.c =================================================================== --- busdma_machdep.c (revision 239020) +++ busdma_machdep.c (working copy) @@ -533,13 +533,14 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, dmat->lowaddr >= ptoa((vm_paddr_t)Maxmem) && attr == VM_MEMATTR_DEFAULT) { *vaddr = malloc(dmat->maxsize, M_DEVBUF, mflags); + } else if (dmat->nsegments >= btoc(dmat->maxsize) && + dmat->alignment <= PAGE_SIZE && + (dmat->boundary == 0 || dmat->boundary >= dmat->lowaddr)) { + /* Page-based multi-segment allocations allowed */ + *vaddr = (void *)kmem_alloc_attr(kernel_map, dmat->maxsize, + mflags, 0ul, dmat->lowaddr, attr); + *mapp = &contig_dmamap; } else { - /* - * XXX Use Contigmalloc until it is merged into this facility - * and handles multi-seg allocations. Nobody is doing - * multi-seg allocations yet though. - * XXX Certain AGP hardware does. - */ *vaddr = (void *)kmem_alloc_contig(kernel_map, dmat->maxsize, mflags, 0ul, dmat->lowaddr, dmat->alignment ? dmat->alignment : 1ul, dmat->boundary, attr); -- John Baldwin