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.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 92608C43387 for ; Tue, 8 Jan 2019 09:39:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5B57F206B7 for ; Tue, 8 Jan 2019 09:39:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="ePRckkWu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728480AbfAHJiu (ORCPT ); Tue, 8 Jan 2019 04:38:50 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:8878 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727932AbfAHJis (ORCPT ); Tue, 8 Jan 2019 04:38:48 -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=1546940327; x=1578476327; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=c3GlsSU9hpztl0F7FBnfC5nPlii3rUi/viUc2pT+k2g=; b=ePRckkWuACHDKjtLxQzXYc+3rFoluAIdBdfH4y2qkfP0FrL/V3mc4gkP u8YR0+33RPYFHgg6m/QaH+L+dZhm6eOg2vPidN2g8/2ipf03e1ijXG45Y BIBfsBV0MAvHhpJXn42nvJKHXcTVYcABp2aRCj9si/isgZDyWZtukHX2l NJ1Z6WIQTc/S4J8QOUl9u9ZCW36X3tJ1bLZSX/GXrCRsOYbzsxt8cdbAr e40gwvik5HYXN+SvjzkX8Nd+6la5gugQ9ttJgE8E0RuGHK/hdGgFYM67I BIPFrJIPRIWnomrAffNo5GbZXjW60VND92rgCZGcI6d2lyo7iqi0USz97 g==; X-IronPort-AV: E=Sophos;i="5.56,453,1539619200"; d="scan'208";a="99458407" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 08 Jan 2019 17:38:46 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 08 Jan 2019 01:18:51 -0800 Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip02.wdc.com with ESMTP; 08 Jan 2019 01:38:46 -0800 From: Atish Patra To: linux-riscv@lists.infradead.org Cc: Atish Patra , Alan Kao , Albert Ou , Andreas Schwab , Anup Patel , Daniel Lezcano , Dmitriy Cherkasov , Jason Cooper , linux-kernel@vger.kernel.org, Marc Zyngier , Michael Clark , Palmer Dabbelt , =?UTF-8?q?Patrick=20St=C3=A4hlin?= , Thomas Gleixner , Zong Li Subject: [PATCH v2 4/8] RISC-V: Allow hartid-to-cpuid function to fail. Date: Tue, 8 Jan 2019 01:38:34 -0800 Message-Id: <1546940318-9752-5-git-send-email-atish.patra@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1546940318-9752-1-git-send-email-atish.patra@wdc.com> References: <1546940318-9752-1-git-send-email-atish.patra@wdc.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is perfectly okay to call riscv_hartid_to_cpuid for a hartid that is not mapped with an CPU id. It can happen if the calling functions retrieves the hartid from DT. However, that hartid was never brought online by the firmware or kernel for any reasons. No need to BUG() in the above case. A negative error return is sufficient and the calling function should check for the return value always. Signed-off-by: Atish Patra --- arch/riscv/kernel/smp.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c index e407bd4f..ce9a2e73 100644 --- a/arch/riscv/kernel/smp.c +++ b/arch/riscv/kernel/smp.c @@ -58,7 +58,6 @@ int riscv_hartid_to_cpuid(int hartid) return i; pr_err("Couldn't find cpu id for hartid [%d]\n", hartid); - BUG(); return i; } -- 2.7.4