linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/8] rtc: cmos: Use shared IRQ only for Microsoft Surface 3
@ 2020-01-17 17:56 Andy Shevchenko
  2020-01-17 17:56 ` [PATCH v1 2/8] x86/platform: Rename x86/apple.h -> x86/machine.h Andy Shevchenko
                   ` (7 more replies)
  0 siblings, 8 replies; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-17 17:56 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Guilherme G . Piccoli, linux-kernel
  Cc: Andy Shevchenko

As reported by Guilherme:

The rtc-cmos interrupt setting was changed in the commit 079062b28fb4
("rtc: cmos: prevent kernel warning on IRQ flags mismatch") in order
to allow shared interrupts; according to that commit's description,
some machine got kernel warnings due to the interrupt line being shared
between rtc-cmos and other hardware, and rtc-cmos didn't allow IRQ sharing
that time.

After the aforementioned commit though it was observed a huge increase
in lost HPET interrupts in some systems, observed through the following
kernel message:

[...] hpet1: lost 35 rtc interrupts

After investigation, it was narrowed down to the shared interrupts
usage when having the kernel option "irqpoll" enabled. In this case,
all IRQ handlers are called for non-timer interrupts, if such handlers
are setup in shared IRQ lines. The rtc-cmos IRQ handler could be set to
hpet_rtc_interrupt(), which will produce the kernel "lost interrupts"
message after doing work - lots of readl/writel to HPET registers, which
are known to be slow.

This patch changes this behavior by preventing shared interrupts for
everything, but Microsoft Surface 3 as stated in the culprit commit message.
Although "irqpoll" is not a default kernel option, it's used in some contexts,
one being the kdump kernel (which is an already "impaired" kernel usually
running with 1 CPU available), so the performance burden could be considerable.
Also, the same issue would happen (in a shorter extent though) when using
"irqfixup" kernel option.

In a quick experiment, a virtual machine with uptime of 2 minutes produced
>300 calls to hpet_rtc_interrupt() when "irqpoll" was set, whereas without
sharing interrupts this number reduced to 1 interrupt. Machines with more
hardware than a VM should generate even more unnecessary HPET interrupts
in this scenario.

Fixes: 079062b28fb4 ("rtc: cmos: prevent kernel warning on IRQ flags mismatch")
Reported-by: Guilherme G. Piccoli <gpiccoli@canonical.com>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/rtc/rtc-cmos.c      | 21 +++++++++++++++++++--
 include/linux/mc146818rtc.h |  4 +++-
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index 033303708c8b..09b7cdda9f55 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -27,6 +27,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
+#include <linux/dmi.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -40,7 +41,6 @@
 #ifdef CONFIG_X86
 #include <asm/i8259.h>
 #include <asm/processor.h>
-#include <linux/dmi.h>
 #endif
 
 /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */
@@ -836,6 +836,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
 
 	if (is_valid_irq(rtc_irq)) {
 		irq_handler_t rtc_cmos_int_handler;
+		unsigned long irq_flags = 0;
 
 		if (use_hpet_alarm()) {
 			rtc_cmos_int_handler = hpet_rtc_interrupt;
@@ -849,8 +850,11 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
 		} else
 			rtc_cmos_int_handler = cmos_interrupt;
 
+		if (flags & CMOS_RTC_FLAGS_SHARED_IRQ)
+			irq_flags |= IRQF_SHARED;
+
 		retval = request_irq(rtc_irq, rtc_cmos_int_handler,
-				IRQF_SHARED, dev_name(&cmos_rtc.rtc->dev),
+				irq_flags, dev_name(&cmos_rtc.rtc->dev),
 				cmos_rtc.rtc);
 		if (retval < 0) {
 			dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);
@@ -1215,6 +1219,16 @@ static void use_acpi_alarm_quirks(void)
 static inline void use_acpi_alarm_quirks(void) { }
 #endif
 
+static const struct dmi_system_id rtc_cmos_surface3_table[] = {
+	{
+		.ident = "Microsoft Surface 3",
+		.matches = {
+			DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
+		},
+	},
+	{}
+};
+
 /* Every ACPI platform has a mc146818 compatible "cmos rtc".  Here we find
  * its device node and pass extra config data.  This helps its driver use
  * capabilities that the now-obsolete mc146818 didn't have, and informs it
@@ -1229,6 +1243,9 @@ static void cmos_wake_setup(struct device *dev)
 
 	use_acpi_alarm_quirks();
 
+	if (dmi_check_system(rtc_cmos_surface3_table))
+		acpi_rtc_info.flags |= CMOS_RTC_FLAGS_SHARED_IRQ;
+
 	rtc_wake_setup(dev);
 	acpi_rtc_info.wake_on = rtc_wake_on;
 	acpi_rtc_info.wake_off = rtc_wake_off;
diff --git a/include/linux/mc146818rtc.h b/include/linux/mc146818rtc.h
index 0661af17a758..d62d69b48b3e 100644
--- a/include/linux/mc146818rtc.h
+++ b/include/linux/mc146818rtc.h
@@ -35,7 +35,9 @@ struct cmos_rtc_board_info {
 	void	(*wake_off)(struct device *dev);
 
 	u32	flags;
-#define CMOS_RTC_FLAGS_NOFREQ	(1 << 0)
+#define CMOS_RTC_FLAGS_NOFREQ		(1 << 0)
+#define CMOS_RTC_FLAGS_SHARED_IRQ	(1 << 1)
+
 	int	address_space;
 
 	u8	rtc_day_alarm;		/* zero, or register index */
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v1 2/8] x86/platform: Rename x86/apple.h -> x86/machine.h
  2020-01-17 17:56 [PATCH v1 1/8] rtc: cmos: Use shared IRQ only for Microsoft Surface 3 Andy Shevchenko
@ 2020-01-17 17:56 ` Andy Shevchenko
  2020-01-17 17:56 ` [PATCH v1 3/8] x86/quirks: Add missed include to satisfy static checker Andy Shevchenko
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-17 17:56 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Guilherme G . Piccoli, linux-kernel
  Cc: Andy Shevchenko

Rename linux/platform_data/x86/apple.h to linux/platform_data/x86/machine.h
in order to add new quirks later on. For sake of being less intrusive,
leave former file that includes a latter one.

While here, add include to linux/types.h due to bool type in use.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/platform_data/x86/apple.h   | 14 +-------------
 include/linux/platform_data/x86/machine.h | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 13 deletions(-)
 create mode 100644 include/linux/platform_data/x86/machine.h

diff --git a/include/linux/platform_data/x86/apple.h b/include/linux/platform_data/x86/apple.h
index 079e816c3c21..1fd0af6ffea9 100644
--- a/include/linux/platform_data/x86/apple.h
+++ b/include/linux/platform_data/x86/apple.h
@@ -1,13 +1 @@
-#ifndef PLATFORM_DATA_X86_APPLE_H
-#define PLATFORM_DATA_X86_APPLE_H
-
-#ifdef CONFIG_X86
-/**
- * x86_apple_machine - whether the machine is an x86 Apple Macintosh
- */
-extern bool x86_apple_machine;
-#else
-#define x86_apple_machine false
-#endif
-
-#endif
+#include <linux/platform_data/x86/machine.h>
diff --git a/include/linux/platform_data/x86/machine.h b/include/linux/platform_data/x86/machine.h
new file mode 100644
index 000000000000..b1e7a560a046
--- /dev/null
+++ b/include/linux/platform_data/x86/machine.h
@@ -0,0 +1,15 @@
+#ifndef PLATFORM_DATA_X86_MACHINE_H
+#define PLATFORM_DATA_X86_MACHINE_H
+
+#include <linux/types.h>
+
+#ifdef CONFIG_X86
+/**
+ * x86_apple_machine - whether the machine is an x86 Apple Macintosh
+ */
+extern bool x86_apple_machine;
+#else
+#define x86_apple_machine			false
+#endif
+
+#endif	/* PLATFORM_DATA_X86_MACHINE_H */
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v1 3/8] x86/quirks: Add missed include to satisfy static checker
  2020-01-17 17:56 [PATCH v1 1/8] rtc: cmos: Use shared IRQ only for Microsoft Surface 3 Andy Shevchenko
  2020-01-17 17:56 ` [PATCH v1 2/8] x86/platform: Rename x86/apple.h -> x86/machine.h Andy Shevchenko
@ 2020-01-17 17:56 ` Andy Shevchenko
  2020-01-17 17:56 ` [PATCH v1 4/8] x86/quirks: Convert DMI matching to use a table Andy Shevchenko
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-17 17:56 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Guilherme G . Piccoli, linux-kernel
  Cc: Andy Shevchenko

Static checker is not happy with

.../kernel/quirks.c:666:6: warning: symbol 'x86_apple_machine' was not declared. Should it be static?

This is due to missed inclusion. Add it to satisfy the static checker.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/kernel/quirks.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index 1daf8f2aa21f..5b96654aacc0 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -4,6 +4,7 @@
  */
 #include <linux/dmi.h>
 #include <linux/pci.h>
+#include <linux/platform_data/x86/machine.h>
 #include <linux/irq.h>
 
 #include <asm/hpet.h>
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v1 4/8] x86/quirks: Convert DMI matching to use a table
  2020-01-17 17:56 [PATCH v1 1/8] rtc: cmos: Use shared IRQ only for Microsoft Surface 3 Andy Shevchenko
  2020-01-17 17:56 ` [PATCH v1 2/8] x86/platform: Rename x86/apple.h -> x86/machine.h Andy Shevchenko
  2020-01-17 17:56 ` [PATCH v1 3/8] x86/quirks: Add missed include to satisfy static checker Andy Shevchenko
@ 2020-01-17 17:56 ` Andy Shevchenko
  2020-01-17 17:56 ` [PATCH v1 5/8] x86/quirks: Add a DMI quirk for Microsoft Surface 3 Andy Shevchenko
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-17 17:56 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Guilherme G . Piccoli, linux-kernel
  Cc: Andy Shevchenko

In order to extend the DMI based quirks, convert them to a table.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/kernel/quirks.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index 5b96654aacc0..447d4fba8516 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -667,8 +667,31 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2083, quirk_intel_purley_xeon_ras
 bool x86_apple_machine;
 EXPORT_SYMBOL(x86_apple_machine);
 
+static int apple_machine_cb(const struct dmi_system_id *id)
+{
+	x86_apple_machine = true;
+	return 1;
+}
+
+static const struct dmi_system_id x86_machine_table[] = {
+	{
+		.ident = "x86 Apple Macintosh",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
+		},
+		.callback = apple_machine_cb,
+	},
+	{
+		.ident = "x86 Apple Macintosh",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."),
+		},
+		.callback = apple_machine_cb,
+	},
+	{}
+};
+
 void __init early_platform_quirks(void)
 {
-	x86_apple_machine = dmi_match(DMI_SYS_VENDOR, "Apple Inc.") ||
-			    dmi_match(DMI_SYS_VENDOR, "Apple Computer, Inc.");
+	dmi_check_system(x86_machine_table);
 }
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v1 5/8] x86/quirks: Add a DMI quirk for Microsoft Surface 3
  2020-01-17 17:56 [PATCH v1 1/8] rtc: cmos: Use shared IRQ only for Microsoft Surface 3 Andy Shevchenko
                   ` (2 preceding siblings ...)
  2020-01-17 17:56 ` [PATCH v1 4/8] x86/quirks: Convert DMI matching to use a table Andy Shevchenko
@ 2020-01-17 17:56 ` Andy Shevchenko
  2020-01-20 12:09   ` Mark Brown
  2020-01-17 17:56 ` [PATCH v1 6/8] platform/x86: surface3_wmi: Switch DMI table match to a test of variable Andy Shevchenko
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-17 17:56 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Guilherme G . Piccoli, linux-kernel
  Cc: Andy Shevchenko, Cezary Rojewski, Pierre-Louis Bossart,
	Liam Girdwood, Jie Yang, Mark Brown, alsa-devel

Add a DMI quirk for Microsoft Surface 3 which will be utilized by few drivers.

Cc: Cezary Rojewski <cezary.rojewski@intel.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Cc: Jie Yang <yang.jie@linux.intel.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: alsa-devel@alsa-project.org
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/kernel/quirks.c                  | 16 ++++++++++++++++
 include/linux/platform_data/x86/machine.h |  5 +++++
 2 files changed, 21 insertions(+)

diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index 447d4fba8516..9574ef7eaa66 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -673,6 +673,15 @@ static int apple_machine_cb(const struct dmi_system_id *id)
 	return 1;
 }
 
+bool x86_microsoft_surface_3_machine;
+EXPORT_SYMBOL(x86_microsoft_surface_3_machine);
+
+static int microsoft_surface_3_machine_cb(const struct dmi_system_id *id)
+{
+	x86_microsoft_surface_3_machine = true;
+	return 1;
+}
+
 static const struct dmi_system_id x86_machine_table[] = {
 	{
 		.ident = "x86 Apple Macintosh",
@@ -688,6 +697,13 @@ static const struct dmi_system_id x86_machine_table[] = {
 		},
 		.callback = apple_machine_cb,
 	},
+	{
+		.ident = "Microsoft Surface 3",
+		.matches = {
+			DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
+		},
+		.callback = microsoft_surface_3_machine_cb,
+	},
 	{}
 };
 
diff --git a/include/linux/platform_data/x86/machine.h b/include/linux/platform_data/x86/machine.h
index b1e7a560a046..9bdf5a06b490 100644
--- a/include/linux/platform_data/x86/machine.h
+++ b/include/linux/platform_data/x86/machine.h
@@ -8,8 +8,13 @@
  * x86_apple_machine - whether the machine is an x86 Apple Macintosh
  */
 extern bool x86_apple_machine;
+/**
+ * x86_microsoft_surface_3_machine - whether the machine is Microsoft Surface 3
+ */
+extern bool x86_microsoft_surface_3_machine;
 #else
 #define x86_apple_machine			false
+#define x86_microsoft_surface_3_machine		false
 #endif
 
 #endif	/* PLATFORM_DATA_X86_MACHINE_H */
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v1 6/8] platform/x86: surface3_wmi: Switch DMI table match to a test of variable
  2020-01-17 17:56 [PATCH v1 1/8] rtc: cmos: Use shared IRQ only for Microsoft Surface 3 Andy Shevchenko
                   ` (3 preceding siblings ...)
  2020-01-17 17:56 ` [PATCH v1 5/8] x86/quirks: Add a DMI quirk for Microsoft Surface 3 Andy Shevchenko
@ 2020-01-17 17:56 ` Andy Shevchenko
  2020-01-17 17:56 ` [PATCH v1 7/8] ASoC: Intel: " Andy Shevchenko
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-17 17:56 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Guilherme G . Piccoli, linux-kernel
  Cc: Andy Shevchenko

Since we have a common x86 quirk that provides an exported variable,
use it instead of local DMI table match.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/platform/x86/surface3-wmi.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/platform/x86/surface3-wmi.c b/drivers/platform/x86/surface3-wmi.c
index 130b6f52a600..5eeedc4ddb8a 100644
--- a/drivers/platform/x86/surface3-wmi.c
+++ b/drivers/platform/x86/surface3-wmi.c
@@ -11,9 +11,9 @@
 #include <linux/slab.h>
 
 #include <linux/acpi.h>
-#include <linux/dmi.h>
 #include <linux/input.h>
 #include <linux/mutex.h>
+#include <linux/platform_data/x86/machine.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
 
@@ -29,18 +29,6 @@ MODULE_LICENSE("GPL");
 
 MODULE_ALIAS("wmi:" SURFACE3_LID_GUID);
 
-static const struct dmi_system_id surface3_dmi_table[] = {
-#if defined(CONFIG_X86)
-	{
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
-		},
-	},
-#endif
-	{ }
-};
-
 struct surface3_wmi {
 	struct acpi_device *touchscreen_adev;
 	struct acpi_device *pnp0c0d_adev;
@@ -201,7 +189,7 @@ static int __init s3_wmi_probe(struct platform_device *pdev)
 {
 	int error;
 
-	if (!dmi_check_system(surface3_dmi_table))
+	if (!x86_microsoft_surface_3_machine)
 		return -ENODEV;
 
 	memset(&s3_wmi, 0, sizeof(s3_wmi));
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v1 7/8] ASoC: Intel: Switch DMI table match to a test of variable
  2020-01-17 17:56 [PATCH v1 1/8] rtc: cmos: Use shared IRQ only for Microsoft Surface 3 Andy Shevchenko
                   ` (4 preceding siblings ...)
  2020-01-17 17:56 ` [PATCH v1 6/8] platform/x86: surface3_wmi: Switch DMI table match to a test of variable Andy Shevchenko
@ 2020-01-17 17:56 ` Andy Shevchenko
  2020-01-17 19:10   ` Pierre-Louis Bossart
  2020-01-17 17:56 ` [PATCH v1 8/8] rtc: cmos: " Andy Shevchenko
  2020-01-22 13:27 ` [PATCH v1 1/8] rtc: cmos: Use shared IRQ only for Microsoft Surface 3 Guilherme G. Piccoli
  7 siblings, 1 reply; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-17 17:56 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Guilherme G . Piccoli, linux-kernel
  Cc: Andy Shevchenko, Cezary Rojewski, Pierre-Louis Bossart,
	Liam Girdwood, Jie Yang, Mark Brown, alsa-devel

Since we have a common x86 quirk that provides an exported variable,
use it instead of local DMI table match.

Cc: Cezary Rojewski <cezary.rojewski@intel.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Cc: Jie Yang <yang.jie@linux.intel.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: alsa-devel@alsa-project.org
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 .../intel/common/soc-acpi-intel-cht-match.c   | 28 ++-----------------
 1 file changed, 3 insertions(+), 25 deletions(-)

diff --git a/sound/soc/intel/common/soc-acpi-intel-cht-match.c b/sound/soc/intel/common/soc-acpi-intel-cht-match.c
index d0fb43c2b9f6..833d2e130e6e 100644
--- a/sound/soc/intel/common/soc-acpi-intel-cht-match.c
+++ b/sound/soc/intel/common/soc-acpi-intel-cht-match.c
@@ -5,31 +5,11 @@
  * Copyright (c) 2017, Intel Corporation.
  */
 
-#include <linux/dmi.h>
+#include <linux/platform_data/x86/machine.h>
+
 #include <sound/soc-acpi.h>
 #include <sound/soc-acpi-intel-match.h>
 
-static unsigned long cht_machine_id;
-
-#define CHT_SURFACE_MACH 1
-
-static int cht_surface_quirk_cb(const struct dmi_system_id *id)
-{
-	cht_machine_id = CHT_SURFACE_MACH;
-	return 1;
-}
-
-static const struct dmi_system_id cht_table[] = {
-	{
-		.callback = cht_surface_quirk_cb,
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
-		},
-	},
-	{ }
-};
-
 static struct snd_soc_acpi_mach cht_surface_mach = {
 	.id = "10EC5640",
 	.drv_name = "cht-bsw-rt5645",
@@ -43,9 +23,7 @@ static struct snd_soc_acpi_mach *cht_quirk(void *arg)
 {
 	struct snd_soc_acpi_mach *mach = arg;
 
-	dmi_check_system(cht_table);
-
-	if (cht_machine_id == CHT_SURFACE_MACH)
+	if (x86_microsoft_surface_3_machine)
 		return &cht_surface_mach;
 	else
 		return mach;
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v1 8/8] rtc: cmos: Switch DMI table match to a test of variable
  2020-01-17 17:56 [PATCH v1 1/8] rtc: cmos: Use shared IRQ only for Microsoft Surface 3 Andy Shevchenko
                   ` (5 preceding siblings ...)
  2020-01-17 17:56 ` [PATCH v1 7/8] ASoC: Intel: " Andy Shevchenko
@ 2020-01-17 17:56 ` Andy Shevchenko
  2020-01-22 13:27 ` [PATCH v1 1/8] rtc: cmos: Use shared IRQ only for Microsoft Surface 3 Guilherme G. Piccoli
  7 siblings, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-17 17:56 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Guilherme G . Piccoli, linux-kernel
  Cc: Andy Shevchenko

Since we have a common x86 quirk that provides an exported variable,
use it instead of local DMI table match.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/rtc/rtc-cmos.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index 09b7cdda9f55..b8b67a98c47a 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -33,6 +33,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
+#include <linux/platform_data/x86/machine.h>
 #include <linux/platform_device.h>
 #include <linux/log2.h>
 #include <linux/pm.h>
@@ -1219,16 +1220,6 @@ static void use_acpi_alarm_quirks(void)
 static inline void use_acpi_alarm_quirks(void) { }
 #endif
 
-static const struct dmi_system_id rtc_cmos_surface3_table[] = {
-	{
-		.ident = "Microsoft Surface 3",
-		.matches = {
-			DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
-		},
-	},
-	{}
-};
-
 /* Every ACPI platform has a mc146818 compatible "cmos rtc".  Here we find
  * its device node and pass extra config data.  This helps its driver use
  * capabilities that the now-obsolete mc146818 didn't have, and informs it
@@ -1243,7 +1234,7 @@ static void cmos_wake_setup(struct device *dev)
 
 	use_acpi_alarm_quirks();
 
-	if (dmi_check_system(rtc_cmos_surface3_table))
+	if (x86_microsoft_surface_3_machine)
 		acpi_rtc_info.flags |= CMOS_RTC_FLAGS_SHARED_IRQ;
 
 	rtc_wake_setup(dev);
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 7/8] ASoC: Intel: Switch DMI table match to a test of variable
  2020-01-17 17:56 ` [PATCH v1 7/8] ASoC: Intel: " Andy Shevchenko
@ 2020-01-17 19:10   ` Pierre-Louis Bossart
  2020-01-20 10:17     ` Andy Shevchenko
  0 siblings, 1 reply; 15+ messages in thread
From: Pierre-Louis Bossart @ 2020-01-17 19:10 UTC (permalink / raw)
  To: Andy Shevchenko, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	H. Peter Anvin, x86, Alessandro Zummo, Alexandre Belloni,
	linux-rtc, Guilherme G . Piccoli, linux-kernel
  Cc: Cezary Rojewski, Liam Girdwood, Jie Yang, Mark Brown, alsa-devel



On 1/17/20 11:56 AM, Andy Shevchenko wrote:
> Since we have a common x86 quirk that provides an exported variable,
> use it instead of local DMI table match.
> 
> Cc: Cezary Rojewski <cezary.rojewski@intel.com>
> Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Cc: Liam Girdwood <liam.r.girdwood@linux.intel.com>
> Cc: Jie Yang <yang.jie@linux.intel.com>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: alsa-devel@alsa-project.org
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Thanks Andy.

Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

> ---
>   .../intel/common/soc-acpi-intel-cht-match.c   | 28 ++-----------------
>   1 file changed, 3 insertions(+), 25 deletions(-)
> 
> diff --git a/sound/soc/intel/common/soc-acpi-intel-cht-match.c b/sound/soc/intel/common/soc-acpi-intel-cht-match.c
> index d0fb43c2b9f6..833d2e130e6e 100644
> --- a/sound/soc/intel/common/soc-acpi-intel-cht-match.c
> +++ b/sound/soc/intel/common/soc-acpi-intel-cht-match.c
> @@ -5,31 +5,11 @@
>    * Copyright (c) 2017, Intel Corporation.
>    */
>   
> -#include <linux/dmi.h>
> +#include <linux/platform_data/x86/machine.h>
> +
>   #include <sound/soc-acpi.h>
>   #include <sound/soc-acpi-intel-match.h>
>   
> -static unsigned long cht_machine_id;
> -
> -#define CHT_SURFACE_MACH 1
> -
> -static int cht_surface_quirk_cb(const struct dmi_system_id *id)
> -{
> -	cht_machine_id = CHT_SURFACE_MACH;
> -	return 1;
> -}
> -
> -static const struct dmi_system_id cht_table[] = {
> -	{
> -		.callback = cht_surface_quirk_cb,
> -		.matches = {
> -			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
> -			DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
> -		},
> -	},
> -	{ }
> -};
> -
>   static struct snd_soc_acpi_mach cht_surface_mach = {
>   	.id = "10EC5640",
>   	.drv_name = "cht-bsw-rt5645",
> @@ -43,9 +23,7 @@ static struct snd_soc_acpi_mach *cht_quirk(void *arg)
>   {
>   	struct snd_soc_acpi_mach *mach = arg;
>   
> -	dmi_check_system(cht_table);
> -
> -	if (cht_machine_id == CHT_SURFACE_MACH)
> +	if (x86_microsoft_surface_3_machine)
>   		return &cht_surface_mach;
>   	else
>   		return mach;
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 7/8] ASoC: Intel: Switch DMI table match to a test of variable
  2020-01-17 19:10   ` Pierre-Louis Bossart
@ 2020-01-20 10:17     ` Andy Shevchenko
  0 siblings, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-20 10:17 UTC (permalink / raw)
  To: Pierre-Louis Bossart
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Guilherme G . Piccoli, linux-kernel, Cezary Rojewski,
	Liam Girdwood, Jie Yang, Mark Brown, alsa-devel

On Fri, Jan 17, 2020 at 01:10:55PM -0600, Pierre-Louis Bossart wrote:
> On 1/17/20 11:56 AM, Andy Shevchenko wrote:
> > Since we have a common x86 quirk that provides an exported variable,
> > use it instead of local DMI table match.
> > 
> > Cc: Cezary Rojewski <cezary.rojewski@intel.com>
> > Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> > Cc: Liam Girdwood <liam.r.girdwood@linux.intel.com>
> > Cc: Jie Yang <yang.jie@linux.intel.com>
> > Cc: Mark Brown <broonie@kernel.org>
> > Cc: alsa-devel@alsa-project.org
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> Thanks Andy.
> 
> Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

Thank you. Though I think I'll re-do this a bit, i.e.
 - convert the cht_quirk() to oneliner that is using ternary operator
 - convert also codec driver to use variable instead of DMI match

> 
> > ---
> >   .../intel/common/soc-acpi-intel-cht-match.c   | 28 ++-----------------
> >   1 file changed, 3 insertions(+), 25 deletions(-)
> > 
> > diff --git a/sound/soc/intel/common/soc-acpi-intel-cht-match.c b/sound/soc/intel/common/soc-acpi-intel-cht-match.c
> > index d0fb43c2b9f6..833d2e130e6e 100644
> > --- a/sound/soc/intel/common/soc-acpi-intel-cht-match.c
> > +++ b/sound/soc/intel/common/soc-acpi-intel-cht-match.c
> > @@ -5,31 +5,11 @@
> >    * Copyright (c) 2017, Intel Corporation.
> >    */
> > -#include <linux/dmi.h>
> > +#include <linux/platform_data/x86/machine.h>
> > +
> >   #include <sound/soc-acpi.h>
> >   #include <sound/soc-acpi-intel-match.h>
> > -static unsigned long cht_machine_id;
> > -
> > -#define CHT_SURFACE_MACH 1
> > -
> > -static int cht_surface_quirk_cb(const struct dmi_system_id *id)
> > -{
> > -	cht_machine_id = CHT_SURFACE_MACH;
> > -	return 1;
> > -}
> > -
> > -static const struct dmi_system_id cht_table[] = {
> > -	{
> > -		.callback = cht_surface_quirk_cb,
> > -		.matches = {
> > -			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
> > -			DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
> > -		},
> > -	},
> > -	{ }
> > -};
> > -
> >   static struct snd_soc_acpi_mach cht_surface_mach = {
> >   	.id = "10EC5640",
> >   	.drv_name = "cht-bsw-rt5645",
> > @@ -43,9 +23,7 @@ static struct snd_soc_acpi_mach *cht_quirk(void *arg)
> >   {
> >   	struct snd_soc_acpi_mach *mach = arg;
> > -	dmi_check_system(cht_table);
> > -
> > -	if (cht_machine_id == CHT_SURFACE_MACH)
> > +	if (x86_microsoft_surface_3_machine)
> >   		return &cht_surface_mach;
> >   	else
> >   		return mach;
> > 

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 5/8] x86/quirks: Add a DMI quirk for Microsoft Surface 3
  2020-01-17 17:56 ` [PATCH v1 5/8] x86/quirks: Add a DMI quirk for Microsoft Surface 3 Andy Shevchenko
@ 2020-01-20 12:09   ` Mark Brown
  2020-01-20 12:21     ` Andy Shevchenko
  0 siblings, 1 reply; 15+ messages in thread
From: Mark Brown @ 2020-01-20 12:09 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Guilherme G . Piccoli, linux-kernel, Cezary Rojewski,
	Pierre-Louis Bossart, Liam Girdwood, Jie Yang, alsa-devel

[-- Attachment #1: Type: text/plain, Size: 233 bytes --]

On Fri, Jan 17, 2020 at 07:56:23PM +0200, Andy Shevchenko wrote:
> Add a DMI quirk for Microsoft Surface 3 which will be utilized by few drivers.

I have patches 5 and 7 with no other context, what's going on with
dependencies here?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 5/8] x86/quirks: Add a DMI quirk for Microsoft Surface 3
  2020-01-20 12:09   ` Mark Brown
@ 2020-01-20 12:21     ` Andy Shevchenko
  0 siblings, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-20 12:21 UTC (permalink / raw)
  To: Mark Brown
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Alessandro Zummo, Alexandre Belloni, linux-rtc,
	Guilherme G . Piccoli, linux-kernel, Cezary Rojewski,
	Pierre-Louis Bossart, Liam Girdwood, Jie Yang, alsa-devel

On Mon, Jan 20, 2020 at 12:09:33PM +0000, Mark Brown wrote:
> On Fri, Jan 17, 2020 at 07:56:23PM +0200, Andy Shevchenko wrote:
> > Add a DMI quirk for Microsoft Surface 3 which will be utilized by few drivers.
> 
> I have patches 5 and 7 with no other context, what's going on with
> dependencies here?

Other patches has no relation to ASoC or vise versa.
I will Cc you for entire series in next version.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 1/8] rtc: cmos: Use shared IRQ only for Microsoft Surface 3
  2020-01-17 17:56 [PATCH v1 1/8] rtc: cmos: Use shared IRQ only for Microsoft Surface 3 Andy Shevchenko
                   ` (6 preceding siblings ...)
  2020-01-17 17:56 ` [PATCH v1 8/8] rtc: cmos: " Andy Shevchenko
@ 2020-01-22 13:27 ` Guilherme G. Piccoli
  2020-01-22 13:38   ` Andy Shevchenko
  7 siblings, 1 reply; 15+ messages in thread
From: Guilherme G. Piccoli @ 2020-01-22 13:27 UTC (permalink / raw)
  To: Andy Shevchenko, linux-rtc
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Alessandro Zummo, Alexandre Belloni, linux-kernel

On 17/01/2020 14:56, Andy Shevchenko wrote:
> As reported by Guilherme:
> 
> The rtc-cmos interrupt setting was changed in the commit 079062b28fb4
> ("rtc: cmos: prevent kernel warning on IRQ flags mismatch") in order
> to allow shared interrupts; according to that commit's description,
> some machine got kernel warnings due to the interrupt line being shared
> between rtc-cmos and other hardware, and rtc-cmos didn't allow IRQ sharing
> that time.
> 
> After the aforementioned commit though it was observed a huge increase
> in lost HPET interrupts in some systems, observed through the following
> kernel message:
> 
> [...] hpet1: lost 35 rtc interrupts
> 
> After investigation, it was narrowed down to the shared interrupts
> usage when having the kernel option "irqpoll" enabled. In this case,
> all IRQ handlers are called for non-timer interrupts, if such handlers
> are setup in shared IRQ lines. The rtc-cmos IRQ handler could be set to
> hpet_rtc_interrupt(), which will produce the kernel "lost interrupts"
> message after doing work - lots of readl/writel to HPET registers, which
> are known to be slow.
> 
> This patch changes this behavior by preventing shared interrupts for
> everything, but Microsoft Surface 3 as stated in the culprit commit message.
> Although "irqpoll" is not a default kernel option, it's used in some contexts,
> one being the kdump kernel (which is an already "impaired" kernel usually
> running with 1 CPU available), so the performance burden could be considerable.
> Also, the same issue would happen (in a shorter extent though) when using
> "irqfixup" kernel option.
> 
> In a quick experiment, a virtual machine with uptime of 2 minutes produced
>> 300 calls to hpet_rtc_interrupt() when "irqpoll" was set, whereas without
> sharing interrupts this number reduced to 1 interrupt. Machines with more
> hardware than a VM should generate even more unnecessary HPET interrupts
> in this scenario.
> 
> Fixes: 079062b28fb4 ("rtc: cmos: prevent kernel warning on IRQ flags mismatch")
> Reported-by: Guilherme G. Piccoli <gpiccoli@canonical.com>
> Suggested-by: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


Andy, thanks for the great patch! It works for me, I've tested it on top
of 5.5-rc7, no more RTC lost interrupts while using the "irqpoll"
parameter. So, feel free to add my:

Tested-by: Guilherme G. Piccoli <gpiccoli@canonical.com>

Cheers,


Guilherme

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 1/8] rtc: cmos: Use shared IRQ only for Microsoft Surface 3
  2020-01-22 13:27 ` [PATCH v1 1/8] rtc: cmos: Use shared IRQ only for Microsoft Surface 3 Guilherme G. Piccoli
@ 2020-01-22 13:38   ` Andy Shevchenko
  2020-01-22 13:53     ` Guilherme Piccoli
  0 siblings, 1 reply; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-22 13:38 UTC (permalink / raw)
  To: Guilherme G. Piccoli
  Cc: linux-rtc, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	H. Peter Anvin, x86, Alessandro Zummo, Alexandre Belloni,
	linux-kernel

On Wed, Jan 22, 2020 at 10:27:18AM -0300, Guilherme G. Piccoli wrote:
> On 17/01/2020 14:56, Andy Shevchenko wrote:

> Andy, thanks for the great patch! It works for me, I've tested it on top
> of 5.5-rc7, no more RTC lost interrupts while using the "irqpoll"
> parameter. So, feel free to add my:
> 
> Tested-by: Guilherme G. Piccoli <gpiccoli@canonical.com>

Thank you for testing!

(Un)fortunately I dug a bit into the history of the patches and into the ACPI
tables of MS Surface 3. I have another (better) solution which I will send
separately from this series.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v1 1/8] rtc: cmos: Use shared IRQ only for Microsoft Surface 3
  2020-01-22 13:38   ` Andy Shevchenko
@ 2020-01-22 13:53     ` Guilherme Piccoli
  0 siblings, 0 replies; 15+ messages in thread
From: Guilherme Piccoli @ 2020-01-22 13:53 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-rtc, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	H. Peter Anvin, x86, Alessandro Zummo, Alexandre Belloni,
	linux-kernel

On Wed, Jan 22, 2020 at 10:39 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> [...]
> Thank you for testing!
>
> (Un)fortunately I dug a bit into the history of the patches and into the ACPI
> tables of MS Surface 3. I have another (better) solution which I will send
> separately from this series.
>

OK, if possible, loop me in and I can test that too.
Appreciate your effort on this!
Thanks,


Guilherme

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2020-01-22 13:53 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-17 17:56 [PATCH v1 1/8] rtc: cmos: Use shared IRQ only for Microsoft Surface 3 Andy Shevchenko
2020-01-17 17:56 ` [PATCH v1 2/8] x86/platform: Rename x86/apple.h -> x86/machine.h Andy Shevchenko
2020-01-17 17:56 ` [PATCH v1 3/8] x86/quirks: Add missed include to satisfy static checker Andy Shevchenko
2020-01-17 17:56 ` [PATCH v1 4/8] x86/quirks: Convert DMI matching to use a table Andy Shevchenko
2020-01-17 17:56 ` [PATCH v1 5/8] x86/quirks: Add a DMI quirk for Microsoft Surface 3 Andy Shevchenko
2020-01-20 12:09   ` Mark Brown
2020-01-20 12:21     ` Andy Shevchenko
2020-01-17 17:56 ` [PATCH v1 6/8] platform/x86: surface3_wmi: Switch DMI table match to a test of variable Andy Shevchenko
2020-01-17 17:56 ` [PATCH v1 7/8] ASoC: Intel: " Andy Shevchenko
2020-01-17 19:10   ` Pierre-Louis Bossart
2020-01-20 10:17     ` Andy Shevchenko
2020-01-17 17:56 ` [PATCH v1 8/8] rtc: cmos: " Andy Shevchenko
2020-01-22 13:27 ` [PATCH v1 1/8] rtc: cmos: Use shared IRQ only for Microsoft Surface 3 Guilherme G. Piccoli
2020-01-22 13:38   ` Andy Shevchenko
2020-01-22 13:53     ` Guilherme Piccoli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).