From patchwork Sun Jun 21 13:10:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagar Shrikant Kadam X-Patchwork-Id: 1313938 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=selector1 header.b=dVkJCYK4; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49qXx21qrkz9sSJ for ; Sun, 21 Jun 2020 23:11:18 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F0B6981D3B; Sun, 21 Jun 2020 15:10:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.b="dVkJCYK4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C769981D4C; Sun, 21 Jun 2020 15:10:39 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2060c.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::60c]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1BB0781D35 for ; Sun, 21 Jun 2020 15:10:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sagar.kadam@sifive.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DXYqCsVYSxf9wcNJwvwrOOdOSlR1389K3KGepqkvuRB4lnOUoQY4thcyh7ugYMTOo+4s2V0WuE+dSbgk+D/e45PwQa1DlI6kjyDvkMHqvuPPSf+RSWUOB5/NUBYZLnjf4OzgxdB7fAoXjSrMvNzHwRG0Mi3za8fQlMTCEn28pUBe0Grzt14F4ekLMkWukGZONjctB7xJRvrtXJKlAfUQtdWeKIvlkHNQK7ssf3ZMAPlM/zo2rCUxWnjK9cXb6a/3ioNx49ha9bzcoWLzOnuzrdl8XzfdvYa8aJvPLracXrBlVC8zfravtGEZylq2PZySu2Ihsz+ykwFTSewjcmKgeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H3Q5xPtmgGdEGdcEcTM+vZona0QqBGqIGdQiV+55lFo=; b=SLdI1kYSDQsHiwewNgZejgTbDP9PF4dSyyY0xL7shOoTtxI1xA6Tdw7BfE+Wp/NDS+TX+nBP/kCGEAOYpGztLaHWoV7OPPyHM0iVE0kD1qeeIR9gISAojxF3gzy0ykkdte3otrsW0bSEBLt/3UAxW4a1rN4pnSsQj3ZlP9omi1Ep+PwyroHctlSNs90Hc2gcE0ep3GDLf9yYyyjCI+W3KL9bNBT9N+l1HdcvEgCi6GlEORwdQxQ6EhwU1np/VPt3iMZtG99N1av7Ew2ltDpyAFdfQdUu4Q3OibZ6DcGQRkZ8y6pBVVTHH4FRaKCssVvJynehiS+N4+pNqzbEExAWsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sifive.com; dmarc=pass action=none header.from=sifive.com; dkim=pass header.d=sifive.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H3Q5xPtmgGdEGdcEcTM+vZona0QqBGqIGdQiV+55lFo=; b=dVkJCYK4+0CpjmJ+nxNjd19dhuKJNdHy6y1rgMujlWqYwOvHtxJFt3fPOhZefgA7fWWbwfNwF1Id+2dSP72QCUn36Uqy7rxHGeHMIMARBMbwOMzi5tF0qp3MybnKTed2WjjJdfjHUS2DIHaLouplCis2uOQrAFMYu/2c412nC2w= Authentication-Results: lists.denx.de; dkim=none (message not signed) header.d=none;lists.denx.de; dmarc=none action=none header.from=sifive.com; Received: from BN8PR13MB2611.namprd13.prod.outlook.com (2603:10b6:408:81::17) by BN6PR13MB1473.namprd13.prod.outlook.com (2603:10b6:404:11a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.10; Sun, 21 Jun 2020 13:10:31 +0000 Received: from BN8PR13MB2611.namprd13.prod.outlook.com ([fe80::c1d9:f4ee:80ab:de83]) by BN8PR13MB2611.namprd13.prod.outlook.com ([fe80::c1d9:f4ee:80ab:de83%6]) with mapi id 15.20.3131.016; Sun, 21 Jun 2020 13:10:31 +0000 From: Sagar Shrikant Kadam To: u-boot@lists.denx.de Cc: rick@andestech.com, lukma@denx.de, bmeng.cn@gmail.com, jagan@amarulasolutions.com, pragnesh.patel@sifive.com, anup.patel@wdc.com, sjg@chromium.org, seanga2@gmail.com, Sagar Shrikant Kadam Subject: [PATCH v4 3/4] riscv: cpu: fixes to display proper CPU features Date: Sun, 21 Jun 2020 06:10:07 -0700 Message-Id: <1592745008-17196-4-git-send-email-sagar.kadam@sifive.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1592745008-17196-1-git-send-email-sagar.kadam@sifive.com> References: <1592745008-17196-1-git-send-email-sagar.kadam@sifive.com> X-ClientProxiedBy: BYAPR21CA0001.namprd21.prod.outlook.com (2603:10b6:a03:114::11) To BN8PR13MB2611.namprd13.prod.outlook.com (2603:10b6:408:81::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from gamma07.internal.sifive.com (64.62.193.194) by BYAPR21CA0001.namprd21.prod.outlook.com (2603:10b6:a03:114::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3153.2 via Frontend Transport; Sun, 21 Jun 2020 13:10:30 +0000 X-Mailer: git-send-email 2.7.4 X-Originating-IP: [64.62.193.194] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6b368df6-ed52-4198-a8ec-08d815e479d7 X-MS-TrafficTypeDiagnostic: BN6PR13MB1473: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-Forefront-PRVS: 04410E544A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uO9ebPL/5MhVP4GpGyl8PCpuhpd0d+6YM2+DByU6iSZ0dryVJfV89HesQhtmnmNjbJR31yIH4dqbbWatn9LV/Nhy0iDLK1KtswIr6QQzzmb+tkGeIVd0qamzUmQCP1s2z0h3aCV1hLIMsqViTwGsS2QA3fPhsTpbF299N18RF8E/j0dByzK26BN7GuxiNXXbppbg51EnqdbqqBAEr9TehX/h64wVKtrj4WhyFy5vXlI+npTgfOY+ShST2/1x+DXwIDwrwa+EF3vUp9C4pkWu6sE+QRMzZO1pBY+u8CJj3NWpzQgAJIO8CzkrkAYSqIE4Oz9uAQP+rb7/xdr7dJX96A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN8PR13MB2611.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(396003)(366004)(376002)(136003)(346002)(39830400003)(316002)(86362001)(83380400001)(6486002)(478600001)(52116002)(7696005)(5660300002)(66556008)(66946007)(66476007)(2616005)(956004)(6666004)(16526019)(186003)(26005)(6916009)(2906002)(36756003)(8936002)(8676002)(107886003)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: HABUruwnfmLUWZv6kBqZ4iuc0VsgDV6BL7fKOZfJzfCDaisNR6QtKXBkwXUxqnsC8eRVbYyU5/ShER4GH93Ix1nnEB6NzJgCBsxeLPdgHfjcCDpdpzDq0Pl1DSUIMm3tRrR83GVMeHIbpCNSWLi1RZ2B+uCeGedsuuB1rdPe/WiJNSNV1B3c58xVJy1Nh+p2QYKlrzKoWI/rTrIbYK//QgbovjkcXYJ7qAeJF7dhgelDcpvzEgxlQZeUEVJ+2nt4BW90UYQSUGkP6ApdBGw0y7dUZjpREX9AWt2HWCHDJIZcsTekGKmGx6Mv9sB3DNmHK/KHU/U3ecI734bTahwtbsNREB2XNgmnUL6PM5oMW2Pieo/EMaxxzxN5aRAOVH2fqB2heVrfgUydmwooInIFgvrkPOZ2snBFYj+y0tRz4Ur5tLQ38u5ixDQI57yEvmQLy+nVwsffKcHRzwRkNrLOOK1Gcititz6mZ0izYBlPXfM= X-OriginatorOrg: sifive.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b368df6-ed52-4198-a8ec-08d815e479d7 X-MS-Exchange-CrossTenant-AuthSource: BN8PR13MB2611.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2020 13:10:31.6966 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 22f88e9d-ae0d-4ed9-b984-cdc9be1529f1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: C59kA3Yrfwo2S21GwVJ6eFawxkDopxxI5MEY4VpqbA8KyWgHQykAdqBc63uppsGlXJ9tGGrHF7e5po7QOs40PA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR13MB1473 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean The cmd "cpu detail" fetches uninitialized cpu feature information and thus displays wrong / inconsitent details as below. FU540-C000 doesn't have any microcode, yet the cmd display's it. => cpu detail 0: cpu@0 rv64imac ID = 0, freq = 999.100 MHz: L1 cache, MMU, Microcode, Device ID Microcode version 0x0 Device ID 0x0 1: cpu@1 rv64imafdc ID = 1, freq = 999.100 MHz: L1 cache, MMU, Microcode, Device ID Microcode version 0x0 Device ID 0x0 2: cpu@2 rv64imafdc ID = 2, freq = 999.100 MHz: L1 cache, MMU, Microcode, Device ID Microcode version 0x0 Device ID 0x0 3: cpu@3 rv64imafdc ID = 3, freq = 999.100 MHz: L1 cache, MMU, Microcode, Device ID Microcode version 0x0 Device ID 0x0 4: cpu@4 rv64imafdc ID = 4, freq = 999.100 MHz: L1 cache, MMU, Microcode, Device ID Microcode version 0x0 Device ID 0x0 The L1 cache or MMU entry seen above is also displayed inconsistently. So initialize features to zero before fetching from device tree. Additionally the conditional check to read "mmu-type" from device tree is not rightly handled due to which the cpu feature doesn't include CPU_FEAT_MMU even if it's corresponding entry is present in device tree. We now see correct features as: => cpu detail 0: cpu@0 rv64imac ID = 0, freq = 999.100 MHz 1: cpu@1 rv64imafdc ID = 1, freq = 999.100 MHz: MMU 2: cpu@2 rv64imafdc ID = 2, freq = 999.100 MHz: MMU 3: cpu@3 rv64imafdc ID = 3, freq = 999.100 MHz: MMU 4: cpu@4 rv64imafdc ID = 4, freq = 999.100 MHz: MMU Signed-off-by: Sagar Shrikant Kadam Reviewed-by: Pragnesh Patel --- drivers/cpu/riscv_cpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/cpu/riscv_cpu.c b/drivers/cpu/riscv_cpu.c index 76b0489..8c4b5e7 100644 --- a/drivers/cpu/riscv_cpu.c +++ b/drivers/cpu/riscv_cpu.c @@ -38,6 +38,8 @@ static int riscv_cpu_get_info(struct udevice *dev, struct cpu_info *info) /* Zero out the frequency, in case sizeof(ulong) != sizeof(u32) */ info->cpu_freq = 0; + /* Initialise cpu features before updating from device tree */ + info->features = 0; /* First try getting the frequency from the assigned clock */ ret = clk_get_by_index(dev, 0, &clk); @@ -52,7 +54,7 @@ static int riscv_cpu_get_info(struct udevice *dev, struct cpu_info *info) dev_read_u32(dev, "clock-frequency", (u32 *)&info->cpu_freq); mmu = dev_read_string(dev, "mmu-type"); - if (!mmu) + if (mmu) info->features |= BIT(CPU_FEAT_MMU); return 0;