From: Yazen Ghannam <yazen.ghan...@amd.com> An instance may have failed probing because the probed node did not have DRAM installed. When the module is unloaded we'll get a WARNing when we try to remove a non-existent instance.
Save a bitmask of enabled instances with a bit for each node. Only try to remove an instance if it was successfully enabled in the first place. Cc: <sta...@vger.kernel.org> # 4.14.x Signed-off-by: Yazen Ghannam <yazen.ghan...@amd.com> --- drivers/edac/amd64_edac.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index af0ce9aa8d24..054086b19c6c 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c @@ -13,6 +13,8 @@ module_param(report_gart_errors, int, 0644); static int ecc_enable_override; module_param(ecc_enable_override, int, 0644); +static unsigned long int enabled_instances; + static struct msr __percpu *msrs; /* Per-node stuff */ @@ -3366,6 +3368,7 @@ static int probe_one_instance(unsigned int nid) goto err_enable; } + set_bit(nid, &enabled_instances); return ret; err_enable: @@ -3383,6 +3386,9 @@ static void remove_one_instance(unsigned int nid) struct mem_ctl_info *mci; struct amd64_pvt *pvt; + if (!test_bit(nid, &enabled_instances)) + return; + mci = find_mci_by_dev(&F3->dev); WARN_ON(!mci); @@ -3405,6 +3411,8 @@ static void remove_one_instance(unsigned int nid) kfree(pvt); edac_mc_free(mci); + + clear_bit(nid, &enabled_instances); } static void setup_pci_device(void) -- 2.14.1