Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp652195pxu; Fri, 23 Oct 2020 09:52:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwc5NAofA/ZMKJOEUtsFTbsE40dcJkIDlyzLY/BHN9qAMPDIrjFxiUYl9+ndrgvIZUo6a2O X-Received: by 2002:a05:6402:4c6:: with SMTP id n6mr3183732edw.204.1603471978830; Fri, 23 Oct 2020 09:52:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603471978; cv=none; d=google.com; s=arc-20160816; b=DNR0kG0CRfrjHvVYoTrl3rfvs0UIuTFpxwobzrETCxSm5ZMmWFYn+qqY+cfMsBMHNh Vq7yCOREWIul+aA+ZBGG1/qaEI3eM5Yo5pf0potmsvCRkeFk4nqCLQlVd7QbWYz+98WM oNuJY7hT+yGDlMNTkP/U/0sihZaX2yoKymixrJkA9Vinqmj9DumijdlkjjfkpMe6l9E7 efLi/5l/ZlhnWCZRKeLCRPCpFngPD6nzSpag0dpzOO/EDeLaib0hvpAUkYERmoq45IjW uvAHs+wrbw53HH0Sjs5dOB7XrrinmUPiCylRdViQY88pnrXCpqbztxlnKAXJVJUcotkH eGdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=U1w9ifRmKhjxfLoEzyg5OZuLuFoK3GZeA1LGX10l+P8=; b=ElMTi5P6b4fbm/FW/nHsP8SwjPBWq6K5XskaAkCDVCqSQy33gAeRh30/uZSx/waE6a 2qiortn81k4Pw3BKEHbPlb3oBGu8F3H1qpWiJn2kzQn2zdchYZnGMycqiHL0ErZ9vLDE 5bmpRo+WChctdjm0tB0beEL9mi1U71dpeNMHOLZ2Xn4yOpa6qt6eTOOzwtcgXGLLQWVq im8AZD1T2K6GVjaoZlutEBQKMsM8ZwHhGH4JQMdUVlS5BzjqI5NomD4oCcakJV2TIixK jc3XJcAL/A9lV7zt98IltWXcpyHy8RHFd3ry4NsZyst5U7wFifBqEOdwfEG9b4/AyjJR DX+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=o32LBurp; 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 oi22si1354250ejb.754.2020.10.23.09.52.36; Fri, 23 Oct 2020 09:52:58 -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; dkim=pass header.i=@kernel.org header.s=default header.b=o32LBurp; 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 S462026AbgJWKS3 (ORCPT + 99 others); Fri, 23 Oct 2020 06:18:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:45212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S461926AbgJWKS2 (ORCPT ); Fri, 23 Oct 2020 06:18:28 -0400 Received: from localhost.localdomain (unknown [42.120.72.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5255E20936; Fri, 23 Oct 2020 10:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603448308; bh=Q2r2MpV4mhDq9ZPXIsBSWpTyiKSzFfZDPrP/d+7Waxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o32LBurpluUVsOnJUTvVZM9MNs2/Yn9MJ9dd9LoErCOY4LYhqGMrav90SdRA1ftoo 3hvBWuzZ7SC0FiGceMW1gP/J/A6nPIV9ajR5ywAJf/rS/VH+j/caR0kVJ4M2lEBW3g ocpv9JC6gAt7ChMeauwUpsf81qXeKTp53BrBYpOw= From: guoren@kernel.org To: palmerdabbelt@google.com, paul.walmsley@sifive.com, anup@brainfault.org, greentime.hu@sifive.com, zong.li@sifive.com, atish.patra@wdc.com, tglx@linutronix.de, jason@lakedaemon.net, maz@kernel.org, wesley@sifive.com, yash.shah@sifive.com, hch@lst.de Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, guoren@kernel.org, Guo Ren Subject: [PATCH 2/3] irqchip/irq-sifive-plic: Fixup couldn't broadcast to multi CPUs Date: Fri, 23 Oct 2020 10:17:24 +0000 Message-Id: <1603448245-79429-2-git-send-email-guoren@kernel.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1603448245-79429-1-git-send-email-guoren@kernel.org> References: <1603448245-79429-1-git-send-email-guoren@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guo Ren If "echo 3 > /proc/irq/1/smp_affinity", we want irq 1 could be broadcast to CPU0 & CPU1 and one of them would pick up the irq handler. But current implementation couldn't let multi CPUs process the same IRQ concurrent. Signed-off-by: Guo Ren --- drivers/irqchip/irq-sifive-plic.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c index 2e56576..0003322 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -114,15 +114,12 @@ static inline void plic_irq_toggle(const struct cpumask *mask, static void plic_irq_unmask(struct irq_data *d) { struct cpumask amask; - unsigned int cpu; struct plic_priv *priv = irq_get_chip_data(d->irq); 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); + cpumask_and(&amask, &amask, irq_data_get_affinity_mask(d)); + + plic_irq_toggle(&amask, d, 1); } static void plic_irq_mask(struct irq_data *d) @@ -136,24 +133,16 @@ static void plic_irq_mask(struct irq_data *d) static int plic_set_affinity(struct irq_data *d, const struct cpumask *mask_val, bool force) { - unsigned int cpu; struct cpumask amask; struct plic_priv *priv = irq_get_chip_data(d->irq); cpumask_and(&amask, &priv->lmask, mask_val); + cpumask_and(&amask, &amask, cpu_online_mask); - if (force) - cpu = cpumask_first(&amask); - else - cpu = cpumask_any_and(&amask, cpu_online_mask); - - if (cpu >= nr_cpu_ids) - return -EINVAL; + irq_data_update_effective_affinity(d, &amask); plic_irq_toggle(&priv->lmask, d, 0); - plic_irq_toggle(cpumask_of(cpu), d, 1); - - irq_data_update_effective_affinity(d, cpumask_of(cpu)); + plic_irq_toggle(&amask, d, 1); return IRQ_SET_MASK_OK_DONE; } -- 2.7.4