From patchwork Thu Aug 13 07:53:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 11711949 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 44B73109B for ; Thu, 13 Aug 2020 07:54:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1BEBD2078B for ; Thu, 13 Aug 2020 07:54:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="JTA1BhxH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726600AbgHMHyu (ORCPT ); Thu, 13 Aug 2020 03:54:50 -0400 Received: from www381.your-server.de ([78.46.137.84]:48648 "EHLO www381.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726174AbgHMHys (ORCPT ); Thu, 13 Aug 2020 03:54:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=JvabeP1Wi9KJ1VRtuiYVKr0uCnGXs0PcB8x9LsqXhQI=; b=JTA1BhxHYQLX5Fj70HoEN0v2K1 6W0CTcGfha0Fdt9g7Xqgmg4w0gYxzXUXbqKXmO1kNnaACAp7jNXWM56CjmcxW0xiHS958g5hpwUJ7 LioYltUHPE4KChh4dm/otX+0Op7ZeiqKkO4z6pA6Tmwf0iCYyYMlnxAWlFvYwZXSu1m85sI25ydjK lHfKw4NxmiWiGdJqxmTUYz/VTs7NDUeCDMRSrz+Cz0qmmTs7HzItKH3MiFtWZDgc0J+tvgkV2UM2j sQkM8WJy4YrE66jrnp5k2B6YNSoDRvJYBRj3GjLSoWLQQU1EeYGFuDmGSO4wF8w5xc1R8WkRmMjnG T8tNzovA==; Received: from sslproxy06.your-server.de ([78.46.172.3]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1k684U-00069n-ST; Thu, 13 Aug 2020 09:54:46 +0200 Received: from [2001:a61:2517:6d01:9e5c:8eff:fe01:8578] (helo=lars-desktop.fritz.box) by sslproxy06.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k684U-000C5M-Ns; Thu, 13 Aug 2020 09:54:46 +0200 From: Lars-Peter Clausen To: Jonathan Cameron Cc: Hartmut Knaack , Peter Meerwald-Stadler , Sebastian Andrzej Siewior , Christian Eggers , linux-iio@vger.kernel.org, Lars-Peter Clausen Subject: [PATCH 1/2] iio: hrtimer-trigger: Mark hrtimer to expire in hard interrupt context Date: Thu, 13 Aug 2020 09:53:57 +0200 Message-Id: <20200813075358.13310-1-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.4/25900/Mon Aug 10 14:44:29 2020) Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On PREEMPT_RT enabled kernels unmarked hrtimers are moved into soft interrupt expiry mode by default. The IIO hrtimer-trigger needs to run in hard interrupt context since it will end up calling generic_handle_irq() which has the requirement to run in hard interrupt context. Explicitly specify that the timer needs to run in hard interrupt context by using the HRTIMER_MODE_REL_HARD flag. Fixes: f5c2f0215e36 ("hrtimer: Move unmarked hrtimers to soft interrupt expiry on RT") Reported-by: Christian Eggers Signed-off-by: Lars-Peter Clausen --- drivers/iio/trigger/iio-trig-hrtimer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/trigger/iio-trig-hrtimer.c b/drivers/iio/trigger/iio-trig-hrtimer.c index f59bf8d58586..b11ca915fcb2 100644 --- a/drivers/iio/trigger/iio-trig-hrtimer.c +++ b/drivers/iio/trigger/iio-trig-hrtimer.c @@ -132,7 +132,7 @@ static struct iio_sw_trigger *iio_trig_hrtimer_probe(const char *name) trig_info->swt.trigger->ops = &iio_hrtimer_trigger_ops; trig_info->swt.trigger->dev.groups = iio_hrtimer_attr_groups; - hrtimer_init(&trig_info->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + hrtimer_init(&trig_info->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD); trig_info->timer.function = iio_hrtimer_trig_handler; trig_info->sampling_frequency = HRTIMER_DEFAULT_SAMPLING_FREQUENCY; From patchwork Thu Aug 13 07:53:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 11711951 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6AF3614E3 for ; Thu, 13 Aug 2020 07:54:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49DA420791 for ; Thu, 13 Aug 2020 07:54:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=metafoo.de header.i=@metafoo.de header.b="RMN+LCs2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726174AbgHMHyu (ORCPT ); Thu, 13 Aug 2020 03:54:50 -0400 Received: from www381.your-server.de ([78.46.137.84]:48652 "EHLO www381.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726574AbgHMHys (ORCPT ); Thu, 13 Aug 2020 03:54:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metafoo.de; s=default2002; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=kseFHIrYtMArcuIr7UZEvMpSII4I4pmSCP9jh0NPbik=; b=RMN+LCs2IMNMtea1KU8f8Sw72L 3W4rBtyJN2bxjenoIUeYKKV45ZdbPN7EbqlGJ8omGjN0uwTUV5LduEaoyqAGrfzK4jd+BnOFG3rHt OknKNQpCSlsBvoTahFAQzwH0Iq9IcIUlrMkG++a1vRYaTKQ55m8Y+cb9jBSOH1SSHlLdA5tyIj+Xs o8M8WkJ3RBYJm9Fk17sSEyOTQNbgaLqf4AZnbG0vCc7xpLMJ2IHwacJGxyRCVEpuqNMjnvO3/qVQT hlQ0RQ3taMZX4u8AJbBINHTyrgYzX6ea2U7cxDIuzMKt/D0VUsGEGGemZdh5PYhX9aAPKQLdMCQgq 41IZZJEQ==; Received: from sslproxy06.your-server.de ([78.46.172.3]) by www381.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1k684U-00069o-V9; Thu, 13 Aug 2020 09:54:46 +0200 Received: from [2001:a61:2517:6d01:9e5c:8eff:fe01:8578] (helo=lars-desktop.fritz.box) by sslproxy06.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k684U-000C5M-Qc; Thu, 13 Aug 2020 09:54:46 +0200 From: Lars-Peter Clausen To: Jonathan Cameron Cc: Hartmut Knaack , Peter Meerwald-Stadler , Sebastian Andrzej Siewior , Christian Eggers , linux-iio@vger.kernel.org, Lars-Peter Clausen Subject: [PATCH 2/2] iio: sysfs-trigger: Mark irq_work to expire in hardirq context Date: Thu, 13 Aug 2020 09:53:58 +0200 Message-Id: <20200813075358.13310-2-lars@metafoo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200813075358.13310-1-lars@metafoo.de> References: <20200813075358.13310-1-lars@metafoo.de> MIME-Version: 1.0 X-Authenticated-Sender: lars@metafoo.de X-Virus-Scanned: Clear (ClamAV 0.102.4/25900/Mon Aug 10 14:44:29 2020) Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Mark the IIO sysfs-trigger irq_work with IRQ_WORK_HARD_IRQ to ensure that it is always executed in hard interrupt context, even with PREEMPT_RT=y. The IIO sysfs-trigger irq_work needs to run in hard interrupt context since it will end up calling generic_handle_irq() which has the requirement to run in hard interrupt context. Note that the IRQ_WORK_HARD_IRQ flag, while it exists, does not seem to do anything in the mainline kernel yet. It does have an effect in the RT patchset though and presumably this is sooner or later going to be added to mainline as well. Reported-by: Christian Eggers Signed-off-by: Lars-Peter Clausen --- drivers/iio/trigger/iio-trig-sysfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/trigger/iio-trig-sysfs.c b/drivers/iio/trigger/iio-trig-sysfs.c index e09e58072872..10a3fd29362b 100644 --- a/drivers/iio/trigger/iio-trig-sysfs.c +++ b/drivers/iio/trigger/iio-trig-sysfs.c @@ -161,6 +161,7 @@ static int iio_sysfs_trigger_probe(int id) iio_trigger_set_drvdata(t->trig, t); init_irq_work(&t->work, iio_sysfs_trigger_work); + atomic_set(&t->work.flags, IRQ_WORK_HARD_IRQ); ret = iio_trigger_register(t->trig); if (ret)