Received: by 2002:ab2:7853:0:b0:1fa:5c73:8e2d with SMTP id m19csp35246lqp; Thu, 30 May 2024 11:08:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWM5eXA9DNStomBpgsSSNfM6bKUgTTCGgyeULq5dwS9YtSzep978/7kbWRjES2iepIufHvSbedgPzO7uIJBaAD8OVc3zIPTSmz1k99u4A== X-Google-Smtp-Source: AGHT+IFAEPPehzKpoxFc7l/5fUSxsBdvsewB7NaQ5xBhYUClYejmEkLA51ucaVK0jcYnbFeKVWIT X-Received: by 2002:a54:4816:0:b0:3c9:6d2b:cd9 with SMTP id 5614622812f47-3d1dcca5ba4mr2734289b6e.16.1717092485392; Thu, 30 May 2024 11:08:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717092485; cv=pass; d=google.com; s=arc-20160816; b=OboReJWxFFa8LCpU4sLp7HzvRUSTTZB+7/nyYgI1gf3Sv86Dds7iJ123irtUHK+qmr g4MBV9I2XNjin+sVNCo2gROaak02BaS9C3qSFrlxL63cyT8isvkQfP/HfQUQ+WwZUuJb 6wEmsOY6N0/IZzgd3ql73P4qqum5v9bwyUEnxz+V4VaxabmtzKkHnr1O35nTdqHRpWIg up876EnM2JX36NWiEnvZjvQPaTqB+HIwf4UCeMPvbamAu6KB0SnmmL2uAzEa0OVbidkM 6VydF6NLcPqXQscugYwWtBqcNUGZ5sRXGNLOIkGdYmqMGa0FxN1ZiiJhg3yhCBz4i/ig bOlQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=ZCBMRcsvlIlqx28L54Rw86q+aPP2pQJ5/hACrELl3Kw=; fh=mpZx2TqYMkeAxou2p1RKk0aGJPS8zFYt2l2C7wHX3IQ=; b=dsYHi0vkHPNb93mzSAYHSLZSInXVPHV5JsOCbz9IncWqewkJQ4LkKaqYjbRWVBzrO5 jkTGo48RvRGCEJYdgbEWCFQk5YSQPswRFy/aU/FdcYYFNCVsrMH6d7eejE5hkb8WjwqX kVuN0GHz+VEw5GJY4GIqmlGsfG8ePHLCeBgr/ISH439Nmxqm0Xkm4azK1oijIHboUoaB XoLlvfXLdMBqnXSqYvqx9vt1rrX4n7OpYFSLxJla3RS190JZ3eU8UQeO0CFd6QIhOb3x L0CREdQWNly7vhqvm9HEMNQl4RdxXJ+PT1nbDIrN+WP4gRb3/emR+tJYz8qGOb0nflhT a7Mw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JbELKxnw; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-195769-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43ff257ecfdsi997641cf.521.2024.05.30.11.08.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 11:08:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195769-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=@gmail.com header.s=20230601 header.b=JbELKxnw; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-195769-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 01F841C2340F for ; Thu, 30 May 2024 18:07:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9CC1C4DA1B; Thu, 30 May 2024 18:07:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JbELKxnw" Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86E494C62B for ; Thu, 30 May 2024 18:07:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717092444; cv=none; b=VUmTpouNo44o37DXXHnEuBikvscQ2Ifv2dP8u6y2CXnfQKKHvc5K0nSmZM8LJFGdR1VhRyEYuCNG8wh2gKAzOI9X2ts8gZpXcWeBvMQ1US5sWj6+00zYXzn/CSCMR1ZYFl2v7tEsjufkns2Kt+QyE0DMosY5OLq/1fa65NF8wx0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717092444; c=relaxed/simple; bh=j27AxGHEZKMmeJIIwPagI+4gamOMev7x0iEQzPnvbvI=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=YU3Al7mWboGY1Uvv149dFdsPHwAs9ms62324vnf0/s5apNLDf4cGdc0rBH0a2bt3TTPMpAkcENiRrt4WyIdNlIhI660f+zZgBnF67EX/1jfAgybu6+dqdDnQFMaePDC6b5WE/ySZW7gP43Blr5rpkCo+ZLCfx0BCMGE3cHg9LF4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JbELKxnw; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1f48bd643a0so8821465ad.3 for ; Thu, 30 May 2024 11:07:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717092443; x=1717697243; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=ZCBMRcsvlIlqx28L54Rw86q+aPP2pQJ5/hACrELl3Kw=; b=JbELKxnwFN2zF8EotiFULQEINBncPojd17A7zPQW98I9znemcpAYxe0ifuHRACc4Vg gqGqLxOLqSJqc9vMkQr5waZ4cOBz2q+MWd2rtP2pJ8PUzM0u2u3ZoDjvahHX7u5IEQqK z3B69GDkn+k7tBJaBzJOhc6IXRA+mkk7dEFBBRzyJVKYE4njdZUWsBeEFJVSfCdl4nCP bAGsMqDP3bxHpyF0xbOgXryF460cO84w+ynsmfvg9uZA7uGIdLFG2tpB3FxE043l4Kjd F8D+0gUYn2XX8+ozLcupDogL5I2Rbf7wWTzVfLOOdg0BR17hDtSjj0eyDQhYjhKUZMPM 7QOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717092443; x=1717697243; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZCBMRcsvlIlqx28L54Rw86q+aPP2pQJ5/hACrELl3Kw=; b=X/Xxp7Ju6nFwune+Dz6OrVO93ncNYIcti7KZexGmVIpx0epkCu0TiIE+mGGO7zVnsm sxwfZjes0dC1YFDXHh5DpAJfAzLuqKv2kX/fTJF9cQgZ113Oe1Xl/S1PRdnbV7hc3fKH D/4IPBJABjleUpBTEj749SKsYAGk/zEqIVVPbmjnrw3UPRyZqTcI5KZKJ7eTUHb6ip/v BpESkgC6e+D5G6BJ/ubaxrIO2fOp2YPgGZaNu0XNn88m77Y54oguTYY6m+p1JeRci8Nj cciXFae5nt81H55w68v1NLNRJCLXDtpBVnG5Ywpvt8HIxjTVAUNtTAJxUciM6nSQi4hV 7+Lw== X-Gm-Message-State: AOJu0Yzf0ZD3fWrqzoB6rdrj/1Pw+dwjHNXoQCJ/1pKPp2/Be6NcdSQZ MPEgdxCn5cV0a/RSfjp+qLOp5frKQkq2rqwElzEbiLj4bcrbyAkudq6Y7Q== X-Received: by 2002:a17:903:22c7:b0:1f4:9759:b226 with SMTP id d9443c01a7336-1f619932b65mr34806945ad.52.1717092442400; Thu, 30 May 2024 11:07:22 -0700 (PDT) Received: from google.com ([2620:15c:9d:2:509f:4b2e:3586:eb1]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f63235561csm791685ad.70.2024.05.30.11.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 11:07:22 -0700 (PDT) Date: Thu, 30 May 2024 11:07:19 -0700 From: Dmitry Torokhov To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Peter Zijlstra Subject: [PATCH] linux/interrupt.h: allow "guard" notation to disable and reenable IRQ Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Drivers often need to first disable an interrupt, carry out some action, and then reenable the interrupt. Introduce support for the "guard" notation for this so that the following is possible: ... scoped_cond_guard(mutex_intr, return -EINTR, &data->sysfs_mutex) { guard(disable_irq)(&client->irq); error = elan_acquire_baseline(data); if (error) return error; } ... Signed-off-by: Dmitry Torokhov --- include/linux/interrupt.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index 5c9bdd3ffccc..3a36e64119c8 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -235,6 +236,9 @@ extern void enable_percpu_irq(unsigned int irq, unsigned int type); extern bool irq_percpu_is_enabled(unsigned int irq); extern void irq_wake_thread(unsigned int irq, void *dev_id); +DEFINE_LOCK_GUARD_1(disable_irq, int, + disable_irq(*_T->lock), enable_irq(*_T->lock)) + extern void disable_nmi_nosync(unsigned int irq); extern void disable_percpu_nmi(unsigned int irq); extern void enable_nmi(unsigned int irq); -- 2.45.1.288.g0e0cd299f1-goog -- Dmitry