Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2264915imw; Sun, 10 Jul 2022 02:01:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tMp8QhDuZafRw+rCRffiq02IOYKAzUKW/QMO497OY1E4JZq99TsDE2MmyQtmxh8BKP2ACS X-Received: by 2002:a63:d70b:0:b0:415:f5f1:dd19 with SMTP id d11-20020a63d70b000000b00415f5f1dd19mr826706pgg.273.1657443707804; Sun, 10 Jul 2022 02:01:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657443707; cv=none; d=google.com; s=arc-20160816; b=HffN81267AXAUbhvPY0ROQ5foMz5licMMGDMxKbYr6vqzIjfYIxHDau1HCDTf5/4e1 rDvCQ+2MiDbpp1GT0L7D/K3oTdmXIbxohMg+w1zBaxa5rPGi5Yos5zPG2oCNquRryUH9 UDFl8wtYSxaSX0YAHpI73rFWoDtukR7t1bNv1GZQHXNYCi3FLx8XmTlmMXgnVOh6+JFc U1jFXz65hld+RsQpmC+Ljn0di/30KOQQLF23wrbDsGgC8eLOMZuDGHqUC2RriM60YLhd 4gydLBp0cM3cYIS0wt/OlMLHhvICROCOXzx37FksCTUTBu/CLpVn63zkOg3BtdYmzLYT /3zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=TU6/Bu1V1S4/6yvxMkEVbW5OTfcRXr5oxRrBsJWkqW4=; b=BIotg76MsPtRuE0o+ajUegLQFKIrNe+uLzXWGTrktjhww/VBS8n0t8LQFdMCbFWcX/ DYtLQM2Xp2cSxdMc5WtfjLVdcFB1Ymg+5RLFsb5+/xWSaGrJKcYVqFfdEtzy1BE7CoiB m4eje5jeJRp8Kdki+UxtXxoRHW4NvhDXavqf4uYP36edaPTht+MOUy9EfG0/NxKCKNHk aY8zNGl+zCDT7uS3DAobsPheHoQ+7AjQEjopUsio0u/eEvqiLvB2wSIQOQVXDOtaXCOX GvuaF74Oui4bv3rL2o8RmuFKaDlCIwipNwm4RemkN/yF17UAaj15Mvjn9FogDCjhy09U q1NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=iNwBpvVx; dkim=neutral (no key) header.i=@linutronix.de header.b=VtWgUWL9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i34-20020a632222000000b00415fa9ad080si347910pgi.133.2022.07.10.02.01.28; Sun, 10 Jul 2022 02:01:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=iNwBpvVx; dkim=neutral (no key) header.i=@linutronix.de header.b=VtWgUWL9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229657AbiGJI4C (ORCPT + 99 others); Sun, 10 Jul 2022 04:56:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229638AbiGJIz7 (ORCPT ); Sun, 10 Jul 2022 04:55:59 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB2B21901F for ; Sun, 10 Jul 2022 01:55:57 -0700 (PDT) Date: Sun, 10 Jul 2022 08:55:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1657443356; 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=TU6/Bu1V1S4/6yvxMkEVbW5OTfcRXr5oxRrBsJWkqW4=; b=iNwBpvVxBATeNIUk97wpeQIoLimQ/2CE3H4Q0CfpTqiCtvemB8t+kcxDZOgN4Y/OzUgxgW GixiEBXiSZ8ptM3ioPTf4xInRZqgkuYyQVPdd/LEJVy1JlEqNc5koWBxzii6DtnEaP8mUf 3vDvP6fmtFvk+YvhPUzNTAJHQXQGSr9BfXNU0gjyDNR9CAzEBf2InteISo+Y6WLxgq/q/j yNZNbykJCQ2/CfCvFoKcLLx3rqDQ0qBBV9roWusvO4NG21D6r35KUCb660S+RlRQwA3Az8 LARBGllojbdxUbOlw8WIJDGTY4zR8q5Uxhyw/Opsur5BrDn3wr2Bg8pFKVvRUQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1657443356; 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=TU6/Bu1V1S4/6yvxMkEVbW5OTfcRXr5oxRrBsJWkqW4=; b=VtWgUWL9h79wN54Zo+5oc/XmmVPTpqtpt6gEExjkA3OBp+tCiSs9mwXDwIB9jkR7ItPOXM Y27GNmMawfosL0Bg== From: "irqchip-bot for Samuel Holland" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-kernel@vger.kernel.org Subject: [irqchip: irq/irqchip-next] irqchip/sifive-plic: Make better use of the effective affinity mask Cc: Samuel Holland , Marc Zyngier , tglx@linutronix.de In-Reply-To: <20220701202440.59059-2-samuel@sholland.org> References: <20220701202440.59059-2-samuel@sholland.org> MIME-Version: 1.0 Message-ID: <165744335515.15455.17575115041613134708.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the irq/irqchip-next branch of irqchip: Commit-ID: de078949218242d57f791b63fac87cdb09cb0424 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/de078949218242d57f791b63fac87cdb09cb0424 Author: Samuel Holland AuthorDate: Fri, 01 Jul 2022 15:24:39 -05:00 Committer: Marc Zyngier CommitterDate: Sun, 10 Jul 2022 09:50:04 +01:00 irqchip/sifive-plic: Make better use of the effective affinity mask The PLIC driver already updates the effective affinity mask in its .irq_set_affinity callback. Take advantage of that information to only touch bits (and take spinlocks) for the specific relevant hart contexts. First, make sure the effective affinity mask is set before IRQ startup. Then, since this mask already takes priv->lmask into account, checking that mask later is no longer needed (and handler->present is equivalent to the bit being set in priv->lmask). Finally, when (un)masking or changing affinity, only clear/set the enable bits in the specific old/new context(s). The cpumask operations in plic_irq_unmask() are not needed because they duplicate the code in plic_set_affinity(). Signed-off-by: Samuel Holland Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220701202440.59059-2-samuel@sholland.org --- drivers/irqchip/Kconfig | 1 + drivers/irqchip/irq-sifive-plic.c | 27 +++++++++------------------ 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 462adac..ea7b748 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -531,6 +531,7 @@ config SIFIVE_PLIC bool "SiFive Platform-Level Interrupt Controller" depends on RISCV select IRQ_DOMAIN_HIERARCHY + select GENERIC_IRQ_EFFECTIVE_AFF_MASK if SMP help This enables support for the PLIC chip found in SiFive (and potentially other) RISC-V systems. The PLIC controls devices diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index b3a36dc..46595e6 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -114,31 +114,18 @@ static inline void plic_irq_toggle(const struct cpumask *mask, for_each_cpu(cpu, mask) { struct plic_handler *handler = per_cpu_ptr(&plic_handlers, cpu); - if (handler->present && - cpumask_test_cpu(cpu, &handler->priv->lmask)) - plic_toggle(handler, d->hwirq, enable); + plic_toggle(handler, d->hwirq, enable); } } static void plic_irq_unmask(struct irq_data *d) { - struct cpumask amask; - unsigned int cpu; - struct plic_priv *priv = irq_data_get_irq_chip_data(d); - - cpumask_and(&amask, &priv->lmask, cpu_online_mask); - cpu = cpumask_any_and(irq_data_get_affinity_mask(d), - &amask); - if (WARN_ON_ONCE(cpu >= nr_cpu_ids)) - return; - plic_irq_toggle(cpumask_of(cpu), d, 1); + plic_irq_toggle(irq_data_get_effective_affinity_mask(d), d, 1); } static void plic_irq_mask(struct irq_data *d) { - struct plic_priv *priv = irq_data_get_irq_chip_data(d); - - plic_irq_toggle(&priv->lmask, d, 0); + plic_irq_toggle(irq_data_get_effective_affinity_mask(d), d, 0); } #ifdef CONFIG_SMP @@ -159,11 +146,13 @@ static int plic_set_affinity(struct irq_data *d, if (cpu >= nr_cpu_ids) return -EINVAL; - plic_irq_toggle(&priv->lmask, d, 0); - plic_irq_toggle(cpumask_of(cpu), d, !irqd_irq_masked(d)); + plic_irq_mask(d); irq_data_update_effective_affinity(d, cpumask_of(cpu)); + if (!irqd_irq_masked(d)) + plic_irq_unmask(d); + return IRQ_SET_MASK_OK_DONE; } #endif @@ -190,6 +179,7 @@ static struct irq_chip plic_edge_chip = { .irq_set_affinity = plic_set_affinity, #endif .irq_set_type = plic_irq_set_type, + .flags = IRQCHIP_AFFINITY_PRE_STARTUP, }; static struct irq_chip plic_chip = { @@ -201,6 +191,7 @@ static struct irq_chip plic_chip = { .irq_set_affinity = plic_set_affinity, #endif .irq_set_type = plic_irq_set_type, + .flags = IRQCHIP_AFFINITY_PRE_STARTUP, }; static int plic_irq_set_type(struct irq_data *d, unsigned int type)