Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp385924pxk; Thu, 17 Sep 2020 05:56:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOYEpHjFJyFrK7StmE9sJ27pjmuRPkrMGWMZDYWJYMtEDRysRmhj/dOvlXv5mfnf8nv7DJ X-Received: by 2002:a50:cdd1:: with SMTP id h17mr33282210edj.94.1600347366688; Thu, 17 Sep 2020 05:56:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600347366; cv=none; d=google.com; s=arc-20160816; b=zn/6BOV/Zfhqm9hzHqVU92WE6njNEE/XXaLsBPgtZbr0inL6O1Tqq1pb8wTW/SrDAO CGe0O34SlzTRSneV0cEjCqs4VXwMQ02xzQLP2S4ujy9+8Pu3rqOGp8JSQFrhUilScg29 Z/JlLgWf0OZzwzB7Q0rNQuYtr3RLNeE5AgQA+XsuvpueI2YI/cDWrrsaVgTtl+m+R2BW yKIw2JC9PK5q46DOcNfWp2AZtLVjNL7pqgwWLcO4ROnPsKTPjthBEimxxyB+XoyrD8JF bz/wbboXm50y8rgw33rTNYcBEDCu1S/PvFetRwnW+OOiPXUlRuHWgXzQ6s3LPC/Gulzm VRhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=w8c1Ge/8xZ2OA8EEaIRlBl/k49F52Hsdt6o7FrVvXs4=; b=VrHnux1oYNP0tOBO/HsjxxNG1w3mAIKmTugoahT1YjAeF7I4/4BOFGnM7ZGMdB/UTK aVrYRqA09Ov1LG6CMtVRdYj+VOF+7X9lfGWpsWh3fn+Py+uK/bbFDigWtdvem/dFYun6 XxmEdPeFt8p6QGvEOqBEHi7FqINCcxEpafX5zzbWBxQnM/nR22cfEZnQ+qErjMkC29Kl JXLNvhQCFjZVCnpuY95LgrdHLUVNIhQGJMnaFSESgB0yGx7eYoS/BgPrF3SDbhXBRJoq 98zmZHD2wDg2gpG1jdNvF4zcHxeNFsioihHBJxvkm6ht10chCrRNcOW+3U28oUE393Bd 4xpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ba30si14475165edb.44.2020.09.17.05.55.43; Thu, 17 Sep 2020 05:56:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727039AbgIQMyo (ORCPT + 99 others); Thu, 17 Sep 2020 08:54:44 -0400 Received: from mailout06.rmx.de ([94.199.90.92]:53012 "EHLO mailout06.rmx.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726993AbgIQMid (ORCPT ); Thu, 17 Sep 2020 08:38:33 -0400 X-Greylist: delayed 1962 seconds by postgrey-1.27 at vger.kernel.org; Thu, 17 Sep 2020 08:37:38 EDT Received: from kdin02.retarus.com (kdin02.dmz1.retloc [172.19.17.49]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailout06.rmx.de (Postfix) with ESMTPS id 4BsbGy2wP2z9x2S; Thu, 17 Sep 2020 14:04:10 +0200 (CEST) Received: from mta.arri.de (unknown [217.111.95.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by kdin02.retarus.com (Postfix) with ESMTPS id 4BsbGR4pKsz2TTN4; Thu, 17 Sep 2020 14:03:43 +0200 (CEST) Received: from N95HX1G2.wgnetz.xx (192.168.54.80) by mta.arri.de (192.168.100.104) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 17 Sep 2020 14:03:43 +0200 From: Christian Eggers To: Jonathan Cameron CC: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , , , Christian Eggers , Subject: [PATCH v2] iio: trigger: Don't use RT priority Date: Thu, 17 Sep 2020 14:03:33 +0200 Message-ID: <20200917120333.2337-1-ceggers@arri.de> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [192.168.54.80] X-RMX-ID: 20200917-140343-4BsbGR4pKsz2TTN4-0@kdin02 X-RMX-SOURCE: 217.111.95.66 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Triggers may raise transactions on slow busses like I2C. Using the original RT priority of a threaded IRQ may prevent other important IRQ handlers from being run. Signed-off-by: Christian Eggers Cc: stable@vger.kernel.org --- In my particular case (on a RT kernel), the RT priority of the sysfstrig threaded IRQ handler caused (temporarily) raising the prio of a user space process which was holding the I2C bus mutex. Due to a bug in the i2c-imx driver, this process spent 500 ms in a busy-wait loop and prevented all threaded IRQ handlers from being run during this time. v2: - Use sched_set_normal() instead of sched_setscheduler_nocheck() drivers/iio/industrialio-trigger.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index 6f16357fd732..7ed00ad695c7 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -9,7 +9,10 @@ #include #include #include +#include +#include #include +#include #include #include @@ -245,6 +248,7 @@ int iio_trigger_attach_poll_func(struct iio_trigger *trig, int ret = 0; bool notinuse = bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER); + struct irq_desc *irq_desc; /* Prevent the module from being removed whilst attached to a trigger */ __module_get(pf->indio_dev->driver_module); @@ -264,6 +268,12 @@ int iio_trigger_attach_poll_func(struct iio_trigger *trig, if (ret < 0) goto out_put_irq; + /* Triggers may raise transactions on slow busses like I2C. Using the original RT priority + * of a threaded IRQ may prevent other threaded IRQ handlers from being run. + */ + irq_desc = irq_to_desc(pf->irq); + sched_set_normal(irq_desc->action->thread, 0); + /* Enable trigger in driver */ if (trig->ops && trig->ops->set_trigger_state && notinuse) { ret = trig->ops->set_trigger_state(trig, true); -- Christian Eggers Embedded software developer Arnold & Richter Cine Technik GmbH & Co. Betriebs KG Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRA 57918 Persoenlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRB 54477 Geschaeftsfuehrer: Dr. Michael Neuhaeuser; Stephan Schenk; Walter Trauninger; Markus Zeiler