diff mbox

[v2,7/7] edac drivers: add MC owner check in init

Message ID 20170803215753.30553-8-toshi.kani@hpe.com (mailing list archive)
State Rejected, archived
Headers show

Commit Message

Kani, Toshi Aug. 3, 2017, 9:57 p.m. UTC
Change generic x86 edac drivers, which probe CPU type with
x86_match_cpu(), to call edac_check_mc_owner() in their
module init functions.  This allows them to fail their init
at the beginning when ghes_edac is enabled.  Similar change
can be made to other edac drivers as necessary.

This is an optimization and there is no functional change.

Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
Suggested-by: Borislav Petkov <bp@alien8.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>
---
 drivers/edac/amd64_edac.c |    3 +++
 drivers/edac/pnd2_edac.c  |    7 ++++++-
 drivers/edac/sb_edac.c    |    7 +++++--
 drivers/edac/skx_edac.c   |    6 +++++-
 4 files changed, 19 insertions(+), 4 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Borislav Petkov Aug. 4, 2017, 8:39 a.m. UTC | #1
On Thu, Aug 03, 2017 at 03:57:53PM -0600, Toshi Kani wrote:
> Change generic x86 edac drivers, which probe CPU type with
> x86_match_cpu(), to call edac_check_mc_owner() in their
> module init functions.  This allows them to fail their init
> at the beginning when ghes_edac is enabled.  Similar change
> can be made to other edac drivers as necessary.
> 
> This is an optimization and there is no functional change.
> 
> Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
> Suggested-by: Borislav Petkov <bp@alien8.de>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Tony Luck <tony.luck@intel.com>
> ---
>  drivers/edac/amd64_edac.c |    3 +++
>  drivers/edac/pnd2_edac.c  |    7 ++++++-
>  drivers/edac/sb_edac.c    |    7 +++++--
>  drivers/edac/skx_edac.c   |    6 +++++-
>  4 files changed, 19 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
> index 3aea556..cdb40d6 100644
> --- a/drivers/edac/amd64_edac.c
> +++ b/drivers/edac/amd64_edac.c
> @@ -3444,6 +3444,9 @@ static int __init amd64_edac_init(void)
>  	if (amd_cache_northbridges() < 0)
>  		return -ENODEV;
>  
> +	if (!edac_check_mc_owner(EDAC_MOD_STR))
> +		return -EBUSY;
> +

That needs to happen first in the init function.

>  	opstate_init();
>  
>  	err = -ENOMEM;
> diff --git a/drivers/edac/pnd2_edac.c b/drivers/edac/pnd2_edac.c
> index 8e59949..a5b7855 100644
> --- a/drivers/edac/pnd2_edac.c
> +++ b/drivers/edac/pnd2_edac.c
> @@ -45,6 +45,8 @@
>  #include "edac_module.h"
>  #include "pnd2_edac.h"
>  
> +#define PND2_MOD_NAME		"pnd2_edac.c"

EDAC_MOD_STR and look how the other drivers define it, i.e., without the ".c"

> +
>  #define APL_NUM_CHANNELS	4
>  #define DNV_NUM_CHANNELS	2
>  #define DNV_MAX_DIMMS		2 /* Max DIMMs per channel */
> @@ -1313,7 +1315,7 @@ static int pnd2_register_mci(struct mem_ctl_info **ppmci)
>  	pvt = mci->pvt_info;
>  	memset(pvt, 0, sizeof(*pvt));
>  
> -	mci->mod_name = "pnd2_edac.c";
> +	mci->mod_name = PND2_MOD_NAME;
>  	mci->dev_name = ops->name;
>  	mci->ctl_name = "Pondicherry2";
>  
> @@ -1513,6 +1515,9 @@ static int __init pnd2_init(void)
>  	if (!id)
>  		return -ENODEV;
>  
> +	if (!edac_check_mc_owner(PND2_MOD_NAME))
> +		return -EBUSY;

Also first thing to do in the function.

> +
>  	ops = (struct dunit_ops *)id->driver_data;
>  
>  	/* Ensure that the OPSTATE is set correctly for POLL or NMI */
> diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
> index 80d860c..71bd66e 100644
> --- a/drivers/edac/sb_edac.c
> +++ b/drivers/edac/sb_edac.c
> @@ -36,7 +36,7 @@ static LIST_HEAD(sbridge_edac_list);
>   * Alter this version for the module when modifications are made
>   */
>  #define SBRIDGE_REVISION    " Ver: 1.1.2 "
> -#define EDAC_MOD_STR      "sbridge_edac"
> +#define SBRIDGE_MOD_NAME    "sb_edac.c"

Why? EDAC_MOD_STR is just fine.

>  /*
>   * Debug macros
> @@ -3124,7 +3124,7 @@ static int sbridge_register_mci(struct sbridge_dev *sbridge_dev, enum type type)
>  		MEM_FLAG_DDR4 : MEM_FLAG_DDR3;
>  	mci->edac_ctl_cap = EDAC_FLAG_NONE;
>  	mci->edac_cap = EDAC_FLAG_NONE;
> -	mci->mod_name = "sb_edac.c";
> +	mci->mod_name = SBRIDGE_MOD_NAME;
>  	mci->mod_ver = SBRIDGE_REVISION;
>  	mci->dev_name = pci_name(pdev);
>  	mci->ctl_page_to_phys = NULL;
> @@ -3380,6 +3380,9 @@ static int __init sbridge_init(void)
>  	if (!id)
>  		return -ENODEV;
>  
> +	if (!edac_check_mc_owner(SBRIDGE_MOD_NAME))
> +		return -EBUSY;

See above.

> +
>  	/* Ensure that the OPSTATE is set correctly for POLL or NMI */
>  	opstate_init();
>  
> diff --git a/drivers/edac/skx_edac.c b/drivers/edac/skx_edac.c
> index 64bef6c9..8347969 100644
> --- a/drivers/edac/skx_edac.c
> +++ b/drivers/edac/skx_edac.c
> @@ -31,6 +31,7 @@
>  
>  #include "edac_module.h"
>  
> +#define SKX_MOD_NAME    "skx_edac.c"
>  #define SKX_REVISION    " Ver: 1.0 "

Ditto.

>  
>  /*
> @@ -471,7 +472,7 @@ static int skx_register_mci(struct skx_imc *imc)
>  	mci->mtype_cap = MEM_FLAG_DDR4;
>  	mci->edac_ctl_cap = EDAC_FLAG_NONE;
>  	mci->edac_cap = EDAC_FLAG_NONE;
> -	mci->mod_name = "skx_edac.c";
> +	mci->mod_name = SKX_MOD_NAME;
>  	mci->dev_name = pci_name(imc->chan[0].cdev);
>  	mci->mod_ver = SKX_REVISION;
>  	mci->ctl_page_to_phys = NULL;
> @@ -1052,6 +1053,9 @@ static int __init skx_init(void)
>  	if (!id)
>  		return -ENODEV;
>  
> +	if (!edac_check_mc_owner(SKX_MOD_NAME))
> +		return -EBUSY;
> +

Ditto.
Kani, Toshi Aug. 4, 2017, 9:48 p.m. UTC | #2
T24gRnJpLCAyMDE3LTA4LTA0IGF0IDEwOjM5ICswMjAwLCBCb3Jpc2xhdiBQZXRrb3Ygd3JvdGU6
DQo+IE9uIFRodSwgQXVnIDAzLCAyMDE3IGF0IDAzOjU3OjUzUE0gLTA2MDAsIFRvc2hpIEthbmkg
d3JvdGU6DQo+ID4gQ2hhbmdlIGdlbmVyaWMgeDg2IGVkYWMgZHJpdmVycywgd2hpY2ggcHJvYmUg
Q1BVIHR5cGUgd2l0aA0KPiA+IHg4Nl9tYXRjaF9jcHUoKSwgdG8gY2FsbCBlZGFjX2NoZWNrX21j
X293bmVyKCkgaW4gdGhlaXINCj4gPiBtb2R1bGUgaW5pdCBmdW5jdGlvbnMuwqDCoFRoaXMgYWxs
b3dzIHRoZW0gdG8gZmFpbCB0aGVpciBpbml0DQo+ID4gYXQgdGhlIGJlZ2lubmluZyB3aGVuIGdo
ZXNfZWRhYyBpcyBlbmFibGVkLsKgwqBTaW1pbGFyIGNoYW5nZQ0KPiA+IGNhbiBiZSBtYWRlIHRv
IG90aGVyIGVkYWMgZHJpdmVycyBhcyBuZWNlc3NhcnkuDQo+ID4gDQo+ID4gVGhpcyBpcyBhbiBv
cHRpbWl6YXRpb24gYW5kIHRoZXJlIGlzIG5vIGZ1bmN0aW9uYWwgY2hhbmdlLg0KPiA+IA0KPiA+
IFNpZ25lZC1vZmYtYnk6IFRvc2hpIEthbmkgPHRvc2hpLmthbmlAaHBlLmNvbT4NCj4gPiBTdWdn
ZXN0ZWQtYnk6IEJvcmlzbGF2IFBldGtvdiA8YnBAYWxpZW44LmRlPg0KPiA+IENjOiBCb3Jpc2xh
diBQZXRrb3YgPGJwQG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GhlIE9QU1RBVEUgaXMgc2V0IGNvcnJlY3RseSBmb3IgUE9MTCBvcg0KPiA+IE5NSSAqLw0KPiA+
IGRpZmYgLS1naXQgYS9kcml2ZXJzL2VkYWMvc2JfZWRhYy5jIGIvZHJpdmVycy9lZGFjL3NiX2Vk
YWMuYw0KPiA+IGluZGV4IDgwZDg2MGMuLjcxYmQ2NmUgMTAwNjQ0DQo+ID4gLS0tIGEvZHJpdmVy
cy9lZGFjL3NiX2VkYWMuYw0KPiA+ICsrKyBiL2RyaXZlcnMvZWRhYy9zYl9lZGFjLmMNCj4gPiBA
QCAtMzYsNyArMzYsNyBAQCBzdGF0aWMgTElTVF9IRUFEKHNicmlkZ2VfZWRhY19saXN0KTsNCj4g
PiDCoCAqIEFsdGVyIHRoaXMgdmVyc2lvbiBmb3IgdGhlIG1vZHVsZSB3aGVuIG1vZGlmaWNhdGlv
bnMgYXJlIG1hZGUNCj4gPiDCoCAqLw0KPiA+IMKgI2RlZmluZSBTQlJJREdFX1JFVklTSU9OwqDC
oMKgwqAiIFZlcjogMS4xLjIgIg0KPiA+IC0jZGVmaW5lIEVEQUNfTU9EX1NUUsKgwqDCoMKgwqDC
oCJzYnJpZGdlX2VkYWMiDQo+ID4gKyNkZWZpbmUgU0JSSURHRV9NT0RfTkFNRcKgwqDCoMKgInNi
X2VkYWMuYyINCj4gDQo+IFdoeT8gRURBQ19NT0RfU1RSIGlzIGp1c3QgZmluZS4NCg0KSSBzaW1w
bHkga2VwdCB3aGF0IGl0IGhhcyB0b2RheS4gIFdpbGwgcmVtb3ZlICIuYyIuDQoNClRoYW5rcywN
Ci1Ub3NoaQ0K
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Borislav Petkov Aug. 5, 2017, 5:49 a.m. UTC | #3
On Fri, Aug 04, 2017 at 09:48:23PM +0000, Kani, Toshimitsu wrote:
> Not sure if anyone cares, but I thought it should return with -ENODEV
> when this modules found no target, and -EBUSY when it found a target
> but it's busy.  Hence, this ordering.

You can still return -EBUSY. Just do the owner check first because if
we're going to return due to ghes_edac being loaded already, we might
just as well skip the other checks as they're a pointless waste of
cycles and energy.
Kani, Toshi Aug. 7, 2017, 2:57 p.m. UTC | #4
T24gU2F0LCAyMDE3LTA4LTA1IGF0IDA3OjQ5ICswMjAwLCBCb3Jpc2xhdiBQZXRrb3Ygd3JvdGU6
DQo+IE9uIEZyaSwgQXVnIDA0LCAyMDE3IGF0IDA5OjQ4OjIzUE0gKzAwMDAsIEthbmksIFRvc2hp
bWl0c3Ugd3JvdGU6DQo+ID4gTm90IHN1cmUgaWYgYW55b25lIGNhcmVzLCBidXQgSSB0aG91Z2h0
IGl0IHNob3VsZCByZXR1cm4gd2l0aA0KPiA+IC1FTk9ERVYgd2hlbiB0aGlzIG1vZHVsZXMgZm91
bmQgbm8gdGFyZ2V0LCBhbmQgLUVCVVNZIHdoZW4gaXQgZm91bmQNCj4gPiBhIHRhcmdldCBidXQg
aXQncyBidXN5LsKgwqBIZW5jZSwgdGhpcyBvcmRlcmluZy4NCj4gDQo+IFlvdSBjYW4gc3RpbGwg
cmV0dXJuIC1FQlVTWS4gSnVzdCBkbyB0aGUgb3duZXIgY2hlY2sgZmlyc3QgYmVjYXVzZSBpZg0K
PiB3ZSdyZSBnb2luZyB0byByZXR1cm4gZHVlIHRvIGdoZXNfZWRhYyBiZWluZyBsb2FkZWQgYWxy
ZWFkeSwgd2UgbWlnaHQNCj4ganVzdCBhcyB3ZWxsIHNraXAgdGhlIG90aGVyIGNoZWNrcyBhcyB0
aGV5J3JlIGEgcG9pbnRsZXNzIHdhc3RlIG9mDQo+IGN5Y2xlcyBhbmQgZW5lcmd5Lg0KDQpHb3Qg
aXQuICBXaWxsIG1vdmUgdXAgdGhlIGNoZWNrLg0KDQpUaGFua3MsDQotVG9zaGkNCg0K
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 3aea556..cdb40d6 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -3444,6 +3444,9 @@  static int __init amd64_edac_init(void)
 	if (amd_cache_northbridges() < 0)
 		return -ENODEV;
 
+	if (!edac_check_mc_owner(EDAC_MOD_STR))
+		return -EBUSY;
+
 	opstate_init();
 
 	err = -ENOMEM;
diff --git a/drivers/edac/pnd2_edac.c b/drivers/edac/pnd2_edac.c
index 8e59949..a5b7855 100644
--- a/drivers/edac/pnd2_edac.c
+++ b/drivers/edac/pnd2_edac.c
@@ -45,6 +45,8 @@ 
 #include "edac_module.h"
 #include "pnd2_edac.h"
 
+#define PND2_MOD_NAME		"pnd2_edac.c"
+
 #define APL_NUM_CHANNELS	4
 #define DNV_NUM_CHANNELS	2
 #define DNV_MAX_DIMMS		2 /* Max DIMMs per channel */
@@ -1313,7 +1315,7 @@  static int pnd2_register_mci(struct mem_ctl_info **ppmci)
 	pvt = mci->pvt_info;
 	memset(pvt, 0, sizeof(*pvt));
 
-	mci->mod_name = "pnd2_edac.c";
+	mci->mod_name = PND2_MOD_NAME;
 	mci->dev_name = ops->name;
 	mci->ctl_name = "Pondicherry2";
 
@@ -1513,6 +1515,9 @@  static int __init pnd2_init(void)
 	if (!id)
 		return -ENODEV;
 
+	if (!edac_check_mc_owner(PND2_MOD_NAME))
+		return -EBUSY;
+
 	ops = (struct dunit_ops *)id->driver_data;
 
 	/* Ensure that the OPSTATE is set correctly for POLL or NMI */
diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
index 80d860c..71bd66e 100644
--- a/drivers/edac/sb_edac.c
+++ b/drivers/edac/sb_edac.c
@@ -36,7 +36,7 @@  static LIST_HEAD(sbridge_edac_list);
  * Alter this version for the module when modifications are made
  */
 #define SBRIDGE_REVISION    " Ver: 1.1.2 "
-#define EDAC_MOD_STR      "sbridge_edac"
+#define SBRIDGE_MOD_NAME    "sb_edac.c"
 
 /*
  * Debug macros
@@ -3124,7 +3124,7 @@  static int sbridge_register_mci(struct sbridge_dev *sbridge_dev, enum type type)
 		MEM_FLAG_DDR4 : MEM_FLAG_DDR3;
 	mci->edac_ctl_cap = EDAC_FLAG_NONE;
 	mci->edac_cap = EDAC_FLAG_NONE;
-	mci->mod_name = "sb_edac.c";
+	mci->mod_name = SBRIDGE_MOD_NAME;
 	mci->mod_ver = SBRIDGE_REVISION;
 	mci->dev_name = pci_name(pdev);
 	mci->ctl_page_to_phys = NULL;
@@ -3380,6 +3380,9 @@  static int __init sbridge_init(void)
 	if (!id)
 		return -ENODEV;
 
+	if (!edac_check_mc_owner(SBRIDGE_MOD_NAME))
+		return -EBUSY;
+
 	/* Ensure that the OPSTATE is set correctly for POLL or NMI */
 	opstate_init();
 
diff --git a/drivers/edac/skx_edac.c b/drivers/edac/skx_edac.c
index 64bef6c9..8347969 100644
--- a/drivers/edac/skx_edac.c
+++ b/drivers/edac/skx_edac.c
@@ -31,6 +31,7 @@ 
 
 #include "edac_module.h"
 
+#define SKX_MOD_NAME    "skx_edac.c"
 #define SKX_REVISION    " Ver: 1.0 "
 
 /*
@@ -471,7 +472,7 @@  static int skx_register_mci(struct skx_imc *imc)
 	mci->mtype_cap = MEM_FLAG_DDR4;
 	mci->edac_ctl_cap = EDAC_FLAG_NONE;
 	mci->edac_cap = EDAC_FLAG_NONE;
-	mci->mod_name = "skx_edac.c";
+	mci->mod_name = SKX_MOD_NAME;
 	mci->dev_name = pci_name(imc->chan[0].cdev);
 	mci->mod_ver = SKX_REVISION;
 	mci->ctl_page_to_phys = NULL;
@@ -1052,6 +1053,9 @@  static int __init skx_init(void)
 	if (!id)
 		return -ENODEV;
 
+	if (!edac_check_mc_owner(SKX_MOD_NAME))
+		return -EBUSY;
+
 	rc = skx_get_hi_lo();
 	if (rc)
 		return rc;