Skip to content

Commit 78153dd

Browse files
committed
nfit/ars: Avoid stale ARS results
Gate ARS result consumption on whether the OS issued start-ARS since the previous consumption. The BIOS may only clear its result buffers after a successful start-ARS. Fixes: 0caeef6 ("libnvdimm: Add a poison list and export badblocks") Cc: <stable@vger.kernel.org> Reported-by: Krzysztof Rusocki <krzysztof.rusocki@intel.com> Reported-by: Vishal Verma <vishal.l.verma@intel.com> Reviewed-by: Toshi Kani <toshi.kani@hpe.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 5479b27 commit 78153dd

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

drivers/acpi/nfit/core.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2652,7 +2652,10 @@ static int ars_start(struct acpi_nfit_desc *acpi_desc,
26522652

26532653
if (rc < 0)
26542654
return rc;
2655-
return cmd_rc;
2655+
if (cmd_rc < 0)
2656+
return cmd_rc;
2657+
set_bit(ARS_VALID, &acpi_desc->scrub_flags);
2658+
return 0;
26562659
}
26572660

26582661
static int ars_continue(struct acpi_nfit_desc *acpi_desc)
@@ -2745,6 +2748,17 @@ static int ars_status_process_records(struct acpi_nfit_desc *acpi_desc)
27452748
*/
27462749
if (ars_status->out_length < 44)
27472750
return 0;
2751+
2752+
/*
2753+
* Ignore potentially stale results that are only refreshed
2754+
* after a start-ARS event.
2755+
*/
2756+
if (!test_and_clear_bit(ARS_VALID, &acpi_desc->scrub_flags)) {
2757+
dev_dbg(acpi_desc->dev, "skip %d stale records\n",
2758+
ars_status->num_records);
2759+
return 0;
2760+
}
2761+
27482762
for (i = 0; i < ars_status->num_records; i++) {
27492763
/* only process full records */
27502764
if (ars_status->out_length
@@ -3229,6 +3243,7 @@ static int acpi_nfit_register_regions(struct acpi_nfit_desc *acpi_desc)
32293243
struct nfit_spa *nfit_spa;
32303244
int rc;
32313245

3246+
set_bit(ARS_VALID, &acpi_desc->scrub_flags);
32323247
list_for_each_entry(nfit_spa, &acpi_desc->spas, list) {
32333248
switch (nfit_spa_type(nfit_spa->spa)) {
32343249
case NFIT_SPA_VOLATILE:

drivers/acpi/nfit/nfit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ struct nfit_mem {
213213
enum scrub_flags {
214214
ARS_BUSY,
215215
ARS_CANCEL,
216+
ARS_VALID,
216217
ARS_POLL,
217218
};
218219

0 commit comments

Comments
 (0)