From patchwork Mon Sep 21 11:51:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1368299 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=WrUcWwb+; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bw2qw3Jh2z9sV0 for ; Mon, 21 Sep 2020 21:52:44 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0A71482563; Mon, 21 Sep 2020 13:52:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WrUcWwb+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 45D7582556; Mon, 21 Sep 2020 13:52:03 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1489582546 for ; Mon, 21 Sep 2020 13:52:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qt1-x841.google.com with SMTP id g3so11899417qtq.10 for ; Mon, 21 Sep 2020 04:52:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rxX2Y4ZN50mibmoTtEAtYEY8rXWm5nQy6bSuIh3SuJo=; b=WrUcWwb+tOuPptrImzauuLvPDR539h4otKSFm0Hb6fNQA7KIuHGtiiAAlaIQsZEHIc O7kb/4t+G8UEEfmHxtKXhvwnjPoZgNKMjvnnzyViElhkPSHph32YHlTEV6TO+DqVL8w/ jlXvIOcMfmBTl4Yy6jBpiYk4OOIkjBDS1TPKlMBXJDq21GDd5dZNbmByZ40wvBQxZaWV XcCk4Nf13k+7R9CHlXy2EIfZnRZSDTXsRp2tfjK81jAg5SZXLjy918yJZolO6AtJFGDv VgG6TxpWDwKLHKvVp5f2MNLT///IMwGjEl2Qxmwnaze595tTBey07GOybuUNkcdBGNUc WpQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rxX2Y4ZN50mibmoTtEAtYEY8rXWm5nQy6bSuIh3SuJo=; b=Pr+/nHuEoziJf7AR1h6UjD+V8dipUmJ7BzVWHEGSicRuIJLluhu7MhkH2jXziYD3KE TLzZy3llErk9mnXAeQp0JxcGBgaskC1NHnxDPhXaoaWYZdjSGt0OXleQYD/A3ou7nIzh B26tkKHfZYE4gyPJcl0D+4v263FezbC5zzLnHQ/vbyUE7jzoSX8lC4SLroOnikSxkMMi vdruTYFJS5dtp8cRYMoZ7txlr91f0zWaWCH725dgqxSok3KEVc4Msz1KrE1AdJW5Yt8c /dS+EIlqioh7pb4/KjbtYtS2SrNiJm6dBfBZH0OC3zUQIDqWiesIvAUCBJRPmWD+GGTQ fHpw== X-Gm-Message-State: AOAM530JRjQ+QAT/gCu0eZvfvBhp+OhORZHyr0GdOIYu62hKgSGPT5fC MEDgW7jd0QzJE8FtnKyButCu2m40BETa8A== X-Google-Smtp-Source: ABdhPJwfQtnP7Qc7KJ/nmmKqOW75Sy+k5l8VQtpADfkXTz3O5yADfCmB6cP8ZS/Hs2W59xsvzUhjAQ== X-Received: by 2002:ac8:1832:: with SMTP id q47mr341192qtj.215.1600689118783; Mon, 21 Sep 2020 04:51:58 -0700 (PDT) Received: from godwin.fios-router.home (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.gmail.com with ESMTPSA id c70sm8658105qkg.4.2020.09.21.04.51.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 04:51:58 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Rick Chen , alankao@andestech.com, Leo Liang , Bin Meng , Sean Anderson , Bin Meng Subject: [PATCH v3 4/7] riscv: Clear pending IPIs on initialization Date: Mon, 21 Sep 2020 07:51:38 -0400 Message-Id: <20200921115141.70598-5-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921115141.70598-1-seanga2@gmail.com> References: <20200921115141.70598-1-seanga2@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Even though we no longer call smp_function if an IPI was not sent by U-Boot, we still need to clear any IPIs which were pending from the execution environment. Otherwise, secondary harts will busy-wait in secondary_hart_loop, instead of relaxing. Along with the previous commit ("riscv: Use a valid bit to ignore already-pending IPIs"), this fixes SMP booting on the Kendryte K210. Signed-off-by: Sean Anderson Reviewed-by: Bin Meng Reviewed-by: Rick Chen --- Changes in v3: - Rename riscv_ipi_init_secondary_hart to dummy_pending_ipi_clear - Only compile dummy_pending_ipi_clear when SMP is enabled Changes in v2: - Make riscv_ipi_init_secondary_hart static arch/riscv/cpu/cpu.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c index bfa2d4a426..85592f5bee 100644 --- a/arch/riscv/cpu/cpu.c +++ b/arch/riscv/cpu/cpu.c @@ -72,6 +72,17 @@ static int riscv_cpu_probe(void) return 0; } +/* + * This is called on secondary harts just after the IPI is init'd. Currently + * there's nothing to do, since we just need to clear any existing IPIs, and + * that is handled by the sending of an ipi itself. + */ +#if CONFIG_IS_ENABLED(SMP) +static void dummy_pending_ipi_clear(ulong hart, ulong arg0, ulong arg1) +{ +} +#endif + int arch_cpu_init_dm(void) { int ret; @@ -111,6 +122,15 @@ int arch_cpu_init_dm(void) ret = riscv_init_ipi(); if (ret) return ret; + + /* + * Clear all pending IPIs on secondary harts. We don't do anything on + * the boot hart, since we never send an IPI to ourselves, and no + * interrupts are enabled + */ + ret = smp_call_function((ulong)dummy_pending_ipi_clear, 0, 0, 0); + if (ret) + return ret; #endif return 0;