From patchwork Fri Nov 9 01:50:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 10675233 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 942861057 for ; Fri, 9 Nov 2018 01:51:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 835982E4C1 for ; Fri, 9 Nov 2018 01:51:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 770C22EA14; Fri, 9 Nov 2018 01:51:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0C8182E4C1 for ; Fri, 9 Nov 2018 01:51:01 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=rmwmDeuau0xU+4wS0Ujj+Mi2XqFE2ycx1d1nt9DT7SU=; b=phBp2H7u0s1vr167n0yeog505U gqlK6WffIymgDgi8cqCVNqC5WAASqBhvD+qK+tHnHKVmSeWyEez9Lp8+Ku49ETa3Ze2SMv1Chen/M LVvp+YKpFnOTD17PWzT0RfD4ZL1msN5y8RttxKQzHzCQnWLUGWGhcc0tYHndXQRr6Oyhat4mmwHWD rKjF3QWXIDMRC6h5aRUK09JDwyGt/5yh14qp5pCp18SX6G0n2A7rtSpXN7yLzgKWFeY/MR9Zp0/OP nhwkgZXn+n4WbPUJac+406afjBwzoRdXSouPIx4ZIYub5r+/Fzsg4Co67OEz3hxlN/G20kAW49oDM EeThw6sA==; 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 1gKvwn-0000xL-Co; Fri, 09 Nov 2018 01:50:57 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gKvwQ-0000K0-8k; Fri, 09 Nov 2018 01:50:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8HQ2vHTko6k0VtyZcrexw1yy9c4VPr8ceXABe1IJ964=; b=J+TuKQMYrq0nFx9bkgiBYrhHM A2+IQ5rnQhYUMD+ie6z5BfeQdB9p/lpoOt4uuNWUD72WZgRbYxK9krNC+8G9fbFp/avGper2CQ/2l aYwmxB4qKD3dfYDvgELCrAnQGTWTs+BE0WzK5hgT/PAoAgQIiT2te/EQo0PEl69cI96yphAtUsrbA Fwo3KraOLBG7bkyGbs8GQvvVnuC2tiJ7d0drYvYERQEcznnHef5PdJWpSgCPDFHsRf2uTFoMBu4dX lS+uh6hAHAfM1EbBjM1xJGuH//uZUkeeRaSNkkeW6/tjbfXsLp5VU0QtTGB831VHa80iydFxsMK9y JNzktWDog==; Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gKvwN-0003pb-6R; Fri, 09 Nov 2018 01:50:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1541728232; x=1573264232; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=wTS7UviMuB1vJqlMidMCF02zuSQf2VK9pjNXvYjC+z4=; b=aB2TKEZbCNFJRltSvao5RBIbldWh1b2UUAph7l6yZI+QP8YPZpA3QaIJ 2Rlh0ofP4oUrdNy1n9tuAZDLAk/vd51/bVJFEdy7XBbU62ayrXDw9cmJ2 Ze4Rf6jbfxBBgpwY8Ej/92rfak2z3+O/+WL9EIWAxSOMJg91P8Jaxe1xh Mm8GBltsdNw6KeEsMfz6rLFXeTSsUIubPBDz6oMmIH0WmcBsCIhGvOQk+ vhhtXQRIDbfyKAq0S5IZF1NjciHO3Bi6nAjCK1UBAtfvByXH5Vp7W4f9M NYbZCskD3Dn+aNj0sdvj4YQAdBRF3TnJ9rFjzxCai8kMrANeI7Ny/qRF+ A==; X-IronPort-AV: E=Sophos;i="5.54,481,1534780800"; d="scan'208";a="93844219" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 09 Nov 2018 09:50:11 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 08 Nov 2018 17:33:44 -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 Nov 2018 17:50:11 -0800 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [RFC 3/3] RISC-V: Parse cpu topology during boot. Date: Thu, 8 Nov 2018 17:50:09 -0800 Message-Id: <1541728209-3224-4-git-send-email-atish.patra@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541728209-3224-1-git-send-email-atish.patra@wdc.com> References: <1541728209-3224-1-git-send-email-atish.patra@wdc.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181109_015031_505195_7F05B5F6 X-CRM114-Status: GOOD ( 13.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, Damien.LeMoal@wdc.com, juri.lelli@arm.com, anup@brainfault.org, palmer@sifive.com, jeremy.linton@arm.com, atish.patra@wdc.com, robh+dt@kernel.org, sudeep.holla@arm.com, mick@ics.forth.gr, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, there are no topology defined for RISC-V. Parse the cpu-map node from device tree and setup the cpu topology. CPU topology after applying the patch. $cat /sys/devices/system/cpu/cpu2/topology/core_siblings_list 0-3 $cat /sys/devices/system/cpu/cpu3/topology/core_siblings_list 0-3 $cat /sys/devices/system/cpu/cpu3/topology/physical_package_id 0 $cat /sys/devices/system/cpu/cpu3/topology/core_id 3 Signed-off-by: Atish Patra --- arch/riscv/Kconfig | 1 + arch/riscv/kernel/smpboot.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 55da93f4..e2d8ddb5 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -42,6 +42,7 @@ config RISCV select THREAD_INFO_IN_TASK select RISCV_TIMER select GENERIC_IRQ_MULTI_HANDLER + select GENERIC_ARCH_TOPOLOGY select ARCH_HAS_PTE_SPECIAL config MMU diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c index 18cda0e8..6fa95442 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,7 @@ void *__cpu_up_task_pointer[NR_CPUS]; void __init smp_prepare_boot_cpu(void) { + init_cpu_topology(); } void __init smp_prepare_cpus(unsigned int max_cpus) @@ -108,13 +110,15 @@ void __init smp_cpus_done(unsigned int max_cpus) asmlinkage void __init smp_callin(void) { struct mm_struct *mm = &init_mm; + unsigned int cpu = smp_processor_id(); /* All kernel threads share the same mm context. */ mmgrab(mm); current->active_mm = mm; trap_init(); - notify_cpu_starting(smp_processor_id()); + notify_cpu_starting(cpu); + update_siblings_masks(cpu); set_cpu_online(smp_processor_id(), 1); /* * Remote TLB flushes are ignored while the CPU is offline, so emit