Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp309733pxu; Fri, 23 Oct 2020 00:59:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwd/EOmcA8rTz5HyJbEaOQOvMlZfWAzIeTe75u7w7K0zIWwLY+jH0Evm9yNQ3ldrGgUWooJ X-Received: by 2002:a17:906:1614:: with SMTP id m20mr791056ejd.258.1603439978605; Fri, 23 Oct 2020 00:59:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603439978; cv=none; d=google.com; s=arc-20160816; b=ZEn0zGWav+VsB/Uzs8JpV8kaVVKUPw01bHU/FTD7gMF6xTORPykqpWfXh/o9bSfb3m QrJP4+gCY1KXQSY/yXsXwRkbl9QprHPEL8/j+dfg+MhcwHdMhgHOB3Ao9M/km0KJ1d5O WojTPoI5PhJJ1tPoGQL3TikInG21NifD30eH451NHeu3jaGiN9XXNiBLj7B9VvMLPkLA 78dB8XY2hBZiQzvwj9eKgtJkBksTwIEs3UqmVL3tVYjVDoVEmUqlaGtG85FDB71UCpUt fKia/hQn5dAGHh6h0JfK/zyYyg/G0Ju2nJiAbvnTgvlUBmbwzOqmn3xSdgpD8lsFObio GH2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=RNqb7CHBD9F9wVVPz+uk8Pad0wWNAw26txn1TZ2nzdc=; b=QJB5bE1PdPxGGj9xka0/NRi9CulcFJNonDN0l2JZMC2ZVG5Cqm4sTBePb6whbUjFEC lAWUjSGtNaXJbThiBdqceiBz4cSQJKn7YUNEkEYFVruhUUxoBDrsESqMEy1v0EJOFM4m tPCvNtEE69PZExStqPidzpp0vnEW8gWBEVfkkxDbZgcuEDpeTi+0yn+3CRawre8xmtlz uCTfWZZpkC184wtLOAmVWCzQG/suVLlGT08wUSyxD94xZUmuiLI9es7DJR1LQp4e+fff cG2hFNTlxJLW2BCmS1NfvFfJ2Sr9y3X8FNR7Gw2ZEJasNMM3dXHGyzrq9bF0unUVDdej 9lbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vivotek.com header.s=dkim header.b=Y8L2ZT1X; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y20si337165ejw.696.2020.10.23.00.59.16; Fri, 23 Oct 2020 00:59:38 -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=@vivotek.com header.s=dkim header.b=Y8L2ZT1X; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S371557AbgJWFlY (ORCPT + 99 others); Fri, 23 Oct 2020 01:41:24 -0400 Received: from mail.vivotek.com ([60.248.39.150]:37728 "EHLO mail.vivotek.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S371546AbgJWFlX (ORCPT ); Fri, 23 Oct 2020 01:41:23 -0400 Received: from pps.filterd (vivotekpps.vivotek.com [127.0.0.1]) by vivotekpps.vivotek.com (8.16.0.42/8.16.0.42) with SMTP id 09N5d7D1013628; Fri, 23 Oct 2020 13:41:15 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivotek.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=dkim; bh=RNqb7CHBD9F9wVVPz+uk8Pad0wWNAw26txn1TZ2nzdc=; b=Y8L2ZT1XlFUT16GcaZ6twLkMeVIV8CE3lj8iLPM/BwKdIKyuo7APpWw8gjoFBqAaHlll 0PWdAYq9aU8Ip8J8KL7ppoKP/QBwGqpgl57sCKTZ9l4Aic+ntiRHEMfbqkDFD7oNYqRg jj1/Fi6/f7JjMZyXsCA/Eg3nbyoSoVDPhV8= Received: from cas01.vivotek.tw ([192.168.0.58]) by vivotekpps.vivotek.com with ESMTP id 349m9fjdsj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 23 Oct 2020 13:41:15 +0800 Received: from localhost.localdomain (192.168.17.134) by CAS01.vivotek.tw (192.168.0.58) with Microsoft SMTP Server (TLS) id 14.3.487.0; Fri, 23 Oct 2020 13:41:14 +0800 From: Michael Wu To: Jarkko Nikula , Andy Shevchenko , Mika Westerberg , , CC: Morgan Chang , Michael Wu Subject: [PATCH v3] i2c: designware: call i2c_dw_read_clear_intrbits_slave() once Date: Fri, 23 Oct 2020 13:40:27 +0800 Message-ID: <20201023054027.13540-1-michael.wu@vatics.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.168.17.134] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.737 definitions=2020-10-23_03:2020-10-20,2020-10-23 signatures=0 X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If some bits were cleared by i2c_dw_read_clear_intrbits_slave() in i2c_dw_isr_slave() and not handled immediately, those cleared bits would not be shown again by later i2c_dw_read_clear_intrbits_slave(). They therefore were forgotten to be handled. i2c_dw_read_clear_intrbits_slave() should be called once in an ISR and take its returned state for all later handlings. Signed-off-by: Michael Wu --- Change in v3: - revert deleted braces of 'else' branch in v2 Change in v2: - revert moving I2C_SLAVE_WRITE_REQUESTED reporting in v1 drivers/i2c/busses/i2c-designware-slave.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-slave.c b/drivers/i2c/busses/i2c-designware-slave.c index 44974b53a626..13de01a0f75f 100644 --- a/drivers/i2c/busses/i2c-designware-slave.c +++ b/drivers/i2c/busses/i2c-designware-slave.c @@ -159,7 +159,6 @@ static int i2c_dw_irq_handler_slave(struct dw_i2c_dev *dev) u32 raw_stat, stat, enabled, tmp; u8 val = 0, slave_activity; - regmap_read(dev->map, DW_IC_INTR_STAT, &stat); regmap_read(dev->map, DW_IC_ENABLE, &enabled); regmap_read(dev->map, DW_IC_RAW_INTR_STAT, &raw_stat); regmap_read(dev->map, DW_IC_STATUS, &tmp); @@ -168,6 +167,7 @@ static int i2c_dw_irq_handler_slave(struct dw_i2c_dev *dev) if (!enabled || !(raw_stat & ~DW_IC_INTR_ACTIVITY) || !dev->slave) return 0; + stat = i2c_dw_read_clear_intrbits_slave(dev); dev_dbg(dev->dev, "%#x STATUS SLAVE_ACTIVITY=%#x : RAW_INTR_STAT=%#x : INTR_STAT=%#x\n", enabled, slave_activity, raw_stat, stat); @@ -188,11 +188,9 @@ static int i2c_dw_irq_handler_slave(struct dw_i2c_dev *dev) val); } regmap_read(dev->map, DW_IC_CLR_RD_REQ, &tmp); - stat = i2c_dw_read_clear_intrbits_slave(dev); } else { regmap_read(dev->map, DW_IC_CLR_RD_REQ, &tmp); regmap_read(dev->map, DW_IC_CLR_RX_UNDER, &tmp); - stat = i2c_dw_read_clear_intrbits_slave(dev); } if (!i2c_slave_event(dev->slave, I2C_SLAVE_READ_REQUESTED, @@ -207,7 +205,6 @@ static int i2c_dw_irq_handler_slave(struct dw_i2c_dev *dev) regmap_read(dev->map, DW_IC_CLR_RX_DONE, &tmp); i2c_slave_event(dev->slave, I2C_SLAVE_STOP, &val); - stat = i2c_dw_read_clear_intrbits_slave(dev); return 1; } @@ -219,7 +216,6 @@ static int i2c_dw_irq_handler_slave(struct dw_i2c_dev *dev) dev_vdbg(dev->dev, "Byte %X acked!", val); } else { i2c_slave_event(dev->slave, I2C_SLAVE_STOP, &val); - stat = i2c_dw_read_clear_intrbits_slave(dev); } return 1; @@ -230,7 +226,6 @@ static irqreturn_t i2c_dw_isr_slave(int this_irq, void *dev_id) struct dw_i2c_dev *dev = dev_id; int ret; - i2c_dw_read_clear_intrbits_slave(dev); ret = i2c_dw_irq_handler_slave(dev); if (ret > 0) complete(&dev->cmd_complete); -- 2.17.1