Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp90042imj; Wed, 13 Feb 2019 05:14:35 -0800 (PST) X-Google-Smtp-Source: AHgI3IbQxcLt6HkVHZD6sbrysUPUWPaS8hp5DEGG4BzGmsDuvaPP+aT27IvMZphpUyq8IFWu3GG2 X-Received: by 2002:a62:345:: with SMTP id 66mr425496pfd.189.1550063675311; Wed, 13 Feb 2019 05:14:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550063675; cv=none; d=google.com; s=arc-20160816; b=F3D9vNsZ0jx82w40xoIXqe6YylH/UCz8jWa50KXbHMvyyT02+wGCI2GwMpzfneXykn +W/tfbtqRFINeMySoZ7puvzfhOOuzqXqTJepHNu5eRIPMQeY9OARWUumsb/eDGTomZIr mRf5EXcqVITial5M0ILMxkWsntSYxUUNvoDxDFqRkhTZfjrBZuhRDFv4OqPZR4M7iUA3 DK6yUzEXGXMSb/VrIv5ykxOiFM8we1TUAqk8SiztW28Ck7xA4KkJOdEnNWJkiKpzM/e3 zEcTnSWoE92NBCsn5iDwQm3QDT9vFOMj0NJHRMehSy43XJwYRz8U52WbSO3Ijn5xeFUM 1g0A== 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=cEpWGg1h+mnrJufQh7Ng7TE3wjG5O41fk+jfrTVIKNw=; b=sk8BqFUHQ9KIKjBHBUeweYqLQhISNIy3mvdJnZbBvai7/j8rJi+X2PfInZ30+J7CPM 2Cva+eax7TzA/1QvgERKDmAt5yM2DdSEjK2B9Ylk7ajUeGhnx1q6vOxDK2scvyvyR5mW kturSCvdK/avt97VvKlUwTa6lSOQ5pQwDkQi1At31NOvb1MGKB3LWKtGlD0rNgkw828t S8QxNpL9Tx2oVTo9pMJ69ebHFbUam3wk8PqYsKuFvZ479nQzjil0zPXkWXfmVGc32wib uo8a93VVew8lzP6p4rzfQ03i8OmkRaWjbRiNh58oV5JPEjDM5DjJQCQmosbUFymRjwyN NdQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cKjafkJT; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q83si14404534pfa.205.2019.02.13.05.14.18; Wed, 13 Feb 2019 05:14: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=pass header.i=@linaro.org header.s=google header.b=cKjafkJT; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389849AbfBMIs3 (ORCPT + 99 others); Wed, 13 Feb 2019 03:48:29 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:42203 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728933AbfBMIs3 (ORCPT ); Wed, 13 Feb 2019 03:48:29 -0500 Received: by mail-wr1-f68.google.com with SMTP id q18so1482441wrx.9 for ; Wed, 13 Feb 2019 00:48:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=cEpWGg1h+mnrJufQh7Ng7TE3wjG5O41fk+jfrTVIKNw=; b=cKjafkJTYOLTG4ho2NBdRPJuHJRUCROn4QQLCiVbiDKGab2p54QMizO3CM961ycXJZ 6ukqMH1AnlS8ifhPgvvl/2NuL3ExnBDBtdcHB2BdmbEOxvLNdsLaL9z2JtvdIVOyOUJW lRPcc1gKVg1rwxPUDZUb8tXECWg9feqt5L6YKKJrNVfuk+qAvRaLvQijCUAURYOlow7Y tm3HrdXcy5sDscxbsT0WFLJ2MyoZaDmouiXCLqTvSqu/i0OWudWvbe80G5dsw7qP7GsW 9OfNgpdmACEAB9Sx7Auhupq0lE6wheTuJtY/TfllBM3gLTKOSptHAQlymzS0Xt6O6ET/ HfIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=cEpWGg1h+mnrJufQh7Ng7TE3wjG5O41fk+jfrTVIKNw=; b=M9T0QpfUcFr64A22twknjZr7e39cbSPlXY8M8pribbuqOeAjqwEC0MkbAVbRg3nAxJ sRoVgC235isGusj5aMHQ5R+otMFQ+RwbCQc88zFiapcgp5ZxvnH/AI60VU3M144vBSoS 3fz+xRBrrLNuYpvCwEwaOuX0/GQqEmNSzcGJoc7ipEPbAWDGUGE4kRzJduHWWvoz67GX 9bzWfwHT33fE/P3gU86VAY8OVu/TFuZGoPz/ppfOpJtsipYqjG7TqO1m8rbjwfHzDGkB z3nBy4rW2kJ9ZdNl39/buSp28O+TnHl+FyGR9uRlyaG8BYWkWA0djgnr5cSac3FcKwLQ fJTw== X-Gm-Message-State: AHQUAub4Wgm54U6WG1T06VRcK5PM1WGEEcUEp/G0Zz4QzSFH2Z34tUNo XeHzYoylGgf+QSFj/QyQE9AtIg== X-Received: by 2002:adf:9f48:: with SMTP id f8mr6314943wrg.151.1550047707235; Wed, 13 Feb 2019 00:48:27 -0800 (PST) Received: from [192.168.27.65] (sju31-1-78-210-255-2.fbx.proxad.net. [78.210.255.2]) by smtp.googlemail.com with ESMTPSA id w16sm11901697wrp.1.2019.02.13.00.48.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 00:48:26 -0800 (PST) Subject: Re: [v4 PATCH 6/8] clocksource/drivers/riscv: Add required checks during clock source init To: Atish Patra , linux-riscv@lists.infradead.org Cc: Alan Kao , Albert Ou , Andreas Schwab , Anup Patel , Dmitriy Cherkasov , Jason Cooper , Johan Hovold , linux-kernel@vger.kernel.org, Marc Zyngier , Palmer Dabbelt , Paul Walmsley , Rob Herring , Thomas Gleixner References: <1549969812-22502-1-git-send-email-atish.patra@wdc.com> <1549969812-22502-7-git-send-email-atish.patra@wdc.com> From: Daniel Lezcano Message-ID: <7bd250fb-c896-64e1-d73b-6f3dd284e2d6@linaro.org> Date: Wed, 13 Feb 2019 09:48:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <1549969812-22502-7-git-send-email-atish.patra@wdc.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ? > --- > 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); > 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; > } > > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog