Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2611205imu; Thu, 17 Jan 2019 18:12:35 -0800 (PST) X-Google-Smtp-Source: ALg8bN62H9WVGew/unLo8YakpgJlyMa28HwZrAiLXpbEU65YouOPs5yh6ychG0LARdQmSr9URjht X-Received: by 2002:a17:902:c85:: with SMTP id 5mr17657718plt.339.1547777555332; Thu, 17 Jan 2019 18:12:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547777555; cv=none; d=google.com; s=arc-20160816; b=U+EXLKw6O14+kFAimR0x4YBFjfSX0UwxEFZWr7UPeYsKWBYteppnVdkCWX8py7a7KT dEZZut9fxXm+OkvnT18DxdVo6tZZnA/H2xpRdFqensPDh/KbGAxckL72tfWZJO/ykmuy vBgMbJVabs/huaG+CftMnQf7Wgv1gadinDxAjw7msfRHMQWmDhka5XhugsAsEJzg80hj IFPrbFWM2It+bznEKj+05WqSA0EdQLdS3JJyMktJCbrvvezye6cdFiOsBR7EUDJH/GE7 PICj79uGLhWnd4Khw48gHccartwpgzpsA1Rn0lEbati64kHmyab4M8JBq+SXAWLWJV54 tTYQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=xMhQMu9lmpx4CRJjQwldbXdWUZJUUyjNuV5zxmNxfsU=; b=Mqgo7H3KvpNVxEVb/uQy7XRAAI//ymZRuqIDibiX658P65hjgotcR04b1rEWhzFzDK z+5jd+lo1yHQPGmUjBbu/1DlOJhEg+ZX4FbArf8vF3lrePNmy0nGFn72m/veZMTEtErx ySQlQfhX1BR8LUIP6QczM5swjp8GTD8vxEUJllEHdwBTZzw8v5ToEdF7TtcNzLVpzlT+ kFl0POXbIZd7sZwzsZ98tI1pNVYYAXV0fuzfWEPNbizuWKdNA0rGEXYw6JB8ez7ZxYIB 71HUAxckq9tW68SGY1UTZ9G97Ier4I3CEqjrPlxiyjOVghSQsgMSQx7Ztz5tsBdxs/0j Fx7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=SeTeN5zF; 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 d12si3253383pga.506.2019.01.17.18.12.16; Thu, 17 Jan 2019 18:12:35 -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=SeTeN5zF; 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 S1727036AbfARCKH (ORCPT + 99 others); Thu, 17 Jan 2019 21:10:07 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:49217 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726979AbfARCKG (ORCPT ); Thu, 17 Jan 2019 21:10:06 -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=1547777411; x=1579313411; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=3UlpWrGy5l0hFV1x1u49o8+zyWo/VDTedhrwg8pOEms=; b=SeTeN5zFQFZg3vvH6NqVHptlukNujJ9d6fqDp7WoYQG4Qun8YU8aU3+3 KVAmT4bkVWNBlvdDf9VLju2NeMgHpydXsib4VH2UUo1KrGQ7Mq2qq3gK4 bJSMQaUiQJDKKquujBO6bcMZ5opYN7rgPs5FIHTstNku5i/izszhR0dbq VgchDoxRc2kh0M+RRYMIg6ki6c3wzzfhf11X5QDQhDc7c13E9mQq2T1cN HqaHGPu5UoWMFmKRC4HRFYYbov9tdivj8v28u82W8Gfy7OxlZzJJShkt5 Mz47/VXIk9x0X4Q0maMkNN2ITD0njbePHnoJzcw/8rXZVig8U1z3hNvVr A==; X-IronPort-AV: E=Sophos;i="5.56,489,1539619200"; d="scan'208";a="197166813" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Jan 2019 10:10:10 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 17 Jan 2019 17:51:23 -0800 Received: from c02v91rdhtd5.sdcorp.global.sandisk.com (HELO [10.111.68.123]) ([10.111.68.123]) by uls-op-cesaip02.wdc.com with ESMTP; 17 Jan 2019 18:10:06 -0800 Subject: Re: [PATCH v2 6/8] RISC-V: Add required checks during clock source init To: Anup Patel Cc: "linux-riscv@lists.infradead.org" , Alan Kao , Albert Ou , Andreas Schwab , Daniel Lezcano , Dmitriy Cherkasov , Jason Cooper , "linux-kernel@vger.kernel.org List" , Marc Zyngier , Michael Clark , Palmer Dabbelt , =?UTF-8?Q?Patrick_St=c3=a4hlin?= , Thomas Gleixner , Zong Li References: <1546940318-9752-1-git-send-email-atish.patra@wdc.com> <1546940318-9752-7-git-send-email-atish.patra@wdc.com> From: Atish Patra Message-ID: <839bee2a-12a0-6bdd-8d59-b83cc0403c96@wdc.com> Date: Thu, 17 Jan 2019 18:10:04 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/8/19 3:57 AM, Anup Patel wrote: > Few nit changes.. > > Prefer, "clocksource/drivers/riscv:" prefix instead of "RISC-V:" for > this patch. > > On Tue, Jan 8, 2019 at 3:08 PM 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 >> --- >> 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..d9b914e9 100644 >> --- a/drivers/clocksource/timer-riscv.c >> +++ b/drivers/clocksource/timer-riscv.c >> @@ -95,14 +95,31 @@ 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; >> + } > > Add empty line here. > >> cpuid = riscv_hartid_to_cpuid(hartid); >> > > Remove empty line here > >> + if (cpuid < 0) { >> + pr_warn("Invalid cpuid for hartid [%d]\n", hartid); >> + return cpuid; >> + } >> + >> if (cpuid != smp_processor_id()) >> return 0; >> >> + pr_err("%s: Registering clocksource cpuid [%d] hartid [%d]\n", >> + __func__, cpuid, hartid); >> cs = per_cpu_ptr(&riscv_clocksource, cpuid); >> - clocksource_register_hz(cs, riscv_timebase); >> + error = clocksource_register_hz(cs, riscv_timebase); >> > > Remove empty line here. > >> + if (error) { >> + pr_err("RISCV timer register failed [%d] for cpu = [%d]\n", >> + error, cpuid); >> + return error; >> + } > > Add empty line here. > >> 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; >> } >> >> -- >> 2.7.4 >> > > Apart from above, looks good to me. > > Reviewed-by: Anup Patel > Thanks for the review. I will fix the empty line issues and subject line. > Regards, > Anup >