From patchwork Thu Mar 3 16:35:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 591515 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (caladan.dune.hu [78.24.191.180]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6DA4A1416F1 for ; Fri, 4 Mar 2016 03:36:16 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id A118DB92678; Thu, 3 Mar 2016 17:36:08 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.1 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP; Thu, 3 Mar 2016 17:36:08 +0100 (CET) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id B0C0FB92676 for ; Thu, 3 Mar 2016 17:36:07 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 CL_IP_EQ_HELO_MX=-3.1 (check from: .true. - helo: .mengele.ibawizard. - helo-domain: .ibawizard.) FROM/MX_MATCHES_NOT_HELO(DOMAIN)=1; rate: -5.1 Received: from mengele.ibawizard.net (ibawizard.net [82.208.49.253]) by arrakis.dune.hu (Postfix) with ESMTP for ; Thu, 3 Mar 2016 17:35:54 +0100 (CET) Received: from localhost.localdomain (localhost [127.0.0.1]) by mengele.ibawizard.net (Postfix) with ESMTP id 8DA921D36050; Thu, 3 Mar 2016 17:35:50 +0100 (CET) From: =?UTF-8?q?Petr=20=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Date: Thu, 3 Mar 2016 17:35:48 +0100 Message-Id: <1457022948-25311-1-git-send-email-ynezz@true.cz> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Subject: [OpenWrt-Devel] [PATCH] kernel: gpio-button-hotplug: Add missing ONESHOT flag to threaded IRQ request X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Without the IRQF_ONESHOT flag in devm_request_threaded_irq() call I get following error: genirq: Threaded irq requested with handler=NULL and !ONESHOT for irq 56 gpio-keys gpio-keys: failed to request irq:56 for gpio:20 From kernel/irq/manage.c: The interrupt was requested with handler = NULL, so we use the default primary handler for it. But it does not have the oneshot flag set. In combination with level interrupts this is deadly, because the default primary handler just wakes the thread, then the irq lines is reenabled, but the device still has the level irq asserted. Rinse and repeat.... While this works for edge type interrupts, we play it safe and reject unconditionally because we can't say for sure which type this interrupt really has. The type flags are unreliable as the underlying chip implementation can override them. Signed-off-by: Petr Štetiar --- package/kernel/gpio-button-hotplug/Makefile | 2 +- package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package/kernel/gpio-button-hotplug/Makefile b/package/kernel/gpio-button-hotplug/Makefile index c2fdaec..b9a481a 100644 --- a/package/kernel/gpio-button-hotplug/Makefile +++ b/package/kernel/gpio-button-hotplug/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=gpio-button-hotplug -PKG_RELEASE:=1 +PKG_RELEASE:=2 include $(INCLUDE_DIR)/package.mk diff --git a/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c b/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c index 6d1a197..0ebe6c5 100644 --- a/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c +++ b/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c @@ -563,7 +563,7 @@ static int gpio_keys_probe(struct platform_device *pdev) } ret = devm_request_threaded_irq(&pdev->dev, button->irq, NULL, button_handle_irq, - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, dev_name(&pdev->dev), bdata); if (ret < 0) dev_err(&pdev->dev, "failed to request irq:%d for gpio:%d\n", button->irq, button->gpio);