From patchwork Mon Sep 1 21:15:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 4822071 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8A7BDC0338 for ; Mon, 1 Sep 2014 21:15:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6AEF82015D for ; Mon, 1 Sep 2014 21:15:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AFC5A20145 for ; Mon, 1 Sep 2014 21:15:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752561AbaIAVPb (ORCPT ); Mon, 1 Sep 2014 17:15:31 -0400 Received: from mail-la0-f51.google.com ([209.85.215.51]:65178 "EHLO mail-la0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752393AbaIAVPa (ORCPT ); Mon, 1 Sep 2014 17:15:30 -0400 Received: by mail-la0-f51.google.com with SMTP id gl10so6584947lab.38 for ; Mon, 01 Sep 2014 14:15:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :user-agent:mime-version:content-transfer-encoding:content-type; bh=mrK/cKDnS4r3Q0smcrQd1oBkIddJAtsFo4+vuyRpbVU=; b=Zjbwlgm1s63MwjACE6uoqxCMhLc3cnNTLh0TqSUJ0NZ/b40rundj+imjqJW8G7waZc EWgcXeYjV1JlkT7vziWq2ZuT6LXoBuTrhL+yuEiRHxhMqdSLKJJZ8JE128R0F2Jc7XzB 3Nw1lJnjbhjKmWcfXyV3o92aMTn/y+uiDrNcGL42orV+i2KEu+ADh4JCXrrybVV6IETu 8gRKFWMot6DJ3ErYZYKO0XJqNvEqZjqp+zn534FiUCKSIRgR5jFyUsYXTzZFLdQS91Qf jQYCa5EUMGVi8Uo4SXIr/13FIfV7UBE1hd6SlIpG630zjXsb2o5OXzJ/qYNA40LHg2tP xrVA== X-Gm-Message-State: ALoCoQl3XEewWZ7QKZmJ82FUejAsFIA8/iDMZ2Gj/RITqz+iE68tQCkj+iDvusU6t/upgkEZdkAA X-Received: by 10.152.205.5 with SMTP id lc5mr12623890lac.45.1409606128642; Mon, 01 Sep 2014 14:15:28 -0700 (PDT) Received: from wasted.cogentembedded.com (ppp19-123.pppoe.mtu-net.ru. [81.195.19.123]) by mx.google.com with ESMTPSA id l10sm2661248lbc.3.2014.09.01.14.15.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Sep 2014 14:15:27 -0700 (PDT) From: Sergei Shtylyov To: wsa@the-dreams.de, linux-i2c@vger.kernel.org Cc: linux-sh@vger.kernel.org Subject: [PATCH] i2c-rcar: fix MNR interrupt handling Date: Tue, 02 Sep 2014 01:15:26 +0400 Message-ID: <1843756.qQiZLxsyqD@wasted.cogentembedded.com> Organization: Cogent Embedded Inc. User-Agent: KMail/4.13.3 (Linux/3.15.10-200.fc20.x86_64; KDE/4.13.3; x86_64; ; ) MIME-Version: 1.0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sometimes the MNR and MST interrupts happen simultaneously (stop automatically follows NACK, according to the manuals) and in such case the ID_NACK flag isn't set since the MST interrupt handling precedes MNR and all interrupts are cleared and disabled then, so that MNR interrupt is never noticed -- this causes NACK'ed transfers to be falsely reported as successful. Exchanging MNR and MST handlers fixes this issue, however the MNR bit somehow gets set again even after being explicitly cleared, so I decided to completely suppress handling of all disabled interrupts (which is a good thing anyway)... Signed-off-by: Sergei Shtylyov Cc: stable@vger.kernel.org --- The patch is against Wolfram Sang's 'linux.git' repo. drivers/i2c/busses/i2c-rcar.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux/drivers/i2c/busses/i2c-rcar.c =================================================================== --- linux.orig/drivers/i2c/busses/i2c-rcar.c +++ linux/drivers/i2c/busses/i2c-rcar.c @@ -367,18 +367,15 @@ static irqreturn_t rcar_i2c_irq(int irq, msr = rcar_i2c_read(priv, ICMSR); + /* Only handle interrupts that are currently enabled */ + msr &= rcar_i2c_read(priv, ICMIER); + /* Arbitration lost */ if (msr & MAL) { rcar_i2c_flags_set(priv, (ID_DONE | ID_ARBLOST)); goto out; } - /* Stop */ - if (msr & MST) { - rcar_i2c_flags_set(priv, ID_DONE); - goto out; - } - /* Nack */ if (msr & MNR) { /* go to stop phase */ @@ -388,6 +385,12 @@ static irqreturn_t rcar_i2c_irq(int irq, goto out; } + /* Stop */ + if (msr & MST) { + rcar_i2c_flags_set(priv, ID_DONE); + goto out; + } + if (rcar_i2c_is_recv(priv)) rcar_i2c_flags_set(priv, rcar_i2c_irq_recv(priv, msr)); else