From patchwork Mon May 31 13:19:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Raviteja Narayanam X-Patchwork-Id: 12289379 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07C11C47082 for ; Mon, 31 May 2021 13:22:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C5CC961420 for ; Mon, 31 May 2021 13:22:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C5CC961420 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=I9eCr+5tZgzyfoJJ7mbWJFiWto9kdiQAiYlPd6mmGs0=; b=bbwffFspdHZBX8 mtIycTeZ5e6a7He6JP86vx/Wyvw7eOYG7pgw/+AaoHAnAkCIfPkAJX/UDfnJixydpnz8AKeL+rSSg 2/y7v9VWK5MZlUY5XsLoT4XjQJDG+b+9MpsU/50yi4pLXMkw01kIkIlXNJX6S/B4bitK+bFX+myci IFtjr77Y1yJimPuCFUg5X2+JdqfBm56qjN+9uqYBzFSlASgD70F46aDgFEgM+Tl55h5sI6hATVTBp 9gHBQpXte5nsIaq5C6m9USdPxLowvPTHH8FyUvLU8+1B1/rUwiJ1czdZZTiF/wJ3Pn9C7t02+PWnl ITx+Vfvvtpydhi5SUfvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lnhqs-00CI9j-M8; Mon, 31 May 2021 13:21:06 +0000 Received: from mail-dm6nam08on2080.outbound.protection.outlook.com ([40.107.102.80] helo=NAM04-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lnhqf-00CI75-MM for linux-arm-kernel@lists.infradead.org; Mon, 31 May 2021 13:20:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hE8jwsFGa47Rbvi0dl3e1GyPlmziZiOyyy+toJhDbPBb0mdC61dod/GWtW3C8pfdjJcNR6EkotwE9jLqU1Y8jG2X1s2Q+3bHUAOK6i7dJYD00YJyVxdlzObCp8/uWwRijY0rYB6UFE8RBAeL8rKvQ/mtvE3IJwTrJv45xVVO1FBG0x/IbkImXGh4+38XgDtjWCQcqDYkKDkQ3Omc0RngsXpK2kvBVfaAR7EV6ogSXWewq2GhOCM1CxV6VA2aMFQZs5H5pFqqN0X5ZbUyIdyFLEKWsbPaCfqM2sCWHi/3Xx4QYKxHbZbQqTO7NGrMUJShdQkB/9kqM6HBzdfUbykAug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LC4+zpcf0ZbBUTbWy21dXn/vwcKYYP23odGRQdGCAK8=; b=NqDnDpOq7HLxYah+yNlYqBAw/wf46I3AjCAmWGqcaTisQOJiOxu8MXequRRJ1UM4g5Dqklz5/C8Qs8ra24NymXFa65Vw9yEqrZWb06gxbHSIi4NX7AmDhGhodZhQg+qJNB/fgrMFk9gsCB6OnwjTFxrXi11bD5H4nTNuH+9P6sM4kLb08kjHKqqEfnyxHvwQK9Hs15BasRRmMLzSDwlrQBzNVzyp6vqlBUKcVUEH62B+qaczAWwP+fY/Pt89mMJFXyhUWYnFHIVlIwgBk8u1sgHjWV4ZFTFlKWpm1iAzTeRHDR5x4f1j69D2R9ZE7GjYpVFV+MYbQcb5Zq1ahrCzHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LC4+zpcf0ZbBUTbWy21dXn/vwcKYYP23odGRQdGCAK8=; b=ZQjGAQswUhk2KkZBdCfEnGwbfLw2zXMOmGkT+Fwbs6zI2u38Lu6vjtwCfdsExRWIdTjZ1jRrgz2cBMUo8vrInKtdQXRvr00Hw6NvGl6Ch56EzGcAbu20/MuGCav3G73PlZOUImGXzPmdMTjaGCF3wbdk0xxzO1IJdLSpoav4O1k= Received: from SN6PR2101CA0018.namprd21.prod.outlook.com (2603:10b6:805:106::28) by MW4PR02MB7330.namprd02.prod.outlook.com (2603:10b6:303:7b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.21; Mon, 31 May 2021 13:20:46 +0000 Received: from SN1NAM02FT0060.eop-nam02.prod.protection.outlook.com (2603:10b6:805:106:cafe::8d) by SN6PR2101CA0018.outlook.office365.com (2603:10b6:805:106::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.3 via Frontend Transport; Mon, 31 May 2021 13:20:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT0060.mail.protection.outlook.com (10.97.4.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4150.30 via Frontend Transport; Mon, 31 May 2021 13:20:46 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 31 May 2021 06:20:26 -0700 Received: from smtp.xilinx.com (172.19.127.95) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Mon, 31 May 2021 06:20:26 -0700 Received: from [10.140.6.25] (port=53014 helo=xhdnagasure40.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1lnhqC-0004GE-OM; Mon, 31 May 2021 06:20:25 -0700 From: Raviteja Narayanam To: , CC: , , , , Raviteja Narayanam Subject: [PATCH 01/10] i2c: xiic: Fix Tx Interrupt path for grouped messages Date: Mon, 31 May 2021 07:19:39 -0600 Message-ID: <20210531131948.19477-2-raviteja.narayanam@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210531131948.19477-1-raviteja.narayanam@xilinx.com> References: <20210531131948.19477-1-raviteja.narayanam@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b458ab11-c663-4512-4b19-08d92436e668 X-MS-TrafficTypeDiagnostic: MW4PR02MB7330: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h9zrsRT0kmDdmPUrdC5aCVjndtOERDTWuhQoGx+czKT04Tqt9D8hOK5YNf0WHPQ296inXyiTVWjqj093XzZ4JRxXIO4VhrdFt496PHQ/a1ifmlu/UluT9frOVNNvAb7BKn1TLDT2+7AXu63LqfOB9ghmn/MoauizaWDBlRONlNQrV3ZsXQlOV1bR5k8tq1/um8SfCUxzb0xf672ATrSnj/oxrNsYrzXuu6ytv2CmbNUbdfar+7/j+OgE+tbqfJCL0UYLx7I5p3s85BitAZthedNQVteisBrcZlzCGjXeHjHdjICbRhbRj4KTHvoCE72h0zushVMR6rCAAHAZt7sLvRhhHyjP/lIu/fSDmDQEfmB5Qo8wDdUlVXNMDbe2k6vapokseg8kqck4NbeROEmRSoFKmuewmOmu/kZMvZYK9kQUzwVHXwbWx7j2h+oqMCo7l7Y7A/qwG9wVqD0Yos0CcochbH5AACL+B1HDB2Ypk+aozcfsddLjbxLI9RP4Pf99xsPNzT2FX4SWNcAEJeuFMYRM8gqZxbqCdEEdFacHhyClHwaycbrv5krAMnp356BCArYMxco2Vel9NgLH5rWaLLZB4vZOzPbDM7f/MJ7QeKL55aF4/9T8MgllOVD9l8IC/eNJTSqlgGJ82CpNhP+wvatred3fiJTvJNTa2MPG8olNJKKTj2KKu7GCDi6w3h/v X-Forefront-Antispam-Report: CIP:149.199.62.198; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapexch02.xlnx.xilinx.com; PTR:unknown-62-198.xilinx.com; CAT:NONE; SFS:(4636009)(396003)(346002)(376002)(136003)(39860400002)(36840700001)(46966006)(7696005)(5660300002)(36860700001)(26005)(8936002)(478600001)(107886003)(6666004)(1076003)(2906002)(47076005)(186003)(8676002)(82310400003)(6636002)(4326008)(70206006)(54906003)(2616005)(70586007)(82740400003)(7636003)(44832011)(36756003)(83380400001)(356005)(9786002)(336012)(15650500001)(316002)(110136005)(426003)(102446001); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2021 13:20:46.1264 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b458ab11-c663-4512-4b19-08d92436e668 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.62.198]; Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT0060.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR02MB7330 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210531_062053_762609_577BD4C3 X-CRM114-Status: GOOD ( 14.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When a group of messages are sent from user space as a set, if the last message has less than Tx FIFO DEPTH number of bytes to transfer, Tx half empty interrupt is triggered continuously from the hardware. It is due to Bus not busy interrupt coming along with Tx half empty and tx empty. Hence, service the Tx interrupts before Bus not busy interrupt to update the i2c message status correctly. Signed-off-by: Raviteja Narayanam --- drivers/i2c/busses/i2c-xiic.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c index 2a8568b97c14..b0cfd9d15467 100644 --- a/drivers/i2c/busses/i2c-xiic.c +++ b/drivers/i2c/busses/i2c-xiic.c @@ -453,22 +453,6 @@ static irqreturn_t xiic_process(int irq, void *dev_id) } } } - if (pend & XIIC_INTR_BNB_MASK) { - /* IIC bus has transitioned to not busy */ - clr |= XIIC_INTR_BNB_MASK; - - /* The bus is not busy, disable BusNotBusy interrupt */ - xiic_irq_dis(i2c, XIIC_INTR_BNB_MASK); - - if (!i2c->tx_msg) - goto out; - - if ((i2c->nmsgs == 1) && !i2c->rx_msg && - xiic_tx_space(i2c) == 0) - xiic_wakeup(i2c, STATE_DONE); - else - xiic_wakeup(i2c, STATE_ERROR); - } if (pend & (XIIC_INTR_TX_EMPTY_MASK | XIIC_INTR_TX_HALF_MASK)) { /* Transmit register/FIFO is empty or ½ empty */ @@ -505,6 +489,24 @@ static irqreturn_t xiic_process(int irq, void *dev_id) */ xiic_irq_dis(i2c, XIIC_INTR_TX_HALF_MASK); } + + if (pend & XIIC_INTR_BNB_MASK) { + /* IIC bus has transitioned to not busy */ + clr |= XIIC_INTR_BNB_MASK; + + /* The bus is not busy, disable BusNotBusy interrupt */ + xiic_irq_dis(i2c, XIIC_INTR_BNB_MASK); + + if (!i2c->tx_msg) + goto out; + + if (i2c->nmsgs == 1 && !i2c->rx_msg && + xiic_tx_space(i2c) == 0) + xiic_wakeup(i2c, STATE_DONE); + else + xiic_wakeup(i2c, STATE_ERROR); + } + out: dev_dbg(i2c->adap.dev.parent, "%s clr: 0x%x\n", __func__, clr);