From patchwork Tue Jun 6 09:20:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 9768341 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 83D4160393 for ; Tue, 6 Jun 2017 09:21:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 886C8212BE for ; Tue, 6 Jun 2017 09:21:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C993205AF; Tue, 6 Jun 2017 09:21:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BD41212BE for ; Tue, 6 Jun 2017 09:21:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751462AbdFFJUu (ORCPT ); Tue, 6 Jun 2017 05:20:50 -0400 Received: from sauhun.de ([88.99.104.3]:55294 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751382AbdFFJUr (ORCPT ); Tue, 6 Jun 2017 05:20:47 -0400 Received: from localhost (p54B33671.dip0.t-ipconnect.de [84.179.54.113]) by pokefinder.org (Postfix) with ESMTPSA id 088BD2C31AA; Tue, 6 Jun 2017 11:20:45 +0200 (CEST) From: Wolfram Sang To: linux-i2c@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Wolfram Sang Subject: [RFC PATCH 2/4] i2c: add docs to clarify DMA handling Date: Tue, 6 Jun 2017 11:20:32 +0200 Message-Id: <20170606092034.1516-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170606092034.1516-1-wsa+renesas@sang-engineering.com> References: <20170606092034.1516-1-wsa+renesas@sang-engineering.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Wolfram Sang --- Documentation/i2c/DMA-considerations | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Documentation/i2c/DMA-considerations diff --git a/Documentation/i2c/DMA-considerations b/Documentation/i2c/DMA-considerations new file mode 100644 index 00000000000000..945ac5cfe55c12 --- /dev/null +++ b/Documentation/i2c/DMA-considerations @@ -0,0 +1,28 @@ +Linux I2C and DMA +----------------- + +Given that I2C is a low-speed bus where largely small messages are transferred, +it is not considered a prime user of DMA access. At this time of writing, only +10% of I2C bus master drivers have DMA support implemented. And the vast +majority of transactions are so small that setting up DMA for it will likely +add more overhead than a plain PIO transfer. + +Therefore, it is *not* mandatory that the buffer of an i2c message is DMA safe. +It does not seem reasonable to apply additional burdens when the feature is so +rarely used. However, it is recommended to use a DMA-safe buffer, if your +message size is likely applicable for DMA (FIXME: > 8 byte?). + +To support this, drivers wishing to implement DMA can use a helper function +checking if the size is suitable for DMA or if the buffer is DMA capable: + + int i2c_check_msg_for_dma(msg, dma_threshold); + +Please check its in kernel documentation for details. + +It should be further noted that bounce buffer handling is left to be handled on +driver level because details like alignment requirements are best known on that +level. + +If you plan to use DMA with I2C (or with any other bus, actually) make sure you +have CONFIG_DMA_API_DEBUG enabled during development. It can help you find +various issues which can be complex to debug otherwise.