From owner-freebsd-embedded@FreeBSD.ORG Mon Oct 13 05:24:53 2014 Return-Path: Delivered-To: freebsd-embedded@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 69117BC0; Mon, 13 Oct 2014 05:24:53 +0000 (UTC) Received: from mail-oi0-x233.google.com (mail-oi0-x233.google.com [IPv6:2607:f8b0:4003:c06::233]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 23DA2D81; Mon, 13 Oct 2014 05:24:53 +0000 (UTC) Received: by mail-oi0-f51.google.com with SMTP id h136so12050714oig.38 for ; Sun, 12 Oct 2014 22:24:52 -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=Ie0enbV1ysSU/HpnrfpfRd5Y+nDGoR47eliYz6/mQ7E=; b=pAt8lk20HOrIQYCWbs4tVOgTYG6m9C09ObmX5Skaglox9DV2DccJh1MUOZU/hrs/tA MIdWjYuJCbT9H5gp2AQhR3AlryjPWOt28Oi+v6SG1hFHoZi9CVpH0HxrWtDwKOgOYOlm dfM9UWO6s60xrGDfm/pkrHmz8nBbUW9Su0fDCLYp+wgSIwEXkHlOfz1Nt+2HQ7ckvyw2 ypCegCHmS5KEqPt5WnifhJ6nan1M4+iwvoxx6YbGLCoExO9zxXs5ju3jSHe2Fr9qr/pI Uy7kRWb3Imd5NCm1KwhbcRDDGcanYbSoS7j1sbXaJzTVvPiilMH7qs/XcE7F5DloRqjf 0s7w== MIME-Version: 1.0 X-Received: by 10.202.196.214 with SMTP id u205mr5847391oif.48.1413177892130; Sun, 12 Oct 2014 22:24:52 -0700 (PDT) Received: by 10.60.118.196 with HTTP; Sun, 12 Oct 2014 22:24:52 -0700 (PDT) In-Reply-To: <20141006171521.GD26076@kib.kiev.ua> References: <20141006171521.GD26076@kib.kiev.ua> Date: Mon, 13 Oct 2014 02:24:52 -0300 Message-ID: Subject: Re: A few questions about SD/MMC drivers From: Martin Galvan To: Konstantin Belousov Content-Type: text/plain; charset=UTF-8 Cc: freebsd-drivers@freebsd.org, freebsd-embedded@freebsd.org X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Oct 2014 05:24:53 -0000 Hi again! I'm in the middle of implementing DMA support for the Allwinner driver, and I was surprised to see that BSD doesn't have a simple DMA API as Linux does. Namely, I didn't see anything like the scatterlists used in Linux. The host found in Allwinner SoCs uses a DMA controller which works with a linked list of descriptors, each having info on a data buffer. In the Linux driver they allocate a coherent DMA buffer using dma_alloc_coherent to get both the virtual and bus addresses of the descriptor list. When it's time to do a DMA transfer, the Linux driver allocates a scatterlist with each entry being a buffer corresponding to a descriptor; it then loops through the descriptor list setting the "buffer pointer" field of each one to the bus address of the corresponding scatterlist entry, and the "next descriptor" to the bus address of the following descriptor. It's pretty neat, though it's worth mentioning the scatterlist that the MMC request handler maps already contains the virtual addresses of the requested buffers. Do we have anything like that on BSD? If not, what would be a simple algorithm to make this work? Again, thanks a lot!