public inbox for fio@vger.kernel.org
 help / color / mirror / Atom feed
From: Runa Guo-oc <RunaGuo-oc@zhaoxin.com>
To: <fio@vger.kernel.org>, <axboe@kernel.dk>, <vincentfu@gmail.com>
Cc: <cobechen@zhaoxin.com>, <tonywwang@zhaoxin.com>,
	<xanderchen@zhaoxin.com>, <louisqi@zhaoxin.com>,
	<runaguo@zhaoxin.com>, <leoliu@zhaoxin.com>
Subject: [PATCH] Add Zhaoxin support to enable tsc_reliable and arch_random features
Date: Wed, 21 May 2025 10:04:21 +0800	[thread overview]
Message-ID: <20250521020421.6862-1-RunaGuo-oc@zhaoxin.com> (raw)

Signed-off-by: Runa Guo-oc <RunaGuo-oc@zhaoxin.com>
---
 arch/arch-x86-common.h | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/arch/arch-x86-common.h b/arch/arch-x86-common.h
index f32835cc..fbbbd62e 100644
--- a/arch/arch-x86-common.h
+++ b/arch/arch-x86-common.h
@@ -56,6 +56,33 @@ static inline void arch_init_amd(void)
 	tsc_reliable = (edx & (1U << 8)) != 0;
 }
 
+static inline void arch_init_zhaoxin(void)
+{
+	unsigned int eax, ebx, ecx = 0, edx;
+
+	/*
+	 * Check for TSC
+	 */
+	eax = 1;
+	do_cpuid(&eax, &ebx, &ecx, &edx);
+	if (!(edx & (1U << 4)))
+		return;
+
+	/*
+	 * Check for constant rate and synced (across cores) TSC
+	 */
+	eax = 0x80000007;
+	do_cpuid(&eax, &ebx, &ecx, &edx);
+	tsc_reliable = (edx & (1U << 8)) != 0;
+
+	/*
+	 * Check for FDRAND
+	 */
+	eax = 0x1;
+	do_cpuid(&eax, &ebx, &ecx, &edx);
+	arch_random = (ecx & (1U << 30)) != 0;
+}
+
 static inline void arch_init(char *envp[])
 {
 	unsigned int level;
@@ -72,6 +99,8 @@ static inline void arch_init(char *envp[])
 		arch_init_intel();
 	else if (!strcmp(str, "AuthenticAMD") || !strcmp(str, "HygonGenuine"))
 		arch_init_amd();
+	else if (!strcmp(str, "  Shanghai  ") || !strcmp(str, "CentaurHauls"))
+		arch_init_zhaoxin();
 }
 
 #endif
-- 
2.17.1


             reply	other threads:[~2025-05-21  2:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-21  2:04 Runa Guo-oc [this message]
2025-05-21 13:20 ` [PATCH] Add Zhaoxin support to enable tsc_reliable and arch_random features Jens Axboe
2025-05-21 17:49 ` fiotestbot
  -- strict thread matches above, loose matches on Subject: below --
2025-05-22  4:37 Runa Guo-oc
2025-05-22  6:49 ` fiotestbot
2025-05-22  8:07 ` Sitsofe Wheeler
2025-05-22 10:40 Runa Guo-oc
2025-05-23  7:38 ` fiotestbot
2025-05-23 13:19   ` Vincent Fu
2025-05-23 15:46 ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250521020421.6862-1-RunaGuo-oc@zhaoxin.com \
    --to=runaguo-oc@zhaoxin.com \
    --cc=axboe@kernel.dk \
    --cc=cobechen@zhaoxin.com \
    --cc=fio@vger.kernel.org \
    --cc=leoliu@zhaoxin.com \
    --cc=louisqi@zhaoxin.com \
    --cc=runaguo@zhaoxin.com \
    --cc=tonywwang@zhaoxin.com \
    --cc=vincentfu@gmail.com \
    --cc=xanderchen@zhaoxin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox