Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp4598249ioo; Tue, 31 May 2022 07:45:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvT1YJe5hrE4Z0c06uHeJHY1HdxgQQj0z17pUQvB7V+E+kEoFpFvqMXgQjdjz1g26ZBPTa X-Received: by 2002:a17:90a:6b41:b0:1e0:e082:14c7 with SMTP id x1-20020a17090a6b4100b001e0e08214c7mr28677449pjl.92.1654008337806; Tue, 31 May 2022 07:45:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654008337; cv=none; d=google.com; s=arc-20160816; b=xbWDGKfghLdAbx5OPqfWSloAXpKfqataKf2TLDnI5gjiiSIk/Vb7MjGuLsD7renhz+ WKDrq5/9i0YdoJYTqhAtQIrT1+g/5guXnbemvRqbTbGngy2OIkrbsoWH9hgD3Y3K9bcH sgDwAZPf07aXxQ9P25HwuC2cdW70vgbsJtJ1kEjQa7rgh6582+ZfHzjqXUcbmIIHFzqx JjsL/8It3fef/sBSFnMI57gFUiUa4o3y7cychSNgXuqUc0PREbgNsfT9xEXoLyFE7hXn gNohWUnzXoDr5OjRTdJnLAWHuF/0ebYjXqsY6iuiIvKia0E28f6Ys9d9QE6cIz2e2vKT kHfA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Cm2ZTqiN/lepyIh9aVHKstMboRxyBzUDmxi0rYk6Tz8=; b=dT9bLnDcrRYuUmF268foY+HwF/+nsd0Yx7tpe18ULchBraySyIHCDxuaFFtWHkH77a n1oimFVjxlkV6Hw+IkzRpvIbYYsfxPQasOcLmuDRlF/sXQyP2p88sBSHejyQc31BYSbt XSjJg5h4apr9c3ZkroI23e9C3Az/Ezp/8nZmhwDtSCZhaD5Bfsxn0LGe3I14kwaMN3rv 3Cd9rRqd4jfrH5VOjEMKZFX5OaR8akUd+KK6jI41lf/HSwgR3v0PXDXE5TZxnVpoz3Ra 1Z8WA/vTr0lxbpZfzHE6pah7+oP0QzCDMz59jDDaK/6Bkw8Nr6uledvHgWc1E9fXzl8B ED0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ag8cajVc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l22-20020a056a0016d600b0051b4e546a3fsi9192034pfc.242.2022.05.31.07.45.18; Tue, 31 May 2022 07:45:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ag8cajVc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S237969AbiE3OxD (ORCPT + 99 others); Mon, 30 May 2022 10:53:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242656AbiE3ObZ (ORCPT ); Mon, 30 May 2022 10:31:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28C1E12DBF6; Mon, 30 May 2022 06:53:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 423786102F; Mon, 30 May 2022 13:53:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57BB2C3411A; Mon, 30 May 2022 13:52:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653918779; bh=Xlh2jYqXF5aWMkpYTrGr9h+FlAuLQOz3xMpWM9qsbjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ag8cajVcjVFPaqJOTl6Lco1bbKm5m7DVAXRVZDLNnOI42Z+UjHEQn8K3iY1jlBoWD s2If/td9jICItwbQ/WJFdiYfW8y8gOy4J6rpW8HrQNBscs5zempWBiW8j82YR944T9 SaeZ3QCLKpQ3UGzxdkXO1LaSX67+k/CWpK07M2iaKIMlcNURCnT9CdiCHSNq7VVn0A BDqritZ44Sd8JVR1zQP3b3yC1bQTr35Xd6GIOWWrnUQcIhnzrozsH5vuONa4dG/e+1 GYJ1IRLrmpPELmlyKCWK1/wEPTH1ldyqABRpkOOl143oI/qFrCj2B6d1Fh5XKwYzt+ U00NNtu2XBM0Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Jason A. Donenfeld" , Thomas Gleixner , Arnd Bergmann , Jonas Bonn , Stefan Kristiansson , Stafford Horne , Guenter Roeck , Sasha Levin , rdunlap@infradead.org, linux@dominikbrodowski.net, openrisc@lists.librecores.org Subject: [PATCH AUTOSEL 4.9 18/24] openrisc: start CPU timer early in boot Date: Mon, 30 May 2022 09:52:05 -0400 Message-Id: <20220530135211.1937674-18-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220530135211.1937674-1-sashal@kernel.org> References: <20220530135211.1937674-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Jason A. Donenfeld" [ Upstream commit 516dd4aacd67a0f27da94f3fe63fe0f4dbab6e2b ] In order to measure the boot process, the timer should be switched on as early in boot as possible. As well, the commit defines the get_cycles macro, like the previous patches in this series, so that generic code is aware that it's implemented by the platform, as is done on other archs. Cc: Thomas Gleixner Cc: Arnd Bergmann Cc: Jonas Bonn Cc: Stefan Kristiansson Acked-by: Stafford Horne Reported-by: Guenter Roeck Signed-off-by: Jason A. Donenfeld Signed-off-by: Sasha Levin --- arch/openrisc/include/asm/timex.h | 1 + arch/openrisc/kernel/head.S | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/arch/openrisc/include/asm/timex.h b/arch/openrisc/include/asm/timex.h index 9935cad1b9b9..34d015bf0462 100644 --- a/arch/openrisc/include/asm/timex.h +++ b/arch/openrisc/include/asm/timex.h @@ -27,6 +27,7 @@ static inline cycles_t get_cycles(void) { return mfspr(SPR_TTCR); } +#define get_cycles get_cycles /* This isn't really used any more */ #define CLOCK_TICK_RATE 1000 diff --git a/arch/openrisc/kernel/head.S b/arch/openrisc/kernel/head.S index 98dd6860bc0b..0b6be5b3522b 100644 --- a/arch/openrisc/kernel/head.S +++ b/arch/openrisc/kernel/head.S @@ -452,6 +452,15 @@ _start: l.ori r3,r0,0x1 l.mtspr r0,r3,SPR_SR + /* + * Start the TTCR as early as possible, so that the RNG can make use of + * measurements of boot time from the earliest opportunity. Especially + * important is that the TTCR does not return zero by the time we reach + * rand_initialize(). + */ + l.movhi r3,hi(SPR_TTMR_CR) + l.mtspr r0,r3,SPR_TTMR + CLEAR_GPR(r1) CLEAR_GPR(r2) CLEAR_GPR(r3) -- 2.35.1