Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5338224ioo; Wed, 1 Jun 2022 03:32:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyPjxKnDKq2ESRhgmQzVXGmzJJi2JWVjvIY1zG/+gagvIFYFLtN8omlif3sMts9U9/XFam X-Received: by 2002:a17:907:6d85:b0:6fa:80ea:7565 with SMTP id sb5-20020a1709076d8500b006fa80ea7565mr59112675ejc.395.1654079529932; Wed, 01 Jun 2022 03:32:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654079529; cv=none; d=google.com; s=arc-20160816; b=p9cDUEgLM5y9UXAHts8JX8wLiXG24k+fBKqfGhuU+VVqansnq19pguG8ycasWo/YxY AgGicH6zpm6j6iMBS0FWcaZp4tg7oxr4etSy7MbLPp8OjCJIeLy/vD/bwY+5Xl8xdRYI 0m+V8fiVft9zuTNw+wRhgNl8JhJiHqkCfAM4/kEjrne98pzgSWg+j4WiyNMl62AuC4/l /GFzz3hOXrdrHYeMDE/rqDOuWKh/h0wnbb3hL8Xoaj8oDVnkxTzF3Z4GrlZrgG2wTWmz t9acJkrIzqU8wxEEzyjT/Y/3P1F9e27ifSMfqmzxN+txG8AMbEAQfGN6a9N9eU/MAGFx KWFg== 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=c42mniWc8JXoIPcsTRZjOoXhrf4EUCSGd05jzwsQGb8=; b=iK/UT5n1crSRA1lvVky0/xsXYKUWWXgoWbIm5xClXpILoLItn3TZu1rcTuIkMPIUFR lryli/e/O+JAsT7nZY4qFHe0LRrhfFWc1sxp7YxXYH2zBBwtUMSaFV6+LxTfz21z4Tmt Cb3qb1GVzsr9ET8R4/WZQIdnSG2hlgK1mTAXQRRGvJNp1rLqDKntdJQ6shb9nwpTOKCS xwJQndjOdl4CKVKFqdL3aSgoOhVIF1NO+qvVNOh7YMR2wjtVjw3FKW4HhUeH2DgOI6nN M8nMzQr68ej9LNppBbeDqow8/k3PIgpCZQfaFS7nfbXgLK1UXOW0b01BKM+XW48tvTHE FVAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dG6+2VAt; 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 gn40-20020a1709070d2800b006f42491e0a0si1637387ejc.655.2022.06.01.03.31.44; Wed, 01 Jun 2022 03:32:09 -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=dG6+2VAt; 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 S242483AbiE3OhR (ORCPT + 99 others); Mon, 30 May 2022 10:37:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242015AbiE3OSS (ORCPT ); Mon, 30 May 2022 10:18:18 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A01B9EB5A; Mon, 30 May 2022 06:48:59 -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 ams.source.kernel.org (Postfix) with ESMTPS id 21502B80DA8; Mon, 30 May 2022 13:48:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E4D2C3411C; Mon, 30 May 2022 13:48:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653918534; bh=yFwBUzVQVJmRKiHFeOtjB13g9HNsfc3vfzdbuCRtjfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dG6+2VAtOq3sG/Bn/2CM6l3Sk3wKNHuyL5YV9lDeCy0o5UlmEGDUYm8tbRf0h+IWD 87G0U050h0RDyuSOnNFKYM2ikxd9iaUpf+7vo55fWTFGWnWMzY0fxGN6D7I3dwAoz2 Bo+SdeO6U2NzV3K6RC6gMlCsvl01ScpYOx5Wv5FOwpJ1Cjn13njs5XajveoqE8/ghc c4WYV7qrxCojaD9swcarvK2ZoBAcr5qLHtYsUSCM7vpIsbrDrw7+PD5gfWEoRZ95ON +NkbdI2NiiAY4Q8gkl8TlVvTPErW0kMZdSeT4Zf6hYLgdsCilAsN6CsiUTz9Ixn1VJ b0uIQOw7wIbxA== 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 , linux@dominikbrodowski.net, rdunlap@infradead.org, openrisc@lists.librecores.org Subject: [PATCH AUTOSEL 5.4 44/55] openrisc: start CPU timer early in boot Date: Mon, 30 May 2022 09:46:50 -0400 Message-Id: <20220530134701.1935933-44-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220530134701.1935933-1-sashal@kernel.org> References: <20220530134701.1935933-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 d52b4e536e3f..5487fa93dd9b 100644 --- a/arch/openrisc/include/asm/timex.h +++ b/arch/openrisc/include/asm/timex.h @@ -23,6 +23,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 b0dc974f9a74..ffbbf639b7f9 100644 --- a/arch/openrisc/kernel/head.S +++ b/arch/openrisc/kernel/head.S @@ -521,6 +521,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