Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2989817lqp; Mon, 25 Mar 2024 15:55:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXnELCgPao8JU+Pl3rhylO9ts7wdz5U0fSTf411yojJm8MvLKcaI0kle9S0moIdK8h8165znBPE/d2qEyUdcDlz819kcU3OBM8guzL4aA== X-Google-Smtp-Source: AGHT+IGBTR3JRzMHCMoAUYqdmii0nz2hyiWdsH6zuVYNTjmaghlyPHiSu8jKS0F9uBfjWdinmPC7 X-Received: by 2002:a05:620a:36f1:b0:789:e6cc:7565 with SMTP id cz49-20020a05620a36f100b00789e6cc7565mr8414160qkb.19.1711407335748; Mon, 25 Mar 2024 15:55:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711407335; cv=pass; d=google.com; s=arc-20160816; b=xdri+4OzZ/HpGBPJFSO6t9AqMVswSZs3zKbh2QQenBap9hlbFUDorSwYClxCXCKqCI xOks5+f03+4aY3+O6jm1Z8OczF8jVHKMruQejXLF3C97t5XAKbRm6ccXjhsE0XgR5J3U ullX6KSr5pSCPoNaI+O9WD3WaQBP394j8EB2DlXz7ZGXaOcxY1CDyJmNprnWQdcz9Jfq FjJ9EEPcfgXivQUkxilbsS0+l50beOkH0xXXL7bDRNVshLLX06QkfeL/6awq8RMyzIT9 3psKZBJO9OJWW3HfDZJj7QDNIHAhFRIdagenv3nZoEPfQtGKOm+yUQJRkrtlt7uHdqLq Dz2A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=VduUBxZAYZw86rW/+SYoj/g0yoJ8Q2ZF+JCtK4WaCKE=; fh=S+TT5ar7SREUofn6SLN1LKULo+7hvKAPFlnYM3bfafc=; b=YcrxK4Rxz6yrFFfY3wPRqbdJLVlPsw9+BFgmHOUJmyIG9uA2MB5H4vj7ZR+c9l6aLK 4JUVTJWK5lyGq5hBZ2NgwdIuhGnbZthU64wgXNyYvEcjjy3ruyoDoGWK0M3GOBQGrYBe hj0r8Qy348kH9nHEx/ZMI2iktMF5wsVZJQMLXXV4QqKggnKvYKJNmFquBZ+6OeDSIGh0 qEyCSJ3kmeL8R+0hQNarL9g49O+/BjGi+mUBqdxqu03iAXO4tzJC6+eDsa6QevkJefYK eTCVlICJdGLYJSRrGZCVRJ5s2iRVvDKhG3IZOVFy3TAgDvlzTar753ErMmqid9dI1fAV Mw7w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=YvXgsTBc; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Qu12Pwuo; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-118145-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118145-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id os33-20020a05620a812100b0078a39dd50absi6243374qkn.150.2024.03.25.15.55.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 15:55:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-118145-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=YvXgsTBc; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Qu12Pwuo; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-118145-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118145-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1C86E1C3F4D2 for ; Mon, 25 Mar 2024 22:55:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8FFE180C16; Mon, 25 Mar 2024 22:55:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="YvXgsTBc"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Qu12Pwuo" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8F327640A; Mon, 25 Mar 2024 22:55:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711407326; cv=none; b=TWgTuphqbtDTUA2+3qn7aCmbICLzYXZvHdwxjK6C3wI8kqbBtaSsIK/hZ0uM3LptZGE9/d32u6NOFjaJxmjRw1MOX+kJB8hgKRf/IwF4yTA7rXauVI6mr3ZZm/3d//m0ZAb3vqsQmYPiyjKSC9zeH0LVRwQWmTfCd2fgSPueXYI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711407326; c=relaxed/simple; bh=3r1y31v3XTJVbXsuNyo5JrJSvUfosXKWdLpQPsBInmU=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=ufAVHcSlUrlDKv52FibX3JPs+cLbcsdmxYVP5TTt6e0LwWbU+3ySGsYeLagNccbZn98D0i7ZO9USOm3vUrhtCPsxiXGgAgDHsWRfd4G1eNAWLFUvNHbFrL/1By653SMVpc/I+2eHbZLuFAa9ZtN8WpxiPswBvnfcNW1761M5RaU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=YvXgsTBc; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Qu12Pwuo; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Mon, 25 Mar 2024 22:55:21 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1711407322; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VduUBxZAYZw86rW/+SYoj/g0yoJ8Q2ZF+JCtK4WaCKE=; b=YvXgsTBcPYeDxtIB0/qQOHBYRo3nYyk1JcCuQttXEm3AqsHP01Zjw2RAtN8pWAN4wm7Enn sIxWxS7PebED335ecJvwOyA7cVlDiQfJs9PKO9W9jSFovQCwKwlgDqKqAakg4e4cTA4zZ8 HppDCsnI8oSD48XYm8i9fFq8XAmri/O58H8h3vrKlgfGW9DdTBNKq1I31bfO+dyh08iquB 2S3f+0Jd0lxxNyD15ySSwruLSk4g4Gnr8QYaByeR0Z6LJq89pNv67HIRxsWp0n63OJIxOS i1DW5+KD+bQiiXDQM1Rwcgv/iYm8ZjvixAb2WzskDLZ4IUgQ15z3MceM1oDMBA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1711407322; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VduUBxZAYZw86rW/+SYoj/g0yoJ8Q2ZF+JCtK4WaCKE=; b=Qu12Pwuoitv961SrVQ/9du4ndKDOCIcATQq/V/cvmAXvHlCilOqZv+2Qf6TBrWai3pw1HX KE1oqAecZgfI2hCg== From: "tip-bot2 for Rafael J. Wysocki" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/urgent] genirq: Introduce IRQF_COND_ONESHOT and use it in pinctrl-amd Cc: Francisco Ayala Le Brun , "Rafael J. Wysocki" , Thomas Gleixner , Linus Walleij , "6.8+" , x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org In-Reply-To: <12417336.O9o76ZdvQC@kreacher> References: <12417336.O9o76ZdvQC@kreacher> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171140732104.10875.14515495184452517144.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the irq/urgent branch of tip: Commit-ID: c2ddeb29612f7ca84ed10c6d4f3ac99705135447 Gitweb: https://git.kernel.org/tip/c2ddeb29612f7ca84ed10c6d4f3ac99705135447 Author: Rafael J. Wysocki AuthorDate: Mon, 25 Mar 2024 13:58:08 +01:00 Committer: Thomas Gleixner CommitterDate: Mon, 25 Mar 2024 23:45:21 +01:00 genirq: Introduce IRQF_COND_ONESHOT and use it in pinctrl-amd There is a problem when a driver requests a shared interrupt line to run a threaded handler on it without IRQF_ONESHOT set if that flag has been set already for the IRQ in question by somebody else. Namely, the request fails which usually leads to a probe failure even though the driver might have worked just fine with IRQF_ONESHOT, but it does not want to use it by default. Currently, the only way to handle this is to try to request the IRQ without IRQF_ONESHOT, but with IRQF_PROBE_SHARED set and if this fails, try again with IRQF_ONESHOT set. However, this is a bit cumbersome and not very clean. When commit 7a36b901a6eb ("ACPI: OSL: Use a threaded interrupt handler for SCI") switched the ACPI subsystem over to using a threaded interrupt handler for the SCI, it had to use IRQF_ONESHOT for it because that's required due to the way the SCI handler works (it needs to walk all of the enabled GPEs before the interrupt line can be unmasked). The SCI interrupt line is not shared with other users very often due to the SCI handling overhead, but on sone systems it is shared and when the other user of it attempts to install a threaded handler, a flags mismatch related to IRQF_ONESHOT may occur. As it turned out, that happened to the pinctrl-amd driver and so commit 4451e8e8415e ("pinctrl: amd: Add IRQF_ONESHOT to the interrupt request") attempted to address the issue by adding IRQF_ONESHOT to the interrupt flags in that driver, but this is now causing an IRQF_ONESHOT-related mismatch to occur on another system which cannot boot as a result of it. Clearly, pinctrl-amd can work with IRQF_ONESHOT if need be, but it should not set that flag by default, so it needs a way to indicate that to the interrupt subsystem. To that end, introdcuce a new interrupt flag, IRQF_COND_ONESHOT, which will only have effect when the IRQ line is shared and IRQF_ONESHOT has been set for it already, in which case it will be promoted to the latter. This is sufficient for drivers sharing the interrupt line with the SCI as it is requested by the ACPI subsystem before any drivers are probed, so they will always see IRQF_ONESHOT set for the interrupt in question. Fixes: 4451e8e8415e ("pinctrl: amd: Add IRQF_ONESHOT to the interrupt request") Reported-by: Francisco Ayala Le Brun Signed-off-by: Rafael J. Wysocki Signed-off-by: Thomas Gleixner Reviewed-by: Linus Walleij Cc: 6.8+ # 6.8+ Closes: https://lore.kernel.org/lkml/CAN-StX1HqWqi+YW=t+V52-38Mfp5fAz7YHx4aH-CQjgyNiKx3g@mail.gmail.com/ Link: https://lore.kernel.org/r/12417336.O9o76ZdvQC@kreacher --- drivers/pinctrl/pinctrl-amd.c | 2 +- include/linux/interrupt.h | 3 +++ kernel/irq/manage.c | 9 +++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c index 49f89b7..7f66ec7 100644 --- a/drivers/pinctrl/pinctrl-amd.c +++ b/drivers/pinctrl/pinctrl-amd.c @@ -1159,7 +1159,7 @@ static int amd_gpio_probe(struct platform_device *pdev) } ret = devm_request_irq(&pdev->dev, gpio_dev->irq, amd_gpio_irq_handler, - IRQF_SHARED | IRQF_ONESHOT, KBUILD_MODNAME, gpio_dev); + IRQF_SHARED | IRQF_COND_ONESHOT, KBUILD_MODNAME, gpio_dev); if (ret) goto out2; diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index 76121c2..5c9bdd3 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -67,6 +67,8 @@ * later. * IRQF_NO_DEBUG - Exclude from runnaway detection for IPI and similar handlers, * depends on IRQF_PERCPU. + * IRQF_COND_ONESHOT - Agree to do IRQF_ONESHOT if already set for a shared + * interrupt. */ #define IRQF_SHARED 0x00000080 #define IRQF_PROBE_SHARED 0x00000100 @@ -82,6 +84,7 @@ #define IRQF_COND_SUSPEND 0x00040000 #define IRQF_NO_AUTOEN 0x00080000 #define IRQF_NO_DEBUG 0x00100000 +#define IRQF_COND_ONESHOT 0x00200000 #define IRQF_TIMER (__IRQF_TIMER | IRQF_NO_SUSPEND | IRQF_NO_THREAD) diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index ad3eaf2..bf9ae8a 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -1643,8 +1643,13 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) } if (!((old->flags & new->flags) & IRQF_SHARED) || - (oldtype != (new->flags & IRQF_TRIGGER_MASK)) || - ((old->flags ^ new->flags) & IRQF_ONESHOT)) + (oldtype != (new->flags & IRQF_TRIGGER_MASK))) + goto mismatch; + + if ((old->flags & IRQF_ONESHOT) && + (new->flags & IRQF_COND_ONESHOT)) + new->flags |= IRQF_ONESHOT; + else if ((old->flags ^ new->flags) & IRQF_ONESHOT) goto mismatch; /* All handlers must agree on per-cpuness */