Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp5698514rwb; Tue, 9 Aug 2022 02:33:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR5n0hvVnlZkFdvVIX99OuU6dLYjYKOBJKCKUsXdPd5kUqC6RgellAggnwqhHl3CbgXaNK0y X-Received: by 2002:a17:906:cc4a:b0:730:850f:5cb5 with SMTP id mm10-20020a170906cc4a00b00730850f5cb5mr16318073ejb.658.1660037636710; Tue, 09 Aug 2022 02:33:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660037636; cv=none; d=google.com; s=arc-20160816; b=Xbl2rvy6D7gPHysJWf1DQ4ctDyp+9aFw27AU1ftnvalx7YKt2hvetFRI6CXvKiXAYv D6KXGa375IttLj91m65QcKYgj+maWH+eZFQ5tMCuD5ShoR0u6riLI3/rvMXkaW5pRKgG MGa/LpqiXqJjOAW6MUk1sMZjM04u7/yudEHlMMkPM8N+mKBIcbh5yWV+1zIZFqpp0R6h ODPSG9NvstpRPd61pyM1SVw+VTSoVXGK+XPkuXf1LR9MA+MuFJWx+QnXCyftLISnxeY5 SYkpjNP8iSsT9ob0mBW3r0rfdoRvYyG255+syCju/asx4sDMdugM2EbVGAsKqizdzF9t 8aZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=zxDJ8YrsiArdajYG1uY262RXEDlHoLukbad/vvULwEc=; b=LlOPCpJy2JVpcVeLZFBKNmvVEhHLfNA5A9TiGzqEr1LpnEaLiwlhC/Nz/90BvIIX+3 wLmzRgUlE3sqiCuC8rWXPmSeYNQPe6W1bei3PZN6s0UisKC3FdmnW18SPTluPd/yB32n q0J/cLbstFOBJm71KpIzAzuIDNkRoz63KK/EqIqTEtn8WGJEMHHqPZeovq8yfy6+T4Qk o3mfvvp2O2F5tkyiri9qL0YGbBOY/DpfKayWJjYQLFocrYJ1pXuQoqul+A1sFq86f1aY blCssJzxm+z+TIf6kyG1dV84lKkJlWQ3unOVQQXDUH7eGpN1b7IwC741qCEz89am4vp9 K1mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iE2wEKtr; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e22-20020a056402331600b00441464f8f24si990763eda.293.2022.08.09.02.33.31; Tue, 09 Aug 2022 02:33:56 -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=@kernel.org header.s=k20201202 header.b=iE2wEKtr; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230194AbiHII5Q (ORCPT + 99 others); Tue, 9 Aug 2022 04:57:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241485AbiHII4t (ORCPT ); Tue, 9 Aug 2022 04:56:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ADEF2252D; Tue, 9 Aug 2022 01:56:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D55C5B80E11; Tue, 9 Aug 2022 08:56:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85606C433C1; Tue, 9 Aug 2022 08:56:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660035404; bh=5UfhFW8R3mc4/i0CbqCEm7Z2hfhkjOqWFTVdTW1KEos=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=iE2wEKtr2NR09x9UoLHFPRZGUQ08Lt79ntrYBu+nF9VtEnjnlbD7/TyeQoDquiKxF DAn79ymhs0TCZDQ68KrMb3y9TVi34kaFMYHp5AzZOwVdoB9HQm6alFSVbGzRIHY1Bl f/5B7zPdEDvqhExncNQq7Te++/PyKJEMtlBF3KpAk5H7vH1jEY0kvTZV7MxGKf9a8Y f9UoR+ixdDTDQ6dK+i9Gsv/CN0P3kmdCOWak1wtLNKnZascfRnXJnhOD4RY+jj4bbI kOPUKl6p3s5vauLsZ3fUroFxVXROtCTv2vWPKvdFgPNc9PAjOhKrqJp0KJKljUkbdG 1hci70Fl1x9Og== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oLL2Y-001sCa-C4; Tue, 09 Aug 2022 09:56:42 +0100 Date: Tue, 09 Aug 2022 09:56:42 +0100 Message-ID: <874jylx0ad.wl-maz@kernel.org> From: Marc Zyngier To: Huacai Chen Cc: Huacai Chen , Thomas Gleixner , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Xuerui Wang , Xuefeng Li , Jiaxun Yang Subject: Re: [PATCH] LoongArch: Don't disable EIOINTC master core In-Reply-To: <20220809074522.2444672-1-chenhuacai@loongson.cn> References: <20220809074522.2444672-1-chenhuacai@loongson.cn> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: chenhuacai@loongson.cn, chenhuacai@kernel.org, tglx@linutronix.de, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@xen0n.name, lixuefeng@loongson.cn, jiaxun.yang@flygoat.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 On Tue, 09 Aug 2022 08:45:22 +0100, Huacai Chen wrote: > > This patch fix a CPU hotplug issue. The EIOINTC master core (the first > core of an EIOINTC node) should not be disabled at runtime, since it has > the responsibility of dispatching I/O interrupts. > > Signed-off-by: Huacai Chen > --- > arch/loongarch/kernel/smp.c | 9 +++++++++ > drivers/irqchip/irq-loongson-eiointc.c | 5 +++++ > 2 files changed, 14 insertions(+) > > diff --git a/arch/loongarch/kernel/smp.c b/arch/loongarch/kernel/smp.c > index 09743103d9b3..54901716f8de 100644 > --- a/arch/loongarch/kernel/smp.c > +++ b/arch/loongarch/kernel/smp.c > @@ -242,9 +242,18 @@ void loongson3_smp_finish(void) > > static bool io_master(int cpu) > { > + int i, node, master; > + > if (cpu == 0) > return true; > > + for (i = 1; i < loongson_sysconf.nr_io_pics; i++) { > + node = eiointc_get_node(i); > + master = cpu_number_map(node * CORES_PER_EIO_NODE); > + if (cpu == master) > + return true; > + } > + > return false; > } > > diff --git a/drivers/irqchip/irq-loongson-eiointc.c b/drivers/irqchip/irq-loongson-eiointc.c > index 170dbc96c7d3..6c99a2ff95f5 100644 > --- a/drivers/irqchip/irq-loongson-eiointc.c > +++ b/drivers/irqchip/irq-loongson-eiointc.c > @@ -56,6 +56,11 @@ static void eiointc_enable(void) > iocsr_write64(misc, LOONGARCH_IOCSR_MISC_FUNC); > } > > +int eiointc_get_node(int id) > +{ > + return eiointc_priv[id]->node; > +} > + > static int cpu_to_eio_node(int cpu) > { > return cpu_logical_map(cpu) / CORES_PER_EIO_NODE; I don't understand why it has to be this complex and make any use of the node number. As I understand it, CPU-0 in any EIOINTC block is a master. So all you need to find out is whether the CPU number is a multiple of CORES_PER_EIO_NODE. Something like: return (cpu_logical_map(cpu) % CORES_PER_EIO_NODE) == 0; which doesn't require exporting anything from anywhere? M. -- Without deviation from the norm, progress is not possible.