Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2002059pxu; Tue, 24 Nov 2020 14:26:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJztlcQAabyxV01Sf5POB+Hq0nrTUFoHd10rmpC5otUs+Bbs6dOafTsoRKVyPfADzqXWvt9o X-Received: by 2002:a50:a40f:: with SMTP id u15mr666295edb.307.1606256799371; Tue, 24 Nov 2020 14:26:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606256799; cv=none; d=google.com; s=arc-20160816; b=xMi1NIccuT+F5wpHelTKYuhJ0bXm8CVX2H7LpTrH0Iw9jNbHn7eiAakhGkyqxM2AFZ vDqvGSoAVoheSZ58l8ku80UWDPK2RnRzYvTv03E7y0VP+yUUC1CGf4d4zSVp197jiexK 34j3Yg7idWpbEjYRRh+8/Ws06BDjEOCTK9qhukZaLCq42WabQ6+L0sWQ5imX/TYmuc2B YgF05GbyMEIRBXGRBs6IiFbUp8nKk4JrQP9v05UM88nXcziDqKcjw1bHk2E9mPtsyMr0 z94wcE//4W1AJn2slM7JCyeUE8tQhJG4fKTdpyqQvDSPDy8sgXy47pyfbw0jiiEFtINI KK5A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VDL71o7OuTB603IOC50TFBfzHEMXq4xaBWac/pUYKj8=; b=SvdHiv9hcB9Kk/HXlWgpWd1LRHirozX839pG/TuAvSd4iTxFPGLLdIWQNfjOo/iYhm +ODRbIfEku9DnCvqVqbvudy9G5V6sUmp4wZ8xJT5BVSjLurx70p6lnuKw1z2WjDIHqjZ uSPY7a5tCmykLELVzoSLcoGSHGVc8BBqdsNtNGxUL4o1/9f1PFsjKie+rsCG//iail7d fmsLoqrmeGNP6Rsrqs+QLsgIll2mtZt4+Qlf8qGzjd8WInDrcG+l6YxO/zvAjYkMdKC6 3IaBXlXb0jeVuAxhgPw+TgDhxHK1Q6WsUu1bLCwJQ9yUfnt1DEKWVZsPRRB/V+uVZq+D ruZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="z7J/st1f"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dc20si141079ejb.747.2020.11.24.14.26.15; Tue, 24 Nov 2020 14:26:39 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b="z7J/st1f"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388639AbgKXOO5 (ORCPT + 99 others); Tue, 24 Nov 2020 09:14:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:49882 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730869AbgKXOO5 (ORCPT ); Tue, 24 Nov 2020 09:14:57 -0500 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 113482076B; Tue, 24 Nov 2020 14:14:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606227296; bh=+rG5SNZYbcFtY3MLFgwny2sPTFB4xCGZc4NSf/NRIs8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z7J/st1fc+p1OP01zR/e3032fDqvIEza2mRMm48l53Ioub2V0xS8uMJW9nVdOs1Px S6nDQnhXASLpFyLmBA6W4cCIAO6sjvR35gyF5HrFeL5xR2v/BXkgGWqKSWp3GheqMo ZjR2Ht0aNnR4iy75x3k/N29WiKYTHeSiNHjmdzT8= Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1khZ5q-00DGcy-6t; Tue, 24 Nov 2020 14:14:54 +0000 From: Marc Zyngier To: LAK , linux-kernel Cc: Will Deacon , Catalin Marinas , Thomas Gleixner , Valentin Schneider , Peter Zijlstra , Mark Rutland , Russell King , Android Kernel Team Subject: [PATCH v2 1/6] genirq: Add __irq_modify_status() helper to clear/set special flags Date: Tue, 24 Nov 2020 14:14:44 +0000 Message-Id: <20201124141449.572446-2-maz@kernel.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201124141449.572446-1-maz@kernel.org> References: <20201124141449.572446-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will@kernel.org, catalin.marinas@arm.com, tglx@linutronix.de, Valentin.Schneider@arm.com, peterz@infradead.org, mark.rutland@arm.com, linux@arm.linux.org.uk, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some arch-specific flags need to be set/cleared, but not exposed to random device drivers. Introduce a new helper (__irq_modify_status()) that takes an arbitrary mask, and rewrite irq_modify_status() to use this new helper. No functionnal change. Signed-off-by: Marc Zyngier --- include/linux/irq.h | 3 +++ kernel/irq/chip.c | 12 ++++++++++-- kernel/irq/settings.h | 10 ++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/include/linux/irq.h b/include/linux/irq.h index c54365309e97..c55f218d5b61 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -751,6 +751,9 @@ void irq_set_chained_handler_and_data(unsigned int irq, irq_flow_handler_t handle, void *data); +void __irq_modify_status(unsigned int irq, unsigned long clr, + unsigned long set, unsigned long mask); + void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set); static inline void irq_set_status_flags(unsigned int irq, unsigned long set) diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index b9b9618e1aca..85176712a484 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -1107,7 +1107,8 @@ irq_set_chip_and_handler_name(unsigned int irq, struct irq_chip *chip, } EXPORT_SYMBOL_GPL(irq_set_chip_and_handler_name); -void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set) +void __irq_modify_status(unsigned int irq, unsigned long clr, + unsigned long set, unsigned long mask) { unsigned long flags, trigger, tmp; struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0); @@ -1121,7 +1122,9 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set) */ WARN_ON_ONCE(!desc->depth && (set & _IRQ_NOAUTOEN)); - irq_settings_clr_and_set(desc, clr, set); + /* Warn when trying to clear or set a bit disallowed by the mask */ + WARN_ON((clr | set) & ~mask); + __irq_settings_clr_and_set(desc, clr, set, mask); trigger = irqd_get_trigger_type(&desc->irq_data); @@ -1144,6 +1147,11 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set) irq_put_desc_unlock(desc, flags); } + +void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set) +{ + __irq_modify_status(irq, clr, set, _IRQF_MODIFY_MASK); +} EXPORT_SYMBOL_GPL(irq_modify_status); /** diff --git a/kernel/irq/settings.h b/kernel/irq/settings.h index 403378b9947b..51acdf43eadc 100644 --- a/kernel/irq/settings.h +++ b/kernel/irq/settings.h @@ -36,11 +36,17 @@ enum { #undef IRQF_MODIFY_MASK #define IRQF_MODIFY_MASK GOT_YOU_MORON +static inline void +__irq_settings_clr_and_set(struct irq_desc *desc, u32 clr, u32 set, u32 mask) +{ + desc->status_use_accessors &= ~(clr & mask); + desc->status_use_accessors |= (set & mask); +} + static inline void irq_settings_clr_and_set(struct irq_desc *desc, u32 clr, u32 set) { - desc->status_use_accessors &= ~(clr & _IRQF_MODIFY_MASK); - desc->status_use_accessors |= (set & _IRQF_MODIFY_MASK); + __irq_settings_clr_and_set(desc, clr, set, _IRQF_MODIFY_MASK); } static inline bool irq_settings_is_per_cpu(struct irq_desc *desc) -- 2.28.0