From patchwork Fri Apr 15 21:54:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 562678 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A11BC433F5 for ; Fri, 15 Apr 2022 21:54:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356000AbiDOV47 (ORCPT ); Fri, 15 Apr 2022 17:56:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244519AbiDOV44 (ORCPT ); Fri, 15 Apr 2022 17:56:56 -0400 Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 373ABDD5 for ; Fri, 15 Apr 2022 14:54:24 -0700 (PDT) Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 3A70483894; Fri, 15 Apr 2022 23:54:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1650059662; bh=CikPWEoVsPPQ9qQACVoJTyNXfRZhEnbtHIAX4K2c1OQ=; h=From:To:Cc:Subject:Date:From; b=foG04/ApDyCcDs20x0fnX3ov7sJ7HaXpZZz0Fh869/+GvmZ7NEFXTA8wJhYDqWvsW WQZS3Ye/3yGG+UkEyZ/hHIT2XMGfo3k+Tm9MVtGlwKII8G4NWD11sX4UjX+y2ZI6qT M8oJdnq8Mfc9vkljkK6YfHVlSgQGlu2GBXrZaVHPcG0/WGqsC86RRU9RlJ47eOcQX4 Ot08cWJCi2F5piweQAqqyomsA9n09su1u7L4eFOO6Twu54Zv1mxAlxTRRGcxl1c0SV KZ627KYsCsXM9C6uMh7Zg9oZJZsvWPNh234lIUe2UR6kzfqvwrVxWtksxoWfID17t7 0Q7bXh6xUlpmA== From: Marek Vasut To: linux-gpio@vger.kernel.org Cc: Marek Vasut , Alexandre Torgue , Fabien Dessenne , Linus Walleij , Marc Zyngier , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH] irqchip/stm32: Do not call stm32_gpio_get() for edge triggered IRQs in EOI Date: Fri, 15 Apr 2022 23:54:10 +0200 Message-Id: <20220415215410.498349-1-marex@denx.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The stm32_gpio_get() should only be called for LEVEL triggered interrupts, skip calling it for EDGE triggered interrupts altogether to avoid wasting CPU cycles in EOI handler. On this platform, EDGE triggered interrupts are the majority and LEVEL triggered interrupts are the exception no less, and the CPU cycles are not abundant. Fixes: 47beed513a85b ("pinctrl: stm32: Add level interrupt support to gpio irq chip") Signed-off-by: Marek Vasut Cc: Alexandre Torgue Cc: Fabien Dessenne Cc: Linus Walleij Cc: Marc Zyngier Cc: linux-stm32@st-md-mailman.stormreply.com Cc: linux-arm-kernel@lists.infradead.org To: linux-gpio@vger.kernel.org --- drivers/pinctrl/stm32/pinctrl-stm32.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c index 09952c463f67d..242d1c37c6e4b 100644 --- a/drivers/pinctrl/stm32/pinctrl-stm32.c +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c @@ -312,6 +312,10 @@ static void stm32_gpio_irq_trigger(struct irq_data *d) struct stm32_gpio_bank *bank = d->domain->host_data; int level; + /* Do not access the GPIO if this is not LEVEL triggered IRQ. */ + if (!(bank->irq_type[d->hwirq] & IRQ_TYPE_LEVEL_MASK)) + return; + /* If level interrupt type then retrig */ level = stm32_gpio_get(&bank->gpio_chip, d->hwirq); if ((level == 0 && bank->irq_type[d->hwirq] == IRQ_TYPE_LEVEL_LOW) ||