From owner-freebsd-mips@FreeBSD.ORG Tue Sep 4 17:40:24 2012 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 83FB8106566C; Tue, 4 Sep 2012 17:40:24 +0000 (UTC) (envelope-from marktinguely@gmail.com) Received: from mail-pb0-f54.google.com (mail-pb0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id 527318FC0A; Tue, 4 Sep 2012 17:40:24 +0000 (UTC) Received: by pbbrp2 with SMTP id rp2so9859260pbb.13 for ; Tue, 04 Sep 2012 10:40:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=FSKxIKJzxlThRtTL/56QWNlwWO8kJIfLNlxB3TT4TxU=; b=pM7jlDAmlPWR1L7rr/T/rSgH89KjR46um82MUGFGD1PtxgwhkNQuqJdH6rFuxHtKQL l+WoW4L68VzFl0VgKcs8ioSW3PpAqqAz7Ctwnja8Co2ULJ6LR3zzXvO18d8WFx1RBnZw q2Jmq2xW+F6/IrwnmjftHKc1ZoTgMWoGRmlTFZUsBOhWrkEqkHYBBUHspkR0ZjqUKd4+ CUel3XcE7WnCdCbGM9MIpswFVzm5q7Yul5uRvrdmIqke+zB7F1LHahKmEwQVIuFYqeTL 6C/N+KeY5ZeKS5b8mmIWHur+/DEL2VacmnUetOLgDpCBQo+KQIy2Zwd1X5hyuCLlcEhm kmrA== MIME-Version: 1.0 Received: by 10.68.231.130 with SMTP id tg2mr47699707pbc.70.1346780423964; Tue, 04 Sep 2012 10:40:23 -0700 (PDT) Received: by 10.68.229.227 with HTTP; Tue, 4 Sep 2012 10:40:23 -0700 (PDT) In-Reply-To: <1346777897.1140.633.camel@revolution.hippie.lan> References: <1346777897.1140.633.camel@revolution.hippie.lan> Date: Tue, 4 Sep 2012 12:40:23 -0500 Message-ID: From: Mark Tinguely To: Ian Lepore Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-arm@freebsd.org, freebsd-mips@freebsd.org Subject: Re: busdma buffer management enhancements - call for review and test X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Sep 2012 17:40:24 -0000 On Tue, Sep 4, 2012 at 11:58 AM, Ian Lepore wrote: > The attached set of patches enhances the ARM v4/v5 busdma management of > small DMA buffers, especially for BUS_DMA_COHERENT and uncacheable > memory. The existing implementation uses malloc(9) to allocate buffers, > then uses arm_remap_nocache() to make the page(s) containing the buffers > uncacheable, even when those pages contain data other than DMA buffers. > > The attached patches address this by: > > * Adding support for pmap_page_set_memattr() and > VM_MEMATTR_UNCACHEABLE to the ARM v4 pmap implemenation. > * Adding new common code usable by any platform that uses uma(9) > to manage pools of power-of-two sized buffers, keeping them > sized and aligned as required to help maintain cache coherency. > * Modifying the busdma implementation to use the new pool manager > to manage pools of both regular and uncacheable buffers, and > also to use uma(9) to manage a pool of map structures. > * Using knowledge of the alignment and padding of pool-allocated > buffers to avoid doing partial cache line flushes on those > buffers. > > I'm CC'ing freebsd-mips because I think these patches can be adapted to > the MIPS busdma implementation as well. The new busdma_bufalloc.[ch] > code isn't arm-specific, and shouldn't live in sys/arm/arm/, but I don't > know where it should go. > > Once we have ARM and MIPS able to efficiently manage small cache-aligned > DMA buffers, the stage is set to begin updating device drivers to > allocate buffers individually, rather than allocating huge chunks and > sub-dividing them, possibly violating cache line boundaries in doing so. > > I've been running these for a couple days on DreamPlug and Atmel > hardware (the latter in an 8.x environment) without problems. > > -- Ian How about having a per processor cache line definition rather than using: +#define MIN_ZONE_BUFSIZE 32 For those archs that have a 64 byte cache line. I like the separation of the regular and BUS_DMA_COHERENT or BUS_DMA_NOCACHE. I never liked turning the cache off the entire page for a few DMA buffers. --Mark.