From patchwork Tue Jul 19 00:44:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Verma X-Patchwork-Id: 9235765 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B27D0600CB for ; Tue, 19 Jul 2016 00:45:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3C012026B for ; Tue, 19 Jul 2016 00:45:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98C4926B41; Tue, 19 Jul 2016 00:45:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 39AC32026B for ; Tue, 19 Jul 2016 00:45:39 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 89C3C1A1E30; Mon, 18 Jul 2016 17:46:28 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by ml01.01.org (Postfix) with ESMTP id 43B721A1E2A for ; Mon, 18 Jul 2016 17:46:27 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP; 18 Jul 2016 17:45:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,386,1464678000"; d="scan'208";a="848809993" Received: from omniknight.lm.intel.com ([10.232.112.171]) by orsmga003.jf.intel.com with ESMTP; 18 Jul 2016 17:45:36 -0700 From: Vishal Verma To: Subject: [PATCH 2/3] nfit, libnvdimm: allow an ARS rescan to be triggered on demand Date: Mon, 18 Jul 2016 18:44:59 -0600 Message-Id: <1468889100-30698-3-git-send-email-vishal.l.verma@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468889100-30698-1-git-send-email-vishal.l.verma@intel.com> References: <1468889100-30698-1-git-send-email-vishal.l.verma@intel.com> X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-acpi@vger.kernel.org, "Rafael J. Wysocki" , Tony Luck MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Normally, an ARS (Address Range Scrub) only happens at boot/initialization time. There can however arise situations where a bus-wide rescan is needed - notably, in the case of discovering a latent media error, we should do a full rescan to figure out what other sectors are bad, and thus potentially avoid triggering an mce on them in the future. Also provide a sysfs trigger to start a bus-wide rescan. Cc: Dan Williams Cc: Rafael J. Wysocki Cc: Cc: Signed-off-by: Vishal Verma --- drivers/acpi/nfit.c | 36 ++++++++++++++++++++++++++++++++---- drivers/acpi/nfit.h | 1 + drivers/nvdimm/core.c | 17 +++++++++++++++++ include/linux/libnvdimm.h | 1 + 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c index ac6ddcc0..def9505 100644 --- a/drivers/acpi/nfit.c +++ b/drivers/acpi/nfit.c @@ -2138,8 +2138,9 @@ static void acpi_nfit_async_scrub(struct acpi_nfit_desc *acpi_desc, unsigned int tmo = scrub_timeout; int rc; - if (nfit_spa->ars_done || !nfit_spa->nd_region) - return; + if (!nfit_spa->ars_rescan) + if (nfit_spa->ars_done || !nfit_spa->nd_region) + return; rc = ars_start(acpi_desc, nfit_spa); /* @@ -2227,7 +2228,9 @@ static void acpi_nfit_scrub(struct work_struct *work) * firmware initiated scrubs to complete and then we go search for the * affected spa regions to mark them scanned. In the second phase we * initiate a directed scrub for every range that was not scrubbed in - * phase 1. + * phase 1. If we're called for a 'rescan', we harmlessly pass through + * the first phase, but really only care about running phase 2, where + * regions can be notified of new poison. */ /* process platform firmware initiated scrubs */ @@ -2336,8 +2339,10 @@ static void acpi_nfit_scrub(struct work_struct *work) acpi_nfit_register_region(acpi_desc, nfit_spa); } - list_for_each_entry(nfit_spa, &acpi_desc->spas, list) + list_for_each_entry(nfit_spa, &acpi_desc->spas, list) { acpi_nfit_async_scrub(acpi_desc, nfit_spa); + nfit_spa->ars_rescan = 0; + } mutex_unlock(&acpi_desc->init_mutex); } @@ -2495,6 +2500,28 @@ static int acpi_nfit_clear_to_send(struct nvdimm_bus_descriptor *nd_desc, return 0; } +static int acpi_nfit_ars_rescan(struct nvdimm_bus_descriptor *nd_desc) +{ + struct acpi_nfit_desc *acpi_desc = to_acpi_nfit_desc(nd_desc); + struct device *dev = acpi_desc->dev; + struct nfit_spa *nfit_spa; + + if (work_busy(&acpi_desc->work)) + return -EBUSY; + + list_for_each_entry(nfit_spa, &acpi_desc->spas, list) { + struct acpi_nfit_system_address *spa = nfit_spa->spa; + + if (nfit_spa_type(spa) != NFIT_SPA_PM) + continue; + + nfit_spa->ars_rescan = 1; + } + queue_work(nfit_wq, &acpi_desc->work); + dev_info(dev, "%s: ars_rescan triggered\n", __func__); + return 0; +} + void acpi_nfit_desc_init(struct acpi_nfit_desc *acpi_desc, struct device *dev) { struct nvdimm_bus_descriptor *nd_desc; @@ -2507,6 +2534,7 @@ void acpi_nfit_desc_init(struct acpi_nfit_desc *acpi_desc, struct device *dev) nd_desc->ndctl = acpi_nfit_ctl; nd_desc->flush_probe = acpi_nfit_flush_probe; nd_desc->clear_to_send = acpi_nfit_clear_to_send; + nd_desc->ars_rescan = acpi_nfit_ars_rescan; nd_desc->attr_groups = acpi_nfit_attribute_groups; INIT_LIST_HEAD(&acpi_desc->spa_maps); diff --git a/drivers/acpi/nfit.h b/drivers/acpi/nfit.h index 02b9ea1..db95c5d 100644 --- a/drivers/acpi/nfit.h +++ b/drivers/acpi/nfit.h @@ -78,6 +78,7 @@ struct nfit_spa { struct list_head list; struct nd_region *nd_region; unsigned int ars_done:1; + unsigned int ars_rescan:1; u32 clear_err_unit; u32 max_ars; }; diff --git a/drivers/nvdimm/core.c b/drivers/nvdimm/core.c index be89764..54f6fd5 100644 --- a/drivers/nvdimm/core.c +++ b/drivers/nvdimm/core.c @@ -313,10 +313,27 @@ static ssize_t wait_probe_show(struct device *dev, } static DEVICE_ATTR_RO(wait_probe); +static ssize_t ars_rescan_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t size) +{ + struct nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev); + struct nvdimm_bus_descriptor *nd_desc = nvdimm_bus->nd_desc; + int rc; + + if (nd_desc->ars_rescan) { + rc = nd_desc->ars_rescan(nd_desc); + if (rc) + return rc; + } + return size; +} +static DEVICE_ATTR_WO(ars_rescan); + static struct attribute *nvdimm_bus_attributes[] = { &dev_attr_commands.attr, &dev_attr_wait_probe.attr, &dev_attr_provider.attr, + &dev_attr_ars_rescan.attr, NULL, }; diff --git a/include/linux/libnvdimm.h b/include/linux/libnvdimm.h index 0c3c30c..1c6867a 100644 --- a/include/linux/libnvdimm.h +++ b/include/linux/libnvdimm.h @@ -74,6 +74,7 @@ struct nvdimm_bus_descriptor { int (*flush_probe)(struct nvdimm_bus_descriptor *nd_desc); int (*clear_to_send)(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm, unsigned int cmd); + int (*ars_rescan)(struct nvdimm_bus_descriptor *nd_desc); }; struct nd_cmd_desc {