Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp254019imj; Fri, 15 Feb 2019 23:07:34 -0800 (PST) X-Google-Smtp-Source: AHgI3Iaega/1zl0vOWtv6cVpepSfPWUOXfIL0O6e2GEnBgU9S+1jmQKB3Th1c0J4mlMvaoXerc6D X-Received: by 2002:a63:e447:: with SMTP id i7mr8960022pgk.70.1550300853948; Fri, 15 Feb 2019 23:07:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550300853; cv=none; d=google.com; s=arc-20160816; b=jWqwmsokm1Eb7YIs98QrMwE/3UqJl3/ctD8zaNGakf9EpYlA0pGn3wTZ0zq3Q+mW4P Xj+2lvgP0Yie8RRooqRLB22YAuWwHbvs36FH+DR0XTOQzCKDj0mCz3uiynVVYFHxPV0P xrnH/ceiYxIQHDmwrv0zUL/0Eh0If4WA4iwlwzI6mUyemBj6FaqQ24IJytbe/5a6aDgF sPGyA28E291vn2uXKaMm/9yBPNRq8a8VhIqS51qmaEYCisyRl1EvX0YHIgbntfcAcTvP tdCINEAgA/YZDTC30t9mkMPLB4jI+aRGfETc+glVShXWARBgf2LB5mJi5VcdE7GRRgrW ZQHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject; bh=tyGfb8OmwnsIFKay59Vtp5nJYfKzmlq9L76sAkioQQg=; b=eDzzzzD7t6BWI21Yo1qDPTKSoIA/lLsBHc5RcdnEI9PyL+o8QzyE4ccx5loTNbwVgf dwofvVEQsFFC2hN3/VgyzWCP+ElU3M++PU0ZBn9yLta3aU7UqWB9kGrsoM4UY+iT6+t1 aDSxp4FwHs8CXNy+7yzm/55tsljUi0ivIkboOxQb3mTYMZg+lb7MM3N/OTZjYD9qKMlY 975kTIDeFUElOxULqGZqqPSyMLA2U40BvSKBEkufB3WhxuWGs3h4h1UeF52z4YPP3gVh mAZP1pzV9qlD1Plyr0wE5qdiWpRIl9LkmDtUGLaEutv/D9SkP78pIypnpBXv1MdCoOkV +EAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x1si2539050plr.439.2019.02.15.23.07.18; Fri, 15 Feb 2019 23:07:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388259AbfBOT45 (ORCPT + 99 others); Fri, 15 Feb 2019 14:56:57 -0500 Received: from mga02.intel.com ([134.134.136.20]:36548 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726317AbfBOT45 (ORCPT ); Fri, 15 Feb 2019 14:56:57 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Feb 2019 11:56:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,373,1544515200"; d="scan'208";a="116562696" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga006.jf.intel.com with ESMTP; 15 Feb 2019 11:56:56 -0800 Subject: [PATCH v2 6/6] nfit/ars: Avoid stale ARS results From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Krzysztof Rusocki , Vishal Verma , linux-kernel@vger.kernel.org Date: Fri, 15 Feb 2019 11:44:18 -0800 Message-ID: <155025985870.1043225.8854289247736261912.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <155025982726.1043225.15436410616433285475.stgit@dwillia2-desk3.amr.corp.intel.com> References: <155025982726.1043225.15436410616433285475.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Reported-by: Krzysztof Rusocki Reported-by: Vishal Verma Signed-off-by: Dan Williams --- drivers/acpi/nfit/core.c | 17 ++++++++++++++++- drivers/acpi/nfit/nfit.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 629cf91649d2..5c9eb8d700d3 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -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) @@ -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 @@ -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: diff --git a/drivers/acpi/nfit/nfit.h b/drivers/acpi/nfit/nfit.h index d14bad687fb8..0cbe5009eb2c 100644 --- a/drivers/acpi/nfit/nfit.h +++ b/drivers/acpi/nfit/nfit.h @@ -213,6 +213,7 @@ struct nfit_mem { enum scrub_flags { ARS_BUSY, ARS_CANCEL, + ARS_VALID, ARS_POLL, };