Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp873063ybt; Fri, 19 Jun 2020 16:31:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSstmrKEQzek2xPHsuBKcmnB1d21fg/6Gi8w8XmwWerHwXdq/YBFZN4FIDRokK67WMx6AU X-Received: by 2002:a17:907:42d5:: with SMTP id ng5mr5898128ejb.164.1592609488355; Fri, 19 Jun 2020 16:31:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592609488; cv=none; d=google.com; s=arc-20160816; b=X7Q8r7OXcefTMQJJ3+9pcFhJjBSVU+ef9KavWh2QohQszdVsHeGQSQvD3NPHig3nhN sWchEw1h45dAaeZ2+6JneRlw7/9RfUaKgUTXzH2ihGoeadnH1Ya6sOV+k2EFdrCyM42P kaZdCtmyAlnJOkzinMx4pNXNj+SaR8mUnpZ7zuANbKqED+nh0AYWSfxasSBaac3itcIv 16zZ9VfxiOTLoZdJIKzC6UVrD4737JFvm5xzhHbOQ63f41R7LxmCGjAPaDB5BUOQQzZu hU8B54fT9gg5e7njL+GSLzEUexaNnPcACwNNl+ha4QozJKF42tTY9Wxe+GzI5btOpK1q +65g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2ynF3an+U9QTEZCTlcHivUAsflnCiEiKFmDu3FnAGNQ=; b=N/+eLEI5SQcQokWQHw6kVoiGbg/nr5ZRXBH/ybHdOCxbJ5D1Npsy+c6YcU35lotSxS VWk1kV8XypevDoLvPpbtwMsO5WhhPTREZ3kMtZzw3FlPNzqfbulgdtB6FOr2fjZ5A2ck ap/oQstEdV69sopPlaR3mvkLhBwgtOHTBJbpjrlUU4WjFwEqR25V6K0YnsNoawoKz07K fDF8G7wphpFsQ3oUN61EjwY7XXfh3j13/KkRXfJAj4Sj0ghhzayJapnxJlEtYcSmH0Pj NVvAGdHIhUf5bLFcKClE+7tkD0O9YAAsCI93FZOAnxGW1TcKYhJBzjEwWEMzW6/PNJn9 RF3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KByzKnHW; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id vr3si4538449ejb.520.2020.06.19.16.31.05; Fri, 19 Jun 2020 16:31:28 -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=KByzKnHW; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404681AbgFSP3h (ORCPT + 99 others); Fri, 19 Jun 2020 11:29:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:32958 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404606AbgFSP3W (ORCPT ); Fri, 19 Jun 2020 11:29:22 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 7428121974; Fri, 19 Jun 2020 15:29:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592580561; bh=PdfeCfXAK1p8plhpCTmU0CIpBO7DWSybpTY5X1iwXG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KByzKnHWYt5rGZuSHVC7a/e7+CUZDC4T/OngtDIY3LWNbd2Y59Y2don9zcUtX7IN6 IkjKovuRfPL33/HLKtQfSQnFQmaVsUKDxYPPqNCcIsFTMRvmGabP96jO1PCMhfR8xH mKQ/S6qcQiy9+/t7humEq17uy6+MxkIhjVqqpvtc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anup Patel , Marc Zyngier , Palmer Dabbelt Subject: [PATCH 5.7 296/376] irqchip/sifive-plic: Setup cpuhp once after boot CPU handler is present Date: Fri, 19 Jun 2020 16:33:34 +0200 Message-Id: <20200619141724.352736298@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141710.350494719@linuxfoundation.org> References: <20200619141710.350494719@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anup Patel commit 2234ae846ccb9ebdf4c391824cb79e73674dceda upstream. For multiple PLIC instances, the plic_init() is called once for each PLIC instance. Due to this we have two issues: 1. cpuhp_setup_state() is called multiple times 2. plic_starting_cpu() can crash for boot CPU if cpuhp_setup_state() is called before boot CPU PLIC handler is available. Address both issues by only initializing the HP notifiers when the boot CPU setup is complete. Fixes: f1ad1133b18f ("irqchip/sifive-plic: Add support for multiple PLICs") Signed-off-by: Anup Patel Signed-off-by: Marc Zyngier Reviewed-by: Palmer Dabbelt Acked-by: Palmer Dabbelt Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20200518091441.94843-3-anup.patel@wdc.com Signed-off-by: Greg Kroah-Hartman --- drivers/irqchip/irq-sifive-plic.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -76,6 +76,7 @@ struct plic_handler { void __iomem *enable_base; struct plic_priv *priv; }; +static bool plic_cpuhp_setup_done; static DEFINE_PER_CPU(struct plic_handler, plic_handlers); static inline void plic_toggle(struct plic_handler *handler, @@ -285,6 +286,7 @@ static int __init plic_init(struct devic int error = 0, nr_contexts, nr_handlers = 0, i; u32 nr_irqs; struct plic_priv *priv; + struct plic_handler *handler; priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) @@ -315,7 +317,6 @@ static int __init plic_init(struct devic for (i = 0; i < nr_contexts; i++) { struct of_phandle_args parent; - struct plic_handler *handler; irq_hw_number_t hwirq; int cpu, hartid; @@ -369,9 +370,18 @@ done: nr_handlers++; } - cpuhp_setup_state(CPUHP_AP_IRQ_SIFIVE_PLIC_STARTING, + /* + * We can have multiple PLIC instances so setup cpuhp state only + * when context handler for current/boot CPU is present. + */ + handler = this_cpu_ptr(&plic_handlers); + if (handler->present && !plic_cpuhp_setup_done) { + cpuhp_setup_state(CPUHP_AP_IRQ_SIFIVE_PLIC_STARTING, "irqchip/sifive/plic:starting", plic_starting_cpu, plic_dying_cpu); + plic_cpuhp_setup_done = true; + } + pr_info("mapped %d interrupts with %d handlers for %d contexts.\n", nr_irqs, nr_handlers, nr_contexts); set_handle_irq(plic_handle_irq);