Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2018985imu; Sat, 8 Dec 2018 12:27:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/UAMU6mpudjgKnYdLF+XRceRH8VyQeOoN/L7ct86foxJ/2+UOImWDbLV2GmD6L8OXkvo1/5 X-Received: by 2002:a62:18ce:: with SMTP id 197mr7208378pfy.88.1544300826034; Sat, 08 Dec 2018 12:27:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544300826; cv=none; d=google.com; s=arc-20160816; b=mtzAZ6cbRRl1iC7jBkXNYOuy3gALrIDPiloQdtxofGr9FAWoYWG+72Gx7uCeTPrd6H 8UvUjdJEMCSFeF62mEoG41AYlP71sY9Oe7bx2HGDatlCluayiFCNFjJR1gbdh9MX4jeq mX/CdCYxiWe8c2se28DWUWp15ETzcSvGjh4/R5oO3yQbQW8Wl17/kbcqH33HzckQqr0R kCyA9EHGIB2zfNK/tjgaMft+V3tc/Kyt7OJZrUUEZxSR2qqqvlUrUCR92rBvdZSbpazg o+lQluQ3zmlDb4MfFs0xwPSThyfWwF3rYOVZhYX+dMMSazIThwTgeG58kyU3KWGeF85J b7gQ== 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 :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=zf7bPVq52POSMrfUrt5neVYgh/TC1AOdO9lXUX5jff0=; b=hPRzaBkfczeBk3i8DSD2dL4Vpdqg0YmJcuipmLbJaCeSq5dssGVKMOC7/idx79On0M zJMBjB8/HYq4IuJVE97CkKsZ6cB9D2PmG/h0M/eLtzzBJ2pWUc4AkqLvX33J7edoXzSD 6iBWuamHx0JJ9FQwfB4Kh+pM8/E6tzbdVau88HHdRvsUidH9MUEQFy/dICp5uYffHgBz 7sj3/Zw56MqNe6T8Ycmfc8yI/+2+/6ahikoCLEUfre/oo5s3N4l1uWAdEXwBAPbX7Pqy Cw+28ivbQ8pG14zgi1ficauIY1fTWSM/KUDq1pJyCSWa4CtUAFcWOMBy+ry1gI75wQTk WyCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=OghsouaC; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si6111371plq.138.2018.12.08.12.26.38; Sat, 08 Dec 2018 12:27:06 -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=pass header.i=@sifive.com header.s=google header.b=OghsouaC; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726211AbeLHUZj (ORCPT + 99 others); Sat, 8 Dec 2018 15:25:39 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:34960 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726193AbeLHUZi (ORCPT ); Sat, 8 Dec 2018 15:25:38 -0500 Received: by mail-pg1-f193.google.com with SMTP id s198so3191209pgs.2 for ; Sat, 08 Dec 2018 12:25:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=zf7bPVq52POSMrfUrt5neVYgh/TC1AOdO9lXUX5jff0=; b=OghsouaCWKSivNi/XjvklEEPKUxAJ4kmmZL4gbJ6d93x8Kgm0dcLb5Pj4NwxzKr/ne 2vmygzxIAphi7WKbza4dwRj8m0+ALVQni7N0zmQXWHsY9F1oiFSX90tPtfa5WhkClXHI ee3OY+WDNBQl4ixVC3iLRT6Xq2SiFSfVcqpkLMHL1hkH426Na9CFGEpxeQdDALwWKVkG tPTmZ65VdzFzf+qXE+X1GUJCsOavXSVhZQXdFss3apaz16lW1ke35vTM7XNspJIq6Jr4 NX11BWxYxUWdCjCvuyBAeyewp8mF2OzAtt8duLRRbakRvtlIXZmhmLq4ScBRbFXcXxak pbJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=zf7bPVq52POSMrfUrt5neVYgh/TC1AOdO9lXUX5jff0=; b=eCckrEFHWQ4QzEe1B5dRQGkamTKEQMlf8rx6AyP3te1NuAYzw6ZzUalT0/kWywzj6k dvxyQ5eJepdxqcaC2QUr28YQlRnP9Ehge1Ufpqi3rZqC+jnv1HxPIlOZPPWpRS3aM4MX NDRp6hXzJckJVPLqVf5Z5K20sr/d5iPkI63tyaeTnSMoaei6EsFD6756qVU4Jiy1+/fe Dg+7Xie5XukBlkDU6xrgw2Qz0zvxKtRBYeCV3RRpuml/UyO/lIZO9M3oD8o8ehYlj2J3 UfMrzXedzadGt9acJlKMsG2FwNHVSdbdY4W9LY+P625D3IvNkJE40/hMoSD7+WtjkVDh VNSQ== X-Gm-Message-State: AA+aEWYJCfxv6d+eMSr89AqCJ0juz2qukKZmM1bE8Cs3nfAMkbzjKPZp n2lTr98WWzz8bvJmKljG6+eov7bTmX8= X-Received: by 2002:a63:990a:: with SMTP id d10mr6095711pge.279.1544300737726; Sat, 08 Dec 2018 12:25:37 -0800 (PST) Received: from localhost ([216.3.10.7]) by smtp.gmail.com with ESMTPSA id j70sm9270301pfc.43.2018.12.08.12.25.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Dec 2018 12:25:36 -0800 (PST) Date: Sat, 08 Dec 2018 12:25:36 -0800 (PST) X-Google-Original-Date: Sat, 08 Dec 2018 12:15:39 PST (-0800) Subject: Re: [PATCH 4/4] RISC-V: Fix non-smp kernel boot on SMP systems In-Reply-To: CC: atish.patra@wdc.com, linux-kernel@vger.kernel.org, aou@eecs.berkeley.edu, daniel.lezcano@linaro.org, devicetree@vger.kernel.org, dmitriy@oss-tech.org, linux-riscv@lists.infradead.org, mark.rutland@arm.com, robh+dt@kernel.org, tglx@linutronix.de, Damien.LeMoal@wdc.com From: Palmer Dabbelt To: anup@brainfault.org Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 07 Dec 2018 09:20:57 PST (-0800), anup@brainfault.org wrote: > On Fri, 7 Dec, 2018, 10:30 PM Palmer Dabbelt >> On Mon, 03 Dec 2018 12:57:31 PST (-0800), atish.patra@wdc.com wrote: >> > 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; >> >> This seems like it's just hiding a bug somewhere else. We should at least >> put >> out a WARN here, as I'm not sure the error will propagate anywhere useful. >> > > We need separate DT node for riscv_timer. The riscv_timer is nothing but > SOC timer accessed via rdtime and SBI calls. It can be viewed as one > device. In fact, this is how it's done in ARM/ARM64. We had that at some point, but this was changed. The logic was that, since the RISC-V ISA mandates the presence of this timer for all harts, the RISC-V CPU node is sufficient to encode the presence of a RISC-V timer. I'm OK changing this, but you should look at the old thread (which I can't find) to make sure all the arguments are taken into account. >> > 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; >> > } >> > > Regards, > Anup > >>