Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3400678imu; Mon, 24 Dec 2018 00:56:01 -0800 (PST) X-Google-Smtp-Source: AFSGD/XYeG6Wqu4x7CaJciunSxbRok1CMVfwHJz4qT69zTW6vrz/JoxhJ93lRcFwYufCEXt9MP2a X-Received: by 2002:aa7:83c6:: with SMTP id j6mr12445613pfn.91.1545641761101; Mon, 24 Dec 2018 00:56:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545641761; cv=none; d=google.com; s=arc-20160816; b=FLuU6lnXlkUh/4C3ZJklGVlZRMPl3q1P5o3nXjbRMfVUPyXA0p4ZyhmQRY1oZrd2Fk wnRYia1I/Z0na9pX4eo5MR4AJV70N5q/i31yk0oVtiKJY+oY4/87+IEnqYfJ/PJKkWnr eNHeNH1TxakPJ2WodGyT8pZ3U0T2utsa7dvxgDNeAKGSmzjC6vQ4Bn7gk62hMGxYLb4Q dQtLfhA7lfC6S7c4qs6QMbe36Bj3x9AwA5N7+4DhP39eqCoPa68OAf8tVCKn6G7QjHio H8oiecDhA2gDM9wIR35WUpOoMCvEFPR1yfRwQdSUCi7MMVLTyBv+7HIWFPv+isPZ9Jyf J30A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:organization:references:in-reply-to:date:cc:to:from :subject:message-id; bh=7EvXLTRKiGRFHrpsJYpwPnVOY9VTbjHlvmiHPCfit1E=; b=qNZQ5Hi3puJitG9YIIW7EkyBGTKjmR8MoqeeT/s/XkLfYtdC+H+9mIT8HU+/2rtrc8 ufSgbubQb1sDt1LeknCPP3JevKkbKErkB9FbzJFnDAu1gf/zYMPgm2XRf/CpH9SATC3I G226m+7hY9O9Cwnt2Np2xU4tuB+gnxC0NBdKMAs9ils4IN6wpCe3ldEbaL5698ZF4rBQ h4gGEO74uVqDLcfOEfvpPvqAAwmRRuTLgSKjOGnqBLw2TfpypAVLjOqCG+GMlVJlNcm8 Dzq5swsr21TByLjaL970l1mnnDsOHo5EwN249r7MCuGLIOEm/3EMYS3CHTsNP/MDuQGw lbjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v11si9022697pgo.11.2018.12.24.00.55.44; Mon, 24 Dec 2018 00:56:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726883AbeLXIyv (ORCPT + 99 others); Mon, 24 Dec 2018 03:54:51 -0500 Received: from mail.bootlin.com ([62.4.15.54]:58428 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726788AbeLXIyv (ORCPT ); Mon, 24 Dec 2018 03:54:51 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id AE2D520A46; Mon, 24 Dec 2018 09:54:48 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from aptenodytes (aaubervilliers-681-1-38-38.w90-88.abo.wanadoo.fr [90.88.157.38]) by mail.bootlin.com (Postfix) with ESMTPSA id 6CC1F20A2E; Mon, 24 Dec 2018 09:54:48 +0100 (CET) Message-ID: Subject: Re: [PATCH] i2c: bcm2835: Clear current message and count after a transaction From: Paul Kocialkowski To: Florian Fainelli , bcm-kernel-feedback-list@broadcom.com, linux-i2c@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Ray Jui , Scott Branden , Eric Anholt , Stefan Wahren Date: Mon, 24 Dec 2018 09:54:48 +0100 In-Reply-To: <4892f080-dff5-8d08-c78f-3c8b85f5a454@gmail.com> References: <20181221121135.4847-1-paul.kocialkowski@bootlin.com> <4892f080-dff5-8d08-c78f-3c8b85f5a454@gmail.com> Organization: Bootlin Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, 2018-12-21 at 09:52 -0800, Florian Fainelli wrote: > On 12/21/18 4:11 AM, Paul Kocialkowski wrote: > > The driver's interrupt handler checks whether a message is currently > > being handled with the curr_msg pointer. When it is NULL, the interrupt > > is considered to be unexpected. Similarly, the i2c_start_transfer > > routine checks for the remaining number of messages to handle in > > num_msgs. > > > > However, these values are never cleared and always keep the message and > > number relevant to the latest transfer (which might be done already and > > the underlying message memory might have been freed). > > > > When an unexpected interrupt hits with the DONE bit set, the isr will > > then try to access the flags field of the curr_msg structure, leading > > to a fatal page fault. > > > > Fix the issue by systematically clearing curr_msg and num_msgs in the > > driver-wide device structure when a transfer is considered complete. > > Should not this get a Fixes tag? Yes it totally should! Thanks for the suggestion. Cheers, Paul > > Signed-off-by: Paul Kocialkowski > > --- > > drivers/i2c/busses/i2c-bcm2835.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c > > index 44deae78913e..5486252f5f2f 100644 > > --- a/drivers/i2c/busses/i2c-bcm2835.c > > +++ b/drivers/i2c/busses/i2c-bcm2835.c > > @@ -298,6 +298,9 @@ static int bcm2835_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], > > return -ETIMEDOUT; > > } > > > > + i2c_dev->curr_msg = NULL; > > + i2c_dev->num_msgs = 0; > > + > > if (!i2c_dev->msg_err) > > return num; > > > > > > -- Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com