From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2F57C169C4 for ; Fri, 8 Feb 2019 09:04:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7247F2147C for ; Fri, 8 Feb 2019 09:04:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mfwoFcyz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7247F2147C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1dHPPp0VlzMBqF8dr1kAqsMH8f8G7mgmM41OX16nQH4=; b=mfwoFcyzXJS1Dt jLcO6VqXG3RZx9pxP6wbPzTtFMMX0X2vr3YfVvEWAweeJzIyu0Vm98gS0jKg4t9QRBkG0UfshZpKM ZWMG7tABou1pidM9R+COLaTQXfh0k7fbfCMLVzYRHl6Gcom9EaYP0qQVz3v3+zVBEvu0suIV0cv9E o4Iut4obtmoP24o2FxI+Ekpta06jSXU394bgMudu5rO8Oi8/NzZSYqCzsoRliOqw2yZj6kcB1V5o1 4B2qgk5E4G6HFMhQiTvrdKZ63O75wXXoP0VKEpVG6OhWSjQqc6R64SDruZ0jvJPQhLRxq/6iOyjtZ R9U151kjTLH1ijHkgNvQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gs24u-0004is-4J; Fri, 08 Feb 2019 09:04:08 +0000 Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gs24r-0004ig-Kh; Fri, 08 Feb 2019 09:04:05 +0000 Date: Fri, 8 Feb 2019 01:04:05 -0800 From: Christoph Hellwig To: Atish Patra Subject: Re: [v3 PATCH 6/8] clocksource/drivers/riscv: Add required checks during clock source init Message-ID: <20190208090405.GC16932@infradead.org> References: <1549590681-24125-1-git-send-email-atish.patra@wdc.com> <1549590681-24125-7-git-send-email-atish.patra@wdc.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1549590681-24125-7-git-send-email-atish.patra@wdc.com> User-Agent: Mutt/1.9.2 (2017-12-15) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Le Moal , Albert Ou , Jason Cooper , Alan Kao , Dmitriy Cherkasov , Anup Patel , Daniel Lezcano , Patrick =?iso-8859-1?Q?St=E4hlin?= , linux-kernel@vger.kernel.org, Marc Zyngier , Palmer Dabbelt , Paul Walmsley , Andreas Schwab , linux-riscv@lists.infradead.org, Thomas Gleixner , Zong Li Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.org On Thu, Feb 07, 2019 at 05:51:19PM -0800, 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..3c7ea75b 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_err("%s: Registering clocksource cpuid [%d] hartid [%d]\n", > + __func__, cpuid, hartid); This does not look like an error case to me. At best it is info, if not debug. _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv