{"id":816406,"url":"http://patchwork.ozlabs.org/api/patches/816406/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20170920185956.13874-5-wsa+renesas@sang-engineering.com/","project":{"id":35,"url":"http://patchwork.ozlabs.org/api/projects/35/?format=json","name":"Linux I2C development","link_name":"linux-i2c","list_id":"linux-i2c.vger.kernel.org","list_email":"linux-i2c@vger.kernel.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170920185956.13874-5-wsa+renesas@sang-engineering.com>","list_archive_url":null,"date":"2017-09-20T18:59:54","name":"[RFC,v5,4/6] i2c: sh_mobile: use helper to decide if DMA is useful","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"7522c9a8f015a8bfb6ff9cd82f3113da2176be4f","submitter":{"id":69646,"url":"http://patchwork.ozlabs.org/api/people/69646/?format=json","name":"Wolfram Sang","email":"wsa+renesas@sang-engineering.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20170920185956.13874-5-wsa+renesas@sang-engineering.com/mbox/","series":[{"id":4199,"url":"http://patchwork.ozlabs.org/api/series/4199/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-i2c/list/?series=4199","date":"2017-09-20T18:59:56","name":"i2c: document DMA handling and add helpers for it","version":5,"mbox":"http://patchwork.ozlabs.org/series/4199/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/816406/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/816406/checks/","tags":{},"related":[],"headers":{"Return-Path":"<linux-i2c-owner@vger.kernel.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=linux-i2c-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xy8Gc2Yn2z9s4s\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Sep 2017 05:01:12 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751862AbdITTBF (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tWed, 20 Sep 2017 15:01:05 -0400","from sauhun.de ([88.99.104.3]:38844 \"EHLO pokefinder.org\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1751506AbdITTAF (ORCPT <rfc822;linux-i2c@vger.kernel.org>);\n\tWed, 20 Sep 2017 15:00:05 -0400","from localhost (p54B332E6.dip0.t-ipconnect.de [84.179.50.230])\n\tby pokefinder.org (Postfix) with ESMTPSA id 876B22C43A5;\n\tWed, 20 Sep 2017 21:00:03 +0200 (CEST)"],"From":"Wolfram Sang <wsa+renesas@sang-engineering.com>","To":"linux-i2c@vger.kernel.org","Cc":"linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org,\n\tlinux-iio@vger.kernel.org, linux-input@vger.kernel.org,\n\tlinux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,\n\tWolfram Sang <wsa+renesas@sang-engineering.com>","Subject":"[RFC PATCH v5 4/6] i2c: sh_mobile: use helper to decide if DMA is\n\tuseful","Date":"Wed, 20 Sep 2017 20:59:54 +0200","Message-Id":"<20170920185956.13874-5-wsa+renesas@sang-engineering.com>","X-Mailer":"git-send-email 2.11.0","In-Reply-To":"<20170920185956.13874-1-wsa+renesas@sang-engineering.com>","References":"<20170920185956.13874-1-wsa+renesas@sang-engineering.com>","Sender":"linux-i2c-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<linux-i2c.vger.kernel.org>","X-Mailing-List":"linux-i2c@vger.kernel.org"},"content":"This ensures that we fall back to PIO if the message length is too small\nfor DMA being useful. Otherwise, we use DMA. A bounce buffer might be\napplied by the helper if the original message buffer is not DMA safe.\n\nSigned-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>\n---\n drivers/i2c/busses/i2c-sh_mobile.c | 8 ++++++--\n 1 file changed, 6 insertions(+), 2 deletions(-)","diff":"diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c\nindex 6f2aaeb7c4fa15..b76399d8a3abd3 100644\n--- a/drivers/i2c/busses/i2c-sh_mobile.c\n+++ b/drivers/i2c/busses/i2c-sh_mobile.c\n@@ -145,6 +145,7 @@ struct sh_mobile_i2c_data {\n \tstruct dma_chan *dma_rx;\n \tstruct scatterlist sg;\n \tenum dma_data_direction dma_direction;\n+\tu8 *dma_buf;\n };\n \n struct sh_mobile_dt_config {\n@@ -548,6 +549,8 @@ static void sh_mobile_i2c_dma_callback(void *data)\n \tpd->pos = pd->msg->len;\n \tpd->stop_after_dma = true;\n \n+\ti2c_release_dma_safe_msg_buf(pd->msg, pd->dma_buf);\n+\n \tiic_set_clr(pd, ICIC, 0, ICIC_TDMAE | ICIC_RDMAE);\n }\n \n@@ -608,7 +611,7 @@ static void sh_mobile_i2c_xfer_dma(struct sh_mobile_i2c_data *pd)\n \tif (IS_ERR(chan))\n \t\treturn;\n \n-\tdma_addr = dma_map_single(chan->device->dev, pd->msg->buf, pd->msg->len, dir);\n+\tdma_addr = dma_map_single(chan->device->dev, pd->dma_buf, pd->msg->len, dir);\n \tif (dma_mapping_error(chan->device->dev, dma_addr)) {\n \t\tdev_dbg(pd->dev, \"dma map failed, using PIO\\n\");\n \t\treturn;\n@@ -665,7 +668,8 @@ static int start_ch(struct sh_mobile_i2c_data *pd, struct i2c_msg *usr_msg,\n \tpd->pos = -1;\n \tpd->sr = 0;\n \n-\tif (pd->msg->len > 8)\n+\tpd->dma_buf = i2c_get_dma_safe_msg_buf(pd->msg, 8);\n+\tif (pd->dma_buf)\n \t\tsh_mobile_i2c_xfer_dma(pd);\n \n \t/* Enable all interrupts to begin with */\n","prefixes":["RFC","v5","4/6"]}