Received: by 10.223.185.116 with SMTP id b49csp3598754wrg; Mon, 19 Feb 2018 02:50:50 -0800 (PST) X-Google-Smtp-Source: AH8x227OjDHnGwHXkVJ/bRtC935J5sACBuancr7RDl8C5u082lA9WkCGZNyIhnBG+W8E5I0lFara X-Received: by 2002:a17:902:6b82:: with SMTP id p2-v6mr14042644plk.30.1519037450578; Mon, 19 Feb 2018 02:50:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519037450; cv=none; d=google.com; s=arc-20160816; b=OeSiQ2C6q00IDV/qX8Vqb2KanY/xvQmCBeGp6d5Qtd/JLQ6TtXa8qNWXzaYvV5M+s/ gonxYu2e0nGMwCjALATVy60FqDqq12yYErnWXYb6pq3hGoos3yok/3xbKz1K6FF/LV/c D1sCkoDiAcNq4HMPiEJEYHV9NzK0RLDKbVuU7yoJkCujK74D7f7RQGIvTsa0gtbC8RJW KGM+w+AjE/kNyuG+lQfqUT12ONAJGJqDowTVdf/ypl7kAsUfd270yVlG4e0WaSGZzVEW /LTlDeX7BOwJAjX2Yw9nnifQTQAV4BAs9yEfsil6qgx6xMZyHdo7NQBI5hut9z1nWndR 3jLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=p72swYNRHKLxTrkgE5EZlVGHy66nO3I7fFDuIGcIVLs=; b=yIRQIau2ihRs19erOcbRFakpXGhQeypmL8d5idNPaN1PToEMO2XAXHOxEox4ivF82c tYJByQFin26UPN3Z+WyrTfOXtoUF3NZ+pWfQZ+Kvqcr0hE0g65vby72kBpe1Y8Sl4+hJ 9cJPzVvgjYIQJaHox6hxRnsBjnjoTqB4t99S0V2KIueISYtJ3TTqRgQ7C75dzHG4f40n RVIhnv1PEs++1i/GpQaYLfSWYQLQvyUP8rklaTOMQJKMES8UGUHEUyL07VIa0R5yzw4u xIz/M4waXR5b3FEROcX3slFI4EMjvRan/IZsan3XmMQg9bA/TbbXTEo3iVdX6ix7gneY tRkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=NfiMy5Ar; dkim=pass header.i=@codeaurora.org header.s=default header.b=NfiMy5Ar; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e9-v6si6013159plt.685.2018.02.19.02.50.36; Mon, 19 Feb 2018 02:50:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=NfiMy5Ar; dkim=pass header.i=@codeaurora.org header.s=default header.b=NfiMy5Ar; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752562AbeBSKtv (ORCPT + 99 others); Mon, 19 Feb 2018 05:49:51 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:52804 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752392AbeBSKtt (ORCPT ); Mon, 19 Feb 2018 05:49:49 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id DAD566079C; Mon, 19 Feb 2018 10:49:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519037388; bh=JTHXnrRbWVgY5N6Xm/D47SUzaZDBN/XxbaH1Er67Dlo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NfiMy5ArNLSYWackPOyAbQb6zUvPRHU62gYZjbl8Vx28W8Za3qFxAQnkIOk+G7bYh IYqlD0mwBqSPNDodVu8waM/pI5oStLtWdHk3JZKM+2SPC75yTkRvZTHT/uEzqowArt bSYzlUw7/YJ4kgEEIH7jHS8DjZcD1x4cpzngcszA= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 75ED260209; Mon, 19 Feb 2018 10:49:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519037388; bh=JTHXnrRbWVgY5N6Xm/D47SUzaZDBN/XxbaH1Er67Dlo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NfiMy5ArNLSYWackPOyAbQb6zUvPRHU62gYZjbl8Vx28W8Za3qFxAQnkIOk+G7bYh IYqlD0mwBqSPNDodVu8waM/pI5oStLtWdHk3JZKM+2SPC75yTkRvZTHT/uEzqowArt bSYzlUw7/YJ4kgEEIH7jHS8DjZcD1x4cpzngcszA= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 19 Feb 2018 16:19:48 +0530 From: Abhishek Sahu To: Sricharan R Cc: Andy Gross , Wolfram Sang , David Brown , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 07/12] i2c: qup: use the complete transfer length to choose DMA mode In-Reply-To: <4a3d98e2-c340-1a13-eaa4-dde07768e7d8@codeaurora.org> References: <1517644697-30806-1-git-send-email-absahu@codeaurora.org> <1517644697-30806-8-git-send-email-absahu@codeaurora.org> <4a3d98e2-c340-1a13-eaa4-dde07768e7d8@codeaurora.org> Message-ID: <0142c0722cd0d444711918741e3691ab@codeaurora.org> X-Sender: absahu@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-02-16 10:05, Sricharan R wrote: > On 2/3/2018 1:28 PM, Abhishek Sahu wrote: >> Currently each message length in complete transfer is being >> checked for determining DMA mode and if any of the message length >> is less than FIFO length then non DMA mode is being used which >> will increase overhead. DMA can be used for any length and it >> should be determined with complete transfer length. Now, this >> patch introduces DMA threshold length and the transfer will be >> done in DMA mode if the total length is greater than this >> threshold length. >> >> Signed-off-by: Abhishek Sahu >> --- >> drivers/i2c/busses/i2c-qup.c | 15 +++++++++------ >> 1 file changed, 9 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/i2c/busses/i2c-qup.c >> b/drivers/i2c/busses/i2c-qup.c >> index 6227a5c..a91fc70 100644 >> --- a/drivers/i2c/busses/i2c-qup.c >> +++ b/drivers/i2c/busses/i2c-qup.c >> @@ -192,6 +192,8 @@ struct qup_i2c_dev { >> bool is_dma; >> /* To check if the current transfer is using DMA */ >> bool use_dma; >> + /* The threshold length above which DMA will be used */ >> + unsigned int dma_threshold; >> struct dma_pool *dpool; >> struct qup_i2c_tag start_tag; >> struct qup_i2c_bam brx; >> @@ -1294,7 +1296,8 @@ static int qup_i2c_xfer_v2(struct i2c_adapter >> *adap, >> int num) >> { >> struct qup_i2c_dev *qup = i2c_get_adapdata(adap); >> - int ret, len, idx = 0; >> + int ret, idx = 0; >> + unsigned int total_len = 0; >> >> qup->bus_err = 0; >> qup->qup_err = 0; >> @@ -1320,14 +1323,13 @@ static int qup_i2c_xfer_v2(struct i2c_adapter >> *adap, >> goto out; >> } >> >> - len = (msgs[idx].len > qup->out_fifo_sz) || >> - (msgs[idx].len > qup->in_fifo_sz); >> - >> - if (is_vmalloc_addr(msgs[idx].buf) || !len) >> + if (is_vmalloc_addr(msgs[idx].buf)) >> break; >> + >> + total_len += msgs[idx].len; >> } >> >> - if (idx == num) >> + if (idx == num && total_len > qup->dma_threshold) >> qup->use_dma = true; >> } >> >> @@ -1587,6 +1589,7 @@ static int qup_i2c_probe(struct platform_device >> *pdev) >> >> size = QUP_INPUT_FIFO_SIZE(io_mode); >> qup->in_fifo_sz = qup->in_blk_sz * (2 << size); >> + qup->dma_threshold = min(qup->out_fifo_sz, qup->in_fifo_sz); > > The patch is fine. small nit, you can avoid this global > dma_threshold. Instead > have it locally in qup_i2c_xfer_v2 itself. Thanks Sricharan. The idea for introducing global dma_threshold was to give option for controlling the behavior from one place. If someone wants to change the length above which dma will be used, then It can be controlled from once place in the probe function itself. Also, min(qup->out_fifo_sz, qup->in_fifo_sz) requires comparison and adding in qup_i2c_xfer_v2 will make this happen everytime. Regards, Abhishek