From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751957AbdKCEdk (ORCPT ); Fri, 3 Nov 2017 00:33:40 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:46294 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750707AbdKCEdj (ORCPT ); Fri, 3 Nov 2017 00:33:39 -0400 X-Google-Smtp-Source: ABhQp+QzaxmCvbSP2Lm9BYyWGD3kkk6o+HazzjYddZQAKH60ukVp+Fr6FfGnXtxTG+pdIspZJDnEhg== From: Stafford Horne To: LKML Cc: matt.redfearn@mips.com, Stafford Horne , Jonas Bonn , Stefan Kristiansson , Jan Henrik Weinstock , openrisc@lists.librecores.org Subject: [PATCH for-next] openrisc: fix possible deadlock scenario during timer sync Date: Fri, 3 Nov 2017 13:33:22 +0900 Message-Id: <20171103043325.20646-1-shorne@gmail.com> X-Mailer: git-send-email 2.13.6 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org OpenRISC borrows its timer sync logic from MIPS, Matt helped to review the OpenRISC implementation and noted that we may suffer the same deadlock case that MIPS has faced. The case being: "the MIPS timer synchronization code contained the possibility of deadlock. If you mark a CPU online before it goes into the synchronize loop, then the boot CPU can schedule a different thread and send IPIs to all "online" CPUs. It gets stuck waiting for the secondary to ack it's IPI, since this secondary CPU has not enabled IRQs yet, and is stuck waiting for the master to synchronise with it. The system then deadlocks." Fix this by moving set_cpu_online() to after timer sync. Reported-by: Matt Redfearn Signed-off-by: Stafford Horne --- arch/openrisc/kernel/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c index 4d80ce6fa045..7d518ee8bddc 100644 --- a/arch/openrisc/kernel/smp.c +++ b/arch/openrisc/kernel/smp.c @@ -127,10 +127,10 @@ asmlinkage __init void secondary_start_kernel(void) /* * OK, now it's safe to let the boot CPU continue */ - set_cpu_online(cpu, true); complete(&cpu_running); synchronise_count_slave(cpu); + set_cpu_online(cpu, true); local_irq_enable(); -- 2.13.6