Skip to content

Commit 450189f

Browse files
committed
[riscv64] mvendorid & marchid based architecture qualification
1 parent 2622871 commit 450189f

File tree

4 files changed

+184
-40
lines changed

4 files changed

+184
-40
lines changed

riscv64/corefreqk.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/module.h>
99
#include <linux/cpu.h>
1010
#include <linux/pci.h>
11+
#include <asm/sbi.h>
1112
#ifdef CONFIG_DMI
1213
#include <linux/dmi.h>
1314
#endif /* CONFIG_DMI */
@@ -507,6 +508,9 @@ static void Query_Features(void *pArg)
507508
{
508509
INIT_ARG *iArg = (INIT_ARG *) pArg;
509510
volatile unsigned long long timectr, instret, perfctr;
511+
const unsigned long
512+
mvendorid = riscv_cached_mvendorid(iArg->localProcessor),
513+
marchid = riscv_cached_marchid(iArg->localProcessor);
510514

511515
iArg->Features->Info.Vendor.CRC = CRC_RESERVED;
512516
iArg->SMT_Count = 1;
@@ -527,10 +531,10 @@ static void Query_Features(void *pArg)
527531
iArg->Features->PerfMon.InstrRetired = instret != 0 ? 0b1 : 0b0;
528532

529533
iArg->Features->Info.Signature.Stepping = 0;
530-
iArg->Features->Info.Signature.Family = 0 & 0x00f;
531-
iArg->Features->Info.Signature.ExtFamily = (0 & 0xff0) >> 4;
532-
iArg->Features->Info.Signature.Model = 0 & 0x0f;
533-
iArg->Features->Info.Signature.ExtModel = (0 & 0xf0) >> 4;
534+
iArg->Features->Info.Signature.Family = mvendorid & 0x00f;
535+
iArg->Features->Info.Signature.ExtFamily = (mvendorid & 0xff0) >> 4;
536+
iArg->Features->Info.Signature.Model = marchid & 0x0f;
537+
iArg->Features->Info.Signature.ExtModel = (marchid & 0xf0) >> 4;
534538
/*
535539
VendorFromMainID(midr, iArg->Features->Info.Vendor.ID,
536540
&iArg->Features->Info.Vendor.CRC, &iArg->HypervisorID);
@@ -887,7 +891,7 @@ static void OverrideCodeNameString(PROCESSOR_SPECIFIC *pSpecific)
887891
StrCopy(PUBLIC(RO(Proc))->Architecture,
888892
Arch[
889893
PUBLIC(RO(Proc))->ArchID
890-
].Architecture.Brand[pSpecific->CodeNameIdx], CODENAME_LEN);
894+
].Architecture[pSpecific->CodeNameIdx], CODENAME_LEN);
891895
}
892896

893897
static void OverrideUnlockCapability(PROCESSOR_SPECIFIC *pSpecific)
@@ -4491,9 +4495,6 @@ static int CoreFreqK_Scale_And_Compute_Level_Up(INIT_ARG *pArg)
44914495

44924496
memcpy(&PUBLIC(RO(Proc))->Features, pArg->Features, sizeof(FEATURES));
44934497

4494-
/* Initialize default uArch's codename with the CPUID brand. */
4495-
Arch[GenuineArch].Architecture.Brand[0] = \
4496-
PUBLIC(RO(Proc))->Features.Info.Vendor.ID;
44974498
/* Initialize with any hypervisor found so far. */
44984499
PUBLIC(RO(Proc))->HypervisorID = pArg->HypervisorID;
44994500
return 0;
@@ -4658,12 +4659,13 @@ static int CoreFreqK_Ignition_Level_Up(INIT_ARG *pArg)
46584659
}
46594660
/* Set the uArch's name with the first found codename */
46604661
StrCopy(PUBLIC(RO(Proc))->Architecture,
4661-
CodeName[Arch[PUBLIC(RO(Proc))->ArchID].Architecture.CN],
4662+
Arch[PUBLIC(RO(Proc))->ArchID].Architecture[0],
46624663
CODENAME_LEN);
46634664

4664-
StrCopy(PUBLIC(RO(Proc))->Features.Info.Brand,
4665-
Arch[PUBLIC(RO(Proc))->ArchID].Architecture.Brand[0],
4666-
BRAND_SIZE);
4665+
StrCopy(PUBLIC(RO(Proc))->Features.Info.Vendor.ID,
4666+
PUBLIC(RO(Proc))->Architecture,
4667+
12 + 4);
4668+
46674669
/* Check if the Processor is actually virtualized ? */
46684670
#ifdef CONFIG_XEN
46694671
if (xen_pv_domain() || xen_hvm_domain())

riscv64/corefreqk.h

Lines changed: 155 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,6 @@ typedef struct {
257257
void (*SetTarget)(void *arg);
258258
} SYSTEM_DRIVER;
259259

260-
typedef struct {
261-
char **Brand;
262-
enum CODENAME CN;
263-
} ARCH_ST;
264-
265260
typedef struct
266261
{
267262
struct SIGNATURE Signature;
@@ -285,7 +280,7 @@ typedef struct
285280
} Uncore;
286281
PROCESSOR_SPECIFIC *Specific;
287282
SYSTEM_DRIVER SystemDriver;
288-
ARCH_ST Architecture;
283+
char **Architecture;
289284
} ARCH;
290285

291286
static CLOCK BaseClock_GenericMachine(unsigned int ratio) ;
@@ -296,19 +291,27 @@ static void Stop_GenericMachine(void *arg) ;
296291
static void InitTimer_GenericMachine(unsigned int cpu) ;
297292

298293
/* [Void] */
299-
#define _Void_Signature {.ExtFamily=0x00, .Family=0x0, .ExtModel=0x0, .Model=0x0}
294+
#define _Void_Signature {.ExtFamily=0x00,.Family=0x0, .ExtModel=0x0,.Model=0x0}
295+
#define _Andes {.ExtFamily=0x31, .Family=0xE, .ExtModel=0x0, .Model=0x0}
296+
#define _SiFive {.ExtFamily=0x48, .Family=0x9, .ExtModel=0x0, .Model=0x0}
297+
#define _T_Head {.ExtFamily=0x5B, .Family=0x7, .ExtModel=0x0, .Model=0x0}
298+
#define _Veyron {.ExtFamily=0x61, .Family=0xF, .ExtModel=0x0, .Model=0x0}
299+
#define _SpacemiT {.ExtFamily=0x71, .Family=0x0, .ExtModel=0x0, .Model=0x0}
300300

301301
typedef kernel_ulong_t (*PCI_CALLBACK)(struct pci_dev *);
302302

303303
static struct pci_device_id PCI_Void_ids[] = {
304304
{0, }
305305
};
306306

307-
static char *CodeName[CODENAMES] = {
308-
[ RV64] = "RV64"
309-
};
307+
static char *Arch_Generic[] = ZLIST("RV64");
308+
static char *Arch_Andes[] = ZLIST("Andes");
309+
static char *Arch_SiFive[] = ZLIST("SiFive");
310+
static char *Arch_T_Head[] = ZLIST("T-Head");
311+
static char *Arch_Veyron[] = ZLIST("Veyron");
312+
static char *Arch_SpacemiT[] = ZLIST("SpacemiT");
310313

311-
#define Arch_Misc_Processor {.Brand = ZLIST(NULL), .CN = RV64}
314+
static PROCESSOR_SPECIFIC Void_Specific[] = { {0} };
312315

313316
static PROCESSOR_SPECIFIC Misc_Specific_Processor[] = {
314317
{0}
@@ -373,6 +376,146 @@ static ARCH Arch[ARCHITECTURES] = {
373376
},
374377
.Specific = Misc_Specific_Processor,
375378
.SystemDriver = VOID_Driver,
376-
.Architecture = Arch_Misc_Processor
379+
.Architecture = Arch_Generic
380+
},
381+
[Andes] = {
382+
.Signature = _Andes,
383+
.Query = Query_GenericMachine,
384+
.Update = PerCore_GenericMachine,
385+
.Start = Start_GenericMachine,
386+
.Stop = Stop_GenericMachine,
387+
.Exit = NULL,
388+
.Timer = InitTimer_GenericMachine,
389+
.BaseClock = BaseClock_GenericMachine,
390+
.ClockMod = NULL,
391+
.TurboClock = NULL,
392+
.thermalFormula = THERMAL_FORMULA_NONE,
393+
#ifdef CONFIG_PM_OPP
394+
.voltageFormula = VOLTAGE_FORMULA_OPP,
395+
#else
396+
.voltageFormula = VOLTAGE_FORMULA_NONE,
397+
#endif
398+
.powerFormula = POWER_FORMULA_NONE,
399+
.PCI_ids = PCI_Void_ids,
400+
.Uncore = {
401+
.Start = NULL,
402+
.Stop = NULL,
403+
.ClockMod = NULL
404+
},
405+
.Specific = Void_Specific,
406+
.SystemDriver = VOID_Driver,
407+
.Architecture = Arch_Andes
408+
},
409+
[SiFive] = {
410+
.Signature = _SiFive,
411+
.Query = Query_GenericMachine,
412+
.Update = PerCore_GenericMachine,
413+
.Start = Start_GenericMachine,
414+
.Stop = Stop_GenericMachine,
415+
.Exit = NULL,
416+
.Timer = InitTimer_GenericMachine,
417+
.BaseClock = BaseClock_GenericMachine,
418+
.ClockMod = NULL,
419+
.TurboClock = NULL,
420+
.thermalFormula = THERMAL_FORMULA_NONE,
421+
#ifdef CONFIG_PM_OPP
422+
.voltageFormula = VOLTAGE_FORMULA_OPP,
423+
#else
424+
.voltageFormula = VOLTAGE_FORMULA_NONE,
425+
#endif
426+
.powerFormula = POWER_FORMULA_NONE,
427+
.PCI_ids = PCI_Void_ids,
428+
.Uncore = {
429+
.Start = NULL,
430+
.Stop = NULL,
431+
.ClockMod = NULL
432+
},
433+
.Specific = Void_Specific,
434+
.SystemDriver = VOID_Driver,
435+
.Architecture = Arch_SiFive
377436
},
437+
[T_Head] = {
438+
.Signature = _T_Head,
439+
.Query = Query_GenericMachine,
440+
.Update = PerCore_GenericMachine,
441+
.Start = Start_GenericMachine,
442+
.Stop = Stop_GenericMachine,
443+
.Exit = NULL,
444+
.Timer = InitTimer_GenericMachine,
445+
.BaseClock = BaseClock_GenericMachine,
446+
.ClockMod = NULL,
447+
.TurboClock = NULL,
448+
.thermalFormula = THERMAL_FORMULA_NONE,
449+
#ifdef CONFIG_PM_OPP
450+
.voltageFormula = VOLTAGE_FORMULA_OPP,
451+
#else
452+
.voltageFormula = VOLTAGE_FORMULA_NONE,
453+
#endif
454+
.powerFormula = POWER_FORMULA_NONE,
455+
.PCI_ids = PCI_Void_ids,
456+
.Uncore = {
457+
.Start = NULL,
458+
.Stop = NULL,
459+
.ClockMod = NULL
460+
},
461+
.Specific = Void_Specific,
462+
.SystemDriver = VOID_Driver,
463+
.Architecture = Arch_T_Head
464+
},
465+
[Veyron] = {
466+
.Signature = _Veyron,
467+
.Query = Query_GenericMachine,
468+
.Update = PerCore_GenericMachine,
469+
.Start = Start_GenericMachine,
470+
.Stop = Stop_GenericMachine,
471+
.Exit = NULL,
472+
.Timer = InitTimer_GenericMachine,
473+
.BaseClock = BaseClock_GenericMachine,
474+
.ClockMod = NULL,
475+
.TurboClock = NULL,
476+
.thermalFormula = THERMAL_FORMULA_NONE,
477+
#ifdef CONFIG_PM_OPP
478+
.voltageFormula = VOLTAGE_FORMULA_OPP,
479+
#else
480+
.voltageFormula = VOLTAGE_FORMULA_NONE,
481+
#endif
482+
.powerFormula = POWER_FORMULA_NONE,
483+
.PCI_ids = PCI_Void_ids,
484+
.Uncore = {
485+
.Start = NULL,
486+
.Stop = NULL,
487+
.ClockMod = NULL
488+
},
489+
.Specific = Void_Specific,
490+
.SystemDriver = VOID_Driver,
491+
.Architecture = Arch_Veyron
492+
},
493+
[SpacemiT] = {
494+
.Signature = _SpacemiT,
495+
.Query = Query_GenericMachine,
496+
.Update = PerCore_GenericMachine,
497+
.Start = Start_GenericMachine,
498+
.Stop = Stop_GenericMachine,
499+
.Exit = NULL,
500+
.Timer = InitTimer_GenericMachine,
501+
.BaseClock = BaseClock_GenericMachine,
502+
.ClockMod = NULL,
503+
.TurboClock = NULL,
504+
.thermalFormula = THERMAL_FORMULA_NONE,
505+
#ifdef CONFIG_PM_OPP
506+
.voltageFormula = VOLTAGE_FORMULA_OPP,
507+
#else
508+
.voltageFormula = VOLTAGE_FORMULA_NONE,
509+
#endif
510+
.powerFormula = POWER_FORMULA_NONE,
511+
.PCI_ids = PCI_Void_ids,
512+
.Uncore = {
513+
.Start = NULL,
514+
.Stop = NULL,
515+
.ClockMod = NULL
516+
},
517+
.Specific = Void_Specific,
518+
.SystemDriver = VOID_Driver,
519+
.Architecture = Arch_SpacemiT
520+
}
378521
};

riscv64/coretypes.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,12 @@ enum CRC_MANUFACTURER
3535
CRC_HYPERV = 0x543a585e
3636
};
3737

38-
enum CODENAME
39-
{
40-
RV64,
41-
CODENAMES
42-
};
43-
4438
enum { GenuineArch = 0,
39+
Andes,
40+
SiFive,
41+
T_Head,
42+
Veyron,
43+
SpacemiT,
4544
ARCHITECTURES
4645
};
4746

riscv64/risc_reg.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,21 @@ typedef union
5353
{
5454
unsigned long long
5555
WPRI0 : 1-0,
56-
SIE : 2-1, /* Enables all interrupts */
56+
SIE : 2-1, /* Supervisor all Interrupts Enable */
5757
WPRI2 : 5-2,
58-
SPIE : 6-5,
59-
UBE : 7-6,
58+
SPIE : 6-5, /* Supervisor Prior Interrupt Enable */
59+
UBE : 7-6, /* Endianness Control. 0:Little; 1:Big*/
6060
WPRI7 : 8-7,
61-
SPP : 9-8,
62-
VS : 11-9,
61+
SPP : 9-8, /* Supervisor Previous Privilege mode */
62+
VS : 11-9, /* Vector Extension State */
6363
WPRI11 : 13-11,
64-
FS : 15-13,
65-
XS : 17-15,
64+
FS : 15-13, /* Floating-point Unit State */
65+
XS : 17-15, /* User-mode eXtensions State */
6666
WPRI17 : 18-17,
67-
SUM : 19-18,
68-
MXR : 20-19,
67+
SUM : 19-18, /* Supervisor User Memory access */
68+
MXR : 20-19, /* Make eXecutable Readable */
6969
WPRI20 : 32-20,
70-
UXL : 34-32,
70+
UXL : 34-32, /* U-mode UXLEN */
7171
WPRI34 : 63-34,
7272
SD : 64-63;
7373
};

0 commit comments

Comments
 (0)