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: 8558631 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6D067C0553 for ; Thu, 10 Mar 2016 16:08:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 65D39201F4 for ; Thu, 10 Mar 2016 16:08:34 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 743EC201D3 for ; Thu, 10 Mar 2016 16:08:33 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ae360-0004UF-6j; Thu, 10 Mar 2016 16:05:52 +0000 Received: from mail-lb0-x231.google.com ([2a00:1450:4010:c04::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ae35w-0004Hf-Qi for linux-arm-kernel@lists.infradead.org; Thu, 10 Mar 2016 16:05:50 +0000 Received: by mail-lb0-x231.google.com with SMTP id k15so119930306lbg.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=URgFrX2kaF3zvWANuyud+RBkCIJoXbFBayrXNLYaCWXJPCvTeZYiasW4i68IKw34Pq V8fl1PksogBpLKTT+CqB8bGkyzVC6VaoZGnQThmKc39vJcl0w5SYN1YB1I+iqBotlB5M C3HKv5lKybI/2sEbokZzrggJ1G31HA8MnhXY/d2xG/UdPwIQuXqPwmT5nut/CjtcYjf1 Z9/+djdFsFBpeR3fZ6m/y5YtnBZQbe+86DA9eWzmMQCDZ41kzH0QRwXL8Tg8sUtHbt1R LzFxZxDSm481NjnIBX0Ck5VSRxSKZncaTEMWUq4Jvmru9gBOlv48Xt4xsbESkt0/QxNY ubBQ== X-Gm-Message-State: AD7BkJLnzD0gzyVwwa4AjjkYacWj4FPaAOAXb5TSXIMOJZDiyqjmpomBL6gtmaf6khPKlg== 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 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160310_080549_144030_99057B10 X-CRM114-Status: GOOD ( 14.27 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, arnd@arndb.de, geert+renesas@glider.be, vinod.koul@intel.com, linus.walleij@linaro.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, iommu@lists.linux-foundation.org, laurent.pinchart@ideasonboard.com, dmaengine@vger.kernel.org, dan.j.williams@intel.com, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable 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