From patchwork Thu Mar 10 16:05:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 8558601 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-renesas-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8BBA59F38C for ; Thu, 10 Mar 2016 16:05:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D0E2A200E1 for ; Thu, 10 Mar 2016 16:05:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CC29A20376 for ; Thu, 10 Mar 2016 16:05:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752967AbcCJQF3 (ORCPT ); Thu, 10 Mar 2016 11:05:29 -0500 Received: from mail-lb0-f171.google.com ([209.85.217.171]:33420 "EHLO mail-lb0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753335AbcCJQF1 (ORCPT ); Thu, 10 Mar 2016 11:05:27 -0500 Received: by mail-lb0-f171.google.com with SMTP id k15so119930374lbg.0 for ; Thu, 10 Mar 2016 08:05:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20150623.gappssmtp.com; s=20150623; h=from:date:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=frlanR/KfC0K1BLGzrj3OnFmHGAfqT9HtCBaTbqTwEU=; b=K6cuLBaTa91vruHAB+z04gdjN6Vx1gqFqOKaR4We1TvjbTrtlkqk+pApjR3xKqacYn Sq6cyASDC6cTi9LNogUrnvq01c2vN9lBAjgeBXXLbR6M2KF4Jg1S1uRpZZcK6LED7y/K wVDy15HXgdXuzIhjmOEjMn3L9/JMi6xBeuTJcxRBFhh2SMslX2DhuwwNwxMjkDMixMXk uB7qZqTMSyDgRNcZFfKKLpVROTvNO4qeUPBeSLigadLd5d9Ft4ccNGjEeMMWnAWemF0o vRg2snHio1Vv/PEchuvcQpBAEbMDK7M8p3ZUI25mGs01rUZ5KBmcABxMv7XVFdJaWHfo gTow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=frlanR/KfC0K1BLGzrj3OnFmHGAfqT9HtCBaTbqTwEU=; b=DkRjw3eBt4nmHFqBFNmiOdLYH0id5jwwPq6gMRbWlRIME7Q0WtrGEacTIu0J7VriwK RsP2tBUHtZwFSY6IHVfmQTh7LTMpFQRKvqQ3FcduxV1I0N85BbKqutrg0AchxXZrP+yh kCmpu2cdjPX+4FZQIYXp+1jzzz6TTGe5+i/e7Vbb33FhsrXP+W8zkt+52DVGajQDiy5s XkJ7e7LFlJG8eiHO/fxnR0KE6V/gOozo/SpQZtgxl48W+O7rp6NtQuEmqEY8uILzrM5C Q/AzBQzYmJN2rR9RFOrGIvuf39rkCS2cZ9iYl7eEEyIgeHQ1mSwEyNG6KuD4ukBhre20 F+KA== X-Gm-Message-State: AD7BkJKHt91u4Uf9phGEhQOBa2zPyxAyfPoRzgsrNgSoD0igQAwc1ayhUf7zKFVKbE/0Jw== X-Received: by 10.112.162.231 with SMTP id yd7mr1534499lbb.40.1457625924791; Thu, 10 Mar 2016 08:05:24 -0800 (PST) Received: from localhost (dynamic.0.6.79d1f80.14cc20ac3a53.cust.bredband2.com. [89.233.230.99]) by smtp.gmail.com with ESMTPSA id mi9sm613796lbc.27.2016.03.10.08.05.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Mar 2016 08:05:23 -0800 (PST) From: "Niklas S??derlund" X-Google-Original-From: Niklas S??derlund Date: Thu, 10 Mar 2016 17:05:23 +0100 To: Christoph Hellwig Cc: vinod.koul@intel.com, linux-renesas-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, iommu@lists.linux-foundation.org, robin.murphy@arm.com, laurent.pinchart@ideasonboard.com, geert+renesas@glider.be, linus.walleij@linaro.org, dan.j.williams@intel.com, arnd@arndb.de, linux-arch@vger.kernel.org Subject: Re: [PATCH v5 3/9] dma-mapping: add dma_{map,unmap}_resource Message-ID: <20160310160522.GB1111@bigcity.dyn.berto.se> Mail-Followup-To: Christoph Hellwig , vinod.koul@intel.com, linux-renesas-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, iommu@lists.linux-foundation.org, robin.murphy@arm.com, laurent.pinchart@ideasonboard.com, geert+renesas@glider.be, linus.walleij@linaro.org, dan.j.williams@intel.com, arnd@arndb.de, linux-arch@vger.kernel.org References: <1457404974-1800-1-git-send-email-niklas.soderlund+renesas@ragnatech.se> <1457404974-1800-4-git-send-email-niklas.soderlund+renesas@ragnatech.se> <20160308073847.GA15520@infradead.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160308073847.GA15520@infradead.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Christoph, On 2016-03-07 23:38:47 -0800, Christoph Hellwig wrote: > Please add some documentation on where/how this should be used. It's > not a very obvious interface. Good idea, I have added the following to Documentation/DMA-API.txt and folded it in to this patch. Do you feel it's adequate and do you know anywhere else I should add documentation? diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt index 45ef3f2..248556a 100644 --- a/Documentation/DMA-API.txt +++ b/Documentation/DMA-API.txt @@ -277,14 +277,29 @@ and parameters are provided to do partial page mapping, it is recommended that you never use these unless you really know what the cache width is. +dma_addr_t +dma_map_resource(struct device *dev, phys_addr_t phys_addr, size_t size, + enum dma_data_direction dir, struct dma_attrs *attrs) + +Maps a MMIO region so it can be accessed by the device and returns the +DMA address of the memory. API should only be used to map device MMIO, +mapping of RAM is not permitted. + +void +dma_unmap_resource(struct device *dev, dma_addr_t addr, size_t size, + enum dma_data_direction dir, struct dma_attrs *attrs) + +Unmaps the IOMMU region previously mapped. All the parameters passed in +must be identical to those passed in (and returned) by the mapping API. + int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) -In some circumstances dma_map_single() and dma_map_page() will fail to create -a mapping. A driver can check for these errors by testing the returned -DMA address with dma_mapping_error(). A non-zero return value means the mapping -could not be created and the driver should take appropriate action (e.g. -reduce current DMA mapping usage or delay and try again later). +In some circumstances dma_map_single(), dma_map_page() and dma_map_resource() +will fail to create a mapping. A driver can check for these errors by testing +the returned DMA address with dma_mapping_error(). A non-zero return value +means the mapping could not be created and the driver should take appropriate +action (e.g. reduce current DMA mapping usage or delay and try again later). -- Regards, Niklas Söderlund