Received: by 10.223.185.116 with SMTP id b49csp3587516wrg; Mon, 19 Feb 2018 02:35:48 -0800 (PST) X-Google-Smtp-Source: AH8x224Gf7Cf1a3tCdKA2qVZ3Hp9jS1z8oaRvV99xXqQJSfz8Z0sy9zj9mgockVUTu7APCuHLH3A X-Received: by 10.98.98.194 with SMTP id w185mr14274174pfb.9.1519036548056; Mon, 19 Feb 2018 02:35:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519036548; cv=none; d=google.com; s=arc-20160816; b=B9lHfNOdtqoVjb0lILppwLrwvePzeZCUkDWyHvL7cBfo3c8gzR0bjW1iP/SPF+BrZq B2WDLH+cdVJ+98xiROyuvgDiP0VWHQd7p2S6JYr1/X8WxxBVeWrIEjubT1JwqQtkRmzP P1JKMRdey8BLaJjaTKbCIgCKhtCC6FjwOvwtbVRr57bvnSt508oUKFUrhySLn7awEh7o Uz8MInv4pSkLVDpEE8bpFf0ZXnYnG0zHoobDyeUS5Vgy/6FglmRd7KLRjbbvwmgR+JGc W55indIVaurzY9QDLzGZmn7xVEB+mm3qRKnyJFflgD+H38Tut6bAmHo4o2yP5NviikD9 ZmGg== 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=PLohNsLLh55dajaQw12CPZ40HyWWDxfcAjSeE1IHj/4=; b=PyIHaRKETPt448sxVD5ErdTiei6zXTMeL5xgO/+edSqum3kMJiHhvn94Og9wdY0o7m ZuX2iYmeaCnexgUuQDVMKNWDdV4DTz8J4JiFsQ5tDmytUfegdqAwJ4tvC++TrhTUlko2 ikEeAQVvDLSkilTRsrOChbVxG9d7Q9iYQZ2UDwBYLdE8VnLMv6HpUDuhVPd0i2p5cpDp DYZhr4CEvWcgPco3k8s8EPzMBjb9IMFswX6nRRYh6Hc0F3Sc3mHLNLruhkh36W8LPnSl VdFRflH8vVxpyHVRVLGAqm3s8nrSokjabImoWhKaXHxJRmZG4iFfhMHhEJbcDYZbAsWC EztQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=eurEVue4; dkim=pass header.i=@codeaurora.org header.s=default header.b=eurEVue4; 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 r1-v6si4363811plb.453.2018.02.19.02.35.33; Mon, 19 Feb 2018 02:35:48 -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=eurEVue4; dkim=pass header.i=@codeaurora.org header.s=default header.b=eurEVue4; 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 S1752563AbeBSKel (ORCPT + 99 others); Mon, 19 Feb 2018 05:34:41 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:42466 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752377AbeBSKej (ORCPT ); Mon, 19 Feb 2018 05:34:39 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id E9A3960A66; Mon, 19 Feb 2018 10:34:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519036478; bh=QF3zQLx6iPREJ3gfUPUIOSGgP08WXC1d0Mzi35GtCvw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=eurEVue49OBzxTj/t8iVcFwFxEffr0Vf13o6Y8ScND9ZBqTxJnCjz9r2cUy1nadjJ RndGyT/Cdi4uncAb/rDokR7AsUI73imP6uhQlcgVVJVFii92siVt9NMu6BXsUp/beF p0wxRBjVShXhoXGMHu5mex1vRLrd04SABqx5fyUo= 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 7915760227; Mon, 19 Feb 2018 10:34:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519036478; bh=QF3zQLx6iPREJ3gfUPUIOSGgP08WXC1d0Mzi35GtCvw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=eurEVue49OBzxTj/t8iVcFwFxEffr0Vf13o6Y8ScND9ZBqTxJnCjz9r2cUy1nadjJ RndGyT/Cdi4uncAb/rDokR7AsUI73imP6uhQlcgVVJVFii92siVt9NMu6BXsUp/beF p0wxRBjVShXhoXGMHu5mex1vRLrd04SABqx5fyUo= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 19 Feb 2018 16:04:38 +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 04/12] i2c: qup: schedule EOT and FLUSH tags at the end of transfer In-Reply-To: References: <1517644697-30806-1-git-send-email-absahu@codeaurora.org> <1517644697-30806-5-git-send-email-absahu@codeaurora.org> Message-ID: <1347ec85b53728e3eec771ea78bcbe5f@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-15 20:01, Sricharan R wrote: > Hi Abhishek, > > On 2/3/2018 1:28 PM, Abhishek Sahu wrote: >> 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++; >> } > > While here, can you please split above the if, else in to two > separate functions ? > and probably one more function for handling the NACK case down below. > The function > size at the moment is too big. > Sure. Already I split this function into 2 functions in [PATCH 09/12] i2c: qup: fix buffer overflow for multiple msg of maximum xfer len which is making function size smaller. I will check if I can split in more functions. >> >> + /* 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; >> + > > May be you can change the commit to make it explicit to say what is > being > fixed, like "current code is broken when there is sequence of > wr,rd,wr" like that. > Agree on this fix otherwise. > Thanks. I will update the commit message to include the failure case which will give clear idea. Thanks, Abhishek