Skip to contentSkip to conversation

x86/cpu: Introduce INTEL_CPU_FAM*_NODATA() helper macros

PATCH Superseded Andy Shevchenko 4 participants 9 messages Aug 31, 2018 – Sep 11, 2018

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 x86/cpu: Introduce INTEL_CPU_FAM*_NODATA() helper macros

These macros are often used by drivers and we have already a lot of duplication as ICPU() macro across the drivers.

Provide a generic x86 macro for users.

This adds no driver data variants.

---
 arch/x86/include/asm/intel-family.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
arch/x86/include/asm/intel-family.h +8 -2
index 7ed08a7c3398..093014aceb65 100644
@@ -83,10 +83,16 @@
 	.family		= _family,				\
 	.model		= _model,				\
 	.feature	= X86_FEATURE_ANY,			\
-	.driver_data	= (kernel_ulong_t)&_driver_data		\
+	.driver_data	= (kernel_ulong_t)_driver_data		\
 }
 
 #define INTEL_CPU_FAM6(_model, _driver_data)			\
-	INTEL_CPU_FAM_ANY(6, INTEL_FAM6_##_model, _driver_data)
+	INTEL_CPU_FAM_ANY(6, INTEL_FAM6_##_model, &_driver_data)
+
+#define INTEL_CPU_FAM_ANY_NODATA(_family, _model)		\
+	INTEL_CPU_FAM_ANY(_family, _model, NULL)
+
+#define INTEL_CPU_FAM6_NODATA(_model)				\
+	INTEL_CPU_FAM_ANY_NODATA(6, INTEL_FAM6_##_model)
 
 #endif /* _ASM_X86_INTEL_FAMILY_H */
Signature · 1 line
2.18.0
#1 lore raw

PATCH 2/4 x86/efi: Get rid of custom ICPU() macro

Replace custom grown macro with generic INTEL_CPU_FAM_ANY() one.

No functional change intended.

---
 arch/x86/include/asm/intel-family.h | 2 ++
 arch/x86/platform/efi/quirks.c      | 6 +-----
 2 files changed, 3 insertions(+), 5 deletions(-)
arch/x86/include/asm/intel-family.h +2 -0
index 093014aceb65..be28519b2020 100644
@@ -16,6 +16,8 @@
  * that group keep the CPUID for the variants sorted by model number.
  */
 
+#define INTEL_FAM5_QUARK_X1000		0x09
+
 #define INTEL_FAM6_CORE_YONAH		0x0E
 
 #define INTEL_FAM6_CORE2_MEROM		0x0F
arch/x86/platform/efi/quirks.c +1 -5
index 844d31cb8a0c..cf8ea09cc52b 100644
@@ -610,12 +610,8 @@ static int qrk_capsule_setup_info(struct capsule_info *cap_info, void **pkbuff,
 	return 1;
 }
 
-#define ICPU(family, model, quirk_handler) \
-	{ X86_VENDOR_INTEL, family, model, X86_FEATURE_ANY, \
-	  (unsigned long)&quirk_handler }
-
 static const struct x86_cpu_id efi_capsule_quirk_ids[] = {
-	ICPU(5, 9, qrk_capsule_setup_info),	/* Intel Quark X1000 */
+	INTEL_CPU_FAM_ANY(5, INTEL_FAM5_QUARK_X1000, &qrk_capsule_setup_info),
 	{ }
 };
 
Signature · 1 line
2.18.0
#2 lore raw

Re: [PATCH v1 2/4] x86/efi: Get rid of custom ICPU() macro

I love your patch! Yet something to improve:

Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on tip/auto-latest]
[also build test ERROR on v4.19-rc2 next-20180831]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Andy-Shevchenko/x86-cpu-Introduce-INTEL_CPU_FAM-_NODATA-helper-macros/20180903-170803
config: i386-randconfig-x078-201835 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0 reproduce:

        # save the attached .config to linux build tree
        make ARCH=i386 
:::::: branch date: 56 minutes ago
:::::: commit date: 56 minutes ago

All errors (new ones prefixed by >>):

>> arch/x86/platform/efi/quirks.c:614:2: error: implicit declaration of function 'INTEL_CPU_FAM_ANY' [-Werror=implicit-function-declaration]
     INTEL_CPU_FAM_ANY(5, INTEL_FAM5_QUARK_X1000, &qrk_capsule_setup_info),
     ^~~~~~~~~~~~~~~~~
>> arch/x86/platform/efi/quirks.c:614:23: error: 'INTEL_FAM5_QUARK_X1000' undeclared here (not in a function)
     INTEL_CPU_FAM_ANY(5, INTEL_FAM5_QUARK_X1000, &qrk_capsule_setup_info),
                          ^~~~~~~~~~~~~~~~~~~~~~

cc1: some warnings being treated as errors

# https://github.com/0day-ci/linux/commit/e4c07e90e85507005bc79839ce9c0dbc8f016578
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout e4c07e90e85507005bc79839ce9c0dbc8f016578
vim +/INTEL_CPU_FAM_ANY +614 arch/x86/platform/efi/quirks.c

2959c95d Jan Kiszka      2017-06-02  612  
2959c95d Jan Kiszka      2017-06-02  613  static const struct x86_cpu_id efi_capsule_quirk_ids[] = {
e4c07e90 Andy Shevchenko 2018-08-31 @614  	INTEL_CPU_FAM_ANY(5, INTEL_FAM5_QUARK_X1000, &qrk_capsule_setup_info),
2959c95d Jan Kiszka      2017-06-02  615  	{ }
2959c95d Jan Kiszka      2017-06-02  616  };

2959c95d Jan Kiszka 2017-06-02 617

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#3 lore raw

PATCH 3/4 ACPI / LPSS: Get rid of custom ICPU() macro

In reply to Andy Shevchenko

Replace custom grown macro with generic INTEL_CPU_FAM6_NODATA() one.

No functional change intended.

---
 drivers/acpi/acpi_lpss.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/acpi/acpi_lpss.c +2 -4
index 9706613eecf9..c363e2a40f13 100644
@@ -289,11 +289,9 @@ static const struct lpss_device_desc bsw_spi_dev_desc = {
 	.setup = lpss_deassert_reset,
 };
 
-#define ICPU(model)	{ X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, }
-
 static const struct x86_cpu_id lpss_cpu_ids[] = {
-	ICPU(INTEL_FAM6_ATOM_SILVERMONT1),	/* Valleyview, Bay Trail */
-	ICPU(INTEL_FAM6_ATOM_AIRMONT),	/* Braswell, Cherry Trail */
+	INTEL_CPU_FAM6_NODATA(ATOM_SILVERMONT1),	/* Valleyview, Bay Trail */
+	INTEL_CPU_FAM6_NODATA(ATOM_AIRMONT),		/* Braswell, Cherry Trail */
 	{}
 };
 
Signature · 1 line
2.18.0
Acked-by on v1 3/4
#4 lore raw

Re: [PATCH v1 3/4] ACPI / LPSS: Get rid of custom ICPU() macro

Quoted 18 lines · CEST Andy Shevchenko

Replace custom grown macro with generic INTEL_CPU_FAM6_NODATA() one.

No functional change intended.

---
 drivers/acpi/acpi_lpss.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/acpi/acpi_lpss.c +0 -0
index 9706613eecf9..c363e2a40f13 100644
@@ -289,11 +289,9 @@ static const struct lpss_device_desc bsw_spi_dev_desc = {
 	.setup = lpss_deassert_reset,
 };
 

drivers/acpi/acpi_lpss.c static const struct lpss_device_desc bsw_spi_dev_desc = { · line 297

Quoted 10 lines
drivers/acpi/acpi_lpss.c +2 -4
-#define ICPU(model)	{ X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, }
-
 static const struct x86_cpu_id lpss_cpu_ids[] = {
-	ICPU(INTEL_FAM6_ATOM_SILVERMONT1),	/* Valleyview, Bay Trail */
-	ICPU(INTEL_FAM6_ATOM_AIRMONT),	/* Braswell, Cherry Trail */
+	INTEL_CPU_FAM6_NODATA(ATOM_SILVERMONT1),	/* Valleyview, Bay Trail */
+	INTEL_CPU_FAM6_NODATA(ATOM_AIRMONT),		/* Braswell, Cherry Trail */
 	{}
 };
 
#5 lore raw

PATCH 4/4 ACPI / x86: utils: Get rid of custom ICPU() macro

In reply to Andy Shevchenko

Replace custom grown macro with generic INTEL_CPU_FAM6_NODATA() one.

No functional change intended.

---
 drivers/acpi/x86/utils.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/acpi/x86/utils.c +8 -10
index 06c31ec3cc70..6bb2a4565386 100644
@@ -40,8 +40,6 @@ struct always_present_id {
 	const char *uid;
 };
 
-#define ICPU(model)	{ X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, }
-
 #define ENTRY(hid, uid, cpu_models, dmi...) {				\
 	{ { hid, }, {} },						\
 	{ cpu_models, {} },						\
@@ -54,24 +52,24 @@ static const struct always_present_id always_present_ids[] = {
 	 * Bay / Cherry Trail PWM directly poked by GPU driver in win10,
 	 * but Linux uses a separate PWM driver, harmless if not used.
 	 */
-	ENTRY("80860F09", "1", ICPU(INTEL_FAM6_ATOM_SILVERMONT1), {}),
-	ENTRY("80862288", "1", ICPU(INTEL_FAM6_ATOM_AIRMONT), {}),
+	ENTRY("80860F09", "1", INTEL_CPU_FAM6_NODATA(ATOM_SILVERMONT1), {}),
+	ENTRY("80862288", "1", INTEL_CPU_FAM6_NODATA(ATOM_AIRMONT), {}),
 	/*
 	 * The INT0002 device is necessary to clear wakeup interrupt sources
 	 * on Cherry Trail devices, without it we get nobody cared IRQ msgs.
 	 */
-	ENTRY("INT0002", "1", ICPU(INTEL_FAM6_ATOM_AIRMONT), {}),
+	ENTRY("INT0002", "1", INTEL_CPU_FAM6_NODATA(ATOM_AIRMONT), {}),
 	/*
 	 * On the Dell Venue 11 Pro 7130 and 7139, the DSDT hides
 	 * the touchscreen ACPI device until a certain time
 	 * after _SB.PCI0.GFX0.LCD.LCD1._ON gets called has passed
 	 * *and* _STA has been called at least 3 times since.
 	 */
-	ENTRY("SYNA7500", "1", ICPU(INTEL_FAM6_HASWELL_ULT), {
+	ENTRY("SYNA7500", "1", INTEL_CPU_FAM6_NODATA(HASWELL_ULT), {
 		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
 		DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7130"),
 	      }),
-	ENTRY("SYNA7500", "1", ICPU(INTEL_FAM6_HASWELL_ULT), {
+	ENTRY("SYNA7500", "1", INTEL_CPU_FAM6_NODATA(HASWELL_ULT), {
 		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
 		DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7139"),
 	      }),
@@ -87,19 +85,19 @@ static const struct always_present_id always_present_ids[] = {
 	 * was copy-pasted from the GPD win, so it has a disabled KIOX000A
 	 * node which we should not enable, thus we also check the BIOS date.
 	 */
-	ENTRY("KIOX000A", "1", ICPU(INTEL_FAM6_ATOM_AIRMONT), {
+	ENTRY("KIOX000A", "1", INTEL_CPU_FAM6_NODATA(ATOM_AIRMONT), {
 		DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
 		DMI_MATCH(DMI_BOARD_NAME, "Default string"),
 		DMI_MATCH(DMI_PRODUCT_NAME, "Default string"),
 		DMI_MATCH(DMI_BIOS_DATE, "02/21/2017")
 	      }),
-	ENTRY("KIOX000A", "1", ICPU(INTEL_FAM6_ATOM_AIRMONT), {
+	ENTRY("KIOX000A", "1", INTEL_CPU_FAM6_NODATA(ATOM_AIRMONT), {
 		DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
 		DMI_MATCH(DMI_BOARD_NAME, "Default string"),
 		DMI_MATCH(DMI_PRODUCT_NAME, "Default string"),
 		DMI_MATCH(DMI_BIOS_DATE, "03/20/2017")
 	      }),
-	ENTRY("KIOX000A", "1", ICPU(INTEL_FAM6_ATOM_AIRMONT), {
+	ENTRY("KIOX000A", "1", INTEL_CPU_FAM6_NODATA(ATOM_AIRMONT), {
 		DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
 		DMI_MATCH(DMI_BOARD_NAME, "Default string"),
 		DMI_MATCH(DMI_PRODUCT_NAME, "Default string"),
Signature · 1 line
2.18.0
Acked-by on v1 4/4
#6 lore raw

Re: [PATCH v1 4/4] ACPI / x86: utils: Get rid of custom ICPU() macro

Quoted 66 lines · CEST Andy Shevchenko

Replace custom grown macro with generic INTEL_CPU_FAM6_NODATA() one.

No functional change intended.

---
 drivers/acpi/x86/utils.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/acpi/x86/utils.c +7 -9
index 06c31ec3cc70..6bb2a4565386 100644
@@ -40,8 +40,6 @@ struct always_present_id {
 	const char *uid;
 };
 
-#define ICPU(model)	{ X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, }
-
 #define ENTRY(hid, uid, cpu_models, dmi...) {				\
 	{ { hid, }, {} },						\
 	{ cpu_models, {} },						\
@@ -54,24 +52,24 @@ static const struct always_present_id always_present_ids[] = {
 	 * Bay / Cherry Trail PWM directly poked by GPU driver in win10,
 	 * but Linux uses a separate PWM driver, harmless if not used.
 	 */
-	ENTRY("80860F09", "1", ICPU(INTEL_FAM6_ATOM_SILVERMONT1), {}),
-	ENTRY("80862288", "1", ICPU(INTEL_FAM6_ATOM_AIRMONT), {}),
+	ENTRY("80860F09", "1", INTEL_CPU_FAM6_NODATA(ATOM_SILVERMONT1), {}),
+	ENTRY("80862288", "1", INTEL_CPU_FAM6_NODATA(ATOM_AIRMONT), {}),
 	/*
 	 * The INT0002 device is necessary to clear wakeup interrupt sources
 	 * on Cherry Trail devices, without it we get nobody cared IRQ msgs.
 	 */
-	ENTRY("INT0002", "1", ICPU(INTEL_FAM6_ATOM_AIRMONT), {}),
+	ENTRY("INT0002", "1", INTEL_CPU_FAM6_NODATA(ATOM_AIRMONT), {}),
 	/*
 	 * On the Dell Venue 11 Pro 7130 and 7139, the DSDT hides
 	 * the touchscreen ACPI device until a certain time
 	 * after _SB.PCI0.GFX0.LCD.LCD1._ON gets called has passed
 	 * *and* _STA has been called at least 3 times since.
 	 */
-	ENTRY("SYNA7500", "1", ICPU(INTEL_FAM6_HASWELL_ULT), {
+	ENTRY("SYNA7500", "1", INTEL_CPU_FAM6_NODATA(HASWELL_ULT), {
 		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
 		DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7130"),
 	      }),
-	ENTRY("SYNA7500", "1", ICPU(INTEL_FAM6_HASWELL_ULT), {
+	ENTRY("SYNA7500", "1", INTEL_CPU_FAM6_NODATA(HASWELL_ULT), {
 		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
 		DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7139"),
 	      }),
@@ -87,19 +85,19 @@ static const struct always_present_id always_present_ids[] = {
 	 * was copy-pasted from the GPD win, so it has a disabled KIOX000A
 	 * node which we should not enable, thus we also check the BIOS date.
 	 */
-	ENTRY("KIOX000A", "1", ICPU(INTEL_FAM6_ATOM_AIRMONT), {
+	ENTRY("KIOX000A", "1", INTEL_CPU_FAM6_NODATA(ATOM_AIRMONT), {
 		DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
 		DMI_MATCH(DMI_BOARD_NAME, "Default string"),
 		DMI_MATCH(DMI_PRODUCT_NAME, "Default string"),
 		DMI_MATCH(DMI_BIOS_DATE, "02/21/2017")
 	      }),
-	ENTRY("KIOX000A", "1", ICPU(INTEL_FAM6_ATOM_AIRMONT), {
+	ENTRY("KIOX000A", "1", INTEL_CPU_FAM6_NODATA(ATOM_AIRMONT), {

drivers/acpi/x86/utils.c static const struct always_present_id always_present_ids[] = { · line 103

Quoted 10 lines
drivers/acpi/x86/utils.c +1 -1
 		DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
 		DMI_MATCH(DMI_BOARD_NAME, "Default string"),
 		DMI_MATCH(DMI_PRODUCT_NAME, "Default string"),
 		DMI_MATCH(DMI_BIOS_DATE, "03/20/2017")
 	      }),
-	ENTRY("KIOX000A", "1", ICPU(INTEL_FAM6_ATOM_AIRMONT), {
+	ENTRY("KIOX000A", "1", INTEL_CPU_FAM6_NODATA(ATOM_AIRMONT), {
 		DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
 		DMI_MATCH(DMI_BOARD_NAME, "Default string"),
 		DMI_MATCH(DMI_PRODUCT_NAME, "Default string"),
#7 lore raw
In reply to Andy Shevchenko

arch/x86/include/asm/intel-family.h line 96

Quoted 6 lines · Andy Shevchenko
arch/x86/include/asm/intel-family.h +6 -0
+
+#define INTEL_CPU_FAM_ANY_NODATA(_family, _model)		\
+	INTEL_CPU_FAM_ANY(_family, _model, NULL)
+
+#define INTEL_CPU_FAM6_NODATA(_model)				\
+	INTEL_CPU_FAM_ANY_NODATA(6, INTEL_FAM6_##_model)

_NODATA is actually longer than passing NULL ?

Seems unnecessary

-Andi

#8 lore raw
Quoted 9 lines · Andi Kleen

arch/x86/include/asm/intel-family.h line 96

Quoted 6 lines · Andy Shevchenko
arch/x86/include/asm/intel-family.h +6 -0
+
+#define INTEL_CPU_FAM_ANY_NODATA(_family, _model)		\
+	INTEL_CPU_FAM_ANY(_family, _model, NULL)
+
+#define INTEL_CPU_FAM6_NODATA(_model)				\
+	INTEL_CPU_FAM_ANY_NODATA(6, INTEL_FAM6_##_model)

_NODATA is actually longer than passing NULL ?

One character longer (you have to compare to ", NULL").

Quoted 1 line

Seems unnecessary

Let's gather other's opinions.

P.S. In any case some refactoring is needed to allow NULL in parameters (move & out from base macro).

Signature · 2 lines
With Best Regards,
Andy Shevchenko