From patchwork Thu Mar 9 06:53:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9612369 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 22AF6602B4 for ; Thu, 9 Mar 2017 07:02:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01F6E28445 for ; Thu, 9 Mar 2017 07:02:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA69B28435; Thu, 9 Mar 2017 07:02:15 +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=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 9DC4328435 for ; Thu, 9 Mar 2017 07:02:15 +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:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+yR9ZvvAmyVjmlwq6rXLkx9DDFMuOGvezKrrwEPIU/I=; b=JSBN83TjxoHuMh XpCaRRbQg2pv2I9kB1vRaK2fLNZ0zliPH6GmzOyHejJT6d1CUP5q2eBN1i48Kyxmt9hdFocDCbKqg MBcGm35XeFUL1M7u3+oEhah9wh97Ru8n6bm/s4lRYhIE0tWIbFhndtFzirXf+OuE2V9A9BErjds1/ TRbekvvSMiWvDAV0Hv6EFYiZQiT/UOVZSmvy6wBaKB1DPPPNv1pX2RSqwihf3s2MCS0bKhsdaxiiY lBCgeycALBFYuvJP12SuBFWARNIB1r2cMIqYQB8bAxQUA5zAZ4cnZKNniascHilnpW8tPDwRQah7W rk8U9ggu6bwVxOH0F79w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cls5U-0002hA-05; Thu, 09 Mar 2017 07:02:12 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cls5Q-0002YK-4x for linux-amlogic@lists.infradead.org; Thu, 09 Mar 2017 07:02:10 +0000 Received: by mail-wr0-x242.google.com with SMTP id u108so6723119wrb.2 for ; Wed, 08 Mar 2017 23:01:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=wFrYZArYZrq/GVpBxdbA1syA26xRdRdpjMadXOfgWUE=; b=Ttu8Y4lHeb85EKsntigfsbCQ3Nvq5TbbW5cj/Z+aJyBgfSo9G82sFG1bXLnW0aJfN8 cKKEUWJy0sNNR22phUepWh8561KGeDNBiM4+tt7vskysAnWE+oqS1yGQLfkdTgmTF+TX cntruSH8VXXEyxZ3pZOiLRPUjytw/ePQMMFmCCyT7q5hHpa+kFEaPkPiNPmg57V61fZz SAlujVdKRsGb07Dgi3vaC2gV9Twpw6XZWiXqx9FKQUUsf5xPXACU5Ioto3iDOmaQlCLy SNGpM4Oxp2mjBKe6kfMr25/aRUGzt7aVd5aljgMSsr9hwC3q4pWggzznXYYyg2p7TMdK FfbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=wFrYZArYZrq/GVpBxdbA1syA26xRdRdpjMadXOfgWUE=; b=Awl9rN9ip7hijCyfHI179EB6T106AvMbIrca8fPQvSA0Zjlrw8t3pZmoKyJS0MY18o +8ZfL2NhBv8MBNTFJaoyJ50H0O5U9T6FNzcR08aeo9aj9gNPGppLaQwg5HZBe11ndakZ U/ghFPnnyi+BDLi609oXzf6FTh4xTW69GgqAkiRTP1MtbHlGo8+2Tyc/NzxmOFa1CcDk 5Mg2878WInTB3nh1cy+m1ktVAm/iRiZF/bzNlpnmekS/gF9YQ89AdPCRjpCswRODyoiR v+GvVunFBzLjdPB2SxRpuWRPTPOW4/HDJO/n3sBM+iszraU9HMenPhU6bX4Jgtp1Ceeh X5lQ== X-Gm-Message-State: AMke39kdvvOJ6aub+bz7wUI4UtJE3a0wl65ZZBzMxQLDTCGdg/+TxY/WXJHLCwE8rRrxCw== X-Received: by 10.223.170.73 with SMTP id q9mr8955825wrd.13.1489042907295; Wed, 08 Mar 2017 23:01:47 -0800 (PST) Received: from ?IPv6:2003:c6:ebdc:4000:b589:624b:5134:aa75? (p200300C6EBDC4000B589624B5134AA75.dip0.t-ipconnect.de. [2003:c6:ebdc:4000:b589:624b:5134:aa75]) by smtp.googlemail.com with ESMTPSA id v1sm6976432wra.65.2017.03.08.23.01.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Mar 2017 23:01:46 -0800 (PST) Subject: [PATCH v2 07/10] i2c: meson: improve interrupt handler and detect spurious interrupts To: Wolfram Sang , Jerome Brunet References: From: Heiner Kallweit Message-ID: <372c966f-253d-fdd0-9675-6f928e02d401@gmail.com> Date: Thu, 9 Mar 2017 07:53:26 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170308_230208_366488_AEDF1CA2 X-CRM114-Status: GOOD ( 11.16 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, "linux-i2c@vger.kernel.org" Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If state is STATE_IDLE no interrupt should occur. Detect this case and warn. In addition move resetting REG_CTRL_START bit to the start of the interrupt handler and remove a unneeded REG_CTRL_START bit reset in meson_i2c_xfer_msg. Signed-off-by: Heiner Kallweit --- v2: - don't print an error if spurious interrupt is detected --- drivers/i2c/busses/i2c-meson.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/busses/i2c-meson.c b/drivers/i2c/busses/i2c-meson.c index 56e15a74..74d433cd 100644 --- a/drivers/i2c/busses/i2c-meson.c +++ b/drivers/i2c/busses/i2c-meson.c @@ -228,12 +228,18 @@ static irqreturn_t meson_i2c_irq(int irqno, void *dev_id) spin_lock(&i2c->lock); meson_i2c_reset_tokens(i2c); + meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_START, 0); ctrl = readl(i2c->regs + REG_CTRL); dev_dbg(i2c->dev, "irq: state %d, pos %d, count %d, ctrl %08x\n", i2c->state, i2c->pos, i2c->count, ctrl); - if (ctrl & REG_CTRL_ERROR && i2c->state != STATE_IDLE) { + if (i2c->state == STATE_IDLE) { + spin_unlock(&i2c->lock); + return IRQ_NONE; + } + + if (ctrl & REG_CTRL_ERROR) { /* * The bit is set when the IGNORE_NAK bit is cleared * and the device didn't respond. In this case, the @@ -276,15 +282,12 @@ static irqreturn_t meson_i2c_irq(int irqno, void *dev_id) i2c->state = STATE_IDLE; complete(&i2c->done); break; - case STATE_IDLE: - break; } out: if (i2c->state != STATE_IDLE) { /* Restart the processing */ meson_i2c_write_tokens(i2c); - meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_START, 0); meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_START, REG_CTRL_START); } @@ -344,9 +347,6 @@ static int meson_i2c_xfer_msg(struct meson_i2c *i2c, struct i2c_msg *msg, */ spin_lock_irqsave(&i2c->lock, flags); - /* Abort any active operation */ - meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_START, 0); - if (!time_left) { i2c->state = STATE_IDLE; ret = -ETIMEDOUT;