From patchwork Wed Mar 8 06:47:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9610437 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 8B372602B4 for ; Wed, 8 Mar 2017 06:51:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6F1128535 for ; Wed, 8 Mar 2017 06:51:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C0C5285C8; Wed, 8 Mar 2017 06:51:17 +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 5BBDD28535 for ; Wed, 8 Mar 2017 06:51:17 +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=Zgl/dvQfGFrfB1+yrvlW5IRgpJ8SKhC/8HIx+qqlzbw=; b=NJRt0ApcFkG6ti NX3zcfS5AOk9hr7ICKDTPLyJTuFM8t7urexkgNr1BC6RkNQo26uXdIXRxQ8nuI6JtmF5C8ED+8sWn 0IAClSsV5eFz3qHTzhuag62/fE6BoctcxIdfGPPsx9xGggFzJLTkDqstemDBKwjDxEKESk0khFa++ +Z5F4yI/0/EQckk0cbWVjPG0zEp/w4SSmscDjRy4ExdJMkxeTa+PfFHLf52en/rftVC/uqU85CGjw Ot/fljuIJISRs3tvCGlEEAF4tvUafwWYDbBfqwaskj3iU34kkpJqAKueGdunoHRMp/SJ1Y1btVm0R 0UsZ4aXOSw6WXyJmGnzA==; 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 1clVRH-0000b6-Io; Wed, 08 Mar 2017 06:51:11 +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 1clVRB-0000Mu-6P for linux-amlogic@lists.infradead.org; Wed, 08 Mar 2017 06:51:08 +0000 Received: by mail-wr0-x242.google.com with SMTP id g10so2862002wrg.0 for ; Tue, 07 Mar 2017 22:50:46 -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=RN+k1PW6Qkz4F93cd8qVxIZSLs/45Tmtl8+rsmVSYuU=; b=AEAI2HsPy48Kfl/ivXXqhz5HcAVrg4pVYFFhb1yygEypUeLLlXwaRHYS31gPNL94pf 0Qm5z7wbkMgW17GDfswYJU+35Vo3LVVzMlrULzZdtn8lhBNkCrADk9FE8fmcqFQ93O+v MQ6oqFGeghvjFbgT+XWQ64/9s2qYBHWFIiY3W2kI6aVrxWFbyiA5SYf2jefgLhAMAbt+ Kks8b8+MKoA+yDlbzI7enzIhCp2K91Da5X/bwCR/jybrXjgBRc9oP+5+M11kbiu0nEe4 4YXmoAqmuRlo6AE13xZsH2mtxcNbeKQ5pIWq4ANHQmhBdvEU+3UO08tfTyAlc7DET3Pl OenQ== 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=RN+k1PW6Qkz4F93cd8qVxIZSLs/45Tmtl8+rsmVSYuU=; b=BPOWNRyS0yyLd26rF0FTagitl00GfbUMDJeqCPdR5WFbzDUTXwy8VIZnnH+jsiGx6I ykh2xe+DwGbA3o5806B+svaMsInMb2uI0LGFhMlsFls/nnpx7peVGOGgh3JFlHzZYY4S I3GQLm58Vg5BXCN7jm77a6sqLRZ9g/y3rlbaHrmndQuJzKSufXR1Jtb/S+ikPl8C8kcw kVWZAjhH98Yy7XsN2kHCD6NNQ5cczaB7qq7+xDZll7UFTXAFwGZ6HFAEJg3FwcB7SqR2 k/9eGA50axBRDCiGtdjKYclPMRdQA9vClYomDvKDtIvD7rYUZ88NuFHKjHtQLEmwNmJO mueg== X-Gm-Message-State: AMke39mmxYKJgoAx2Fenc3mU7x/wQVpbqhejP9PqFR9xEo32PSmOF0eIcaAJUy8VZ1Sb0A== X-Received: by 10.223.161.204 with SMTP id v12mr4013772wrv.36.1488955844821; Tue, 07 Mar 2017 22:50:44 -0800 (PST) Received: from ?IPv6:2003:c6:ebdc:4000:2c95:2fb7:1198:794b? (p200300C6EBDC40002C952FB71198794B.dip0.t-ipconnect.de. [2003:c6:ebdc:4000:2c95:2fb7:1198:794b]) by smtp.googlemail.com with ESMTPSA id k43sm2818186wrk.42.2017.03.07.22.50.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Mar 2017 22:50:44 -0800 (PST) Subject: [PATCH 07/12] i2c: meson: improve interrupt handler and detect spurious interrupts To: Wolfram Sang References: From: Heiner Kallweit Message-ID: Date: Wed, 8 Mar 2017 07:47:16 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170307_225106_875941_3456B0FD X-CRM114-Status: GOOD ( 10.15 ) 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 --- drivers/i2c/busses/i2c-meson.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/busses/i2c-meson.c b/drivers/i2c/busses/i2c-meson.c index 81304840..b3b881f9 100644 --- a/drivers/i2c/busses/i2c-meson.c +++ b/drivers/i2c/busses/i2c-meson.c @@ -233,7 +233,15 @@ static irqreturn_t meson_i2c_irq(int irqno, void *dev_id) 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) { + meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_START, 0); + + if (i2c->state == STATE_IDLE) { + dev_notice(i2c->dev, "spurious interrupt detected\n"); + 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 +284,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 +349,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;