Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1156893imj; Thu, 14 Feb 2019 02:07:20 -0800 (PST) X-Google-Smtp-Source: AHgI3IZF81MPaVbEjgA9OI8OU89RNgq23I3zePOSrVIEI8Aw3lZRcWFLn0l8Vqkj6N8WBmB87e3W X-Received: by 2002:a63:5b65:: with SMTP id l37mr2958077pgm.395.1550138840888; Thu, 14 Feb 2019 02:07:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550138840; cv=none; d=google.com; s=arc-20160816; b=lNI43SGZNqbUmLkSRVbX2L/owhQYCBHs0CMUzCO4Vs8/kjFGuXEaOm7NISUdBio6CV f9sMJal1QmfwPi9lSqS7/zxBPUyL4IGR0Wc61ahCGGHf6GkoB9wvC6pbatwNt1dOApQi zXhYFrjmljkOaAcMGdjj2FtPVZ2+2mWrBvGaaysKOSGgVArI+ONYJSW5YE9hztRG730C RaQSOasPn+tkHU+vib+Rifs0nHQJOk5U7tcvWCFkEmp7kNJHZaZ3w2Sv+8ZST+MX3AWN 4EVoWM2q6TRgOL5eT+gOPFh28zC2Tc3fAXRsN94DMhOD78JeUhWmNHTeK9bs7a7PfX53 DGeA== 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=pHNw059Ci1wHj7G3Kds8q+VVsU1SsIwdPhpbayBk3Jk=; b=N85+5LLfi57ltt26nNzYr7L8OkNfkyi4ljTho9JT8r68rlRZzj4iWagDbmzGEJDcCF toWqW+RCVN1t/QSkf9WDVSINNwnFoZXFFi3ibslYYhAQBywBKqpxj398u2+peoYvTmp+ OmIWd511CXkghlSsz88qFEbUEpFydzEd4E0Y+4KEWew+bHlYmaQzepA5Cv1RlP5V60l5 OuPoUMtdsshH0JNqfdd7I9KlF4zuqKPND5AWiguNI3WGYxqpEkJoNiOUbaejS5ZiAQGa 5MpIFv7ffWIG5wpYa0jSiJT6zJr51zfrPsqC2bVH6Ab2AqiYSlPAdvybhnTrISPcfMJ2 qXlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=H7pdVNh+; 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 3si2086282plo.217.2019.02.14.02.07.04; Thu, 14 Feb 2019 02:07:20 -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=H7pdVNh+; 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 S1727012AbfBNAh6 (ORCPT + 99 others); Wed, 13 Feb 2019 19:37:58 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40234 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726663AbfBNAhy (ORCPT ); Wed, 13 Feb 2019 19:37:54 -0500 Received: by mail-pf1-f195.google.com with SMTP id h1so2064747pfo.7 for ; Wed, 13 Feb 2019 16:37:53 -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=pHNw059Ci1wHj7G3Kds8q+VVsU1SsIwdPhpbayBk3Jk=; b=H7pdVNh+4GGqUzIfWeoO9MUlkt9ktCqUjcJi68lP83Dramg4gIjVZfDfsVEuL7uD2Q aAg++qo3qVyPwxayHHsaMOIKBF7qm6JjD+eEoHlKze7umnRszT8T9iLO8qv6r/726kR4 6d9WqgeMnJ1kKX+a2Zhhe+KW9pMvgzjixTBgJXAheKawxRuffWJm+8cE/q6Zh8enXggY 4xZxRNVzGAu9E3msIH7+HFyT9sKXklacm6xt/YZhuKaawru6P+lAEQ45O3U3hz358Bt7 chq9m7UoTuUeSojubgfTpP8uJRoEtY9IiApqmCKD47pJq0TtmN2YW8cV/txp1yovnIb1 P1Zg== 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=pHNw059Ci1wHj7G3Kds8q+VVsU1SsIwdPhpbayBk3Jk=; b=MZtMJCT3XAMaEgytDcjI3OQCq4gihY35IaQhyJm+6leUMQcltxl3SwoimXi1HRJNjO WAj8TF6y/Q8Zgv00RKQbmJB6h1M8I3Y+h7CQvf0F8nN9YSvV915WpC2jf6pNA0Vf5WHz QHm1KwdkyQwAgR1hN/JJJFuFrJqMO8LBQ0ariUoC4PFBUqVDVihtFINCmbgPqJ1UPd5Z zXUbpH6mBrGizid/zh75J1X8JnGXTtPw63XEc5NG7rMqE2VMDx3+vnUUBz87J4B5/Dvk TZ+4m1AqPkb8T7GQ62XUtkQbJ7f34SGyKlUL+/OH0fIBtm6B1mez4kVHEmwjdCSAvdWg Cv/Q== X-Gm-Message-State: AHQUAuaqW+7BEDEeVjbJ2iGNWGHMYpChxy1EkysBbl0KX+Pb6gbHywtD NpoEr7GJvX37KzI2DJXtepAGfg== X-Received: by 2002:a62:e50b:: with SMTP id n11mr1031760pff.212.1550104672989; Wed, 13 Feb 2019 16:37:52 -0800 (PST) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id g2sm603568pfi.95.2019.02.13.16.37.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 16:37:52 -0800 (PST) Date: Wed, 13 Feb 2019 16:37:52 -0800 (PST) X-Google-Original-Date: Wed, 13 Feb 2019 16:35:45 PST (-0800) Subject: Re: [v4 PATCH 6/8] clocksource/drivers/riscv: Add required checks during clock source init In-Reply-To: <7bd250fb-c896-64e1-d73b-6f3dd284e2d6@linaro.org> CC: atish.patra@wdc.com, linux-riscv@lists.infradead.org, alankao@andestech.com, aou@eecs.berkeley.edu, schwab@suse.de, anup@brainfault.org, dmitriy@oss-tech.org, jason@lakedaemon.net, johan@kernel.org, linux-kernel@vger.kernel.org, marc.zyngier@arm.com, Paul Walmsley , robh@kernel.org, tglx@linutronix.de From: Palmer Dabbelt To: daniel.lezcano@linaro.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 Wed, 13 Feb 2019 00:48:24 PST (-0800), daniel.lezcano@linaro.org wrote: > On 12/02/2019 12:10, Atish Patra 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. Moreover, riscv_hartid_to_cpuid can return >> errors now. >> >> Do not proceed if hartid or cpuid is invalid. Take this opprtunity to >> print appropriate error strings for different failure cases. >> >> Signed-off-by: Atish Patra > > Do you want me to take it through my tree ? Works for me. Aside from the typo: Reviewed-by: Palmer Dabbelt > > >> --- >> drivers/clocksource/timer-riscv.c | 23 ++++++++++++++++++++--- >> 1 file changed, 20 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c >> index 43189220..e8163693 100644 >> --- a/drivers/clocksource/timer-riscv.c >> +++ b/drivers/clocksource/timer-riscv.c >> @@ -95,13 +95,30 @@ static int __init riscv_timer_init_dt(struct device_node *n) >> struct clocksource *cs; >> >> hartid = riscv_of_processor_hartid(n); >> + if (hartid < 0) { >> + pr_warn("Not valid hartid for node [%pOF] error = [%d]\n", >> + n, hartid); >> + return hartid; >> + } >> + >> cpuid = riscv_hartid_to_cpuid(hartid); >> + if (cpuid < 0) { >> + pr_warn("Invalid cpuid for hartid [%d]\n", hartid); >> + return cpuid; >> + } >> >> if (cpuid != smp_processor_id()) >> return 0; >> >> + pr_info("%s: Registering clocksource cpuid [%d] hartid [%d]\n", >> + __func__, cpuid, hartid); My only comment is that we flipped back and forth on whether or not to print info on driver initialization. I like it because I have to go add the prints in to debug things, but IIRC we removed it at some point (probably more than once, as I have to keep adding these sorts of things back in and forget to remove them). The review stands either way :) >> cs = per_cpu_ptr(&riscv_clocksource, cpuid); >> - clocksource_register_hz(cs, riscv_timebase); >> + error = clocksource_register_hz(cs, riscv_timebase); >> + if (error) { >> + pr_err("RISCV timer register failed [%d] for cpu = [%d]\n", >> + error, cpuid); >> + return error; >> + } >> >> sched_clock_register(riscv_sched_clock, >> BITS_PER_LONG, riscv_timebase); >> @@ -110,8 +127,8 @@ static int __init riscv_timer_init_dt(struct device_node *n) >> "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; >> } >> >>