Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8101536imu; Tue, 4 Dec 2018 03:02:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/XAd02JGt8P3mLekqvJEm6PKlX6YFvJ7wS9F9+ZR5kjikFIPKKjggbUKvu2423KCHdvKQmU X-Received: by 2002:a65:434d:: with SMTP id k13mr16464404pgq.269.1543921349645; Tue, 04 Dec 2018 03:02:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543921349; cv=none; d=google.com; s=arc-20160816; b=OIa/szOUvCn8U1L2l9+ngFeju1fxPBIoG3CG/ZbdMTWB3fHcdXUPf4KOZh6MqL+07p GGHxrqdloATxo+aDe9OI3SYxWmCA3vkQkAEMFuJx23sYT78ULs6YVKtBONTcaHYzlmh3 L4/1iPw4J4mJO8/x0PotOKEfpoWtnCBPiw/uIaTLvHSTacZqaJGhoT6HYGaW/3IcxXNr Q7jCkx6hdMAvSaavYbGlBUjacF628ScaLKDss3i8I5KZ06Duq17XKf16PE9Fx54s0Ezv 1WjcHbaM65hm2ZbCXscbQ009NmX8vLy362vI4eqEvU2I+jDu9I6P5gwRvYPTdhXMwS+B KjHQ== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PqJ1Mn/AmmMyAa4a20aSP9vYsco6pOqQ7np5462FXgA=; b=a2wxbxVYXDyLecVyFB3nCEetKkJxIamqCk+OhkRNgm6nhxw4+jq3NghPSIOXlRvlwT lqkrl1XBjvlh67vzEPG03DT0+A5oJecESi+nCY9+XTP3OQCD2yIzGnmgP/ZSs7qmFDyR u4ahMAwqL61Et21yKBnio+UJkgqEnsNFMVaQaw/s3o54tELXGIozvRoW7WYCiwQwXHJD /9beOfK02fAa3MR4e4VY1zy0pNXqMJyL/23jpcyXQLIImHqz85w0Y7klkLGM09B56GGH 1VQXiIjsHOxGjS8AemQCRHj+xNLBdPRAV+NQ0D5zEOBttxlNW6fCB3KVToEbQPd4aezd 60WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eU+smFmM; 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 g184si17321854pfb.288.2018.12.04.03.02.13; Tue, 04 Dec 2018 03:02:29 -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; dkim=pass header.i=@kernel.org header.s=default header.b=eU+smFmM; 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 S1726860AbeLDLAo (ORCPT + 99 others); Tue, 4 Dec 2018 06:00:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:45934 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726675AbeLDLAk (ORCPT ); Tue, 4 Dec 2018 06:00:40 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6A6002146D; Tue, 4 Dec 2018 11:00:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543921238; bh=ebiBTEj/7u9Wo/LDJy2vQ6vA+RmmpxjaOsDPW+ZkyjA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eU+smFmM5iHNcNuZRXBA2yyLwQDq+08ELFKRY0YiJbKg6Z2J6mOHNZIZMv9Kne/iy mcONEyxkEiZrX9T/UlrefJqUO1hWWX3QK2MmPCstD49FCn4/GNRkHS0aZ6bTpSpF7N QWpcrV/mUUB0goRV/mvsNWIhYvTOUhk0O//Q8LSM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Kelly , Denis Ciocca , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 4.19 134/139] iio:st_magn: Fix enable device after trigger Date: Tue, 4 Dec 2018 11:50:15 +0100 Message-Id: <20181204103656.330234585@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204103649.950154335@linuxfoundation.org> References: <20181204103649.950154335@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Martin Kelly commit fe5192ac81ad0d4dfe1395d11f393f0513c15f7f upstream. Currently, we enable the device before we enable the device trigger. At high frequencies, this can cause interrupts that don't yet have a poll function associated with them and are thus treated as spurious. At high frequencies with level interrupts, this can even cause an interrupt storm of repeated spurious interrupts (~100,000 on my Beagleboard with the LSM9DS1 magnetometer). If these repeat too much, the interrupt will get disabled and the device will stop functioning. To prevent these problems, enable the device prior to enabling the device trigger, and disable the divec prior to disabling the trigger. This means there's no window of time during which the device creates interrupts but we have no trigger to answer them. Fixes: 90efe055629 ("iio: st_sensors: harden interrupt handling") Signed-off-by: Martin Kelly Tested-by: Denis Ciocca Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/magnetometer/st_magn_buffer.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) --- a/drivers/iio/magnetometer/st_magn_buffer.c +++ b/drivers/iio/magnetometer/st_magn_buffer.c @@ -30,11 +30,6 @@ int st_magn_trig_set_state(struct iio_tr return st_sensors_set_dataready_irq(indio_dev, state); } -static int st_magn_buffer_preenable(struct iio_dev *indio_dev) -{ - return st_sensors_set_enable(indio_dev, true); -} - static int st_magn_buffer_postenable(struct iio_dev *indio_dev) { int err; @@ -50,7 +45,7 @@ static int st_magn_buffer_postenable(str if (err < 0) goto st_magn_buffer_postenable_error; - return err; + return st_sensors_set_enable(indio_dev, true); st_magn_buffer_postenable_error: kfree(mdata->buffer_data); @@ -63,11 +58,11 @@ static int st_magn_buffer_predisable(str int err; struct st_sensor_data *mdata = iio_priv(indio_dev); - err = iio_triggered_buffer_predisable(indio_dev); + err = st_sensors_set_enable(indio_dev, false); if (err < 0) goto st_magn_buffer_predisable_error; - err = st_sensors_set_enable(indio_dev, false); + err = iio_triggered_buffer_predisable(indio_dev); st_magn_buffer_predisable_error: kfree(mdata->buffer_data); @@ -75,7 +70,6 @@ st_magn_buffer_predisable_error: } static const struct iio_buffer_setup_ops st_magn_buffer_setup_ops = { - .preenable = &st_magn_buffer_preenable, .postenable = &st_magn_buffer_postenable, .predisable = &st_magn_buffer_predisable, };