[10/18] EDAC: i10nm, skx: fix mixed module-builtin object

Message ID 20221119225650.1044591-11-alobakin@pm.me
State New
Headers
Series treewide: fix object files shared between several modules |

Commit Message

Alexander Lobakin Nov. 19, 2022, 11:07 p.m. UTC
  With CONFIG_EDAC_SKX=m and CONFIG_EDAC_I10NM=y (or vice versa),
skx_common.o are linked to a module and also to vmlinux even though
the expected CFLAGS are different between builtins and modules:

> scripts/Makefile.build:252: ./drivers/edac/Makefile: skx_common.o
> is added to multiple modules: i10nm_edac skx_edac

This is the same situation as fixed by commit 637a642f5ca5 ("zstd:
Fixing mixed module-builtin objects").

Introduce the new module, skx_edac_common, to provide the common
functions to skx_edac and i10nm_edac. skx_adxl_{get,put}() loose
their __init/__exit annotations in order to become exportable.

Fixes: d4dc89d069aa ("EDAC, i10nm: Add a driver for Intel 10nm server processors")
Suggested-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
---
 drivers/edac/Kconfig      | 11 +++++++----
 drivers/edac/Makefile     |  7 +++++--
 drivers/edac/i10nm_base.c |  2 ++
 drivers/edac/skx_base.c   |  2 ++
 drivers/edac/skx_common.c | 21 +++++++++++++++++++--
 drivers/edac/skx_common.h |  4 ++--
 6 files changed, 37 insertions(+), 10 deletions(-)

--
2.38.1
  

Comments

Masahiro Yamada Nov. 23, 2022, 4:12 p.m. UTC | #1
On Sun, Nov 20, 2022 at 8:08 AM Alexander Lobakin <alobakin@pm.me> wrote:
>
> With CONFIG_EDAC_SKX=m and CONFIG_EDAC_I10NM=y (or vice versa),
> skx_common.o are linked to a module and also to vmlinux even though
> the expected CFLAGS are different between builtins and modules:
>
> > scripts/Makefile.build:252: ./drivers/edac/Makefile: skx_common.o
> > is added to multiple modules: i10nm_edac skx_edac
>
> This is the same situation as fixed by commit 637a642f5ca5 ("zstd:
> Fixing mixed module-builtin objects").
>
> Introduce the new module, skx_edac_common, to provide the common
> functions to skx_edac and i10nm_edac. skx_adxl_{get,put}() loose
> their __init/__exit annotations in order to become exportable.
>
> Fixes: d4dc89d069aa ("EDAC, i10nm: Add a driver for Intel 10nm server processors")
> Suggested-by: Masahiro Yamada <masahiroy@kernel.org>
> Signed-off-by: Alexander Lobakin <alobakin@pm.me>

Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>





--
Best Regards
Masahiro Yamada
  

Patch

diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index 456602d373b7..c3d96d2a814b 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -236,12 +236,16 @@  config EDAC_SBRIDGE
 	  Support for error detection and correction the Intel
 	  Sandy Bridge, Ivy Bridge and Haswell Integrated Memory Controllers.

+config EDAC_SKX_COMMON
+	tristate
+	select ACPI_ADXL
+	select DMI
+
 config EDAC_SKX
 	tristate "Intel Skylake server Integrated MC"
 	depends on PCI && X86_64 && X86_MCE_INTEL && PCI_MMCONFIG && ACPI
 	depends on ACPI_NFIT || !ACPI_NFIT # if ACPI_NFIT=m, EDAC_SKX can't be y
-	select DMI
-	select ACPI_ADXL
+	select EDAC_SKX_COMMON
 	help
 	  Support for error detection and correction the Intel
 	  Skylake server Integrated Memory Controllers. If your
@@ -252,8 +256,7 @@  config EDAC_I10NM
 	tristate "Intel 10nm server Integrated MC"
 	depends on PCI && X86_64 && X86_MCE_INTEL && PCI_MMCONFIG && ACPI
 	depends on ACPI_NFIT || !ACPI_NFIT # if ACPI_NFIT=m, EDAC_I10NM can't be y
-	select DMI
-	select ACPI_ADXL
+	select EDAC_SKX_COMMON
 	help
 	  Support for error detection and correction the Intel
 	  10nm server Integrated Memory Controllers. If your
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index 2d1641a27a28..36e6e07d4048 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -54,10 +54,13 @@  obj-$(CONFIG_EDAC_MPC85XX)		+= mpc85xx_edac_mod.o
 layerscape_edac_mod-y			:= fsl_ddr_edac.o layerscape_edac.o
 obj-$(CONFIG_EDAC_LAYERSCAPE)		+= layerscape_edac_mod.o

-skx_edac-y				:= skx_common.o skx_base.o
+skx_edac_common-y			:= skx_common.o
+obj-$(CONFIG_EDAC_SKX_COMMON)		+= skx_edac_common.o
+
+skx_edac-y				:= skx_base.o
 obj-$(CONFIG_EDAC_SKX)			+= skx_edac.o

-i10nm_edac-y				:= skx_common.o i10nm_base.o
+i10nm_edac-y				:= i10nm_base.o
 obj-$(CONFIG_EDAC_I10NM)		+= i10nm_edac.o

 obj-$(CONFIG_EDAC_CELL)			+= cell_edac.o
diff --git a/drivers/edac/i10nm_base.c b/drivers/edac/i10nm_base.c
index a22ea053f8e1..949f665fd94c 100644
--- a/drivers/edac/i10nm_base.c
+++ b/drivers/edac/i10nm_base.c
@@ -900,5 +900,7 @@  MODULE_PARM_DESC(decoding_via_mca, "decoding_via_mca: 0=off(default), 1=enable")
 module_param(retry_rd_err_log, int, 0444);
 MODULE_PARM_DESC(retry_rd_err_log, "retry_rd_err_log: 0=off(default), 1=bios(Linux doesn't reset any control bits, but just reports values.), 2=linux(Linux tries to take control and resets mode bits, clear valid/UC bits after reading.)");

+MODULE_IMPORT_NS(EDAC_SKX_COMMON);
+
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("MC Driver for Intel 10nm server processors");
diff --git a/drivers/edac/skx_base.c b/drivers/edac/skx_base.c
index 7e2762f62eec..1656cd4cd0ed 100644
--- a/drivers/edac/skx_base.c
+++ b/drivers/edac/skx_base.c
@@ -751,6 +751,8 @@  module_exit(skx_exit);
 module_param(edac_op_state, int, 0444);
 MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI");

+MODULE_IMPORT_NS(EDAC_SKX_COMMON);
+
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Tony Luck");
 MODULE_DESCRIPTION("MC Driver for Intel Skylake server processors");
diff --git a/drivers/edac/skx_common.c b/drivers/edac/skx_common.c
index f0f8e98f6efb..15a3fb1224ae 100644
--- a/drivers/edac/skx_common.c
+++ b/drivers/edac/skx_common.c
@@ -48,7 +48,7 @@  static u64 skx_tolm, skx_tohm;
 static LIST_HEAD(dev_edac_list);
 static bool skx_mem_cfg_2lm;

-int __init skx_adxl_get(void)
+int skx_adxl_get(void)
 {
 	const char * const *names;
 	int i, j;
@@ -110,12 +110,14 @@  int __init skx_adxl_get(void)

 	return -ENODEV;
 }
+EXPORT_SYMBOL_NS_GPL(skx_adxl_get, EDAC_SKX_COMMON);

-void __exit skx_adxl_put(void)
+void skx_adxl_put(void)
 {
 	kfree(adxl_values);
 	kfree(adxl_msg);
 }
+EXPORT_SYMBOL_NS_GPL(skx_adxl_put, EDAC_SKX_COMMON);

 static bool skx_adxl_decode(struct decoded_addr *res, bool error_in_1st_level_mem)
 {
@@ -187,12 +189,14 @@  void skx_set_mem_cfg(bool mem_cfg_2lm)
 {
 	skx_mem_cfg_2lm = mem_cfg_2lm;
 }
+EXPORT_SYMBOL_NS_GPL(skx_set_mem_cfg, EDAC_SKX_COMMON);

 void skx_set_decode(skx_decode_f decode, skx_show_retry_log_f show_retry_log)
 {
 	driver_decode = decode;
 	skx_show_retry_rd_err_log = show_retry_log;
 }
+EXPORT_SYMBOL_NS_GPL(skx_set_decode, EDAC_SKX_COMMON);

 int skx_get_src_id(struct skx_dev *d, int off, u8 *id)
 {
@@ -206,6 +210,7 @@  int skx_get_src_id(struct skx_dev *d, int off, u8 *id)
 	*id = GET_BITFIELD(reg, 12, 14);
 	return 0;
 }
+EXPORT_SYMBOL_NS_GPL(skx_get_src_id, EDAC_SKX_COMMON);

 int skx_get_node_id(struct skx_dev *d, u8 *id)
 {
@@ -219,6 +224,7 @@  int skx_get_node_id(struct skx_dev *d, u8 *id)
 	*id = GET_BITFIELD(reg, 0, 2);
 	return 0;
 }
+EXPORT_SYMBOL_NS_GPL(skx_get_node_id, EDAC_SKX_COMMON);

 static int get_width(u32 mtr)
 {
@@ -284,6 +290,7 @@  int skx_get_all_bus_mappings(struct res_config *cfg, struct list_head **list)
 		*list = &dev_edac_list;
 	return ndev;
 }
+EXPORT_SYMBOL_NS_GPL(skx_get_all_bus_mappings, EDAC_SKX_COMMON);

 int skx_get_hi_lo(unsigned int did, int off[], u64 *tolm, u64 *tohm)
 {
@@ -323,6 +330,7 @@  int skx_get_hi_lo(unsigned int did, int off[], u64 *tolm, u64 *tohm)
 	pci_dev_put(pdev);
 	return -ENODEV;
 }
+EXPORT_SYMBOL_NS_GPL(skx_get_hi_lo, EDAC_SKX_COMMON);

 static int skx_get_dimm_attr(u32 reg, int lobit, int hibit, int add,
 			     int minval, int maxval, const char *name)
@@ -394,6 +402,7 @@  int skx_get_dimm_info(u32 mtr, u32 mcmtr, u32 amap, struct dimm_info *dimm,

 	return 1;
 }
+EXPORT_SYMBOL_NS_GPL(skx_get_dimm_info, EDAC_SKX_COMMON);

 int skx_get_nvdimm_info(struct dimm_info *dimm, struct skx_imc *imc,
 			int chan, int dimmno, const char *mod_str)
@@ -442,6 +451,7 @@  int skx_get_nvdimm_info(struct dimm_info *dimm, struct skx_imc *imc,

 	return (size == 0 || size == ~0ull) ? 0 : 1;
 }
+EXPORT_SYMBOL_NS_GPL(skx_get_nvdimm_info, EDAC_SKX_COMMON);

 int skx_register_mci(struct skx_imc *imc, struct pci_dev *pdev,
 		     const char *ctl_name, const char *mod_str,
@@ -512,6 +522,7 @@  int skx_register_mci(struct skx_imc *imc, struct pci_dev *pdev,
 	imc->mci = NULL;
 	return rc;
 }
+EXPORT_SYMBOL_NS_GPL(skx_register_mci, EDAC_SKX_COMMON);

 static void skx_unregister_mci(struct skx_imc *imc)
 {
@@ -694,6 +705,7 @@  int skx_mce_check_error(struct notifier_block *nb, unsigned long val,
 	mce->kflags |= MCE_HANDLED_EDAC;
 	return NOTIFY_DONE;
 }
+EXPORT_SYMBOL_NS_GPL(skx_mce_check_error, EDAC_SKX_COMMON);

 void skx_remove(void)
 {
@@ -731,3 +743,8 @@  void skx_remove(void)
 		kfree(d);
 	}
 }
+EXPORT_SYMBOL_NS_GPL(skx_remove, EDAC_SKX_COMMON);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Tony Luck");
+MODULE_DESCRIPTION("MC Common Library for Intel server processors");
diff --git a/drivers/edac/skx_common.h b/drivers/edac/skx_common.h
index 0cbadd3d2cd3..c0c174c101d2 100644
--- a/drivers/edac/skx_common.h
+++ b/drivers/edac/skx_common.h
@@ -178,8 +178,8 @@  typedef int (*get_dimm_config_f)(struct mem_ctl_info *mci,
 typedef bool (*skx_decode_f)(struct decoded_addr *res);
 typedef void (*skx_show_retry_log_f)(struct decoded_addr *res, char *msg, int len, bool scrub_err);

-int __init skx_adxl_get(void);
-void __exit skx_adxl_put(void);
+int skx_adxl_get(void);
+void skx_adxl_put(void);
 void skx_set_decode(skx_decode_f decode, skx_show_retry_log_f show_retry_log);
 void skx_set_mem_cfg(bool mem_cfg_2lm);