linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/9] x86: Easy way of detecting MS Surface 3
@ 2020-01-20 16:07 Andy Shevchenko
  2020-01-20 16:07 ` [PATCH v2 1/9] x86/platform: Rename x86/apple.h -> x86/machine.h Andy Shevchenko
                   ` (8 more replies)
  0 siblings, 9 replies; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-20 16:07 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Mark Brown, linux-kernel
  Cc: Andy Shevchenko, Cezary Rojewski, Pierre-Louis Bossart,
	Liam Girdwood, Jie Yang, alsa-devel

While working on RTC regression, I noticed that we are using the same DMI check
over and over in the drivers for MS Surface 3 platform. This series dedicated
for making it easier in the same way how it's done for Apple machines.

Changelog v2:
- removed RTC patches for now
- added couple more clean ups to arch/x86/kernel/quirks.c
- redone DMI quirk to use driver_data instead of callback
- simplified check in soc-acpi-intel-cht-match.c to be oneliner
- added a new patch to cover rt5645 codec driver

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

Andy Shevchenko (9):
  x86/platform: Rename x86/apple.h -> x86/machine.h
  x86/quirks: Add missed include to satisfy static checker
  x86/quirks: Introduce hpet_dev_print_force_hpet_address() helper
  x86/quirks: Join string literals back
  x86/quirks: Convert DMI matching to use a table
  x86/quirks: Add a DMI quirk for Microsoft Surface 3
  platform/x86: surface3_wmi: Switch DMI table match to a test of
    variable
  ASoC: rt5645: Switch DMI table match to a test of variable
  ASoC: Intel: Switch DMI table match to a test of variable

 arch/x86/kernel/quirks.c                      | 91 +++++++++++++------
 drivers/platform/x86/surface3-wmi.c           | 16 +---
 include/linux/platform_data/x86/apple.h       | 14 +--
 include/linux/platform_data/x86/machine.h     | 20 ++++
 sound/soc/codecs/rt5645.c                     | 14 ++-
 .../intel/common/soc-acpi-intel-cht-match.c   | 33 +------
 6 files changed, 93 insertions(+), 95 deletions(-)
 create mode 100644 include/linux/platform_data/x86/machine.h

-- 
2.24.1


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

* [PATCH v2 1/9] x86/platform: Rename x86/apple.h -> x86/machine.h
  2020-01-20 16:07 [PATCH v2 0/9] x86: Easy way of detecting MS Surface 3 Andy Shevchenko
@ 2020-01-20 16:07 ` Andy Shevchenko
  2020-01-20 16:07 ` [PATCH v2 2/9] x86/quirks: Add missed include to satisfy static checker Andy Shevchenko
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-20 16:07 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Mark Brown, 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 v2 2/9] x86/quirks: Add missed include to satisfy static checker
  2020-01-20 16:07 [PATCH v2 0/9] x86: Easy way of detecting MS Surface 3 Andy Shevchenko
  2020-01-20 16:07 ` [PATCH v2 1/9] x86/platform: Rename x86/apple.h -> x86/machine.h Andy Shevchenko
@ 2020-01-20 16:07 ` Andy Shevchenko
  2020-01-20 16:07 ` [PATCH v2 3/9] x86/quirks: Introduce hpet_dev_print_force_hpet_address() helper Andy Shevchenko
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-20 16:07 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Mark Brown, 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 v2 3/9] x86/quirks: Introduce hpet_dev_print_force_hpet_address() helper
  2020-01-20 16:07 [PATCH v2 0/9] x86: Easy way of detecting MS Surface 3 Andy Shevchenko
  2020-01-20 16:07 ` [PATCH v2 1/9] x86/platform: Rename x86/apple.h -> x86/machine.h Andy Shevchenko
  2020-01-20 16:07 ` [PATCH v2 2/9] x86/quirks: Add missed include to satisfy static checker Andy Shevchenko
@ 2020-01-20 16:07 ` Andy Shevchenko
  2020-01-20 16:07 ` [PATCH v2 4/9] x86/quirks: Join string literals back Andy Shevchenko
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-20 16:07 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Mark Brown, linux-kernel
  Cc: Andy Shevchenko

Introduce hpet_dev_print_force_hpet_address() helper to unify printing
forced HPET address. No functional change intended.

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

diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index 5b96654aacc0..ce8fc9bec43b 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -68,6 +68,11 @@ static enum {
 	ATI_FORCE_HPET_RESUME,
 } force_hpet_resume_type;
 
+static void hpet_dev_print_force_hpet_address(struct device *dev)
+{
+	dev_printk(KERN_DEBUG, dev, "Force enabled HPET at 0x%lx\n", force_hpet_address);
+}
+
 static void __iomem *rcba_base;
 
 static void ich_force_hpet_resume(void)
@@ -125,8 +130,7 @@ static void ich_force_enable_hpet(struct pci_dev *dev)
 		/* HPET is enabled in HPTC. Just not reported by BIOS */
 		val = val & 0x3;
 		force_hpet_address = 0xFED00000 | (val << 12);
-		dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
-			"0x%lx\n", force_hpet_address);
+		hpet_dev_print_force_hpet_address(&dev->dev);
 		iounmap(rcba_base);
 		return;
 	}
@@ -149,8 +153,7 @@ static void ich_force_enable_hpet(struct pci_dev *dev)
 			"Failed to force enable HPET\n");
 	} else {
 		force_hpet_resume_type = ICH_FORCE_HPET_RESUME;
-		dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
-			"0x%lx\n", force_hpet_address);
+		hpet_dev_print_force_hpet_address(&dev->dev);
 	}
 }
 
@@ -223,8 +226,7 @@ static void old_ich_force_enable_hpet(struct pci_dev *dev)
 	if (val & 0x4) {
 		val &= 0x3;
 		force_hpet_address = 0xFED00000 | (val << 12);
-		dev_printk(KERN_DEBUG, &dev->dev, "HPET at 0x%lx\n",
-			force_hpet_address);
+		hpet_dev_print_force_hpet_address(&dev->dev);
 		return;
 	}
 
@@ -244,8 +246,7 @@ static void old_ich_force_enable_hpet(struct pci_dev *dev)
 		/* HPET is enabled in HPTC. Just not reported by BIOS */
 		val &= 0x3;
 		force_hpet_address = 0xFED00000 | (val << 12);
-		dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
-			"0x%lx\n", force_hpet_address);
+		hpet_dev_print_force_hpet_address(&dev->dev);
 		cached_dev = dev;
 		force_hpet_resume_type = OLD_ICH_FORCE_HPET_RESUME;
 		return;
@@ -316,8 +317,7 @@ static void vt8237_force_enable_hpet(struct pci_dev *dev)
 	 */
 	if (val & 0x80) {
 		force_hpet_address = (val & ~0x3ff);
-		dev_printk(KERN_DEBUG, &dev->dev, "HPET at 0x%lx\n",
-			force_hpet_address);
+		hpet_dev_print_force_hpet_address(&dev->dev);
 		return;
 	}
 
@@ -331,8 +331,7 @@ static void vt8237_force_enable_hpet(struct pci_dev *dev)
 	pci_read_config_dword(dev, 0x68, &val);
 	if (val & 0x80) {
 		force_hpet_address = (val & ~0x3ff);
-		dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
-			"0x%lx\n", force_hpet_address);
+		hpet_dev_print_force_hpet_address(&dev->dev);
 		cached_dev = dev;
 		force_hpet_resume_type = VT8237_FORCE_HPET_RESUME;
 		return;
@@ -412,8 +411,7 @@ static void ati_force_enable_hpet(struct pci_dev *dev)
 
 	force_hpet_address = val;
 	force_hpet_resume_type = ATI_FORCE_HPET_RESUME;
-	dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at 0x%lx\n",
-		   force_hpet_address);
+	hpet_dev_print_force_hpet_address(&dev->dev);
 	cached_dev = dev;
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_SMBUS,
@@ -444,8 +442,7 @@ static void nvidia_force_enable_hpet(struct pci_dev *dev)
 	pci_read_config_dword(dev, 0x44, &val);
 	force_hpet_address = val & 0xfffffffe;
 	force_hpet_resume_type = NVIDIA_FORCE_HPET_RESUME;
-	dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at 0x%lx\n",
-		force_hpet_address);
+	hpet_dev_print_force_hpet_address(&dev->dev);
 	cached_dev = dev;
 }
 
@@ -509,8 +506,7 @@ static void e6xx_force_enable_hpet(struct pci_dev *dev)
 
 	force_hpet_address = 0xFED00000;
 	force_hpet_resume_type = NONE_FORCE_HPET_RESUME;
-	dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
-		"0x%lx\n", force_hpet_address);
+	hpet_dev_print_force_hpet_address(&dev->dev);
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E6XX_CU,
 			 e6xx_force_enable_hpet);
-- 
2.24.1


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

* [PATCH v2 4/9] x86/quirks: Join string literals back
  2020-01-20 16:07 [PATCH v2 0/9] x86: Easy way of detecting MS Surface 3 Andy Shevchenko
                   ` (2 preceding siblings ...)
  2020-01-20 16:07 ` [PATCH v2 3/9] x86/quirks: Introduce hpet_dev_print_force_hpet_address() helper Andy Shevchenko
@ 2020-01-20 16:07 ` Andy Shevchenko
  2020-01-20 16:07 ` [PATCH v2 5/9] x86/quirks: Convert DMI matching to use a table Andy Shevchenko
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-20 16:07 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Mark Brown, linux-kernel
  Cc: Andy Shevchenko

There is no need to split string literals. Moreover, it would be simpler
to grep for an actual code line, when debugging, by using almost any
part of the string literal in question.

No functional change intended.

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

diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index ce8fc9bec43b..6c122f35508a 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -36,8 +36,7 @@ static void quirk_intel_irqbalance(struct pci_dev *dev)
 	pci_bus_read_config_word(dev->bus, PCI_DEVFN(8, 0), 0x4c, &word);
 
 	if (!(word & (1 << 13))) {
-		dev_info(&dev->dev, "Intel E7520/7320/7525 detected; "
-			"disabling irq balancing and affinity\n");
+		dev_info(&dev->dev, "Intel E7520/7320/7525 detected; disabling irq balancing and affinity\n");
 		noirqdebug_setup("");
 #ifdef CONFIG_PROC_FS
 		no_irq_affinity = 1;
@@ -110,16 +109,14 @@ static void ich_force_enable_hpet(struct pci_dev *dev)
 	pci_read_config_dword(dev, 0xF0, &rcba);
 	rcba &= 0xFFFFC000;
 	if (rcba == 0) {
-		dev_printk(KERN_DEBUG, &dev->dev, "RCBA disabled; "
-			"cannot force enable HPET\n");
+		dev_printk(KERN_DEBUG, &dev->dev, "RCBA disabled; cannot force enable HPET\n");
 		return;
 	}
 
 	/* use bits 31:14, 16 kB aligned */
 	rcba_base = ioremap_nocache(rcba, 0x4000);
 	if (rcba_base == NULL) {
-		dev_printk(KERN_DEBUG, &dev->dev, "ioremap failed; "
-			"cannot force enable HPET\n");
+		dev_printk(KERN_DEBUG, &dev->dev, "ioremap failed; cannot force enable HPET\n");
 		return;
 	}
 
@@ -149,8 +146,7 @@ static void ich_force_enable_hpet(struct pci_dev *dev)
 	if (err) {
 		force_hpet_address = 0;
 		iounmap(rcba_base);
-		dev_printk(KERN_DEBUG, &dev->dev,
-			"Failed to force enable HPET\n");
+		dev_printk(KERN_DEBUG, &dev->dev, "Failed to force enable HPET\n");
 	} else {
 		force_hpet_resume_type = ICH_FORCE_HPET_RESUME;
 		hpet_dev_print_force_hpet_address(&dev->dev);
@@ -182,8 +178,7 @@ static struct pci_dev *cached_dev;
 
 static void hpet_print_force_info(void)
 {
-	printk(KERN_INFO "HPET not enabled in BIOS. "
-	       "You might try hpet=force boot option\n");
+	printk(KERN_INFO "HPET not enabled in BIOS. You might try hpet=force boot option\n");
 }
 
 static void old_ich_force_hpet_resume(void)
-- 
2.24.1


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

* [PATCH v2 5/9] x86/quirks: Convert DMI matching to use a table
  2020-01-20 16:07 [PATCH v2 0/9] x86: Easy way of detecting MS Surface 3 Andy Shevchenko
                   ` (3 preceding siblings ...)
  2020-01-20 16:07 ` [PATCH v2 4/9] x86/quirks: Join string literals back Andy Shevchenko
@ 2020-01-20 16:07 ` Andy Shevchenko
  2020-01-21 11:51   ` Jonathan McDowell
  2020-01-20 16:07 ` [PATCH v2 6/9] x86/quirks: Add a DMI quirk for Microsoft Surface 3 Andy Shevchenko
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-20 16:07 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Mark Brown, 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 | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index 6c122f35508a..78846a8dc88b 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -658,8 +658,37 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2083, quirk_intel_purley_xeon_ras
 bool x86_apple_machine;
 EXPORT_SYMBOL(x86_apple_machine);
 
+static const struct dmi_system_id x86_machine_table[] __initconst = {
+	{
+		.ident = "x86 Apple Macintosh",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
+		},
+		.driver_data = &x86_apple_machine,
+	},
+	{
+		.ident = "x86 Apple Macintosh",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."),
+		},
+		.driver_data = &x86_apple_machine,
+	},
+	{}
+};
+
+static void __init early_platfrom_detect_quirk(void)
+{
+	const struct dmi_system_id *id;
+
+	id = dmi_first_match(x86_machine_table);
+	if (!id)
+		return;
+
+	printk(KERN_DEBUG "Detected %s platform\n", id->ident);
+	*((bool *)id->driver_data) = true;
+}
+
 void __init early_platform_quirks(void)
 {
-	x86_apple_machine = dmi_match(DMI_SYS_VENDOR, "Apple Inc.") ||
-			    dmi_match(DMI_SYS_VENDOR, "Apple Computer, Inc.");
+	early_platfrom_detect_quirk();
 }
-- 
2.24.1


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

* [PATCH v2 6/9] x86/quirks: Add a DMI quirk for Microsoft Surface 3
  2020-01-20 16:07 [PATCH v2 0/9] x86: Easy way of detecting MS Surface 3 Andy Shevchenko
                   ` (4 preceding siblings ...)
  2020-01-20 16:07 ` [PATCH v2 5/9] x86/quirks: Convert DMI matching to use a table Andy Shevchenko
@ 2020-01-20 16:07 ` Andy Shevchenko
  2020-01-20 16:07 ` [PATCH v2 7/9] platform/x86: surface3_wmi: Switch DMI table match to a test of variable Andy Shevchenko
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-20 16:07 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Mark Brown, linux-kernel
  Cc: Andy Shevchenko, Cezary Rojewski, Pierre-Louis Bossart,
	Liam Girdwood, Jie Yang, 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                  | 10 ++++++++++
 include/linux/platform_data/x86/machine.h |  5 +++++
 2 files changed, 15 insertions(+)

diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index 78846a8dc88b..501fbcd16282 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -658,6 +658,9 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2083, quirk_intel_purley_xeon_ras
 bool x86_apple_machine;
 EXPORT_SYMBOL(x86_apple_machine);
 
+bool x86_microsoft_surface_3_machine;
+EXPORT_SYMBOL(x86_microsoft_surface_3_machine);
+
 static const struct dmi_system_id x86_machine_table[] __initconst = {
 	{
 		.ident = "x86 Apple Macintosh",
@@ -673,6 +676,13 @@ static const struct dmi_system_id x86_machine_table[] __initconst = {
 		},
 		.driver_data = &x86_apple_machine,
 	},
+	{
+		.ident = "Microsoft Surface 3",
+		.matches = {
+			DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
+		},
+		.driver_data = &x86_microsoft_surface_3_machine,
+	},
 	{}
 };
 
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 v2 7/9] platform/x86: surface3_wmi: Switch DMI table match to a test of variable
  2020-01-20 16:07 [PATCH v2 0/9] x86: Easy way of detecting MS Surface 3 Andy Shevchenko
                   ` (5 preceding siblings ...)
  2020-01-20 16:07 ` [PATCH v2 6/9] x86/quirks: Add a DMI quirk for Microsoft Surface 3 Andy Shevchenko
@ 2020-01-20 16:07 ` Andy Shevchenko
  2020-01-20 16:08 ` [PATCH v2 8/9] ASoC: rt5645: " Andy Shevchenko
  2020-01-20 16:08 ` [PATCH v2 9/9] ASoC: Intel: " Andy Shevchenko
  8 siblings, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-20 16:07 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Mark Brown, 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 v2 8/9] ASoC: rt5645: Switch DMI table match to a test of variable
  2020-01-20 16:07 [PATCH v2 0/9] x86: Easy way of detecting MS Surface 3 Andy Shevchenko
                   ` (6 preceding siblings ...)
  2020-01-20 16:07 ` [PATCH v2 7/9] platform/x86: surface3_wmi: Switch DMI table match to a test of variable Andy Shevchenko
@ 2020-01-20 16:08 ` Andy Shevchenko
  2020-01-20 17:46   ` Mark Brown
  2020-01-20 16:08 ` [PATCH v2 9/9] ASoC: Intel: " Andy Shevchenko
  8 siblings, 1 reply; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-20 16:08 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Mark Brown, linux-kernel
  Cc: Andy Shevchenko, Cezary Rojewski, Pierre-Louis Bossart,
	Liam Girdwood, Jie Yang, alsa-devel

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

Note, arch/x86/kernel/quirks.c::early_platform_detect_quirk() prints
the detected platform.

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>
---
 sound/soc/codecs/rt5645.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 92d67010aeed..3ccecb81bc37 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -12,6 +12,7 @@
 #include <linux/delay.h>
 #include <linux/pm.h>
 #include <linux/i2c.h>
+#include <linux/platform_data/x86/machine.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
 #include <linux/gpio.h>
@@ -3674,13 +3675,6 @@ static const struct dmi_system_id dmi_platform_data[] = {
 		},
 		.driver_data = (void *)&intel_braswell_platform_data,
 	},
-	{
-		.ident = "Microsoft Surface 3",
-		.matches = {
-			DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
-		},
-		.driver_data = (void *)&intel_braswell_platform_data,
-	},
 	{
 		/*
 		 * Match for the GPDwin which unfortunately uses somewhat
@@ -3789,7 +3783,7 @@ static int rt5645_parse_dt(struct rt5645_priv *rt5645, struct device *dev)
 static int rt5645_i2c_probe(struct i2c_client *i2c,
 		    const struct i2c_device_id *id)
 {
-	struct rt5645_platform_data *pdata = dev_get_platdata(&i2c->dev);
+	const struct rt5645_platform_data *pdata = dev_get_platdata(&i2c->dev);
 	const struct dmi_system_id *dmi_data;
 	struct rt5645_priv *rt5645;
 	int ret, i;
@@ -3804,6 +3798,10 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
 	rt5645->i2c = i2c;
 	i2c_set_clientdata(i2c, rt5645);
 
+	/* Put it first to allow DMI to override, if needed */
+	if (x86_microsoft_surface_3_machine)
+		pdata = &intel_braswell_platform_data;
+
 	dmi_data = dmi_first_match(dmi_platform_data);
 	if (dmi_data) {
 		dev_info(&i2c->dev, "Detected %s platform\n", dmi_data->ident);
-- 
2.24.1


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

* [PATCH v2 9/9] ASoC: Intel: Switch DMI table match to a test of variable
  2020-01-20 16:07 [PATCH v2 0/9] x86: Easy way of detecting MS Surface 3 Andy Shevchenko
                   ` (7 preceding siblings ...)
  2020-01-20 16:08 ` [PATCH v2 8/9] ASoC: rt5645: " Andy Shevchenko
@ 2020-01-20 16:08 ` Andy Shevchenko
  2020-01-20 17:55   ` Mark Brown
  8 siblings, 1 reply; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-20 16:08 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, Mark Brown, linux-kernel
  Cc: Andy Shevchenko, Cezary Rojewski, Pierre-Louis Bossart,
	Liam Girdwood, Jie Yang, 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   | 33 ++-----------------
 1 file changed, 3 insertions(+), 30 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..c35766125d5e 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",
@@ -41,14 +21,7 @@ static struct snd_soc_acpi_mach cht_surface_mach = {
 
 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)
-		return &cht_surface_mach;
-	else
-		return mach;
+	return x86_microsoft_surface_3_machine ? &cht_surface_mach : arg;
 }
 
 /* Cherryview-based platforms: CherryTrail and Braswell */
-- 
2.24.1


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

* Re: [PATCH v2 8/9] ASoC: rt5645: Switch DMI table match to a test of variable
  2020-01-20 16:08 ` [PATCH v2 8/9] ASoC: rt5645: " Andy Shevchenko
@ 2020-01-20 17:46   ` Mark Brown
  0 siblings, 0 replies; 15+ messages in thread
From: Mark Brown @ 2020-01-20 17:46 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, linux-kernel, Cezary Rojewski, Pierre-Louis Bossart,
	Liam Girdwood, Jie Yang, alsa-devel

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

On Mon, Jan 20, 2020 at 06:08:00PM +0200, Andy Shevchenko wrote:
> Since we have a common x86 quirk that provides an exported variable,
> use it instead of local DMI table match.

Acked-by: Mark Brown <broonie@kernel.org>

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

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

* Re: [PATCH v2 9/9] ASoC: Intel: Switch DMI table match to a test of variable
  2020-01-20 16:08 ` [PATCH v2 9/9] ASoC: Intel: " Andy Shevchenko
@ 2020-01-20 17:55   ` Mark Brown
  2020-01-21 15:20     ` Andy Shevchenko
  0 siblings, 1 reply; 15+ messages in thread
From: Mark Brown @ 2020-01-20 17:55 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, H. Peter Anvin,
	x86, linux-kernel, Cezary Rojewski, Pierre-Louis Bossart,
	Liam Girdwood, Jie Yang, alsa-devel

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

On Mon, Jan 20, 2020 at 06:08:01PM +0200, Andy Shevchenko wrote:
> Since we have a common x86 quirk that provides an exported variable,
> use it instead of local DMI table match.

Acked-by: Mark Brown <broonie@kernel.org>

> -	if (cht_machine_id == CHT_SURFACE_MACH)
> -		return &cht_surface_mach;
> -	else
> -		return mach;
> +	return x86_microsoft_surface_3_machine ? &cht_surface_mach : arg;

but if you're respinning this please replace this with a normal
conditional statement to improve legibility.

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

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

* Re: [PATCH v2 5/9] x86/quirks: Convert DMI matching to use a table
  2020-01-20 16:07 ` [PATCH v2 5/9] x86/quirks: Convert DMI matching to use a table Andy Shevchenko
@ 2020-01-21 11:51   ` Jonathan McDowell
  2020-01-21 15:20     ` Andy Shevchenko
  0 siblings, 1 reply; 15+ messages in thread
From: Jonathan McDowell @ 2020-01-21 11:51 UTC (permalink / raw)
  To: andriy.shevchenko; +Cc: x86, linux-kernel

In article <20200120160801.53089-6-andriy.shevchenko@linux.intel.com> you wrote:
> 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 | 33 +++++++++++++++++++++++++++++++--
>  1 file changed, 31 insertions(+), 2 deletions(-)

> diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
> index 6c122f35508a..78846a8dc88b 100644
> --- a/arch/x86/kernel/quirks.c
> +++ b/arch/x86/kernel/quirks.c
> @@ -658,8 +658,37 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2083, quirk_intel_purley_xeon_ras
>  bool x86_apple_machine;
>  EXPORT_SYMBOL(x86_apple_machine);
>  
> +static const struct dmi_system_id x86_machine_table[] __initconst = {
> +	{
> +		.ident = "x86 Apple Macintosh",
> +		.matches = {
> +			DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
> +		},
> +		.driver_data = &x86_apple_machine,
> +	},
> +	{
> +		.ident = "x86 Apple Macintosh",
> +		.matches = {
> +			DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."),
> +		},
> +		.driver_data = &x86_apple_machine,
> +	},
> +	{}
> +};
> +
> +static void __init early_platfrom_detect_quirk(void)

"platform"

> +{
> +	const struct dmi_system_id *id;
> +
> +	id = dmi_first_match(x86_machine_table);
> +	if (!id)
> +		return;
> +
> +	printk(KERN_DEBUG "Detected %s platform\n", id->ident);
> +	*((bool *)id->driver_data) = true;
> +}
> +
>  void __init early_platform_quirks(void)
>  {
> -	x86_apple_machine = dmi_match(DMI_SYS_VENDOR, "Apple Inc.") ||
> -			    dmi_match(DMI_SYS_VENDOR, "Apple Computer, Inc.");
> +	early_platfrom_detect_quirk();

As above.

>  }

J.

-- 
If I follow you home, will you keep me?
This .sig brought to you by the letter C and the number  9
Product of the Republic of HuggieTag

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

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

On Mon, Jan 20, 2020 at 05:55:54PM +0000, Mark Brown wrote:
> On Mon, Jan 20, 2020 at 06:08:01PM +0200, Andy Shevchenko wrote:
> > Since we have a common x86 quirk that provides an exported variable,
> > use it instead of local DMI table match.
> 
> Acked-by: Mark Brown <broonie@kernel.org>
> 
> > -	if (cht_machine_id == CHT_SURFACE_MACH)
> > -		return &cht_surface_mach;
> > -	else
> > -		return mach;
> > +	return x86_microsoft_surface_3_machine ? &cht_surface_mach : arg;
> 
> but if you're respinning this please replace this with a normal
> conditional statement to improve legibility.

Okay, will do. Thanks for review!

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 5/9] x86/quirks: Convert DMI matching to use a table
  2020-01-21 11:51   ` Jonathan McDowell
@ 2020-01-21 15:20     ` Andy Shevchenko
  0 siblings, 0 replies; 15+ messages in thread
From: Andy Shevchenko @ 2020-01-21 15:20 UTC (permalink / raw)
  To: Jonathan McDowell; +Cc: x86, linux-kernel

On Tue, Jan 21, 2020 at 11:51:25AM +0000, Jonathan McDowell wrote:
> In article <20200120160801.53089-6-andriy.shevchenko@linux.intel.com> you wrote:
> > In order to extend the DMI based quirks, convert them to a table.

> > +static void __init early_platfrom_detect_quirk(void)
> 
> "platform"

> > +	early_platfrom_detect_quirk();
> 
> As above.

Thanks! Will fix in v3.

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2020-01-21 15:21 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-20 16:07 [PATCH v2 0/9] x86: Easy way of detecting MS Surface 3 Andy Shevchenko
2020-01-20 16:07 ` [PATCH v2 1/9] x86/platform: Rename x86/apple.h -> x86/machine.h Andy Shevchenko
2020-01-20 16:07 ` [PATCH v2 2/9] x86/quirks: Add missed include to satisfy static checker Andy Shevchenko
2020-01-20 16:07 ` [PATCH v2 3/9] x86/quirks: Introduce hpet_dev_print_force_hpet_address() helper Andy Shevchenko
2020-01-20 16:07 ` [PATCH v2 4/9] x86/quirks: Join string literals back Andy Shevchenko
2020-01-20 16:07 ` [PATCH v2 5/9] x86/quirks: Convert DMI matching to use a table Andy Shevchenko
2020-01-21 11:51   ` Jonathan McDowell
2020-01-21 15:20     ` Andy Shevchenko
2020-01-20 16:07 ` [PATCH v2 6/9] x86/quirks: Add a DMI quirk for Microsoft Surface 3 Andy Shevchenko
2020-01-20 16:07 ` [PATCH v2 7/9] platform/x86: surface3_wmi: Switch DMI table match to a test of variable Andy Shevchenko
2020-01-20 16:08 ` [PATCH v2 8/9] ASoC: rt5645: " Andy Shevchenko
2020-01-20 17:46   ` Mark Brown
2020-01-20 16:08 ` [PATCH v2 9/9] ASoC: Intel: " Andy Shevchenko
2020-01-20 17:55   ` Mark Brown
2020-01-21 15:20     ` Andy Shevchenko

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).