Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7438447imu; Mon, 3 Dec 2018 12:58:33 -0800 (PST) X-Google-Smtp-Source: AFSGD/VmN2GvEITaU21wOlLr+hZoDOy03DmuY0bSB+14qmtgC3YEjit7gHFZ8qfzZzXUumQBepsG X-Received: by 2002:a17:902:ba89:: with SMTP id k9mr17649941pls.189.1543870713703; Mon, 03 Dec 2018 12:58:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543870713; cv=none; d=google.com; s=arc-20160816; b=ABldNoCc0nCVKPnxEJqI26q30zJlv/UyFlpbWnpjqEHDsXMxy86SGlwfnrH10CQuuB 5ubKX8Jr+WcyyJjvMUCEwlgpy9Dv6F+Xa7FtfhNqq0DWrdu6D33ihXZp+j4ag03vWTVI x3ANN72XGZrD5z7D4rfVZuas/ChXW3qFbh2QqA88xkjBSgZbnRT+QQKaUyoUqMEIdV6E ozIbC4Laf9ku52Z3NGyZtJxySJB1wpn0AirExg3k3GwQN7D9fk3dzku+WJGjZWr1Ehio mz/esDZNEfz4jxzivd9J8FuJg2J3geqe1wgv8nbAhw2yv8XW/8g/Jo/y3EMIQZBPURfS zoXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=nqtm9f3q+4U5HtI9h6zDqvbp21Dbs0OD7gp2JIWMwT4=; b=oWEyh549lnvC7wc+iUrMv77u9F4NaCv5Hbe9N05mKWLq0O4KRSAReJC2BgsfZMtMxR pJ49tOjjOyjXuK0jKoouQetSo816gTtUJLawXkNgf9G3uWF/7SxGz+sUrRlMcH+C62sA n4F6N36oEzz9B23mV3SKNgsUU89Y8UIKUguYB8I9RJ7+mMmxnEARrt6gt+NAFRQ1bIFp +pG5rxpnAhC/wXcOiIX0jVWCRD34eigj+2+y3a+zDIv9HX6JMyXJSc2S7Np+qQ1p7tOF S2ElntTQpiKaEKhXoFPbpWOnRnT4Hod3y801FWK/0187eedp+p9tXlENxO0ZzLKTl0FW n1dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=MuAxEXQr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c17si13516562pgl.385.2018.12.03.12.58.19; Mon, 03 Dec 2018 12:58:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=MuAxEXQr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726058AbeLCU5p (ORCPT + 99 others); Mon, 3 Dec 2018 15:57:45 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:19087 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726013AbeLCU5l (ORCPT ); Mon, 3 Dec 2018 15:57:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1543870661; x=1575406661; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=BSOlOVz1k4WQ8zp+c29OSEXPkk6Skbx3t6enWZR9980=; b=MuAxEXQrHwOUlXjCvNQrJeRv8ZrcR779ZE3bmpTlsb/JcnApi8kbijDC jcKE8BRNQw16f3oXWJt/P9HTP9ArzvQxuwTvYmTM0FA3o15lYwoYMW27V omGnbixUZwCdjYdm2KTAaOuJdhRNkFHqx6hC0y6TLuX49nvVfkuxAM2Yu XOAf6n6+WcwFac3sPpZlkN1PMxElSZ2NVc3apyhWHSsvHbbfm7K9y3pN4 qG//BB0yRSYliM6BlEKIyjzwwY2XfJvEkdjxAEho8kHQL8S0BHpt3yS2x x7bVcSnfCK1tRnht9UXJhvjb7hkundfsF0PCtMl/nLwz4NpWcrQziSBP4 g==; X-IronPort-AV: E=Sophos;i="5.56,311,1539619200"; d="scan'208";a="100519863" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 04 Dec 2018 04:57:40 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 03 Dec 2018 12:39:55 -0800 Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Dec 2018 12:57:40 -0800 From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Albert Ou , Daniel Lezcano , devicetree@vger.kernel.org, Dmitriy Cherkasov , linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Rob Herring , Thomas Gleixner , Anup Patel , Damien Le Moal Subject: [PATCH 4/4] RISC-V: Fix non-smp kernel boot on SMP systems Date: Mon, 3 Dec 2018 12:57:31 -0800 Message-Id: <1543870651-16669-5-git-send-email-atish.patra@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543870651-16669-1-git-send-email-atish.patra@wdc.com> References: <1543870651-16669-1-git-send-email-atish.patra@wdc.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, clocksource registration happens for an invalid cpu for non-smp kernels. This lead to kernel panic as cpu hotplug registration will fail for those cpus. Do not proceed if hartid is invalid. Take this opprtunity to print appropriate error strings for different failure cases. Signed-off-by: Atish Patra --- drivers/clocksource/riscv_timer.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/clocksource/riscv_timer.c b/drivers/clocksource/riscv_timer.c index 39de6e49..4af4af47 100644 --- a/drivers/clocksource/riscv_timer.c +++ b/drivers/clocksource/riscv_timer.c @@ -108,6 +108,8 @@ static int __init riscv_timer_init_dt(struct device_node *n) int cpuid, hartid, error; hartid = riscv_of_processor_hartid(n); + if (hartid < 0) + return hartid; cpuid = riscv_hartid_to_cpuid(hartid); if (cpuid != smp_processor_id()) @@ -115,14 +117,19 @@ static int __init riscv_timer_init_dt(struct device_node *n) /* This should be called only for boot cpu */ riscv_timebase = riscv_timebase_frequency(n); - clocksource_register_hz(&riscv_clocksource, riscv_timebase); + error = clocksource_register_hz(&riscv_clocksource, riscv_timebase); + if (error) { + pr_err("RISCV timer register failed [%d] for cpu = [%d]\n", + error, cpuid); + return error; + } error = cpuhp_setup_state(CPUHP_AP_RISCV_TIMER_STARTING, "clockevents/riscv/timer:starting", riscv_timer_starting_cpu, riscv_timer_dying_cpu); if (error) - pr_err("RISCV timer register failed [%d] for cpu = [%d]\n", - error, cpuid); + pr_err("cpu hp setup state failed for RISCV timer [%d]\n", + error); return error; } -- 2.7.4