Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp4034384pxb; Tue, 7 Sep 2021 13:09:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqC6wtD0D3oCk+jL5AmWhvB05XXn8zkdgeHinP7uQndWUrN38yPdgG3VS5N00nc88fLflY X-Received: by 2002:a05:6402:1cb9:: with SMTP id cz25mr7834edb.11.1631045382208; Tue, 07 Sep 2021 13:09:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631045382; cv=none; d=google.com; s=arc-20160816; b=eKEMM9rneXqp2z9p7szYcwCFF4t0mJgg3/g6xht1kMItkjhkfBaU+woaQXoR+5s5fh FUNGOQaoFFTgjuk8FszROw+4SnO0o2TjhsfE7WZOvqA14wMUXQ8G+ZGa5GMHiSD/Pvai dfTm2QO9T4Jt1IbWmiBJeahFbZLF+FcCK4p2xecC8+6zu6+4CtmM52Ra8RMWIi7MVQ9m b4wS63jy+m2S0wqOzxRu/kdlCVder76YaSeZwrOsdbSA3Yoz58IZlu3yBSIZOrboN4eb T9VtXo7OiVk/VgHOgCphFXRDOdWfRvXZ3QOth1O6MtHS21cNlOhhJSIG1vlQV6wEvfXG XhRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=OZZM6TLBXZAfdvO/Y0uKCVbha+YIm/V01uid7/EPiYU=; b=kmPe4BwSa0momY5fkKxBV+zotWxhWq6wzuEdTP5ZUEd/bwcisdbWlQA4H8034hgC+t +lSHJtp1OBLXxzYa8rHe5EjP312qSz+LovG6uUvusiC0It5nTs182+jzEgrEftWeBKjW aZZDhEPuRWI5EVjpNGPKuTwwgzxoEl7iBj1VoITqkraWzxaOp3FgjVRv5htWqoIPEv30 cX3B7FpXM18HmVwxDi2WaUdKyWtTJjaA31YfrvPyx+k/RJZnYwr8tPcqzFxhmoAiGa4K pJhSgrACYQJXeBcdks69f9Xe56096aVJ1ZIT+KARqly5CpIkctfgZW/Xw4TH6TZgBPKR 5dug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VSZqEbIr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c19si12253860ejj.716.2021.09.07.13.09.17; Tue, 07 Sep 2021 13:09:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VSZqEbIr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346226AbhIGUEI (ORCPT + 99 others); Tue, 7 Sep 2021 16:04:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:59138 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230467AbhIGUEH (ORCPT ); Tue, 7 Sep 2021 16:04:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C859161106; Tue, 7 Sep 2021 20:03:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631044981; bh=GHY5U3+0IXVjerpc2D86xOqagWOy0yZ5l0MYkJly+sU=; h=From:To:Cc:Subject:Date:From; b=VSZqEbIrNDCJTGP2NgiDmbVHwrEH1yz+kRLMwgnx51fVrcMKr5XiXKIuf/bLtOBgo QEWBXK2AkQVySrKZShWAJOfQL/z9efWEhm6Fw3xs33BtC+62frShpIUcvuz9uGM/wg sW2JYwT6EQak30j/o+xCY4hVg2l1JQjg8G/PQbXc8Tl35t2piE8BubXvWYgBTgyA/K c7r4k93UndMXvDF8DeXa3ZLJSPweoOAJEI9AHpSuuMLTFbzn9n8NBMKkWSzTbEPKXg VhIkEDXrzp0gph0h4O3PjKTqav3kwyK+A6T9uoI+pk/9i0pw96kZb9a8FsbICLyJZw nHLoCntOOutlw== From: Vineet Gupta To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Anup Patel , Jisheng Zhang , Guo Ren , Kefeng Wang Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Vineet Gupta Subject: [PATCH] riscv: mm: don't advertise 1 num_asid for 0 asid bits Date: Tue, 7 Sep 2021 13:02:54 -0700 Message-Id: <20210907200254.467375-1-vgupta@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Even if mmu doesn't support ASID, current code calculates @num_asids=1 which is misleading, so avoid setting any asid related variables in such a case. Also while here, print the number of asid bits discovered even for the disabled case. Verified this on Hifive Unmatched. Signed-off-by: Vineet Gupta --- arch/riscv/mm/context.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/riscv/mm/context.c b/arch/riscv/mm/context.c index ee3459cb6750..c8c6f8831a3b 100644 --- a/arch/riscv/mm/context.c +++ b/arch/riscv/mm/context.c @@ -233,8 +233,10 @@ static int __init asids_init(void) local_flush_tlb_all(); /* Pre-compute ASID details */ - num_asids = 1 << asid_bits; - asid_mask = num_asids - 1; + if (asid_bits) { + num_asids = 1 << asid_bits; + asid_mask = num_asids - 1; + } /* * Use ASID allocator only if number of HW ASIDs are @@ -255,7 +257,7 @@ static int __init asids_init(void) pr_info("ASID allocator using %lu bits (%lu entries)\n", asid_bits, num_asids); } else { - pr_info("ASID allocator disabled\n"); + pr_info("ASID allocator disabled: %lu bits\n", asid_bits); } return 0; -- 2.30.2