Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4694593pxj; Tue, 25 May 2021 14:09:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKqj1AYyHfh2Zm0hxrZRZZsq/K6khGpCiPPoo1bwLCVPoPjhHUr0MBy9csPilmym+ZDVda X-Received: by 2002:a5e:9515:: with SMTP id r21mr23147545ioj.19.1621976992083; Tue, 25 May 2021 14:09:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621976992; cv=none; d=google.com; s=arc-20160816; b=K++uJAxvLvDc2YUqmxLLkxfppsqDretqSr1cghd13vkEnkJ6TmoLTfQs8aaLH3lS2C eLK0RCWhx6tI01BLcYcNf9rhXUTLJDzxPLvE8IwxNKAzd3qpJldlDJ/9HOkxwGipGypV l/cUYaKdVydq24EPeC+gkGbAacGfpO3rz+n+KuyuXC8KFy6p0cNhV+/vXnjLsFnpzC2z qXgFTayDw/2lxfoHb4NCjW0wF7VqI9lwc66GAz91Mr+sO74tYKyKaXjAdc2uTBSAKaeg 5N9BlbBYDXeHhJeEyn7fWHHXZDIloxb1PgeqbYjVg3fM/kvFB+ZODrqpB4sZTRWzxj50 /HHQ== 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; bh=BPVAVzEaAPRA9/P94zZ6ytWW0QDAqQQnqi44LgUrd+M=; b=Ub4gVLOvFZrmlo4OIpvkQSu/R+N+yuBMTIKybxUoHu8C+ag6UZWEwlPrUiDdyTwIUC 2yGDjeX66XrPxgspha8et+7K81XWuHzvqmr6+xnm0HQpst95O3GC7ZBo0sa4gELtfH24 PzL5eswHQ++6gNE47fn+636Wzm4TXIc1urGs2HJOAXApO6Qk7XspJ+1HEA+JvhoTgHzD VLnPL8BnDRXPZ6Wm8HieiNV8cRzvqpMopJ6qRh60HKPy1xMHM5QTjMNYz2cv4W0K2f0X ntsgF9vELpIKdiMktb27RcI+b0ap6LbW+n/oINJti/fi8COZEguki30uOKvW6KVfudO1 /SgA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b15si1231813jav.75.2021.05.25.14.09.38; Tue, 25 May 2021 14:09:52 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230475AbhEYRe7 (ORCPT + 99 others); Tue, 25 May 2021 13:34:59 -0400 Received: from foss.arm.com ([217.140.110.172]:33056 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232853AbhEYReu (ORCPT ); Tue, 25 May 2021 13:34:50 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5DB01169E; Tue, 25 May 2021 10:33:20 -0700 (PDT) Received: from e113632-lin.cambridge.arm.com (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5C9683F73B; Tue, 25 May 2021 10:33:19 -0700 (PDT) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Marc Zyngier , Thomas Gleixner , Lorenzo Pieralisi , Vincenzo Frascino Subject: [RFC PATCH v2 04/10] genirq: Add handle_strict_flow_irq() flow handler Date: Tue, 25 May 2021 18:32:49 +0100 Message-Id: <20210525173255.620606-5-valentin.schneider@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210525173255.620606-1-valentin.schneider@arm.com> References: <20210525173255.620606-1-valentin.schneider@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The GIC family of irqchips have been so far treated as "fasteoi" chips. As handle_fasteoi_irq() states, this implies: * Only a single callback will be issued to the chip: an ->eoi() * call when the interrupt has been serviced. However, the GICs have an operating mode (EOImode=1) which requires an additional chip interaction during the IRQ handling. Said operating mode already has some uses with virtualization, but could also be leveraged to slightly optimize ONESHOT IRQs. This extra interaction is currently hidden away in the drivers, but further exploiting its effects (see IRQD_IRQ_FLOW_MASKED) requires lifting it from the driver code into core code. It so happens that it fits the role of ->irq_ack(); unfortunately, the GICs require both callbacks to be strictly paired with one another: for a given IRQ activation, there must be a single ->irq_ack() followed by a single ->irq_eoi(). No more, no less, and in that order. Introduce a new flow handler which guarantees said ack / eoi pairing. Note that it is strikingly similar to handle_fasteoi_mask_irq() for now, but will be further modified in later patches Signed-off-by: Valentin Schneider --- include/linux/irq.h | 1 + kernel/irq/chip.c | 48 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/include/linux/irq.h b/include/linux/irq.h index ef179245a642..37075929e329 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -663,6 +663,7 @@ extern void handle_edge_irq(struct irq_desc *desc); extern void handle_edge_eoi_irq(struct irq_desc *desc); extern void handle_simple_irq(struct irq_desc *desc); extern void handle_untracked_irq(struct irq_desc *desc); +extern void handle_strict_flow_irq(struct irq_desc *desc); extern void handle_percpu_irq(struct irq_desc *desc); extern void handle_percpu_devid_irq(struct irq_desc *desc); extern void handle_bad_irq(struct irq_desc *desc); diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 4d3bde55c5d9..699e70b51aae 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -896,6 +896,54 @@ void handle_edge_eoi_irq(struct irq_desc *desc) } #endif +/** + * handle_strict_flow_irq - irq handler for strict controllers + * @desc: the interrupt description structure for this irq + * + * Ensures strict pairing of ->ack() and ->eoi() for any IRQ passing + * through here. The ->eoi() may be deferred to the tail of the IRQ thread + * for ONESHOT IRQs. + */ +void handle_strict_flow_irq(struct irq_desc *desc) +{ + struct irq_chip *chip = desc->irq_data.chip; + + raw_spin_lock(&desc->lock); + mask_ack_irq(desc); + + if (!irq_may_run(desc)) + goto out; + + desc->istate &= ~(IRQS_REPLAY | IRQS_WAITING); + + /* + * If it's disabled or no action available then keep it masked and + * get out of here: + */ + if (unlikely(!desc->action || irqd_irq_disabled(&desc->irq_data))) { + desc->istate |= IRQS_PENDING; + goto out; + } + + kstat_incr_irqs_this_cpu(desc); + + handle_irq_event(desc); + + cond_unmask_eoi_irq(desc, chip); + + raw_spin_unlock(&desc->lock); + return; +out: + /* + * XXX: this is where IRQCHIP_EOI_IF_HANDLED would be checked, but + * it's conceptually incompatible with this handler (it breaks the + * strict pairing) + */ + eoi_irq(desc); + raw_spin_unlock(&desc->lock); +} +EXPORT_SYMBOL_GPL(handle_strict_flow_irq); + /** * handle_percpu_irq - Per CPU local irq handler * @desc: the interrupt description structure for this irq -- 2.25.1