Skip to content

Commit

Permalink
nfit/ars: Avoid stale ARS results
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dan Williams committed Feb 20, 2019
1 parent 5479b27 commit 78153dd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 16 additions & 1 deletion drivers/acpi/nfit/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2652,7 +2652,10 @@ static int ars_start(struct acpi_nfit_desc *acpi_desc,

if (rc < 0)
return rc;
return cmd_rc;
if (cmd_rc < 0)
return cmd_rc;
set_bit(ARS_VALID, &acpi_desc->scrub_flags);
return 0;
}

static int ars_continue(struct acpi_nfit_desc *acpi_desc)
Expand Down Expand Up @@ -2745,6 +2748,17 @@ static int ars_status_process_records(struct acpi_nfit_desc *acpi_desc)
*/
if (ars_status->out_length < 44)
return 0;

/*
* Ignore potentially stale results that are only refreshed
* after a start-ARS event.
*/
if (!test_and_clear_bit(ARS_VALID, &acpi_desc->scrub_flags)) {
dev_dbg(acpi_desc->dev, "skip %d stale records\n",
ars_status->num_records);
return 0;
}

for (i = 0; i < ars_status->num_records; i++) {
/* only process full records */
if (ars_status->out_length
Expand Down Expand Up @@ -3229,6 +3243,7 @@ static int acpi_nfit_register_regions(struct acpi_nfit_desc *acpi_desc)
struct nfit_spa *nfit_spa;
int rc;

set_bit(ARS_VALID, &acpi_desc->scrub_flags);
list_for_each_entry(nfit_spa, &acpi_desc->spas, list) {
switch (nfit_spa_type(nfit_spa->spa)) {
case NFIT_SPA_VOLATILE:
Expand Down
1 change: 1 addition & 0 deletions drivers/acpi/nfit/nfit.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ struct nfit_mem {
enum scrub_flags {
ARS_BUSY,
ARS_CANCEL,
ARS_VALID,
ARS_POLL,
};

Expand Down

0 comments on commit 78153dd

Please sign in to comment.