Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1062818imj; Thu, 14 Feb 2019 00:13:47 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibq4zhIeEOIyhGBx9zuDS0u3s7DeFto3+AibhCVdHIrqahOs4YJETa9CfsMoCtQBOz8CsC5 X-Received: by 2002:a17:902:7c82:: with SMTP id y2mr2813208pll.33.1550132027475; Thu, 14 Feb 2019 00:13:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550132027; cv=none; d=google.com; s=arc-20160816; b=KZa7Kxli87+Hd34lewS/wpaydpmeMw9josy5v4KYWQWwlx5mAEIuFSunnjq4MrOibI F9HYQDBKD7qFNc3uQwlePnAPrEBAq60k5WcPkB91ogVQljIQVB4VZo2zLV69nvboZg9S kwLaUI8s2rb+dbvfvX/tFG6/1JiwlkJt77HOlroN1Eu/A74LiGarFQDLa9SjghBUroLH Bq4YyqaGrdl4XrqLaVQl5htDdwun3Sg0iIvT/MEkklYkACzFD5qFjOY1pYk6x0tE/fD7 maJlyU71LCIHdr35O99wV9SsIN0ijlmoSI4eK5Oa6CGlBugMCnkSKDEEAc7Skik48o6t l5lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=LT+TQXEyzAhDa4veJzKF4qvBq8lB/5e4edmvwYCSE3g=; b=G7lTrss0Z+Lg/qZYkEZ7yhV3zLjjfT6sYA1TX4bXz5ej3zMdsrL4DQVgJXCuUNkHYt CDODbpaAAmO5qYkMiqaAiMOs9Jo4wDvxX4idMpjZ0Viiy8uDmmvFBWNlZumNhA56FEBi F9E2R1Ri+qNRg1uR00pJ43gz1GSO57jAJ88aZeurH4HBW3hZ4F4Ubw8DMyLw+6lheOnr K780xyf1Wm5hwjm1oZICGfjmNukgI7vRWuYGG9fKva4liyj2sH2+2YlX7D1k3FsO8Is0 fhbiCPeDqSIAlr+DOFK5xHPAHpvvsaqdOzVMCSUG1cL2siWa3wa5mjKBTT4J3mQpsllw ySPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=MeYwiGJX; 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 89si1772416pfk.121.2019.02.14.00.13.31; Thu, 14 Feb 2019 00:13:47 -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=MeYwiGJX; 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 S2436610AbfBMUSX (ORCPT + 99 others); Wed, 13 Feb 2019 15:18:23 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:65222 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388690AbfBMUSV (ORCPT ); Wed, 13 Feb 2019 15:18:21 -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=1550089101; x=1581625101; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=BXPJoBB0Kgm4J4WvDGeNZxKZbFFkYo9XWYKOd8CvDv0=; b=MeYwiGJXL/kN0g3se9mB8Cow2WRc5tebYFdM6bd8qvp/2TkAuKEiarRh ZwUCNSjSCKwTHu2/uFhsWMmSeXwupQPHfYhAYsu+0f9ILr/1UnjRM16ST ScizG8cnc/qdPC9z9AdM8LLNk+9XKbRY5bigC61S49u8+PKp6Gd5wTL+V 1tgZApMSFT4gL5vLFHxX0A4Gf7SJahiQVfpmK1dqKbOg4x8kFoAAytDWU 8ErkwGffejNzZ7MBe1wseke8kt1hbtNwZ5fsX+WuuM9LQo9n7kf0jeG3+ wk8k6d+uk+nuu0PkbCX4J32LNlc0weoRCqpy+LwOspDdtfF/3mdLuHkVb Q==; X-IronPort-AV: E=Sophos;i="5.58,366,1544457600"; d="scan'208";a="106167278" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 14 Feb 2019 04:18:21 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 13 Feb 2019 11:58:55 -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; 13 Feb 2019 12:18:21 -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 , Guenter Roeck , Jason Cooper , Johan Hovold , linux-kernel@vger.kernel.org, Marc Zyngier , Palmer Dabbelt , Paul Walmsley , Thomas Gleixner Subject: [v5 PATCH 4/8] RISC-V: Allow hartid-to-cpuid function to fail. Date: Wed, 13 Feb 2019 12:18:08 -0800 Message-Id: <1550089092-28783-5-git-send-email-atish.patra@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550089092-28783-1-git-send-email-atish.patra@wdc.com> References: <1550089092-28783-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 Reviewed-by: Anup Patel Reviewed-by: Christoph Hellwig --- 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 b69883c6..ca99f0fb 100644 --- a/arch/riscv/kernel/smp.c +++ b/arch/riscv/kernel/smp.c @@ -60,7 +60,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