From patchwork Wed Oct 24 10:50:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhrajyoti Datta X-Patchwork-Id: 10654521 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 510BF13A4 for ; Wed, 24 Oct 2018 10:51:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EBE72A16E for ; Wed, 24 Oct 2018 10:51:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3321C2A23E; Wed, 24 Oct 2018 10:51:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B874A2A23C for ; Wed, 24 Oct 2018 10:51:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Lh9WFdY7EDVH1XEjFsEvrJ7dD2G6jvBS/99MYcFfoOs=; b=LezwpP/vBgCuxp m2n0om21XB/A45RpOTjSYvDlCsvMFNBCuBcTi3WQtokK/gMqoHUiRZx+tLbvJaayvlqNohw7D6VY5 7zUOXyF5uNy2mR4a1MhOyO2y+tWWR5E9bsiYvQVRjHNfV5LBq3Jo6ptN3153AwHjdwjCkEFH2CWiE vBdMdoFyGC36GV97YL+KO7H+aYrJgV7VKgPkvUHfRm1qHqUKSJByfgIZ6YMg+jDc6hw3oKy+YtUGh +u4Yha4Jejx9OMDw57MvdO46XcfVZYITcSFhbPi4lbGV1rTs3glVA490Q0kJAjLTXBF4ij0YAn0nF 2yqVketxeoVkB5ErQOLw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gFGkd-0002oh-LN; Wed, 24 Oct 2018 10:50:59 +0000 Received: from mail-sn1nam01on0058.outbound.protection.outlook.com ([104.47.32.58] helo=NAM01-SN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gFGk8-00024r-UM for linux-arm-kernel@lists.infradead.org; Wed, 24 Oct 2018 10:50:53 +0000 Received: from SN4PR0201CA0070.namprd02.prod.outlook.com (2603:10b6:803:20::32) by SN6PR02MB4685.namprd02.prod.outlook.com (2603:10b6:805:8f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1250.30; Wed, 24 Oct 2018 10:50:16 +0000 Received: from SN1NAM02FT017.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::208) by SN4PR0201CA0070.outlook.office365.com (2603:10b6:803:20::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1250.29 via Frontend Transport; Wed, 24 Oct 2018 10:50:16 +0000 Authentication-Results: spf=softfail (sender IP is 149.199.60.100) smtp.mailfrom=gmail.com; lists.infradead.org; dkim=none (message not signed) header.d=none;lists.infradead.org; dmarc=fail action=none header.from=gmail.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning gmail.com discourages use of 149.199.60.100 as permitted sender) Received: from xsj-pvapsmtpgw02 (149.199.60.100) by SN1NAM02FT017.mail.protection.outlook.com (10.152.72.115) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1273.13 via Frontend Transport; Wed, 24 Oct 2018 10:50:15 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66]:37083 helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw02 with esmtp (Exim 4.63) (envelope-from ) id 1gFGjv-0006QH-GI; Wed, 24 Oct 2018 03:50:15 -0700 Received: from [127.0.0.1] (helo=xsj-smtp-dlp2.xlnx.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1gFGjp-0006QD-Rs; Wed, 24 Oct 2018 03:50:09 -0700 Received: from xsj-pvapsmtp01 (xsj-smtp.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id w9OAo8e7024371; Wed, 24 Oct 2018 03:50:08 -0700 Received: from [172.23.37.106] (helo=xhdshubhraj40.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1gFGjo-0006Bq-1Y; Wed, 24 Oct 2018 03:50:08 -0700 From: To: , Subject: [PATCH] i2c: cadence: Implement timeout Date: Wed, 24 Oct 2018 16:20:03 +0530 Message-ID: <1540378203-1655-1-git-send-email-shubhrajyoti.datta@gmail.com> X-Mailer: git-send-email 2.1.1 X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 X-TM-AS-Result: No--4.500-7.0-31-1 X-imss-scan-details: No--4.500-7.0-31-1;No--4.500-5.0-31-1 X-TM-AS-User-Approved-Sender: No;No X-TM-AS-Result-Xfilter: Match text exemption rules:No X-EOPAttributedMessage: 0 X-Matching-Connectors: 131848518161347780; (f9e945fa-a09a-4caa-7158-08d2eb1d8c44); () X-Forefront-Antispam-Report: CIP:149.199.60.100; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(136003)(396003)(346002)(39860400002)(376002)(2980300002)(199004)(189003)(2876002)(5660300001)(51416003)(9786002)(47776003)(61266001)(8936002)(2906002)(8676002)(76482006)(107886003)(6666004)(81156014)(86152003)(356004)(305945005)(81166006)(26005)(36756003)(73392003)(1857600001)(86362001)(106466001)(87572001)(16586007)(2616005)(48376002)(105596002)(82202002)(486006)(316002)(126002)(55446002)(336012)(110136005)(50466002)(14444005)(476003)(498600001)(73972006)(426003)(50226002)(4326008)(54906003)(83322999)(63266004)(77096007)(107986001)(5001870100001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN6PR02MB4685; H:xsj-pvapsmtpgw02; FPR:; SPF:SoftFail; LANG:en; PTR:unknown-60-100.xilinx.com,xapps1.xilinx.com; A:1; MX:1; X-Microsoft-Exchange-Diagnostics: 1; SN1NAM02FT017; 1:rb4EMjdy8IrdSXxR5xeOzCRZeEePODXT8MHc2muNjqpgBvQfCSQQurRFawXpxUz19cU7vZV5t05+wQJyqd4aa5TOFPnvlnhrPVQFj+CfCk8aD5lAhhLIvAmq4TixLc0V MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b84649a2-40f9-486b-4902-08d6399e7b96 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(5600074)(711020)(2017052603328); SRVR:SN6PR02MB4685; X-Microsoft-Exchange-Diagnostics: 1; SN6PR02MB4685; 3:JrE3JFXVqgcvmTdeCfoSdSYXScRlPhayQgpHUL7GF8QWdZNhZm2k88AIo8yP5IMHcqsBhpmLbvEOaGXIXg8w3vPaJneZ8F2t7yL05GwcHDuMB8I9nfkSQ/LT2kxGCs+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H8f48lueczCz5SmIKgnrJTHO8UIbp8mwKoWdAqCEUZPSmngi19lqWk0GiW0QmGP1SnrP68VtdhLP6OWRSdI1fPvS5iH2QfMeqHlBUJRtn5ORK4W09IDWR1J0iC9kxuutsx7+Re4hnrURz3NCYRluAQn8GfyEmS9w== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192813158149592)(788757137089); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(8121501046)(5005006)(3002001)(3231355)(944501410)(52105095)(10201501046)(93006095)(93001095)(6055026)(148016)(6096035)(20161123563025)(20161123559100)(201703131430075)(201703131448075)(201703131433075)(201703151042153)(20161123561025)(20161123565025)(20161123556025)(201708071742011)(7699051)(76991095); SRVR:SN6PR02MB4685; BCL:0; PCL:0; RULEID:(400006); SRVR:SN6PR02MB4685; X-Forefront-PRVS: 083526BF8A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN6PR02MB4685; 23:rtUpd7JSJjcdAFxG+h9ZEaSzcPWSc/5RnO2JX1L21?= VJzFtoOf1sK9qLVOqqF2pSalWKrVP2XK0AiM9eKpzlVprXoYoeLq056ogDNrfrNtkR4LJBAD4en4ztsL4KYGRrgO9gTWiTJP+fn3y/t6x20zTL5Yu9HvESlj2y701scvB3uMdxPqHmB5MfZuXrNISN3bBK1T/LnAPWnnJiZ98Y/2dzq/RyM+z5Sde+eBU2phvMocBMiQkb6ZwAKso2V01gRd7/5xbUCfQ/bbbfstZ73zWq86r+hy5hfD07ydTH+UNYZdnjFkA6etKBKtKF93mV/AkaHgf7oUV1IqB6064/MM/RGLpGQU8WIqbbWFJ2SMdsFKnjmoztUiKHCwgrgTAli2WCZy7uredu1ORrTc06/rJbcGZ9WitSpdOgTp07PaGHP5rdQAzJ1n5WyZCcozTmykyjpJnqIwj4a5YYhtWpLFdOWR1c+3NflLkMuD2RAlVaALZB1Kg0k3faiQYxIj2MTvLR1UF5z018Hqx/hlRFktHey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IU2Zs9njx/QZUQ4TAocDl87f6xegCNsjPLRD8vkzlESqLtueIpDfh/OPs= X-Microsoft-Exchange-Diagnostics: 1; SN6PR02MB4685; 6:uaBfgdOjh9DJcbYQTTISn7jD4V4COMIUUpKAQFCiJhvTjt6wmEbsAOEw5MHCS1XfaYzq9D0UPaJ7URrzgmjHnlegsA5cXHdcrmMoeU46GDfP0jeBMrly2cHR1cly/NlYwZp+OR/vAlI3JobYWgwlNv0jQCY3oZ/fsfe2lW17LzxdBwWFd+RKvs3v5f+/1J1/WlU8ZxKIn/PEP5oOGzCrRAokjyKYvVMVgaPUy9uzS9N4+rispsbMCVhbHW0iz53rRpcTCp50uCdQiz0tcmc7ocQ3Z3xpA6nDu3uPXng1M5SP+xLkBJzFHQSZSAcFSk98jryoplHauBuUxFg8kxQHvA72WKu+wDwKHmlI8cafwU4nFoaSUQWwVYvWui9m/axxiKCdTJk78z7nOWwG5Yvid8EGpNvjVDyeMXKla1K1XY6x+WIZK1o5+O/SuGJbjpFwv4fiiNz6xjF+B122cJEfyw==; 5:6fAsB1m/maxcQl7iN17QulwauvIrjLSBA2mtrQyONDdvGHhn5Ur0opr1RnREUDRGnNEJ1dbO/sYZM+9F3tvBm4MQeACbFpRUxv9Y2/KZSQaCoqBKmCmOZHSMI9eOXAg1J2/Qhnbe+rCld60xxaW9mtc0YveKLMQtPciRWA7WtMw=; 7:FP5h9ACx+LOdQqJ9h1iQYlTuUoWya0+hfSWzmadzedgoUcbYHwreZljQS4vm48/w1d3aX6YUxCfTAkVFrdojbZ9on2StsvRb60vCqyvPtfecdTpws8Ekf/pBnlYfN/6m5JUSAhn4hFx/805TSU6WYJhXap6YrYe2YV6da8rpJkmWk2w3lIowcgKvN/A/lUJ8qGtbN3FPT0ANCCqkxHB3iz+fhS+x7/n0kRUx/EuAWsXgnAlieFB6QD3kAGgg/aLA SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2018 10:50:15.9316 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b84649a2-40f9-486b-4902-08d6399e7b96 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[149.199.60.100]; Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR02MB4685 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181024_035029_032746_9F56DE3D X-CRM114-Status: UNSURE ( 8.37 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Shubhrajyoti Datta , michal.simek@xilinx.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Shubhrajyoti Datta In some cases we are waiting in a loop. Replace the infinite wait with the timeout. Signed-off-by: Shubhrajyoti Datta --- drivers/i2c/busses/i2c-cadence.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c index b136057..9c38278 100644 --- a/drivers/i2c/busses/i2c-cadence.c +++ b/drivers/i2c/busses/i2c-cadence.c @@ -209,6 +209,7 @@ static irqreturn_t cdns_i2c_isr(int irq, void *ptr) struct cdns_i2c *id = ptr; /* Signal completion only after everything is updated */ int done_flag = 0; + unsigned int timeout; irqreturn_t status = IRQ_NONE; isr_status = cdns_i2c_readreg(CDNS_I2C_ISR_OFFSET); @@ -235,6 +236,7 @@ static irqreturn_t cdns_i2c_isr(int irq, void *ptr) ((isr_status & CDNS_I2C_IXR_COMP) || (isr_status & CDNS_I2C_IXR_DATA))) { /* Read data if receive data valid is set */ + timeout = 1000; while (cdns_i2c_readreg(CDNS_I2C_SR_OFFSET) & CDNS_I2C_SR_RXDV) { /* @@ -253,6 +255,16 @@ static irqreturn_t cdns_i2c_isr(int irq, void *ptr) if (cdns_is_holdquirk(id, hold_quirk)) break; + timeout--; + if (timeout) + mdelay(1); + else + break; + } + if (!timeout) { + id->err_status = -ETIMEDOUT; + complete(&id->xfer_done); + return IRQ_HANDLED; } /* @@ -262,12 +274,22 @@ static irqreturn_t cdns_i2c_isr(int irq, void *ptr) * maintain transfer size non-zero while performing a large * receive operation. */ + timeout = 1000; if (cdns_is_holdquirk(id, hold_quirk)) { /* wait while fifo is full */ - while (cdns_i2c_readreg(CDNS_I2C_XFER_SIZE_OFFSET) != - (id->curr_recv_count - CDNS_I2C_FIFO_DEPTH)) - ; - + while ((cdns_i2c_readreg(CDNS_I2C_XFER_SIZE_OFFSET) != + (id->curr_recv_count - CDNS_I2C_FIFO_DEPTH))) { + timeout--; + if (timeout) + mdelay(1); + else + break; + } + if (!timeout) { + id->err_status = -ETIMEDOUT; + complete(&id->xfer_done); + return IRQ_HANDLED; + } /* * Check number of bytes to be received against maximum * transfer size and update register accordingly.