Received: by 10.223.176.5 with SMTP id f5csp337735wra; Sat, 3 Feb 2018 00:20:29 -0800 (PST) X-Google-Smtp-Source: AH8x225G/HDbB0bHl9vcZ5GVhtVYPrMl7TxEoxnXc2f60En1oJwStHN9FQQtDw9NXVlyQ9fdTWYX X-Received: by 2002:a17:902:7841:: with SMTP id e1-v6mr17798233pln.130.1517646029466; Sat, 03 Feb 2018 00:20:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517646029; cv=none; d=google.com; s=arc-20160816; b=oaBPd2JbkrYyDo6MTOYWLwfXO+/VUKLQ/J2ljj0KSafnEIg+8T4yzCL7vGiNLo0aJU +c20CoVwGFe8n63WLjK26Lj369Q5xrhlcOFh+6e8gyBQ2ry/LB+jyV4UscQSGJXW7WZl j8VNsBuwDrw17I/nPtEQHXCj+GCMREidh7kojKsuIX6NVWFc1pgJyTeqckueNpdLsW5z FM5jc/eDtOUxuSsHdmqblD9dhmNXZHyvS/5ebphGNrO+km7XaO+cdqP5sYHn4rn3HwI9 hkmRPl9oJh270xFKzLHs6SHHllRXOAYuRZan0fvzeigrdKed1nQ6wzUJcNqyR1ytLIVa 7/Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=cH70j+wbZ3dsYT20sZRaSDy2T9pIJqoJGVAT4s2Ubmc=; b=pnCws7oxUmKRlTY7DagG7hIJiZCY8A4cnwQZXXXLPA0OPG0hlgiKvejZAaamZXCqtg oNXiSX6+3nSmTVKmf1eKciZs5qz+STdvt6YZXV6xJswriyDwAK+8VYutQaISlw12Dk8U GxQq/AsF1kgv+OX+ithXsrItfB5qoSLHL4sHjKmCUHkABmUbT4fq22nq8RMX56wn8gRS xHUYFLYHppFyGVGLDarS1gW/L083SjQV1fBy7Huv7174AZOWP70UkpkPiU+Z6YfaZ+hy myYmS8YvV/W1KXDNl6kav41Wwkfv08A8/BNl36C21xrzlQ0qbJcw07bakJklSitxpGYR OY8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=hPMGI+8E; dkim=pass header.i=@codeaurora.org header.s=default header.b=EmW8a7Z4; 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 d25-v6si3357347plj.438.2018.02.03.00.20.15; Sat, 03 Feb 2018 00:20:29 -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=hPMGI+8E; dkim=pass header.i=@codeaurora.org header.s=default header.b=EmW8a7Z4; 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 S1752218AbeBCH7i (ORCPT + 99 others); Sat, 3 Feb 2018 02:59:38 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:35490 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750725AbeBCH6n (ORCPT ); Sat, 3 Feb 2018 02:58:43 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id B818F6079C; Sat, 3 Feb 2018 07:58:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1517644722; bh=wwo7TFzxjCCTUCiUN+6+uwSP4OaLEgjOx9XfXOCL0AE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hPMGI+8EBNf1s2FiDD/sOwoxAALVjLp6tfQw2gRFBTG0esAnrE7+Ny+f+aEJE+iYI /Qw/vVPHgZiQ7WrsaCBrYntQVp3fNd24P9t6xG+5Rtcd2A/hQhxlepjtYXi1DXlMCc GfwxTrjitiKxdVznRuqXEz1ko/gtWDmThnsv6k7Y= 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 absahu-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: absahu@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 6ECF56090E; Sat, 3 Feb 2018 07:58:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1517644721; bh=wwo7TFzxjCCTUCiUN+6+uwSP4OaLEgjOx9XfXOCL0AE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EmW8a7Z4Mr7hV0rkY+NWLsMPjlOdJH3AVfrLZ/El85dHmRzW7/vdfVubTXsW7XbR5 MnW2ShwmqGM18c/7Kr0h+rSwVl9CLNIMAxNzA03TuHezskWPuf3zExP+g/+D0BLu9k Gu5Z9bKwXH/8nzMQCcFioFvLBJY0klbYM7deb/Ew= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 6ECF56090E Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=absahu@codeaurora.org From: Abhishek Sahu To: Andy Gross , Wolfram Sang Cc: David Brown , Sricharan R , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Abhishek Sahu Subject: [PATCH 04/12] i2c: qup: schedule EOT and FLUSH tags at the end of transfer Date: Sat, 3 Feb 2018 13:28:09 +0530 Message-Id: <1517644697-30806-5-git-send-email-absahu@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1517644697-30806-1-git-send-email-absahu@codeaurora.org> References: <1517644697-30806-1-git-send-email-absahu@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A single BAM transfer can have multiple read and write messages. The EOT and FLUSH tags should be scheduled at the end of BAM HW descriptors. Since the READ and WRITE can be present in any order so for some of the cases, these tags are not being written correctly. Signed-off-by: Abhishek Sahu --- drivers/i2c/busses/i2c-qup.c | 54 ++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c index bb83a2967..6357aff 100644 --- a/drivers/i2c/busses/i2c-qup.c +++ b/drivers/i2c/busses/i2c-qup.c @@ -560,7 +560,7 @@ static int qup_i2c_set_tags_smb(u16 addr, u8 *tags, struct qup_i2c_dev *qup, } static int qup_i2c_set_tags(u8 *tags, struct qup_i2c_dev *qup, - struct i2c_msg *msg, int is_dma) + struct i2c_msg *msg) { u16 addr = i2c_8bit_addr_from_msg(msg); int len = 0; @@ -601,11 +601,6 @@ static int qup_i2c_set_tags(u8 *tags, struct qup_i2c_dev *qup, else tags[len++] = data_len; - if ((msg->flags & I2C_M_RD) && last && is_dma) { - tags[len++] = QUP_BAM_INPUT_EOT; - tags[len++] = QUP_BAM_FLUSH_STOP; - } - return len; } @@ -614,7 +609,7 @@ static int qup_i2c_issue_xfer_v2(struct qup_i2c_dev *qup, struct i2c_msg *msg) int data_len = 0, tag_len, index; int ret; - tag_len = qup_i2c_set_tags(qup->blk.tags, qup, msg, 0); + tag_len = qup_i2c_set_tags(qup->blk.tags, qup, msg); index = msg->len - qup->blk.data_len; /* only tags are written for read */ @@ -710,7 +705,7 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg, while (qup->blk.pos < blocks) { tlen = (i == (blocks - 1)) ? rem : limit; tags = &qup->start_tag.start[off + len]; - len += qup_i2c_set_tags(tags, qup, msg, 1); + len += qup_i2c_set_tags(tags, qup, msg); qup->blk.data_len -= tlen; /* scratch buf to read the start and len tags */ @@ -738,17 +733,11 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg, return ret; off += len; - /* scratch buf to read the BAM EOT and FLUSH tags */ - ret = qup_sg_set_buf(&qup->brx.sg[rx_buf++], - &qup->brx.tag.start[0], - 2, qup, DMA_FROM_DEVICE); - if (ret) - return ret; } else { while (qup->blk.pos < blocks) { tlen = (i == (blocks - 1)) ? rem : limit; tags = &qup->start_tag.start[off + tx_len]; - len = qup_i2c_set_tags(tags, qup, msg, 1); + len = qup_i2c_set_tags(tags, qup, msg); qup->blk.data_len -= tlen; ret = qup_sg_set_buf(&qup->btx.sg[tx_buf++], @@ -768,26 +757,31 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg, } off += tx_len; - if (idx == (num - 1)) { - len = 1; - if (rx_buf) { - qup->btx.tag.start[0] = - QUP_BAM_INPUT_EOT; - len++; - } - qup->btx.tag.start[len - 1] = - QUP_BAM_FLUSH_STOP; - ret = qup_sg_set_buf(&qup->btx.sg[tx_buf++], - &qup->btx.tag.start[0], - len, qup, DMA_TO_DEVICE); - if (ret) - return ret; - } } idx++; msg++; } + /* schedule the EOT and FLUSH I2C tags */ + len = 1; + if (rx_buf) { + qup->btx.tag.start[0] = QUP_BAM_INPUT_EOT; + len++; + + /* scratch buf to read the BAM EOT and FLUSH tags */ + ret = qup_sg_set_buf(&qup->brx.sg[rx_buf++], + &qup->brx.tag.start[0], + 2, qup, DMA_FROM_DEVICE); + if (ret) + return ret; + } + + qup->btx.tag.start[len - 1] = QUP_BAM_FLUSH_STOP; + ret = qup_sg_set_buf(&qup->btx.sg[tx_buf++], &qup->btx.tag.start[0], + len, qup, DMA_TO_DEVICE); + if (ret) + return ret; + txd = dmaengine_prep_slave_sg(qup->btx.dma, qup->btx.sg, tx_buf, DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_PREP_FENCE); -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation