From patchwork Wed Feb 20 07:13:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhrajyoti Datta X-Patchwork-Id: 1045163 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44482r1lcdz9s5c for ; Wed, 20 Feb 2019 18:13:24 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725869AbfBTHNW (ORCPT ); Wed, 20 Feb 2019 02:13:22 -0500 Received: from mail-eopbgr720061.outbound.protection.outlook.com ([40.107.72.61]:26304 "EHLO NAM05-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725857AbfBTHNW (ORCPT ); Wed, 20 Feb 2019 02:13:22 -0500 Received: from MWHPR0201CA0013.namprd02.prod.outlook.com (2603:10b6:301:74::26) by DM2PR02MB430.namprd02.prod.outlook.com (2a01:111:e400:2424::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1622.19; Wed, 20 Feb 2019 07:13:20 +0000 Received: from BL2NAM02FT025.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::207) by MWHPR0201CA0013.outlook.office365.com (2603:10b6:301:74::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1622.16 via Frontend Transport; Wed, 20 Feb 2019 07:13:19 +0000 Authentication-Results: spf=softfail (sender IP is 149.199.60.83) smtp.mailfrom=gmail.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.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.83 as permitted sender) Received: from xsj-pvapsmtpgw01 (149.199.60.83) by BL2NAM02FT025.mail.protection.outlook.com (10.152.77.151) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1643.11 via Frontend Transport; Wed, 20 Feb 2019 07:13:19 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1gwM4E-0004B8-Fn for linux-i2c@vger.kernel.org; Tue, 19 Feb 2019 23:13:18 -0800 Received: from [127.0.0.1] (helo=xsj-smtp-dlp1.xlnx.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1gwM49-0000VS-B3; Tue, 19 Feb 2019 23:13:13 -0800 Received: from xsj-pvapsmtp01 (xsj-mail.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id x1K7DClx004905; Tue, 19 Feb 2019 23:13:12 -0800 Received: from [172.23.37.106] (helo=xhdshubhraj40.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1gwM48-0000VE-5k; Tue, 19 Feb 2019 23:13:12 -0800 From: To: CC: , Shubhrajyoti Datta Subject: [PATCHv3] i2c: cadence: Fix the driver in interrupt flurry case Date: Wed, 20 Feb 2019 12:43:09 +0530 Message-ID: <1550646789-11100-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--5.851-7.0-31-1 X-imss-scan-details: No--5.851-7.0-31-1;No--5.851-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: 131951203993195635; (f9e945fa-a09a-4caa-7158-08d2eb1d8c44); () X-Forefront-Antispam-Report: CIP:149.199.60.83; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(396003)(39860400002)(136003)(346002)(376002)(2980300002)(189003)(199004)(2876002)(2616005)(61266001)(2351001)(55446002)(36756003)(2906002)(47776003)(305945005)(87572001)(9786002)(106466001)(76482006)(105596002)(8936002)(8676002)(81156014)(81166006)(26005)(50466002)(48376002)(50226002)(107886003)(14444005)(4326008)(498600001)(83322999)(356004)(82202003)(6666004)(63266004)(73392003)(336012)(486006)(426003)(126002)(476003)(54906003)(73972006)(86362001)(86152003)(5660300002)(6916009)(316002)(16586007)(51416003)(77096007)(107986001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR02MB430; H:xsj-pvapsmtpgw01; FPR:; SPF:SoftFail; LANG:en; PTR:unknown-60-83.xilinx.com; MX:1; A:1; MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8294c621-1cf8-42e3-cef9-08d69702e41a X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(5600110)(711020)(4605104)(2017052603328); SRVR:DM2PR02MB430; X-MS-TrafficTypeDiagnostic: DM2PR02MB430: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 0954EE4910 X-Microsoft-Exchange-Diagnostics: 1; DM2PR02MB430; 23:C7+wdDlNb20h5EoYfyiRxDq4psT6A8Vz7sGOv61c1AxqCxnAPPevuMS3rWfke5M0JpwKsCYV36RIKbHDtVjTRH+DMhZBMMzaCVj2V2kpmJekBxC1w5vRVdsyBtAZ7nhdHTSKay6hk+z5zSzZxIGFQzs/yO2WFDtqx6VxdHX41RIFlyMsWEG6hIU5fSPJfOUeLumaxhAfAFnTbkPw8fIJ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pEintWArJka9R+v2qyynMvwgqWkNu32UdLYzPCbFk2Y6n3W2Y5CyXvCAp1AcjRKWWxKzGvHuPi+ibLlvW0oBxnaftExg75sXGg3IKB/E08OPTXtM2PCxQWzo6AZWdDKX/JMrI+NG3pOYqN/dJXpXTP4Ck06PGqGQ57cnYqDkcAyJZ858YSuRvWo7rIak4CMIW3xlme5VYYtS5Efap6rDSSFbve5+/PPpjFgPYk09uT8d+cGjiBkmZ0w7/uITqs+q9oaDRRhLROr9qFGQgiOC04X2qDfl0GhbRiayvKl2F344JC3NDvdgwgp+xtaZArCr7QXyYyBratRRnami/Nt0aSGsZ+o/iWbRiRzZKLYttT5jOhJ6ABWSqIMBHVZZjbsJHthSgcLCmHRNKh594tdFNUykg= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2019 07:13:19.0463 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8294c621-1cf8-42e3-cef9-08d69702e41a 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.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR02MB430 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Shubhrajyoti Datta In case there are a lot of interrupts then the hold bit is not released. Protect the code by making it atomic by disabling interrupts. Fixes: df8eb5691c48 ("i2c: Add driver for Cadence I2C controller" Signed-off-by: Shubhrajyoti Datta Acked-by: Michal Simek --- v2: Update the wording v3: Add fixes tag drivers/i2c/busses/i2c-cadence.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c index b136057..92829be 100644 --- a/drivers/i2c/busses/i2c-cadence.c +++ b/drivers/i2c/busses/i2c-cadence.c @@ -365,6 +365,7 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id) { unsigned int ctrl_reg; unsigned int isr_status; + unsigned long flags; id->p_recv_buf = id->p_msg->buf; id->recv_count = id->p_msg->len; @@ -405,6 +406,7 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id) cdns_i2c_writereg(id->recv_count, CDNS_I2C_XFER_SIZE_OFFSET); } + local_irq_save(flags); /* Set the slave address in address register - triggers operation */ cdns_i2c_writereg(id->p_msg->addr & CDNS_I2C_ADDR_MASK, CDNS_I2C_ADDR_OFFSET); @@ -413,6 +415,7 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id) ((id->p_msg->flags & I2C_M_RECV_LEN) != I2C_M_RECV_LEN) && (id->recv_count <= CDNS_I2C_FIFO_DEPTH)) cdns_i2c_clear_bus_hold(id); + local_irq_restore(flags); cdns_i2c_writereg(CDNS_I2C_ENABLED_INTR_MASK, CDNS_I2C_IER_OFFSET); }