Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2610176pxj; Mon, 31 May 2021 06:31:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCBoaq5jEYrqfmjWl6iNSiFvlmSEui0eh/+YfP/uU1qkuQfVq+rZF07mfzXIe5m4A54O4I X-Received: by 2002:a17:906:1dc2:: with SMTP id v2mr23248524ejh.8.1622467872965; Mon, 31 May 2021 06:31:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1622467872; cv=pass; d=google.com; s=arc-20160816; b=UNF4dXAPt0qLg+Q+KtMEWkyGxiwAE2yeXGjmgoQz2yOFFxTM+WZGL03ccarJnMwPfP V4TNy+rSn6a6RwJINGv4+qbt+lD/Vg05NmHPhcfa1KYSg47kzpFPuy9ryJSulJ0dfGyX AehBLU8tl1FC1TLFVdYRIY0oSMTV1nVbF+z4V/UHJoOdyTdVb5Zc7Ao3H4p54YibVDMG PwS6SSy1BfhsYaVTMXTpOyqTFF9ClnbIkjZBDdsp/8ywril/zxDh5WoRe0UNr1CX1S98 8WBcY4S+j1oKyYGsKhf2xuFf1U1ij1aKRktUZXLuJVE8MdlHp94sU6KAD+b19eOK97Vb E//A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :envelope-to:dkim-signature; bh=LC4+zpcf0ZbBUTbWy21dXn/vwcKYYP23odGRQdGCAK8=; b=qw5yiVHnbd6/+DqgPjvI7t17udELe7MkzwBWxPsC7XuPv/BTdC5PoMBrPuXGHQyo9K RE+FDSx2yCFFPBkavgK7L4L4Qs7jQi3ni9+aKMpYTOChgoV2AkK+UqJANT8cVQE6fZLT 0pPae0HH1PWw4pF/A9WlGHDk25wWzvOJ9wyscKS0XyrivjErSPOoipjff34UJAZJDWVH QXHQSqpYLxPp97MPVkJuVEXZH9OOo9MEbM1B16w5P4daBmtrXWl5sahbVD6AN8iCttLo vOUFqZRBjC3MWYqFwymtjOb9HTdwj4J8Hu8PJQhYcw8TnKCRb0+dkJ/tf3wsqLKetn0Z P13g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xilinx.onmicrosoft.com header.s=selector2-xilinx-onmicrosoft-com header.b=ZQjGAQsw; arc=pass (i=1 spf=pass spfdomain=xilinx.com dmarc=pass fromdomain=xilinx.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xilinx.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z27si12844517ejc.287.2021.05.31.06.30.49; Mon, 31 May 2021 06:31:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@xilinx.onmicrosoft.com header.s=selector2-xilinx-onmicrosoft-com header.b=ZQjGAQsw; arc=pass (i=1 spf=pass spfdomain=xilinx.com dmarc=pass fromdomain=xilinx.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xilinx.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232573AbhEaN3c (ORCPT + 99 others); Mon, 31 May 2021 09:29:32 -0400 Received: from mail-dm6nam12on2087.outbound.protection.outlook.com ([40.107.243.87]:15073 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231977AbhEaNWd (ORCPT ); Mon, 31 May 2021 09:22:33 -0400 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 Envelope-to: git@xilinx.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, marex@denx.de 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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); -- 2.17.1