Skip to contentSkip to conversation

arch_timer: acpi: Add workaround for hisilicon-161010101 erratum

PATCH In review Hanjun Guo 10 participants 27 messages Jan 24, 2017 – Feb 22, 2017

Subsystems (4)
lore
Share & tools
lore

Hanjun Guo

author
#0 lore raw

cover arch_timer: acpi: Add workaround for hisilicon-161010101 erratum

From: Hanjun Guo <[email protected]>

Introduce a general quirk framework for arch timer erratum in ACPI, which use the oem information in GTDT table for platform specific erratums, then add specific handler and data for hisilicon-161010101 erratum.

Hanjun Guo (2):
arm64: arch_timer: acpi: Introduce a generic aquirk framework for
erratum
arch_timer: acpi: add hisi timer erratum data

 drivers/clocksource/arm_arch_timer.c | 58 ++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
Signature · 1 line
1.7.12.4
author
#1 lore raw

PATCH 1/2 arm64: arch_timer: acpi: Introduce a generic aquirk framework for erratum

From: Hanjun Guo <[email protected]>

Introduce a general quirk framework for arch timer erratum in ACPI, which use the oem information in GTDT table for platform specific erratums. The struct gtdt_arch_timer_fixup is introduced to record the oem information to match the quirk and handle the erratum.

---
 drivers/clocksource/arm_arch_timer.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
drivers/clocksource/arm_arch_timer.c +36 -0
index 2dc571d..80d6f76 100644
@@ -1146,6 +1146,39 @@ static int __init arch_timer_mem_of_init(struct device_node *np)
 		       arch_timer_mem_of_init);
 
 #ifdef CONFIG_ACPI_GTDT
+struct gtdt_arch_timer_fixup {
+	char oem_id[ACPI_OEM_ID_SIZE + 1];
+	char oem_table_id[ACPI_OEM_TABLE_ID_SIZE + 1];
+	u32 oem_revision;
+
+	/* quirk handler for arch timer erratum */
+	void (*handler)(void *context);
+	void *context;
+};
+
+/* note: this needs to be updated according to the doc of OEM ID
+ * and TABLE ID for different board.
+ */
+static struct gtdt_arch_timer_fixup arch_timer_quirks[] __initdata = {
+};
+
+static void __init arch_timer_acpi_quirks_handler(char *oem_id,
+						  char *oem_table_id,
+						  u32 oem_revision)
+{
+	struct gtdt_arch_timer_fixup *quirks = arch_timer_quirks;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(arch_timer_quirks); i++, quirks++) {
+		if (!memcmp(quirks->oem_id, oem_id, ACPI_OEM_ID_SIZE) &&
+		    !memcmp(quirks->oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE) &&
+		    quirks->oem_revision == oem_revision) {
+			if (quirks->handler && quirks->context)
+				quirks->handler(quirks->context);
+		}
+	}
+}
+
 static int __init arch_timer_mem_acpi_init(int platform_timer_count)
 {
 	struct arch_timer_mem *timer_mem;
@@ -1182,6 +1215,9 @@ static int __init arch_timer_acpi_init(struct acpi_table_header *table)
 		return -EINVAL;
 	}
 
+	arch_timer_acpi_quirks_handler(table->oem_id, table->oem_table_id,
+				       table->oem_revision);
+
 	arch_timers_present |= ARCH_TIMER_TYPE_CP15;
 
 	ret = acpi_gtdt_init(table, &platform_timer_count);
Signature · 1 line
1.7.12.4
author
#2 lore raw

PATCH 2/2 arch_timer: acpi: add hisi timer erratum data

In reply to Hanjun Guo

From: Hanjun Guo <[email protected]>

Add hisilicon timer specific erratum fixes.

---
 drivers/clocksource/arm_arch_timer.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/clocksource/arm_arch_timer.c +22 -0
index 80d6f76..3e62a09 100644
@@ -1156,10 +1156,32 @@ struct gtdt_arch_timer_fixup {
 	void *context;
 };
 
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+static void __init hisi_erratum_workaroud_enable(void *context)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ool_workarounds); i++) {
+		if (!strcmp(context, ool_workarounds[i].id)) {
+			timer_unstable_counter_workaround = &ool_workarounds[i];
+			static_branch_enable(&arch_timer_read_ool_enabled);
+			pr_info("arch_timer: Enabling workaround for %s\n",
+				timer_unstable_counter_workaround->id);
+			break;
+		}
+	}
+}
+#endif
+
 /* note: this needs to be updated according to the doc of OEM ID
  * and TABLE ID for different board.
  */
 static struct gtdt_arch_timer_fixup arch_timer_quirks[] __initdata = {
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+	{"HISI  ", "HIP05   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP06   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP07   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+#endif
 };
 
 static void __init arch_timer_acpi_quirks_handler(char *oem_id,
Signature · 1 line
1.7.12.4
#26 lore raw
In reply to Hanjun Guo
Quoted 6 lines · Hanjun Guo

From: Hanjun Guo <[email protected]>

Introduce a general quirk framework for arch timer erratum in ACPI, which use the oem information in GTDT table for platform specific erratums, then add specific handler and data for hisilicon-161010101 erratum.

Sorry, forgot to mention that this patch set is based on Mark's git tree [1] and plus remaining patches for GTDT patch set.

[1] git://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git
arch-timer/updates

Thanks
Hanjun

maintainer
#3 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

In reply to Hanjun Guo
Quoted 34 lines · Hanjun Guo

From: Hanjun Guo <[email protected]>

Add hisilicon timer specific erratum fixes.

---
 drivers/clocksource/arm_arch_timer.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/clocksource/arm_arch_timer.c +17 -0
index 80d6f76..3e62a09 100644
@@ -1156,10 +1156,32 @@ struct gtdt_arch_timer_fixup {
 	void *context;
 };
 
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+static void __init hisi_erratum_workaroud_enable(void *context)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ool_workarounds); i++) {
+		if (!strcmp(context, ool_workarounds[i].id)) {
+			timer_unstable_counter_workaround = &ool_workarounds[i];
+			static_branch_enable(&arch_timer_read_ool_enabled);
+			pr_info("arch_timer: Enabling workaround for %s\n",
+				timer_unstable_counter_workaround->id);
+			break;
+		}
+	}
+}
+#endif
+

drivers/clocksource/arm_arch_timer.c struct gtdt_arch_timer_fixup { · line 1185

Quoted 10 lines
drivers/clocksource/arm_arch_timer.c +5 -0
 /* note: this needs to be updated according to the doc of OEM ID
  * and TABLE ID for different board.
  */
 static struct gtdt_arch_timer_fixup arch_timer_quirks[] __initdata = {
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+	{"HISI  ", "HIP05   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP06   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP07   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+#endif
 };

NAK. This duplicates logic unnecessarily (for enabling the workaround), and (ab)uses the id, which was intended to be specific to DT (since it is a DT property name).

We should split the matching from the particular workaround (and enabling thereof), so that we can go straight from ACPI match to workaround (without having to use the DT id in this manner), and don't have to duplicate the logic to enable the workaround.

I believe Marc is looking at some rework in this area which may enable this, so please wait for that to appear.

Thanks,
Mark.

#4 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

Quoted 41 lines · Mark Rutland
Quoted 40 lines · Hanjun Guo

From: Hanjun Guo <[email protected]>

Add hisilicon timer specific erratum fixes.

---
 drivers/clocksource/arm_arch_timer.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/clocksource/arm_arch_timer.c +19 -0
index 80d6f76..3e62a09 100644
@@ -1156,10 +1156,32 @@ struct gtdt_arch_timer_fixup {
 	void *context;
 };
 
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+static void __init hisi_erratum_workaroud_enable(void *context)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ool_workarounds); i++) {
+		if (!strcmp(context, ool_workarounds[i].id)) {
+			timer_unstable_counter_workaround = &ool_workarounds[i];
+			static_branch_enable(&arch_timer_read_ool_enabled);
+			pr_info("arch_timer: Enabling workaround for %s\n",
+				timer_unstable_counter_workaround->id);
+			break;
+		}
+	}
+}
+#endif
+
 /* note: this needs to be updated according to the doc of OEM ID
  * and TABLE ID for different board.
  */
 static struct gtdt_arch_timer_fixup arch_timer_quirks[] __initdata = {
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+	{"HISI  ", "HIP05   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
Quoted 8 lines

drivers/clocksource/arm_arch_timer.c struct gtdt_arch_timer_fixup { · line 1185

Quoted 4 lines
drivers/clocksource/arm_arch_timer.c +3 -0
+	{"HISI  ", "HIP06   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP07   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+#endif
 };

NAK. This duplicates logic unnecessarily (for enabling the workaround), and (ab)uses the id, which was intended to be specific to DT (since it is a DT property name).

Agreed, that's properly revolting.

Quoted 7 lines

We should split the matching from the particular workaround (and enabling thereof), so that we can go straight from ACPI match to workaround (without having to use the DT id in this manner), and don't have to duplicate the logic to enable the workaround.

I believe Marc is looking at some rework in this area which may enable this, so please wait for that to appear.

Yeah, I'm implementing a semi-flexible way to add new quirk types, and the last thing I want to see is two (or more) tables describing the same thing.

Thanks,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#5 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

Quoted 58 lines · Marc Zyngier
Quoted 41 lines · Mark Rutland
Quoted 40 lines · Hanjun Guo

From: Hanjun Guo <[email protected]>

Add hisilicon timer specific erratum fixes.

---
 drivers/clocksource/arm_arch_timer.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/clocksource/arm_arch_timer.c +19 -0
index 80d6f76..3e62a09 100644
@@ -1156,10 +1156,32 @@ struct gtdt_arch_timer_fixup {
 	void *context;
 };
 
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+static void __init hisi_erratum_workaroud_enable(void *context)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ool_workarounds); i++) {
+		if (!strcmp(context, ool_workarounds[i].id)) {
+			timer_unstable_counter_workaround = &ool_workarounds[i];
+			static_branch_enable(&arch_timer_read_ool_enabled);
+			pr_info("arch_timer: Enabling workaround for %s\n",
+				timer_unstable_counter_workaround->id);
+			break;
+		}
+	}
+}
+#endif
+
 /* note: this needs to be updated according to the doc of OEM ID
  * and TABLE ID for different board.
  */
 static struct gtdt_arch_timer_fixup arch_timer_quirks[] __initdata = {
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+	{"HISI  ", "HIP05   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
Quoted 8 lines

drivers/clocksource/arm_arch_timer.c struct gtdt_arch_timer_fixup { · line 1185

Quoted 4 lines
drivers/clocksource/arm_arch_timer.c +3 -0
+	{"HISI  ", "HIP06   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP07   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+#endif
 };

NAK. This duplicates logic unnecessarily (for enabling the workaround), and (ab)uses the id, which was intended to be specific to DT (since it is a DT property name).

Agreed, that's properly revolting.

Quoted 5 lines

We should split the matching from the particular workaround (and enabling thereof), so that we can go straight from ACPI match to workaround (without having to use the DT id in this manner), and don't have to duplicate the logic to enable the workaround.

Quoted 7 lines
Quoted 2 lines

I believe Marc is looking at some rework in this area which may enable this, so please wait for that to appear.

Yeah, I'm implementing a semi-flexible way to add new quirk types, and the last thing I want to see is two (or more) tables describing the same thing.

FYI, We have a similar requirement to enable a quirk on the GICv3 ITS driver. For that driver the current quirk framework relies on matching the IIDR, which is not properly populated for our hardware. So will this framework cover this/many/all drivers?

Shameer has prepared the patchset for this quirk - should it send it? It will be rejected for the same reason as this one, but at least it is more reference for this framework wishlist.

Cheers,
John

Quoted 4 lines

Thanks,

	M.
#6 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

Quoted 67 lines · John Garry
Quoted 58 lines · Marc Zyngier
Quoted 41 lines · Mark Rutland
Quoted 40 lines · Hanjun Guo

From: Hanjun Guo <[email protected]>

Add hisilicon timer specific erratum fixes.

---
 drivers/clocksource/arm_arch_timer.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/clocksource/arm_arch_timer.c +19 -0
index 80d6f76..3e62a09 100644
@@ -1156,10 +1156,32 @@ struct gtdt_arch_timer_fixup {
 	void *context;
 };
 
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+static void __init hisi_erratum_workaroud_enable(void *context)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ool_workarounds); i++) {
+		if (!strcmp(context, ool_workarounds[i].id)) {
+			timer_unstable_counter_workaround = &ool_workarounds[i];
+			static_branch_enable(&arch_timer_read_ool_enabled);
+			pr_info("arch_timer: Enabling workaround for %s\n",
+				timer_unstable_counter_workaround->id);
+			break;
+		}
+	}
+}
+#endif
+
 /* note: this needs to be updated according to the doc of OEM ID
  * and TABLE ID for different board.
  */
 static struct gtdt_arch_timer_fixup arch_timer_quirks[] __initdata = {
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+	{"HISI  ", "HIP05   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
Quoted 8 lines

drivers/clocksource/arm_arch_timer.c struct gtdt_arch_timer_fixup { · line 1185

Quoted 4 lines
drivers/clocksource/arm_arch_timer.c +3 -0
+	{"HISI  ", "HIP06   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP07   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+#endif
 };

NAK. This duplicates logic unnecessarily (for enabling the workaround), and (ab)uses the id, which was intended to be specific to DT (since it is a DT property name).

Agreed, that's properly revolting.

Quoted 5 lines

We should split the matching from the particular workaround (and enabling thereof), so that we can go straight from ACPI match to workaround (without having to use the DT id in this manner), and don't have to duplicate the logic to enable the workaround.

Quoted 7 lines
Quoted 2 lines

I believe Marc is looking at some rework in this area which may enable this, so please wait for that to appear.

Yeah, I'm implementing a semi-flexible way to add new quirk types, and the last thing I want to see is two (or more) tables describing the same thing.

Quoted 4 lines

FYI, We have a similar requirement to enable a quirk on the GICv3 ITS driver. For that driver the current quirk framework relies on matching the IIDR, which is not properly populated for our hardware. So will this framework cover this/many/all drivers?

Most probably not. Each driver has its own requirements, and it is unlikely that the timer's fit with the GIC's. But maybe we can use similar patterns.

Quoted 3 lines

Shameer has prepared the patchset for this quirk - should it send it? It will be rejected for the same reason as this one, but at least it is more reference for this framework wishlist.

Well, try and see it the other way around. If you don't send the patch, it can't be rejected! ;-) Now, if you're genuinely interested in finding out what I think of it, and possibly some advise on how to address the issue, then please post it.

Thanks,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#8 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

In reply to Marc Zyngier
Quoted 51 lines · Marc Zyngier
Quoted 41 lines · Mark Rutland
Quoted 40 lines · Hanjun Guo

From: Hanjun Guo <[email protected]>

Add hisilicon timer specific erratum fixes.

---
  drivers/clocksource/arm_arch_timer.c | 22 ++++++++++++++++++++++
  1 file changed, 22 insertions(+)
drivers/clocksource/arm_arch_timer.c +19 -0
index 80d6f76..3e62a09 100644
@@ -1156,10 +1156,32 @@ struct gtdt_arch_timer_fixup {
  	void *context;
  };
 
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+static void __init hisi_erratum_workaroud_enable(void *context)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ool_workarounds); i++) {
+		if (!strcmp(context, ool_workarounds[i].id)) {
+			timer_unstable_counter_workaround = &ool_workarounds[i];
+			static_branch_enable(&arch_timer_read_ool_enabled);
+			pr_info("arch_timer: Enabling workaround for %s\n",
+				timer_unstable_counter_workaround->id);
+			break;
+		}
+	}
+}
+#endif
+
  /* note: this needs to be updated according to the doc of OEM ID
   * and TABLE ID for different board.
   */
  static struct gtdt_arch_timer_fixup arch_timer_quirks[] __initdata = {
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+	{"HISI  ", "HIP05   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
Quoted 8 lines

drivers/clocksource/arm_arch_timer.c struct gtdt_arch_timer_fixup { · line 1185

Quoted 4 lines
drivers/clocksource/arm_arch_timer.c +3 -0
+	{"HISI  ", "HIP06   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP07   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+#endif
  };

NAK. This duplicates logic unnecessarily (for enabling the workaround), and (ab)uses the id, which was intended to be specific to DT (since it is a DT property name).

Quoted 1 line

Agreed, that's properly revolting.

I had a bad feeling about duplicating using of DT based ID string in ACPI world and it's confirmed :)

Quoted 6 lines
Quoted 6 lines

We should split the matching from the particular workaround (and enabling thereof), so that we can go straight from ACPI match to workaround (without having to use the DT id in this manner), and don't have to duplicate the logic to enable the workaround.

Quoted 6 lines
Quoted 2 lines

I believe Marc is looking at some rework in this area which may enable this, so please wait for that to appear.

Yeah, I'm implementing a semi-flexible way to add new quirk types, and the last thing I want to see is two (or more) tables describing the same thing.

Thank you for doing this, I will wait for your patches.

Hanjun

#7 lore raw

RE: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

In reply to Marc Zyngier
Quoted 107 lines

-----Original Message-----
From: Marc Zyngier [mailto:marc.zyngier at arm.com]
Sent: Tuesday, January 24, 2017 1:09 PM
To: John Garry; Mark Rutland; Guohanjun (Hanjun Guo)
Cc: Will Deacon; Daniel Lezcano; Rafael J. Wysocki; Lorenzo Pieralisi; Fu Wei; Dingtianhong; linux-acpi at vger.kernel.org; linux-arm- kernel at lists.infradead.org; Linuxarm; Hanjun Guo; Shameerali Kolothum Thodi
Subject: Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

Quoted 5 lines · John Garry
Quoted 4 lines · Marc Zyngier
Quoted 3 lines · Mark Rutland
Quoted 2 lines · Hanjun Guo

From: Hanjun Guo <[email protected]>

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Review

Quoted 8 lines

Add hisilicon timer specific erratum fixes.

---
 drivers/clocksource/arm_arch_timer.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
(quoted diff) +0 -0

b/drivers/clocksource/arm_arch_timer.c

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

index 80d6f76..3e62a09 100644

drivers/clocksource/arm_arch_timer.c +0 -0
@@ -1156,10 +1156,32 @@ struct gtdt_arch_timer_fixup {
 	void *context;
 };
 
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/clocksource/arm_arch_timer.c struct gtdt_arch_timer_fixup {

Quoted 8 lines
drivers/clocksource/arm_arch_timer.c +8 -0
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+static void __init hisi_erratum_workaroud_enable(void *context)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ool_workarounds); i++) {
+		if (!strcmp(context, ool_workarounds[i].id)) {
+			timer_unstable_counter_workaround =

&ool_workarounds[i];

Quoted 1 line
Quoted 1 line
Quoted 1 line

drivers/clocksource/arm_arch_timer.c struct gtdt_arch_timer_fixup { · line 1167

Quoted 1 line
drivers/clocksource/arm_arch_timer.c +1 -0
+
	static_branch_enable(&arch_timer_read_ool_enabled);
Quoted 1 line
Quoted 1 line
Quoted 1 line

drivers/clocksource/arm_arch_timer.c struct gtdt_arch_timer_fixup { · line 1168

Quoted 1 line
drivers/clocksource/arm_arch_timer.c +1 -0
+			pr_info("arch_timer: Enabling workaround for

%s\n",

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

drivers/clocksource/arm_arch_timer.c struct gtdt_arch_timer_fixup {

Quoted 11 lines
drivers/clocksource/arm_arch_timer.c +7 -0
+				timer_unstable_counter_workaround->id);
+			break;
+		}
+	}
+}
+#endif
+
 /* note: this needs to be updated according to the doc of OEM ID
  * and TABLE ID for different board.
  */
 static struct gtdt_arch_timer_fixup arch_timer_quirks[]

__initdata = {

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

drivers/clocksource/arm_arch_timer.c struct gtdt_arch_timer_fixup { · line 1181

Quoted 2 lines
drivers/clocksource/arm_arch_timer.c +2 -0
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+	{"HISI  ", "HIP05   ", 0, &hisi_erratum_workaroud_enable,

"hisilicon,erratum-161010101"},

Quoted 1 line
Quoted 1 line
Quoted 1 line

drivers/clocksource/arm_arch_timer.c struct gtdt_arch_timer_fixup { · line 1182

Quoted 1 line
drivers/clocksource/arm_arch_timer.c +1 -0
+	{"HISI  ", "HIP06   ", 0, &hisi_erratum_workaroud_enable,

"hisilicon,erratum-161010101"},

Quoted 1 line
Quoted 1 line
Quoted 1 line

drivers/clocksource/arm_arch_timer.c struct gtdt_arch_timer_fixup { · line 1183

Quoted 1 line
drivers/clocksource/arm_arch_timer.c +1 -0
+	{"HISI  ", "HIP07   ", 0, &hisi_erratum_workaroud_enable,

"hisilicon,erratum-161010101"},

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

drivers/clocksource/arm_arch_timer.c struct gtdt_arch_timer_fixup { · line 1185

Quoted 2 lines
drivers/clocksource/arm_arch_timer.c +1 -0
+#endif
 };

NAK. This duplicates logic unnecessarily (for enabling the

workaround),

Quoted 1 line
Quoted 1 line
Quoted 1 line

and (ab)uses the id, which was intended to be specific to DT (since

it

Quoted 7 lines
Quoted 7 lines
Quoted 1 line

is a DT property name).

Agreed, that's properly revolting.

Quoted 3 lines

We should split the matching from the particular workaround (and enabling thereof), so that we can go straight from ACPI match to workaround (without having to use the DT id in this manner), and

don't

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

have to duplicate the logic to enable the workaround.

I believe Marc is looking at some rework in this area which may

enable

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

this, so please wait for that to appear.

Yeah, I'm implementing a semi-flexible way to add new quirk types,

and

Quoted 1 line
Quoted 1 line

the last thing I want to see is two (or more) tables describing the

same

Quoted 5 lines
Quoted 2 lines

thing.

FYI, We have a similar requirement to enable a quirk on the GICv3 ITS driver. For that driver the current quirk framework relies on

matching

Quoted 1 line

the IIDR, which is not properly populated for our hardware. So will

this

Quoted 1 line

framework cover this/many/all drivers?

Most probably not. Each driver has its own requirements, and it is unlikely that the timer's fit with the GIC's. But maybe we can use similar patterns.

Quoted 1 line

Shameer has prepared the patchset for this quirk - should it send it?

It

Quoted 8 lines
Quoted 2 lines

will be rejected for the same reason as this one, but at least it is more reference for this framework wishlist.

Well, try and see it the other way around. If you don't send the patch, it can't be rejected! ;-) Now, if you're genuinely interested in finding
out what I think of it, and possibly some advise on how to address the issue, then please post it.

Sure :).

Thanks,
Shameer

#25 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

In reply to Mark Rutland
Quoted 50 lines · Mark Rutland
Quoted 34 lines · Hanjun Guo

From: Hanjun Guo <[email protected]>

Add hisilicon timer specific erratum fixes.

---
  drivers/clocksource/arm_arch_timer.c | 22 ++++++++++++++++++++++
  1 file changed, 22 insertions(+)
drivers/clocksource/arm_arch_timer.c +17 -0
index 80d6f76..3e62a09 100644
@@ -1156,10 +1156,32 @@ struct gtdt_arch_timer_fixup {
  	void *context;
  };
 
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+static void __init hisi_erratum_workaroud_enable(void *context)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ool_workarounds); i++) {
+		if (!strcmp(context, ool_workarounds[i].id)) {
+			timer_unstable_counter_workaround = &ool_workarounds[i];
+			static_branch_enable(&arch_timer_read_ool_enabled);
+			pr_info("arch_timer: Enabling workaround for %s\n",
+				timer_unstable_counter_workaround->id);
+			break;
+		}
+	}
+}
+#endif
+

drivers/clocksource/arm_arch_timer.c struct gtdt_arch_timer_fixup { · line 1185

Quoted 10 lines
drivers/clocksource/arm_arch_timer.c +5 -0
  /* note: this needs to be updated according to the doc of OEM ID
   * and TABLE ID for different board.
   */
  static struct gtdt_arch_timer_fixup arch_timer_quirks[] __initdata = {
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+	{"HISI  ", "HIP05   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP06   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP07   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+#endif
  };

NAK. This duplicates logic unnecessarily (for enabling the workaround), and (ab)uses the id, which was intended to be specific to DT (since it is a DT property name).

Quoted 4 lines

We should split the matching from the particular workaround (and enabling thereof), so that we can go straight from ACPI match to workaround (without having to use the DT id in this manner), and don't have to duplicate the logic to enable the workaround.

maybe we can add ACPI quirk matching information in struct arch_timer_erratum_workaround, then reuse the code for both ACPI and DT, but it needs further cleanup to support multi platforms sharing the same erratum in ACPI way.

Thanks
Hanjun

author
#9 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

In reply to Marc Zyngier

Hi Marc,

Quoted 56 lines · Marc Zyngier
Quoted 40 lines · Mark Rutland
Quoted 39 lines · Hanjun Guo

From: Hanjun Guo <[email protected]>

Add hisilicon timer specific erratum fixes.

---
 drivers/clocksource/arm_arch_timer.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/clocksource/arm_arch_timer.c +18 -0
index 80d6f76..3e62a09 100644
@@ -1156,10 +1156,32 @@ struct gtdt_arch_timer_fixup {
 	void *context;
 };
 
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+static void __init hisi_erratum_workaroud_enable(void *context)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ool_workarounds); i++) {
+		if (!strcmp(context, ool_workarounds[i].id)) {
+			timer_unstable_counter_workaround = &ool_workarounds[i];
+			static_branch_enable(&arch_timer_read_ool_enabled);
+			pr_info("arch_timer: Enabling workaround for %s\n",
+				timer_unstable_counter_workaround->id);
+			break;
+		}
+	}
+}
+#endif
+
 /* note: this needs to be updated according to the doc of OEM ID
  * and TABLE ID for different board.
  */
 static struct gtdt_arch_timer_fixup arch_timer_quirks[] __initdata = {
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
Quoted 8 lines

drivers/clocksource/arm_arch_timer.c struct gtdt_arch_timer_fixup { · line 1185

Quoted 5 lines
drivers/clocksource/arm_arch_timer.c +4 -0
+	{"HISI  ", "HIP05   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP06   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP07   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+#endif
 };

NAK. This duplicates logic unnecessarily (for enabling the workaround), and (ab)uses the id, which was intended to be specific to DT (since it is a DT property name).

Agreed, that's properly revolting.

Quoted 5 lines

We should split the matching from the particular workaround (and enabling thereof), so that we can go straight from ACPI match to workaround (without having to use the DT id in this manner), and don't have to duplicate the logic to enable the workaround.

Quoted 5 lines
Quoted 2 lines

I believe Marc is looking at some rework in this area which may enable this, so please wait for that to appear.

Yeah, I'm implementing a semi-flexible way to add new quirk types, and the last thing I want to see is two (or more) tables describing the same thing.

Kindly ping, if you have patches in hand, I can test against our platforms, thank you very much.

Best Regards
Hanjun

#10 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

Quoted 59 lines · Hanjun Guo

Hi Marc,

Quoted 56 lines · Marc Zyngier
Quoted 40 lines · Mark Rutland
Quoted 39 lines · Hanjun Guo

From: Hanjun Guo <[email protected]>

Add hisilicon timer specific erratum fixes.

---
 drivers/clocksource/arm_arch_timer.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/clocksource/arm_arch_timer.c +18 -0
index 80d6f76..3e62a09 100644
@@ -1156,10 +1156,32 @@ struct gtdt_arch_timer_fixup {
 	void *context;
 };
 
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+static void __init hisi_erratum_workaroud_enable(void *context)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ool_workarounds); i++) {
+		if (!strcmp(context, ool_workarounds[i].id)) {
+			timer_unstable_counter_workaround = &ool_workarounds[i];
+			static_branch_enable(&arch_timer_read_ool_enabled);
+			pr_info("arch_timer: Enabling workaround for %s\n",
+				timer_unstable_counter_workaround->id);
+			break;
+		}
+	}
+}
+#endif
+
 /* note: this needs to be updated according to the doc of OEM ID
  * and TABLE ID for different board.
  */
 static struct gtdt_arch_timer_fixup arch_timer_quirks[] __initdata = {
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
Quoted 8 lines

drivers/clocksource/arm_arch_timer.c struct gtdt_arch_timer_fixup { · line 1185

Quoted 5 lines
drivers/clocksource/arm_arch_timer.c +4 -0
+	{"HISI  ", "HIP05   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP06   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP07   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+#endif
 };

NAK. This duplicates logic unnecessarily (for enabling the workaround), and (ab)uses the id, which was intended to be specific to DT (since it is a DT property name).

Agreed, that's properly revolting.

Quoted 5 lines

We should split the matching from the particular workaround (and enabling thereof), so that we can go straight from ACPI match to workaround (without having to use the DT id in this manner), and don't have to duplicate the logic to enable the workaround.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I believe Marc is looking at some rework in this area which may enable this, so please wait for that to appear.

Yeah, I'm implementing a semi-flexible way to add new quirk types, and the last thing I want to see is two (or more) tables describing the same thing.

Kindly ping, if you have patches in hand, I can test against our platforms, thank you very much.

Any progress on this? I'm not a big fan of stalling erratum fixes upstream because of potential future refactoring.

Alex

#11 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

On Thu, Feb 16, 2017 at 09:42:11AM +0100, Alexander Graf wrote:

[ ... ]

Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I believe Marc is looking at some rework in this area which may enable this, so please wait for that to appear.

Yeah, I'm implementing a semi-flexible way to add new quirk types, and the last thing I want to see is two (or more) tables describing the same thing.

Kindly ping, if you have patches in hand, I can test against our platforms, thank you very much.

Any progress on this? I'm not a big fan of stalling erratum fixes upstream because of potential future refactoring.

The fix is in the tip tree, soon in v4.11-rc1 when the merge will be finished.

http://goo.gl/x90qwE
http://goo.gl/asCBBD

-- Daniel

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#12 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

Quoted 13 lines · Daniel Lezcano

On Thu, Feb 16, 2017 at 09:42:11AM +0100, Alexander Graf wrote:

[ ... ]

Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I believe Marc is looking at some rework in this area which may enable this, so please wait for that to appear.

Yeah, I'm implementing a semi-flexible way to add new quirk types, and the last thing I want to see is two (or more) tables describing the same thing.

Kindly ping, if you have patches in hand, I can test against our platforms, thank you very much.

Quoted 7 lines
Quoted 2 lines

Any progress on this? I'm not a big fan of stalling erratum fixes upstream because of potential future refactoring.

The fix is in the tip tree, soon in v4.11-rc1 when the merge will be finished.

http://goo.gl/x90qwE
http://goo.gl/asCBBD

Oh, I missed that. Sorry for the fuss :).

Alex

#13 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

Quoted 21 lines · Alexander Graf
Quoted 18 lines · Daniel Lezcano

On Thu, Feb 16, 2017 at 09:42:11AM +0100, Alexander Graf wrote:

[ ... ]

Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I believe Marc is looking at some rework in this area which may enable this, so please wait for that to appear.

Yeah, I'm implementing a semi-flexible way to add new quirk types, and the last thing I want to see is two (or more) tables describing the same thing.

Kindly ping, if you have patches in hand, I can test against our platforms, thank you very much.

Any progress on this? I'm not a big fan of stalling erratum fixes upstream because of potential future refactoring.

The fix is in the tip tree, soon in v4.11-rc1 when the merge will be finished.

Quoted 8 lines
Quoted 2 lines

http://goo.gl/x90qwE
http://goo.gl/asCBBD

Oh, I missed that. Sorry for the fuss :).

Alex

Hi, I thinks the tip tree is only applied the erratum for DT, not for ACPI, the patch for ACPI is not applied yet, so the work isn't finished. o<o<

Thanks
Ding

Quoted 7 lines

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

.

author
#16 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

In reply to Daniel Lezcano

Hi Daniel,

Quoted 9 lines · Daniel Lezcano

On Thu, Feb 16, 2017 at 09:42:11AM +0100, Alexander Graf wrote:

[ ... ]

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

I believe Marc is looking at some rework in this area which may enable this, so please wait for that to appear.

Yeah, I'm implementing a semi-flexible way to add new quirk types, and the last thing I want to see is two (or more) tables describing the same thing.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Kindly ping, if you have patches in hand, I can test against our platforms, thank you very much.

Any progress on this? I'm not a big fan of stalling erratum fixes upstream because of potential future refactoring.

The fix is in the tip tree, soon in v4.11-rc1 when the merge will be finished.

http://goo.gl/x90qwE
http://goo.gl/asCBBD

I think it's the erratum core code and the device tree support are merged by you, not the ACPI support in this patch set, did I miss something?

Thanks
Hanjun

#14 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

In reply to Ding Tianhong
Quoted 21 lines · Ding Tianhong
Quoted 19 lines · Alexander Graf
Quoted 17 lines · Daniel Lezcano

On Thu, Feb 16, 2017 at 09:42:11AM +0100, Alexander Graf wrote:

[ ... ]

Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I believe Marc is looking at some rework in this area which may enable this, so please wait for that to appear.

Yeah, I'm implementing a semi-flexible way to add new quirk types, and the last thing I want to see is two (or more) tables describing the same thing.

Kindly ping, if you have patches in hand, I can test against our platforms, thank you very much.

Any progress on this? I'm not a big fan of stalling erratum fixes upstream because of potential future refactoring.

The fix is in the tip tree, soon in v4.11-rc1 when the merge will be finished.

http://goo.gl/x90qwE
http://goo.gl/asCBBD

Quoted 7 lines
Quoted 5 lines

Oh, I missed that. Sorry for the fuss :).

Alex

Hi, I thinks the tip tree is only applied the erratum for DT, not for ACPI, the patch for ACPI is not applied yet, so the work isn't finished. ??

Yes, initial thread was about ACPI part. I think Alex was asking about that.

Quoted 15 lines

Thanks
Ding

Quoted 7 lines

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

.

.

Signature · 11 lines
Thanks and Regards
Sanil.
"Lets make things simple and better, today, tomorrow and always!"
www.huawei.com , www.hisilicon.com
-----------------------------------
This e-mail and its attachments contain confidential information from HUAWEI, which
is intended only for the person or entity whose address is listed above. Any use of
the information contained herein in any way (including, but not limited to, total
or partial disclosure, reproduction, or dissemination) by persons other than the
intended recipient(s) is prohibited. If you receive this e-mail in error, please
notify the sender by phone or email immediately and delete it!
#15 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

Quoted 31 lines · Sanil Kumar
Quoted 30 lines · Ding Tianhong
Quoted 28 lines · Alexander Graf
Quoted 15 lines · Daniel Lezcano

On Thu, Feb 16, 2017 at 09:42:11AM +0100, Alexander Graf wrote:

[ ... ]

Quoted 11 lines
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines

I believe Marc is looking at some rework in this area which may enable
this, so please wait for that to appear.

Yeah, I'm implementing a semi-flexible way to add new quirk types, and
the last thing I want to see is two (or more) tables describing the same
thing.

Kindly ping, if you have patches in hand, I can test against our platforms,
thank you very much.

Quoted 8 lines
Quoted 3 lines

Any progress on this? I'm not a big fan of stalling erratum fixes upstream
because of potential future refactoring.

The fix is in the tip tree, soon in v4.11-rc1 when the merge will be finished.

http://goo.gl/x90qwE
http://goo.gl/asCBBD

Oh, I missed that. Sorry for the fuss :).

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Alex

Hi, I thinks the tip tree is only applied the erratum for DT, not for ACPI, the patch
for ACPI is not applied yet, so the work isn't finished. ??

Yes, initial thread was about ACPI part. I think Alex was asking about that.

Ah yes. Indeed.

Thanks.

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#17 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

In reply to Hanjun Guo
Quoted 59 lines · Hanjun Guo

Hi Marc,

Quoted 56 lines · Marc Zyngier
Quoted 40 lines · Mark Rutland
Quoted 39 lines · Hanjun Guo

From: Hanjun Guo <[email protected]>

Add hisilicon timer specific erratum fixes.

---
 drivers/clocksource/arm_arch_timer.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/clocksource/arm_arch_timer.c +18 -0
index 80d6f76..3e62a09 100644
@@ -1156,10 +1156,32 @@ struct gtdt_arch_timer_fixup {
 	void *context;
 };
 
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+static void __init hisi_erratum_workaroud_enable(void *context)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ool_workarounds); i++) {
+		if (!strcmp(context, ool_workarounds[i].id)) {
+			timer_unstable_counter_workaround = &ool_workarounds[i];
+			static_branch_enable(&arch_timer_read_ool_enabled);
+			pr_info("arch_timer: Enabling workaround for %s\n",
+				timer_unstable_counter_workaround->id);
+			break;
+		}
+	}
+}
+#endif
+
 /* note: this needs to be updated according to the doc of OEM ID
  * and TABLE ID for different board.
  */
 static struct gtdt_arch_timer_fixup arch_timer_quirks[] __initdata = {
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
Quoted 8 lines

drivers/clocksource/arm_arch_timer.c struct gtdt_arch_timer_fixup { · line 1185

Quoted 5 lines
drivers/clocksource/arm_arch_timer.c +4 -0
+	{"HISI  ", "HIP05   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP06   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP07   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+#endif
 };

NAK. This duplicates logic unnecessarily (for enabling the workaround), and (ab)uses the id, which was intended to be specific to DT (since it is a DT property name).

Agreed, that's properly revolting.

Quoted 5 lines

We should split the matching from the particular workaround (and enabling thereof), so that we can go straight from ACPI match to workaround (without having to use the DT id in this manner), and don't have to duplicate the logic to enable the workaround.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I believe Marc is looking at some rework in this area which may enable this, so please wait for that to appear.

Yeah, I'm implementing a semi-flexible way to add new quirk types, and the last thing I want to see is two (or more) tables describing the same thing.

Kindly ping, if you have patches in hand, I can test against our platforms, thank you very much.

I'm planning to make something available next week. I don't think there is any sense of urgency anyway (it is not like we've broken something, as this platform has always been defective).

Thanks,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny.
#18 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

In reply to Hanjun Guo
Quoted 59 lines · Hanjun Guo

Hi Marc,

Quoted 56 lines · Marc Zyngier
Quoted 40 lines · Mark Rutland
Quoted 39 lines · Hanjun Guo

From: Hanjun Guo <[email protected]>

Add hisilicon timer specific erratum fixes.

---
 drivers/clocksource/arm_arch_timer.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/clocksource/arm_arch_timer.c +18 -0
index 80d6f76..3e62a09 100644
@@ -1156,10 +1156,32 @@ struct gtdt_arch_timer_fixup {
 	void *context;
 };
 
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+static void __init hisi_erratum_workaroud_enable(void *context)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ool_workarounds); i++) {
+		if (!strcmp(context, ool_workarounds[i].id)) {
+			timer_unstable_counter_workaround = &ool_workarounds[i];
+			static_branch_enable(&arch_timer_read_ool_enabled);
+			pr_info("arch_timer: Enabling workaround for %s\n",
+				timer_unstable_counter_workaround->id);
+			break;
+		}
+	}
+}
+#endif
+
 /* note: this needs to be updated according to the doc of OEM ID
  * and TABLE ID for different board.
  */
 static struct gtdt_arch_timer_fixup arch_timer_quirks[] __initdata = {
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
Quoted 8 lines

drivers/clocksource/arm_arch_timer.c struct gtdt_arch_timer_fixup { · line 1185

Quoted 5 lines
drivers/clocksource/arm_arch_timer.c +4 -0
+	{"HISI  ", "HIP05   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP06   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP07   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+#endif
 };

NAK. This duplicates logic unnecessarily (for enabling the workaround), and (ab)uses the id, which was intended to be specific to DT (since it is a DT property name).

Agreed, that's properly revolting.

Quoted 5 lines

We should split the matching from the particular workaround (and enabling thereof), so that we can go straight from ACPI match to workaround (without having to use the DT id in this manner), and don't have to duplicate the logic to enable the workaround.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I believe Marc is looking at some rework in this area which may enable this, so please wait for that to appear.

Yeah, I'm implementing a semi-flexible way to add new quirk types, and the last thing I want to see is two (or more) tables describing the same thing.

Kindly ping, if you have patches in hand, I can test against our platforms, thank you very much.

I've just pushed out a branch based on arm64/for-next/core, plus the HiSi timer workaround:

https://git.kernel.org/cgit/linux/kernel/git/maz/arm-platforms.git/log/?h=timers/errata-rework

I'll post the patches for review once the merge window is open, but hopefully that should get you going.

Thanks,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
author
#19 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

Hi Marc,

Quoted 67 lines · Marc Zyngier
Quoted 59 lines · Hanjun Guo

Hi Marc,

Quoted 56 lines · Marc Zyngier
Quoted 40 lines · Mark Rutland
Quoted 39 lines · Hanjun Guo

From: Hanjun Guo <[email protected]>

Add hisilicon timer specific erratum fixes.

---
 drivers/clocksource/arm_arch_timer.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/clocksource/arm_arch_timer.c +18 -0
index 80d6f76..3e62a09 100644
@@ -1156,10 +1156,32 @@ struct gtdt_arch_timer_fixup {
 	void *context;
 };
 
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+static void __init hisi_erratum_workaroud_enable(void *context)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ool_workarounds); i++) {
+		if (!strcmp(context, ool_workarounds[i].id)) {
+			timer_unstable_counter_workaround = &ool_workarounds[i];
+			static_branch_enable(&arch_timer_read_ool_enabled);
+			pr_info("arch_timer: Enabling workaround for %s\n",
+				timer_unstable_counter_workaround->id);
+			break;
+		}
+	}
+}
+#endif
+
 /* note: this needs to be updated according to the doc of OEM ID
  * and TABLE ID for different board.
  */
 static struct gtdt_arch_timer_fixup arch_timer_quirks[] __initdata = {
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
Quoted 8 lines

drivers/clocksource/arm_arch_timer.c struct gtdt_arch_timer_fixup { · line 1185

Quoted 5 lines
drivers/clocksource/arm_arch_timer.c +4 -0
+	{"HISI  ", "HIP05   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP06   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP07   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+#endif
 };

NAK. This duplicates logic unnecessarily (for enabling the workaround), and (ab)uses the id, which was intended to be specific to DT (since it is a DT property name).

Agreed, that's properly revolting.

Quoted 5 lines

We should split the matching from the particular workaround (and enabling thereof), so that we can go straight from ACPI match to workaround (without having to use the DT id in this manner), and don't have to duplicate the logic to enable the workaround.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I believe Marc is looking at some rework in this area which may enable this, so please wait for that to appear.

Yeah, I'm implementing a semi-flexible way to add new quirk types, and the last thing I want to see is two (or more) tables describing the same thing.

Kindly ping, if you have patches in hand, I can test against our platforms, thank you very much.

Quoted 7 lines

I've just pushed out a branch based on arm64/for-next/core, plus the HiSi timer workaround:

https://git.kernel.org/cgit/linux/kernel/git/maz/arm-platforms.git/log/?h=timers/errata-rework

I'll post the patches for review once the merge window is open, but hopefully that should get you going.

Thank you very much! I prepared an ACPI patch based on your branch, I was trying to reuse the "const void *id" for ACPI as well but we need to match the oem_id, oem_table_id and oem_revision in GTDT table, so I introduced new matching information for ACPI, please take a look if it's OK.

commit 02d531ae4a88c483db849a611bd9bf7c39d2e1bf

Author: Hanjun Guo <[email protected]>
Date:   Tue Feb 21 15:17:14 2017 +0800

arm64: arch_timer: enable the erratums in ACPI way

Match OEM information which are oem_id, oem_table_id and oem_revision to enable the erratum for specific platforms.

---
 arch/arm64/include/asm/arch_timer.h  |  7 +++++++
 drivers/clocksource/arm_arch_timer.c | 31 +++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)
arch/arm64/include/asm/arch_timer.h +7 -0
index 1595134..79d033c 100644
@@ -22,6 +22,7 @@
 #include <asm/barrier.h>
 #include <asm/sysreg.h>
 
+#include <linux/acpi.h>
 #include <linux/bug.h>
 #include <linux/init.h>
 #include <linux/jump_label.h>
@@ -42,6 +43,7 @@ enum arch_timer_erratum_match_type {
        ate_match_dt,
        ate_match_global_cap_id,
        ate_match_local_cap_id,
+ ate_match_acpi,
 };
 
 struct clock_event_device;
@@ -49,6 +51,11 @@ enum arch_timer_erratum_match_type {
 struct arch_timer_erratum_workaround {
        enum arch_timer_erratum_match_type match_type;
        const void *id;         /* Indicate the Erratum ID */
+#ifdef CONFIG_ACPI
+ char oem_id[ACPI_OEM_ID_SIZE + 1];
+ char oem_table_id[ACPI_OEM_TABLE_ID_SIZE + 1];
+ u32 oem_revision;
+#endif
        const char *desc_str;
        u32 (*read_cntp_tval_el0)(void);
        u32 (*read_cntv_tval_el0)(void);
drivers/clocksource/arm_arch_timer.c +0 -0
index bbd9361..82ff6e4 100644
@@ -363,6 +363,32 @@ bool arch_timer_check_dt_erratum(const struct arch_timer_erratum_workaround

*wa,

        return of_property_read_bool(np, wa->id);

}

+#ifdef CONFIG_ACPI
+static bool
+arch_timer_check_acpi_erratum(const struct arch_timer_erratum_workaround *wa,
+ const void *arg)
+{
+ const struct acpi_table_header *table = arg;
+
+ if (!wa->oem_id || !wa->oem_table_id)
+ return false;
+
+ if (!memcmp(wa->oem_id, table->oem_id, ACPI_OEM_ID_SIZE) &&
+ !memcmp(wa->oem_table_id, table->oem_table_id,
+ ACPI_OEM_TABLE_ID_SIZE) &&
+ wa->oem_revision == table->oem_revision) {
+ return true;
+ }
+
+ return false;
+}
+#else
+static inline bool
+arch_timer_check_acpi_erratum(const struct arch_timer_erratum_workaround *wa,
+ const void *arg)
+{ return false; }
+#endif
+
static
bool arch_timer_check_global_cap_erratum(const struct arch_timer_erratum_workaround *wa,
const void *arg)
@@ -440,6 +466,9 @@ static void arch_timer_check_ool_workaround(enum arch_timer_erratum_match_typ e t

                match_fn = arch_timer_check_local_cap_erratum;
                local = true;
                break;
+ case ate_match_acpi:
+         match_fn = arch_timer_check_acpi_erratum;
+         break;
        }

        wa = arch_timer_iterate_errata(type, match_fn, arg);
@@ -1284,6 +1313,8 @@ static int __init arch_timer_acpi_init(struct acpi_table_header *table)
        /* Check for globally applicable workarounds */
        arch_timer_check_ool_workaround(ate_match_global_cap_id, NULL);

+ arch_timer_check_ool_workaround(ate_match_acpi, table); +

        arch_timer_init();
        return 0;

}

And I got compile errors for this patch [1], seems "#include <linux/acpi.h>" in arch/arm64/include/asm/arch_timer.h triggers the problem of head file inclusions (too early to include <linux/sched.h>?), I'm looking into it, if you can help to take a look too, that will be great :)

Thanks
Hanjun

[1]:
In file included from ./arch/arm64/include/asm/spinlock.h:21:0,

                 from ./include/linux/spinlock.h:87,
                 from ./include/linux/seqlock.h:35,
                 from ./include/linux/time.h:5,
                 from ./include/uapi/linux/timex.h:56,
                 from ./include/linux/timex.h:56,
                 from ./include/linux/sched.h:19,
                 from arch/arm64/kernel/asm-offsets.c:21:
./arch/arm64/include/asm/compat.h: In function ?arch_compat_alloc_user_space?:
./arch/arm64/include/asm/processor.h:157:11: error: implicit declaration of function ?task_stack_page? [-Werror=implicit-function-declaration]
  ((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1)
           ^
./arch/arm64/include/asm/compat.h:236:57: note: in expansion of macro ?task_pt_regs?
 #define compat_user_stack_pointer() (user_stack_pointer(task_pt_regs(current)))
                                                         ^
./arch/arm64/include/asm/compat.h:240:24: note: in expansion of macro ?compat_user_stack_pointer?
  return (void __user *)compat_user_stack_pointer() - len;
                        ^

./arch/arm64/include/asm/processor.h:157:3: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1)
^
./arch/arm64/include/asm/compat.h:236:57: note: in expansion of macro ?task_pt_regs?

 #define compat_user_stack_pointer() (user_stack_pointer(task_pt_regs(current)))
                                                         ^
./arch/arm64/include/asm/compat.h:240:24: note: in expansion of macro ?compat_user_stack_pointer?
  return (void __user *)compat_user_stack_pointer() - len;
                        ^
In file included from ./include/linux/kernel.h:13:0,
                 from ./include/linux/sched.h:17,
                 from arch/arm64/kernel/asm-offsets.c:21:
./include/linux/ratelimit.h: In function ?ratelimit_state_exit?:
./include/linux/ratelimit.h:62:11: error: dereferencing pointer to incomplete type
    current->comm, rs->missed);
           ^
./include/linux/printk.h:294:37: note: in definition of macro ?pr_warning?
  printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
                                     ^

./include/linux/ratelimit.h:61:3: note: in expansion of macro ?pr_warn?
pr_warn("%s: %d output lines suppressed due to ratelimiting\n", ^
In file included from ./arch/arm64/include/asm/arch_timer.h:25:0,

                 from ./arch/arm64/include/asm/timex.h:19,
                 from ./include/linux/timex.h:65,
                 from ./include/linux/sched.h:19,
                 from arch/arm64/kernel/asm-offsets.c:21:
./include/linux/acpi.h: At top level:
./include/linux/acpi.h:604:37: warning: ?struct arch_timer_mem? declared inside parameter list
 int acpi_arch_timer_mem_init(struct arch_timer_mem *data, int *timer_count);
                                     ^

./include/linux/acpi.h:604:37: warning: its scope is only this definition or declaration, which is probably not what you want In file included from arch/arm64/kernel/asm-offsets.c:21:0:
./include/linux/sched.h:3190:21: error: conflicting types for ?task_stack_page?
static inline void *task_stack_page(const struct task_struct *task)

                     ^
In file included from ./arch/arm64/include/asm/spinlock.h:21:0,
                 from ./include/linux/spinlock.h:87,
                 from ./include/linux/seqlock.h:35,
                 from ./include/linux/time.h:5,
                 from ./include/uapi/linux/timex.h:56,
                 from ./include/linux/timex.h:56,
                 from ./include/linux/sched.h:19,
                 from arch/arm64/kernel/asm-offsets.c:21:
./arch/arm64/include/asm/processor.h:157:40: note: previous implicit declaration of ?task_stack_page? was here
  ((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1)
                                        ^
./arch/arm64/include/asm/compat.h:236:57: note: in expansion of macro ?task_pt_regs?
 #define compat_user_stack_pointer() (user_stack_pointer(task_pt_regs(current)))
                                                         ^
./arch/arm64/include/asm/compat.h:240:24: note: in expansion of macro ?compat_user_stack_pointer?
  return (void __user *)compat_user_stack_pointer() - len;
                        ^

cc1: some warnings being treated as errors make[1]: *** [arch/arm64/kernel/asm-offsets.s] Error 1
make: *** [prepare0] Error 2

#24 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

In reply to Marc Zyngier
Quoted 72 lines · Marc Zyngier
Quoted 59 lines · Hanjun Guo

Hi Marc,

Quoted 56 lines · Marc Zyngier
Quoted 40 lines · Mark Rutland
Quoted 39 lines · Hanjun Guo

From: Hanjun Guo <[email protected]>

Add hisilicon timer specific erratum fixes.

---
 drivers/clocksource/arm_arch_timer.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/clocksource/arm_arch_timer.c +18 -0
index 80d6f76..3e62a09 100644
@@ -1156,10 +1156,32 @@ struct gtdt_arch_timer_fixup {
 	void *context;
 };
 
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
+static void __init hisi_erratum_workaroud_enable(void *context)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ool_workarounds); i++) {
+		if (!strcmp(context, ool_workarounds[i].id)) {
+			timer_unstable_counter_workaround = &ool_workarounds[i];
+			static_branch_enable(&arch_timer_read_ool_enabled);
+			pr_info("arch_timer: Enabling workaround for %s\n",
+				timer_unstable_counter_workaround->id);
+			break;
+		}
+	}
+}
+#endif
+
 /* note: this needs to be updated according to the doc of OEM ID
  * and TABLE ID for different board.
  */
 static struct gtdt_arch_timer_fixup arch_timer_quirks[] __initdata = {
+#ifdef CONFIG_HISILICON_ERRATUM_161010101
Quoted 8 lines

drivers/clocksource/arm_arch_timer.c struct gtdt_arch_timer_fixup { · line 1185

Quoted 5 lines
drivers/clocksource/arm_arch_timer.c +4 -0
+	{"HISI  ", "HIP05   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP06   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+	{"HISI  ", "HIP07   ", 0, &hisi_erratum_workaroud_enable, "hisilicon,erratum-161010101"},
+#endif
 };

NAK. This duplicates logic unnecessarily (for enabling the workaround), and (ab)uses the id, which was intended to be specific to DT (since it is a DT property name).

Agreed, that's properly revolting.

Quoted 5 lines

We should split the matching from the particular workaround (and enabling thereof), so that we can go straight from ACPI match to workaround (without having to use the DT id in this manner), and don't have to duplicate the logic to enable the workaround.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I believe Marc is looking at some rework in this area which may enable this, so please wait for that to appear.

Yeah, I'm implementing a semi-flexible way to add new quirk types, and the last thing I want to see is two (or more) tables describing the same thing.

Kindly ping, if you have patches in hand, I can test against our platforms, thank you very much.

I've just pushed out a branch based on arm64/for-next/core, plus the HiSi timer workaround:

Quoted 7 lines

https://git.kernel.org/cgit/linux/kernel/git/maz/arm-platforms.git/log/?h=timers/errata-rework

I'll post the patches for review once the merge window is open, but hopefully that should get you going.

Thanks,

Test this branch and could work fine for Hisilicon board, great work !

Still need time to review the details, but this should not seem very difficult. :)

Thanks
Ding

Quoted 2 lines
	M.
#20 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

In reply to Hanjun Guo
Quoted 1 line · Hanjun Guo

Hi Marc,

[...]

Quoted 111 lines

Thank you very much! I prepared an ACPI patch based on your branch, I was trying to reuse the "const void *id" for ACPI as well but we need to match the oem_id, oem_table_id and oem_revision in GTDT table, so I introduced new matching information for ACPI, please take a look if it's OK.

commit 02d531ae4a88c483db849a611bd9bf7c39d2e1bf

Author: Hanjun Guo <[email protected]>
Date:   Tue Feb 21 15:17:14 2017 +0800

arm64: arch_timer: enable the erratums in ACPI way

Match OEM information which are oem_id, oem_table_id and oem_revision to enable the erratum for specific platforms.

---
 arch/arm64/include/asm/arch_timer.h  |  7 +++++++
 drivers/clocksource/arm_arch_timer.c | 31 +++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)
arch/arm64/include/asm/arch_timer.h +7 -0
index 1595134..79d033c 100644
@@ -22,6 +22,7 @@
 #include <asm/barrier.h>
 #include <asm/sysreg.h>
 
+#include <linux/acpi.h>
 #include <linux/bug.h>
 #include <linux/init.h>
 #include <linux/jump_label.h>
@@ -42,6 +43,7 @@ enum arch_timer_erratum_match_type {
        ate_match_dt,
        ate_match_global_cap_id,
        ate_match_local_cap_id,
+ ate_match_acpi,
 };
 
 struct clock_event_device;
@@ -49,6 +51,11 @@ enum arch_timer_erratum_match_type {
 struct arch_timer_erratum_workaround {
        enum arch_timer_erratum_match_type match_type;
        const void *id;         /* Indicate the Erratum ID */
+#ifdef CONFIG_ACPI
+ char oem_id[ACPI_OEM_ID_SIZE + 1];
+ char oem_table_id[ACPI_OEM_TABLE_ID_SIZE + 1];
+ u32 oem_revision;
+#endif
        const char *desc_str;
        u32 (*read_cntp_tval_el0)(void);
        u32 (*read_cntv_tval_el0)(void);
drivers/clocksource/arm_arch_timer.c +26 -0
index bbd9361..82ff6e4 100644
@@ -363,6 +363,32 @@ bool arch_timer_check_dt_erratum(const struct arch_timer_erratum_workaround
 *wa,
        return of_property_read_bool(np, wa->id);
 }
 
+#ifdef CONFIG_ACPI
+static bool
+arch_timer_check_acpi_erratum(const struct arch_timer_erratum_workaround *wa,
+                       const void *arg)
+{
+ const struct acpi_table_header *table = arg;
+
+ if (!wa->oem_id || !wa->oem_table_id)
+         return false;
+
+ if (!memcmp(wa->oem_id, table->oem_id, ACPI_OEM_ID_SIZE) &&
+     !memcmp(wa->oem_table_id, table->oem_table_id,
+             ACPI_OEM_TABLE_ID_SIZE) &&
+     wa->oem_revision == table->oem_revision) {
+         return true;
+ }
+
+ return false;
+}
+#else
+static inline bool
+arch_timer_check_acpi_erratum(const struct arch_timer_erratum_workaround *wa,
+                       const void *arg)
+{ return false; }
+#endif
+
 static
 bool arch_timer_check_global_cap_erratum(const struct arch_timer_erratum_workaround *wa,

const void *arg)

drivers/clocksource/arm_arch_timer.c +0 -0
@@ -440,6 +466,9 @@ static void arch_timer_check_ool_workaround(enum arch_timer_erratum_match_typ

e t

                match_fn = arch_timer_check_local_cap_erratum;
                local = true;
                break;

+ case ate_match_acpi:

drivers/clocksource/arm_arch_timer.c +4 -0
+         match_fn = arch_timer_check_acpi_erratum;
+         break;
        }
 
        wa = arch_timer_iterate_errata(type, match_fn, arg);
@@ -1284,6 +1313,8 @@ static int __init arch_timer_acpi_init(struct acpi_table_header *table)
        /* Check for globally applicable workarounds */
        arch_timer_check_ool_workaround(ate_match_global_cap_id, NULL);
 
+ arch_timer_check_ool_workaround(ate_match_acpi, table);
+
        arch_timer_init();
        return 0;
 }
Quoted 4 lines

And I got compile errors for this patch [1], seems "#include <linux/acpi.h>" in arch/arm64/include/asm/arch_timer.h triggers the problem of head file inclusions (too early to include <linux/sched.h>?), I'm looking into it, if you can help to take a look too, that will be great :)

This is really much more complicated (and uglier) than what I had in mind, and I don't want to add more cruft to the erratum description structure. So instead of trying to explain what I wanted to see, here's the patches I whipped together.

Please let me know if they work for you (as I have no way of testing them).

Thanks,

	M.
Quoted 1 line

From 50eb735436f9f6482285939b39b52d858d848537 Mon Sep 17 00:00:00 2001

From: Marc Zyngier <[email protected]>
Date: Tue, 21 Feb 2017 14:37:30 +0000
Subject: [PATCH 1/2] arm64: arch_timer: Allow erratum matching with ACPI OEM
information

Just as we're able to identify a broken platform using some DT information, let's enable a way to spot the offenders with ACPI.

The difference is that we can only match on some OEM info instead of implementation-specific properties. So in order to avoid the insane multiplication of errata structures, we allow an array of OEM descriptions to be attached to an erratum structure.

---
 arch/arm64/include/asm/arch_timer.h  |  1 +
 drivers/clocksource/arm_arch_timer.c | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)
arch/arm64/include/asm/arch_timer.h +1 -0
index 159513479f6e..2e635deba776 100644
@@ -42,6 +42,7 @@ enum arch_timer_erratum_match_type {
 	ate_match_dt,
 	ate_match_global_cap_id,
 	ate_match_local_cap_id,
+	ate_match_acpi_oem_info,
 };
 
 struct clock_event_device;
drivers/clocksource/arm_arch_timer.c +33 -0
index bbd9361c7d66..1de18113e5ae 100644
@@ -189,6 +189,12 @@ static struct cyclecounter cyclecounter = {
 	.mask	= CLOCKSOURCE_MASK(56),
 };
 
+struct ate_acpi_oem_info {
+	char oem_id[ACPI_OEM_ID_SIZE + 1];
+	char oem_table_id[ACPI_OEM_TABLE_ID_SIZE + 1];
+	u32 oem_revision;
+};
+
 #ifdef CONFIG_FSL_ERRATUM_A008585
 /*
  * The number of retries is an arbitrary value well beyond the highest number
@@ -377,6 +383,29 @@ bool arch_timer_check_local_cap_erratum(const struct arch_timer_erratum_workarou
 	return this_cpu_has_cap((uintptr_t)wa->id);
 }
 
+
+static
+bool arch_timer_check_acpi_oem_erratum(const struct arch_timer_erratum_workaround *wa,
+				       const void *arg)
+{
+	static const struct ate_acpi_oem_info empty_oem_info = {};
+	const struct ate_acpi_oem_info *info = wa->id;
+	const struct acpi_table_header *table = arg;
+
+	/* Iterate over the ACPI EOM info array, looking for a match */
+	while (memcmp(info, &empty_oem_info, sizeof(*info))) {
+		if (!memcmp(info->oem_id, table->oem_id, ACPI_OEM_ID_SIZE) &&
+		    !memcmp(info->oem_table_id, table->oem_table_id, ACPI_OEM_TABLE_ID_SIZE) &&
+		    info->oem_revision == table->oem_revision)
+
+			return true;
+
+		info++;
+	}
+
+	return false;
+}
+
 static const struct arch_timer_erratum_workaround *
 arch_timer_iterate_errata(enum arch_timer_erratum_match_type type,
 			  ate_match_fn_t match_fn,
@@ -440,6 +469,9 @@ static void arch_timer_check_ool_workaround(enum arch_timer_erratum_match_type t
 		match_fn = arch_timer_check_local_cap_erratum;
 		local = true;
 		break;
+	case ate_match_acpi_oem_info:
+		match_fn = arch_timer_check_acpi_oem_erratum;
+		break;
 	}
 
 	wa = arch_timer_iterate_errata(type, match_fn, arg);
@@ -1283,6 +1315,7 @@ static int __init arch_timer_acpi_init(struct acpi_table_header *table)
 
 	/* Check for globally applicable workarounds */
 	arch_timer_check_ool_workaround(ate_match_global_cap_id, NULL);
+	arch_timer_check_ool_workaround(ate_match_acpi_oem_info, table);
 
 	arch_timer_init();
 	return 0;
Signature · 1 line
2.11.0
Quoted 1 line

From 857eae645c7dd0cf6c7cd652dd87bbe8041a5d70 Mon Sep 17 00:00:00 2001

From: Marc Zyngier <[email protected]>
Date: Tue, 21 Feb 2017 15:04:27 +0000
Subject: [PATCH 2/2] arm64: arch_timer: Add HISILICON_ERRATUM_161010101 ACPI
matching data

In order to deal with ACPI enabled platforms suffering from the HISILICON_ERRATUM_161010101, let's add the required OEM data that allow the workaround to be enabled.

---
 drivers/clocksource/arm_arch_timer.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/clocksource/arm_arch_timer.c +29 -0
index 1de18113e5ae..062046bca9eb 100644
@@ -269,6 +269,25 @@ static u64 notrace hisi_161010101_read_cntvct_el0(void)
 {
 	return __hisi_161010101_read_reg(cntvct_el0);
 }
+
+static struct ate_acpi_oem_info hisi_161010101_oem_info[] = {
+	{
+		.oem_id		= "HISI  ",
+		.oem_table_id	= "HIP05   ",
+		.oem_revision	= 0,
+	},
+	{
+		.oem_id		= "HISI  ",
+		.oem_table_id	= "HIP06   ",
+		.oem_revision	= 0,
+	},
+	{
+		.oem_id		= "HISI  ",
+		.oem_table_id	= "HIP07   ",
+		.oem_revision	= 0,
+	},
+	{ },
+};
 #endif
 
 #ifdef CONFIG_ARM64_ERRATUM_858921
@@ -346,6 +365,16 @@ static const struct arch_timer_erratum_workaround ool_workarounds[] = {
 		.set_next_event_phys = erratum_set_next_event_tval_phys,
 		.set_next_event_virt = erratum_set_next_event_tval_virt,
 	},
+	{
+		.match_type = ate_match_acpi_oem_info,
+		.id = hisi_161010101_oem_info,
+		.desc_str = "HiSilicon erratum 161010101",
+		.read_cntp_tval_el0 = hisi_161010101_read_cntp_tval_el0,
+		.read_cntv_tval_el0 = hisi_161010101_read_cntv_tval_el0,
+		.read_cntvct_el0 = hisi_161010101_read_cntvct_el0,
+		.set_next_event_phys = erratum_set_next_event_tval_phys,
+		.set_next_event_virt = erratum_set_next_event_tval_virt,
+	},
 #endif
 #ifdef CONFIG_ARM64_ERRATUM_858921
 	{
Signature · 5 lines
2.11.0


-- 
Jazz is not dead, it just smell funny.
#21 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

Quoted 130 lines

Am 21.02.2017 um 07:22 schrieb Marc Zyngier <[email protected]>:

Quoted 2 lines · Hanjun Guo

Hi Marc,

[...]

Quoted 111 lines

Thank you very much! I prepared an ACPI patch based on your branch, I was trying to reuse the "const void *id" for ACPI as well but we need to match the oem_id, oem_table_id and oem_revision in GTDT table, so I introduced new matching information for ACPI, please take a look if it's OK.

commit 02d531ae4a88c483db849a611bd9bf7c39d2e1bf

Author: Hanjun Guo <[email protected]>
Date:   Tue Feb 21 15:17:14 2017 +0800

arm64: arch_timer: enable the erratums in ACPI way

Match OEM information which are oem_id, oem_table_id and oem_revision to enable the erratum for specific platforms.

---
arch/arm64/include/asm/arch_timer.h | 7 +++++++ drivers/clocksource/arm_arch_timer.c | 31 +++++++++++++++++++++++++++++++

2 files changed, 38 insertions(+)
arch/arm64/include/asm/arch_timer.h +7 -0
index 1595134..79d033c 100644
@@ -22,6 +22,7 @@
 #include <asm/barrier.h>
 #include <asm/sysreg.h>
 
+#include <linux/acpi.h>
 #include <linux/bug.h>
 #include <linux/init.h>
 #include <linux/jump_label.h>
@@ -42,6 +43,7 @@ enum arch_timer_erratum_match_type {
       ate_match_dt,
       ate_match_global_cap_id,
       ate_match_local_cap_id,
+ ate_match_acpi,
 };
 
 struct clock_event_device;
@@ -49,6 +51,11 @@ enum arch_timer_erratum_match_type {
 struct arch_timer_erratum_workaround {
       enum arch_timer_erratum_match_type match_type;
       const void *id;         /* Indicate the Erratum ID */
+#ifdef CONFIG_ACPI
+ char oem_id[ACPI_OEM_ID_SIZE + 1];
+ char oem_table_id[ACPI_OEM_TABLE_ID_SIZE + 1];
+ u32 oem_revision;
+#endif
       const char *desc_str;
       u32 (*read_cntp_tval_el0)(void);
       u32 (*read_cntv_tval_el0)(void);
drivers/clocksource/arm_arch_timer.c +26 -0
index bbd9361..82ff6e4 100644
@@ -363,6 +363,32 @@ bool arch_timer_check_dt_erratum(const struct arch_timer_erratum_workaround
 *wa,
       return of_property_read_bool(np, wa->id);
 }
 
+#ifdef CONFIG_ACPI
+static bool
+arch_timer_check_acpi_erratum(const struct arch_timer_erratum_workaround *wa,
+                       const void *arg)
+{
+ const struct acpi_table_header *table = arg;
+
+ if (!wa->oem_id || !wa->oem_table_id)
+         return false;
+
+ if (!memcmp(wa->oem_id, table->oem_id, ACPI_OEM_ID_SIZE) &&
+     !memcmp(wa->oem_table_id, table->oem_table_id,
+             ACPI_OEM_TABLE_ID_SIZE) &&
+     wa->oem_revision == table->oem_revision) {
+         return true;
+ }
+
+ return false;
+}
+#else
+static inline bool
+arch_timer_check_acpi_erratum(const struct arch_timer_erratum_workaround *wa,
+                       const void *arg)
+{ return false; }
+#endif
+

static
bool arch_timer_check_global_cap_erratum(const struct arch_timer_erratum_workaround *wa,
const void *arg)

drivers/clocksource/arm_arch_timer.c +0 -0
@@ -440,6 +466,9 @@ static void arch_timer_check_ool_workaround(enum arch_timer_erratum_match_typ

e t

               match_fn = arch_timer_check_local_cap_erratum;
               local = true;
               break;

+ case ate_match_acpi:

drivers/clocksource/arm_arch_timer.c +4 -0
+         match_fn = arch_timer_check_acpi_erratum;
+         break;
       }
 
       wa = arch_timer_iterate_errata(type, match_fn, arg);
@@ -1284,6 +1313,8 @@ static int __init arch_timer_acpi_init(struct acpi_table_header *table)
       /* Check for globally applicable workarounds */
       arch_timer_check_ool_workaround(ate_match_global_cap_id, NULL);
 
+ arch_timer_check_ool_workaround(ate_match_acpi, table);
+
       arch_timer_init();
       return 0;
 }
Quoted 4 lines

And I got compile errors for this patch [1], seems "#include <linux/acpi.h>" in arch/arm64/include/asm/arch_timer.h triggers the problem of head file inclusions (too early to include <linux/sched.h>?), I'm looking into it, if you can help to take a look too, that will be great :)

This is really much more complicated (and uglier) than what I had in mind, and I don't want to add more cruft to the erratum description structure. So instead of trying to explain what I wanted to see, here's the patches I whipped together.

Quoted 2 lines

Please let me know if they work for you (as I have no way of testing them).

Thanks for handling this quickly :).

One thing I can't get my head around yet is VM propagation of these erratas. For the dt property based approach, I can at least see how someone adds that property into the guest dt when running on broken hosts.

But how would that work when the erratum matching happens based on the OEM identifier? Would a VM suddenly have to have HiSilicon as OEM? Or would we forbid kvm usage altogether on those CPUs?

Alex

author
#23 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

In reply to Marc Zyngier
Quoted 4 lines · Marc Zyngier
Quoted 1 line · Hanjun Guo

Hi Marc,

[...]

[...]

Quoted 31 lines
Quoted 5 lines

And I got compile errors for this patch [1], seems "#include <linux/acpi.h>" in arch/arm64/include/asm/arch_timer.h triggers the problem of head file inclusions (too early to include <linux/sched.h>?), I'm looking into it, if you can help to take a look too, that will be great :)

This is really much more complicated (and uglier) than what I had in mind, and I don't want to add more cruft to the erratum description structure. So instead of trying to explain what I wanted to see, here's the patches I whipped together.

Please let me know if they work for you (as I have no way of testing them).

Thanks,

	M.
Quoted 1 line

From 50eb735436f9f6482285939b39b52d858d848537 Mon Sep 17 00:00:00 2001

From: Marc Zyngier <[email protected]>
Date: Tue, 21 Feb 2017 14:37:30 +0000
Subject: [PATCH 1/2] arm64: arch_timer: Allow erratum matching with ACPI OEM
information

Just as we're able to identify a broken platform using some DT information, let's enable a way to spot the offenders with ACPI.

The difference is that we can only match on some OEM info instead of implementation-specific properties. So in order to avoid the insane multiplication of errata structures, we allow an array of OEM descriptions to be attached to an erratum structure.

Quoted 5 lines
---
 arch/arm64/include/asm/arch_timer.h  |  1 +
 drivers/clocksource/arm_arch_timer.c | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

Marc, thank you for the help, I tested your patches on D03, I got:

[    0.000000] arm_arch_timer: Enabling global workaround for HiSilicon erratum 161010101
[    0.000000] arm_arch_timer: CPU0: Trapping CNTVCT access

in the boot log, which means the framework and ACPI patches work fine.

Thanks
Hanjun

#22 lore raw

Re: [PATCH 2/2] arch_timer: acpi: add hisi timer erratum data

In reply to Alexander Graf

On 22/02/17 04:08, Alexander Graf wrote:

[irrelevant stuff]

Quoted 10 lines

Thanks for handling this quickly :).

One thing I can't get my head around yet is VM propagation of these erratas. For the dt property based approach, I can at least see how someone adds that property into the guest dt when running on broken hosts.

But how would that work when the erratum matching happens based on the OEM identifier? Would a VM suddenly have to have HiSilicon as OEM? Or would we forbid kvm usage altogether on those CPUs?

s/CPU/SoC/

Simple: you only use DT as a guest, because it is the only firmware interface that allows you to reliably describe an arbitrary erratum. ACPI is too inflexible for that. Injecting bits of the host's ACPI tables in the guest doesn't strike me as a reliable solution, as you're not describing the erratum itself. I imagine you 'd have some userspace tool to dump the host ACPI table, match it against a list of known errata, and inject the corresponding property into the guest's DT.

Furthermore, I don't see any reason to actively prevent KVM from running on any system. If we did, we'd start with the RPi...

Thanks,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...