platform: generic: thead: separate T-Head PMU Errata
authorYangyu Chen <cyy@cyyself.name>
Sun, 21 Apr 2024 15:52:08 +0000 (23:52 +0800)
committerAnup Patel <anup@brainfault.org>
Thu, 9 May 2024 12:39:05 +0000 (18:09 +0530)
As Guo Ren said from the kernel mailing list [1], future T-Head CPUs,
including the newer versions of T-Head C908, will feature standard
Sscofpmf extension. For these CPUs, T-Head's implementation of PMU
Overflow Interrupts may not needed anymore. In this case, we shouldn't
apply T-Head PMU for all T-Head CPUs. Thus, this patch separated T-Head PMU
errata.

[1] https://lore.kernel.org/linux-riscv/Zh9sUUUT09LZb0MO@gmail.com/

Signed-off-by: Yangyu Chen <cyy@cyyself.name>
Reviewed-by: Inochi Amaoto <inochiama@outlook.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
platform/generic/include/thead/c9xx_errata.h
platform/generic/thead/thead-generic.c

index bf9793840480ff9e14c8166467a24382520b697c..40c1587bcf70c6ad0853ea95970c8e9c5e733b24 100644 (file)
@@ -7,6 +7,7 @@
  * stale entrie avoid incorrect memory access.
  */
 #define THEAD_QUIRK_ERRATA_TLB_FLUSH           BIT(0)
+#define THEAD_QUIRK_ERRATA_THEAD_PMU           BIT(1)
 
 void thead_register_tlb_flush_trap_handler(void);
 
index 72f4aaacce792597e87d9b1ded1619e62f2cb12c..da55e054c57ecf1dd987606af009334de745840f 100644 (file)
@@ -33,12 +33,16 @@ static int thead_generic_early_init(bool cold_boot,
 static int thead_generic_extensions_init(const struct fdt_match *match,
                                         struct sbi_hart_features *hfeatures)
 {
-       thead_c9xx_register_pmu_device();
+       struct thead_generic_quirks *quirks = (void *)match->data;
+
+       if (quirks->errata & THEAD_QUIRK_ERRATA_THEAD_PMU)
+               thead_c9xx_register_pmu_device();
+
        return 0;
 }
 
 static struct thead_generic_quirks thead_th1520_quirks = {
-       .errata = THEAD_QUIRK_ERRATA_TLB_FLUSH,
+       .errata = THEAD_QUIRK_ERRATA_TLB_FLUSH | THEAD_QUIRK_ERRATA_THEAD_PMU,
 };
 
 static const struct fdt_match thead_generic_match[] = {