mmc: host: sh_mobile_sdhi: don't populate unneeded functions
[linux/fpc-iii.git] / drivers / acpi / nfit / mce.c
blob161f91539ae62b5d05547a939825321015580943
1 /*
2 * NFIT - Machine Check Handler
4 * Copyright(c) 2013-2016 Intel Corporation. All rights reserved.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 #include <linux/notifier.h>
16 #include <linux/acpi.h>
17 #include <asm/mce.h>
18 #include "nfit.h"
20 static int nfit_handle_mce(struct notifier_block *nb, unsigned long val,
21 void *data)
23 struct mce *mce = (struct mce *)data;
24 struct acpi_nfit_desc *acpi_desc;
25 struct nfit_spa *nfit_spa;
27 /* We only care about memory errors */
28 if (!(mce->status & MCACOD))
29 return NOTIFY_DONE;
32 * mce->addr contains the physical addr accessed that caused the
33 * machine check. We need to walk through the list of NFITs, and see
34 * if any of them matches that address, and only then start a scrub.
36 mutex_lock(&acpi_desc_lock);
37 list_for_each_entry(acpi_desc, &acpi_descs, list) {
38 struct device *dev = acpi_desc->dev;
39 int found_match = 0;
41 mutex_lock(&acpi_desc->init_mutex);
42 list_for_each_entry(nfit_spa, &acpi_desc->spas, list) {
43 struct acpi_nfit_system_address *spa = nfit_spa->spa;
45 if (nfit_spa_type(spa) != NFIT_SPA_PM)
46 continue;
47 /* find the spa that covers the mce addr */
48 if (spa->address > mce->addr)
49 continue;
50 if ((spa->address + spa->length - 1) < mce->addr)
51 continue;
52 found_match = 1;
53 dev_dbg(dev, "%s: addr in SPA %d (0x%llx, 0x%llx)\n",
54 __func__, spa->range_index, spa->address,
55 spa->length);
57 * We can break at the first match because we're going
58 * to rescan all the SPA ranges. There shouldn't be any
59 * aliasing anyway.
61 break;
63 mutex_unlock(&acpi_desc->init_mutex);
66 * We can ignore an -EBUSY here because if an ARS is already
67 * in progress, just let that be the last authoritative one
69 if (found_match)
70 acpi_nfit_ars_rescan(acpi_desc);
73 mutex_unlock(&acpi_desc_lock);
74 return NOTIFY_DONE;
77 static struct notifier_block nfit_mce_dec = {
78 .notifier_call = nfit_handle_mce,
81 void nfit_mce_register(void)
83 mce_register_decode_chain(&nfit_mce_dec);
86 void nfit_mce_unregister(void)
88 mce_unregister_decode_chain(&nfit_mce_dec);