Received: by 10.213.65.68 with SMTP id h4csp47882imn; Mon, 12 Mar 2018 06:20:29 -0700 (PDT) X-Google-Smtp-Source: AG47ELsqqUyzoXVIDw2+OVsm0/2EepQT6zzN9JLAsEgKzZeGTWMslK1KqRcXM3KBe9xB6GDfIjW0 X-Received: by 2002:a17:902:7d93:: with SMTP id a19-v6mr8302489plm.160.1520860829732; Mon, 12 Mar 2018 06:20:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520860829; cv=none; d=google.com; s=arc-20160816; b=E5c5aGybcuU+WsmPRcHvzPMktQejHUlIMKjj2o9V3+ccD9ZtrO3vO38VnFyaqwY9a8 88gA4+2xQS1/nLioGFIgFTSE568qdhXrLZzZrJHsL31fFuSzRDLkAydI91hp5rDU2oMr T/4bqdPjqNV/zVUPgBTKPzwXsT/ZXPdpI1Tgt1GjIfpAMF943kv5JLK0kb3zSuwkNt9K DCZnDizIWngMWrNGhTBezB/k5ENDx51GyaWBYC5ytUF/48IogSbX5S0PiSfLQWiYF67u FDWkDTzIQX5zJm9Z/dAMZCtjspAXSbZdaWWKRSIjodocbChJUxQFdsKdWIM8BxDCOcIN OaLA== 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=2/olx2dDEjrJyDPBXpYbJWjXZSlB+WMOOKPVwDnkMfU=; b=YRcvkEtrJjX2Sw5Sn5bzYA6aJc8blBmrSRItTwwampAobgPOs21BFCqjwNvKgtv0Gn Fjxnssr2vdbxVLUPm9uKY/nWL44rOasavutry6Q86t/uCFbKSbxNfmDTaSHrwoAlV55i UR7d2e3P/FxiA/6f0WAy2LUMrYoNNk/Iyhi52oB/Sm1yU8EVz0iWUu0CWbP8kNyR+Uxw RfvdjnfHLKOzsWSnV5eFddq+Wro00bi+qDwKF7LVpE5D/RlQYSjlCa9fAIBdR5tAlj6F kHfThwePOLjKiNOpy6YbJNwQsCUo7K6sgEOMo9FVoexyLIB2Pi8pUR0fGzQw3sU416ks xuZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=YBpOgoFq; dkim=pass header.i=@codeaurora.org header.s=default header.b=YBpOgoFq; 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 f29si5717038pff.364.2018.03.12.06.20.14; Mon, 12 Mar 2018 06:20:29 -0700 (PDT) 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=YBpOgoFq; dkim=pass header.i=@codeaurora.org header.s=default header.b=YBpOgoFq; 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 S932211AbeCLNPj (ORCPT + 99 others); Mon, 12 Mar 2018 09:15:39 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:41828 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751572AbeCLNPg (ORCPT ); Mon, 12 Mar 2018 09:15:36 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A5FD9606DB; Mon, 12 Mar 2018 13:15:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520860535; bh=D5NCAJ4kd0sFgxB7yE9NRFdNiGIxr1k+60uiB8DjgE0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YBpOgoFqBpO61oI+kb8MX2NRMQCfpSB/FYqrnOwiBvaeeFZz7O8vODNKtZNNb3lEC Aoe64W58pILGG4/czGjTj7xZuhGV7RImcRImGaVyVLzU0xCqWlq5DWGgxZ+8Vov6IR hDiQ9+bsjhZuu5LbR6UMVKDf+F8WzF5lFT2tFZIU= 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 777016070A; Mon, 12 Mar 2018 13:15:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520860535; bh=D5NCAJ4kd0sFgxB7yE9NRFdNiGIxr1k+60uiB8DjgE0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YBpOgoFqBpO61oI+kb8MX2NRMQCfpSB/FYqrnOwiBvaeeFZz7O8vODNKtZNNb3lEC Aoe64W58pILGG4/czGjTj7xZuhGV7RImcRImGaVyVLzU0xCqWlq5DWGgxZ+8Vov6IR hDiQ9+bsjhZuu5LbR6UMVKDf+F8WzF5lFT2tFZIU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 777016070A 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 , Austin Christ , 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 v2 05/13] i2c: qup: schedule EOT and FLUSH tags at the end of transfer Date: Mon, 12 Mar 2018 18:44:54 +0530 Message-Id: <1520860502-14886-6-git-send-email-absahu@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520860502-14886-1-git-send-email-absahu@codeaurora.org> References: <1520860502-14886-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 The role of FLUSH and EOT tag is to flush already scheduled descriptors in BAM HW in case of error. EOT is required only when descriptors are scheduled in RX FIFO. If all the messages are WRITE, then only FLUSH tag will be used. 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. Following is one of the example READ, READ, READ, READ Currently EOT and FLUSH tags are being written after each READ. If QUP gets NACK for first READ itself, then flush will be triggered. It will look for first FLUSH tag in TX FIFO and will stop there so only descriptors for first READ descriptors be flushed. All the scheduled descriptors should be cleared to generate BAM DMA completion. Now this patch is scheduling FLUSH and EOT only once after all the descriptors. So, flush will clear all the scheduled descriptors and BAM will generate the completion interrupt. Signed-off-by: Abhishek Sahu --- * Changes from v1: 1. Modified commit message with more details drivers/i2c/busses/i2c-qup.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c index d970458..b2e8f57 100644 --- a/drivers/i2c/busses/i2c-qup.c +++ b/drivers/i2c/busses/i2c-qup.c @@ -551,7 +551,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; @@ -592,11 +592,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; } @@ -605,7 +600,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 */ @@ -701,7 +696,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 */ @@ -729,17 +724,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_cnt++], - &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_cnt++], @@ -779,6 +768,26 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg, msg++; } + /* schedule the EOT and FLUSH I2C tags */ + len = 1; + if (rx_cnt) { + 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_cnt++], + &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_cnt++], &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_cnt, 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