Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4689055imu; Tue, 8 Jan 2019 04:42:56 -0800 (PST) X-Google-Smtp-Source: ALg8bN4MB0Ulvo1Ez1r3n5CMV+4Sn7dIlquHGHdAINZPwdolBdT5T0FAon/l1L+Sx5OUfWwCXte0 X-Received: by 2002:a62:44d8:: with SMTP id m85mr1633472pfi.164.1546951376647; Tue, 08 Jan 2019 04:42:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546951376; cv=none; d=google.com; s=arc-20160816; b=tEdOBnwsrVkJ5CRLYAg1oEr/GtYJsAsHWi+c2EkqJbgC6p7V+hgdM8BDFmfoEnUAA1 7LGDv7y0O7/HijtRL90/Lv7zm46mHy2mVAdC4AjxKNwlpyeQYV2IHPRIbtOgtR9fbtVb jnTUZQGp/Nl+vptbeuWVpNDHW9Wb4paBHc7xo8MfW4HKbWqgLEbztT1Z26Zcf6HFD+gp ZruZvBmpaNuLZxCXPFIQjb3cDr/5lOuyYZmVRKciU8qEqbyGMmrjtPijjIj3HjEBbZ4c H7cZ9xM1WHGokbumUKWIKOjvYIFGmLw7LqaXIAuwRVUlfPvCXm7VCFR6m7JRTS6GquZH tcqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ZhAZJuqPU7RKOJhMeSxOJONoJ67G3o8MCo8xEvxcW8E=; b=cXYG5I4ejrHQMFW3dmdvPf/PCYACB+pmM4UE5X2aOo/EexTGi1hq5+g11PVtEtx4FZ r4ELD90Vo772RNl6p7MYfq0+YkcP77hK4o+ZiNNe8iPWx+2UzeuxOS+2g0R+8NTHON7r xDKc16XfzosXJKYXmCgP7VmX7UFH/gaxhBFZQji68pfHuvI31me/TOcFaRfsYKX6eCKe FRu1z9eKsnEGiX7SYz3pmPN5zZXpxkQbWnyCVCGhCCLl986GNbm9LNTzKkPbToQRWaRk pqJpWBPL5RVfLEwF3BWfo5O3/BcglXyhfGt4JMbpyS+O1+UifXZCIq07AP3PxfnqLoaG fWeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b="m5G4xg/0"; 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 i6si23080803plt.290.2019.01.08.04.42.41; Tue, 08 Jan 2019 04:42:56 -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=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b="m5G4xg/0"; 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 S1728649AbfAHL46 (ORCPT + 99 others); Tue, 8 Jan 2019 06:56:58 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:37247 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727107AbfAHL46 (ORCPT ); Tue, 8 Jan 2019 06:56:58 -0500 Received: by mail-wm1-f68.google.com with SMTP id g67so4085289wmd.2 for ; Tue, 08 Jan 2019 03:56:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZhAZJuqPU7RKOJhMeSxOJONoJ67G3o8MCo8xEvxcW8E=; b=m5G4xg/0cyJYmjd1Ky/f2AU9v7fJ4SPYRWFV4xsXlZiGBtigpCDw36KTwMss2VbTy7 Km/7fwHldwVB1HgDX4egn2hQbvyBgwP3n+XtQ+OyEvQwk0Jw3zjhQTBQ++NNdt4rM01v 1HIyPhfX63YlT8XKhfj1U6kmW8HNw39jJugwcZ0Nl5UfjlWfGsggCmMo3/JdMK+ggCPn wsrGq0fRmna7/YE4azAbuwLyWtv0yLNIaLwKsrDV+6i8IHtojdFcS5o7N778Cbve6pZD 2vg+tlh4zrbm8rkJwaDsYLwY3rHlifawK5sbUdqbyPyL8YT2htkvXcMGKJNAtz34fHj+ 5wkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZhAZJuqPU7RKOJhMeSxOJONoJ67G3o8MCo8xEvxcW8E=; b=B+WFYBhsf3m1UDWBoLaqqaZADF/HaM68TbHCWCH5S8qDlUf2zpEanch1MHiCmKYPPB OSKqs4qTMAl4khR5DpfhGlNoSMtgOQxSJEqBs+wz82XIzJvX7rVXFASB/KybjYSAqziB LqcBKLGajre1heabpTwjK9SR1yR5FVck+rTI+CkiJzq7HNeNz0neFhhw+Jg0yG3KsCl3 pd7QwRItvLIiqoip5dgzH28nfvwyCnkwDbG+aGRUm4rXGdKQyyc4wL0sfy9+MMQRHXHd 9RjpyTpJ+nP55yTT/7bBSdsPMAkNfKxxODun8uOCH6V86rpaStozFE8FW1zxBkUkmTIV qCqA== X-Gm-Message-State: AJcUukfCnN8Xjj/RjIGyqJjwh/NSt4O5mL5kO742Lm02+nSF2ifN5+w/ 5qh1i6pEkEsbT5npzmx7wVLtOGZsFTias58peh3Pyg== X-Received: by 2002:a1c:f509:: with SMTP id t9mr1662305wmh.76.1546948616128; Tue, 08 Jan 2019 03:56:56 -0800 (PST) MIME-Version: 1.0 References: <1546940318-9752-1-git-send-email-atish.patra@wdc.com> <1546940318-9752-7-git-send-email-atish.patra@wdc.com> In-Reply-To: <1546940318-9752-7-git-send-email-atish.patra@wdc.com> From: Anup Patel Date: Tue, 8 Jan 2019 17:26:45 +0530 Message-ID: Subject: Re: [PATCH v2 6/8] RISC-V: Add required checks during clock source init To: Atish Patra 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Regards, Anup