From owner-freebsd-arm@FreeBSD.ORG Mon Dec 9 12:14:40 2013 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AD9A1F99 for ; Mon, 9 Dec 2013 12:14:40 +0000 (UTC) Received: from mail-qa0-x22c.google.com (mail-qa0-x22c.google.com [IPv6:2607:f8b0:400d:c00::22c]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6F0B914BB for ; Mon, 9 Dec 2013 12:14:40 +0000 (UTC) Received: by mail-qa0-f44.google.com with SMTP id i13so2538016qae.17 for ; Mon, 09 Dec 2013 04:14:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=DwiHCru4xjQsfWDcVTE6M826RHy7b/tvMVWrmNtbArU=; b=S5yjjPWdxAkAfSIt9RJgFkHYrODX0zYomQSmBurVNR9WDrQlAf83VUjSNgndsTLD80 JF7derjapn3Cf/XcVyvFVv/M4n3jsjDhriDnjf0536WAkRy7373GkC+UmrbTQ8+yPUce 1XgIWNB66N4M+CGHv3Cu62uOyeKldv6t06BCpsErWRPU89mb9YORwYMPIJqhGKWmLjva zl1qRnrisXMoJCbEGRvHIXocnQMhTD+h25tFBj66ZLmJeJeZVIlwo4DuYC6QL4cQERDY /xeCTuOmiwoPOSPy7g6uiEA7SFJIXBFOHedgDHeqbYCtav+nGOfH+ptTJ5/7DsHi+UM0 9U8w== MIME-Version: 1.0 X-Received: by 10.49.129.38 with SMTP id nt6mr24844005qeb.78.1386591279685; Mon, 09 Dec 2013 04:14:39 -0800 (PST) Received: by 10.140.42.87 with HTTP; Mon, 9 Dec 2013 04:14:39 -0800 (PST) Date: Mon, 9 Dec 2013 13:14:39 +0100 Message-ID: Subject: _bus_dmamap_sync() and L2 cache sync From: Svatopluk Kraus To: freebsd-arm@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.17 X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Dec 2013 12:14:40 -0000 Hi, when I and Michal Meloun were debugging problems on our ethernet driver on arm11 mpcore platform at work, we found out that rx/tx descriptors rings are not correctly synced for DMA. These descriptors are mapped as uncachable, i.e. their bus_dmamap_t maps have DMAMAP_COHERENT flag set. We realized that L2 cache must be synced the same way as L1 cache. I.e., L2 cache write buffer and others must be flushed before DMA is started. Now, in our implementation, we always call cache_dma_sync() in the beginning of _bus_dmamap_sync() even for DMAMAP_COHERENT maps. The cache_dma_sync() is implemented as: static __inline void cache_dma_sync(void) { dsb(); l2cache.sync(l2cache.arg); dsb(); } Regards, Svatopluk Kraus