]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/5.0.10/nfit-ars-avoid-stale-ars-results.patch
Fixes for 5.10
[thirdparty/kernel/stable-queue.git] / releases / 5.0.10 / nfit-ars-avoid-stale-ars-results.patch
1 From ddaf917919fa4ff38a4e87397717069e75aee8f4 Mon Sep 17 00:00:00 2001
2 From: Dan Williams <dan.j.williams@intel.com>
3 Date: Mon, 22 Apr 2019 16:08:26 -0700
4 Subject: nfit/ars: Avoid stale ARS results
5
6 commit 78153dd45e7e0596ba32b15d02bda08e1513111e upstream.
7
8 Gate ARS result consumption on whether the OS issued start-ARS since the
9 previous consumption. The BIOS may only clear its result buffers after a
10 successful start-ARS.
11
12 Fixes: 0caeef63e6d2 ("libnvdimm: Add a poison list and export badblocks")
13 Cc: <stable@vger.kernel.org>
14 Reported-by: Krzysztof Rusocki <krzysztof.rusocki@intel.com>
15 Reported-by: Vishal Verma <vishal.l.verma@intel.com>
16 Reviewed-by: Toshi Kani <toshi.kani@hpe.com>
17 Signed-off-by: Dan Williams <dan.j.williams@intel.com>
18 Signed-off-by: Sasha Levin <sashal@kernel.org>
19 ---
20 drivers/acpi/nfit/core.c | 17 ++++++++++++++++-
21 drivers/acpi/nfit/nfit.h | 1 +
22 2 files changed, 17 insertions(+), 1 deletion(-)
23
24 diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
25 index 61d3fd65fbe9..4be4dc3e8aa6 100644
26 --- a/drivers/acpi/nfit/core.c
27 +++ b/drivers/acpi/nfit/core.c
28 @@ -2661,7 +2661,10 @@ static int ars_start(struct acpi_nfit_desc *acpi_desc,
29
30 if (rc < 0)
31 return rc;
32 - return cmd_rc;
33 + if (cmd_rc < 0)
34 + return cmd_rc;
35 + set_bit(ARS_VALID, &acpi_desc->scrub_flags);
36 + return 0;
37 }
38
39 static int ars_continue(struct acpi_nfit_desc *acpi_desc)
40 @@ -2754,6 +2757,17 @@ static int ars_status_process_records(struct acpi_nfit_desc *acpi_desc)
41 */
42 if (ars_status->out_length < 44)
43 return 0;
44 +
45 + /*
46 + * Ignore potentially stale results that are only refreshed
47 + * after a start-ARS event.
48 + */
49 + if (!test_and_clear_bit(ARS_VALID, &acpi_desc->scrub_flags)) {
50 + dev_dbg(acpi_desc->dev, "skip %d stale records\n",
51 + ars_status->num_records);
52 + return 0;
53 + }
54 +
55 for (i = 0; i < ars_status->num_records; i++) {
56 /* only process full records */
57 if (ars_status->out_length
58 @@ -3238,6 +3252,7 @@ static int acpi_nfit_register_regions(struct acpi_nfit_desc *acpi_desc)
59 struct nfit_spa *nfit_spa;
60 int rc;
61
62 + set_bit(ARS_VALID, &acpi_desc->scrub_flags);
63 list_for_each_entry(nfit_spa, &acpi_desc->spas, list) {
64 switch (nfit_spa_type(nfit_spa->spa)) {
65 case NFIT_SPA_VOLATILE:
66 diff --git a/drivers/acpi/nfit/nfit.h b/drivers/acpi/nfit/nfit.h
67 index d14bad687fb8..0cbe5009eb2c 100644
68 --- a/drivers/acpi/nfit/nfit.h
69 +++ b/drivers/acpi/nfit/nfit.h
70 @@ -213,6 +213,7 @@ struct nfit_mem {
71 enum scrub_flags {
72 ARS_BUSY,
73 ARS_CANCEL,
74 + ARS_VALID,
75 ARS_POLL,
76 };
77
78 --
79 2.19.1
80