From patchwork Thu Mar 29 22:37:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 10316629 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 EF6F360212 for ; Thu, 29 Mar 2018 22:37:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8ADE2A29E for ; Thu, 29 Mar 2018 22:37:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CCF822A53E; Thu, 29 Mar 2018 22:37:16 +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=unavailable 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 53AA62A29E for ; Thu, 29 Mar 2018 22:37:16 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0ECD3225E4025; Thu, 29 Mar 2018 15:30:36 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=dave.jiang@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5C68C224DD140 for ; Thu, 29 Mar 2018 15:30:34 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Mar 2018 15:37:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,378,1517904000"; d="scan'208";a="39286346" Received: from djiang5-desk3.ch.intel.com ([143.182.136.93]) by orsmga003.jf.intel.com with ESMTP; 29 Mar 2018 15:37:13 -0700 Subject: [PATCH 2/4] acpi/libnvdimm: search through BERT records and add to nvdimm badblocks From: Dave Jiang To: dan.j.williams@intel.com Date: Thu, 29 Mar 2018 15:37:13 -0700 Message-ID: <152236303313.35558.14974025959641773033.stgit@djiang5-desk3.ch.intel.com> In-Reply-To: <152236282506.35558.2067249639136170490.stgit@djiang5-desk3.ch.intel.com> References: <152236282506.35558.2067249639136170490.stgit@djiang5-desk3.ch.intel.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-acpi@vger.kernel.org, tony.luck@intel.com, rjw@rjwysocki.net, lenb@kernel.org, linux-nvdimm@lists.01.org Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP To avoid hitting bad address in nvdimm from previous boot, we will search through the BERT records to find the matching address and add them to the nvdimm_bus badblocks. Signed-off-by: Dave Jiang --- drivers/acpi/nfit/core.c | 22 ++++++++++++++++++++++ drivers/nvdimm/core.c | 6 ++++++ include/linux/libnvdimm.h | 1 + 3 files changed, 29 insertions(+) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index bbe48ad20886..3e3b95298a21 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -2639,6 +2639,15 @@ static bool nfit_spa_is_volatile(struct acpi_nfit_system_address *spa) nfit_spa_type(spa) == NFIT_SPA_VOLATILE); } +static void acpi_nfit_bert_callback(void *data, u64 addr, u64 len) +{ + struct nd_region *nd_region = (struct nd_region *)data; + struct nvdimm_bus *nvdimm_bus = nvdimm_region_to_bus(nd_region); + + nvdimm_bus_add_badrange(nvdimm_bus, ALIGN(addr, L1_CACHE_BYTES), len); + nvdimm_region_notify(nd_region, NVDIMM_REVALIDATE_POISON); +} + static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc, struct nfit_spa *nfit_spa) { @@ -2735,6 +2744,19 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc, if (rc) dev_err(acpi_desc->dev, "failed to register spa range %d\n", nfit_spa->spa->range_index); + + /* If we have a region, we can check the BERT */ + if (nfit_spa->nd_region) { + int count = bert_find_mem_error_record( + acpi_nfit_bert_callback, + (void *)nfit_spa->nd_region, spa->address, + spa->length); + + if (count > 0) + dev_dbg(acpi_desc->dev, "%d BERT records added\n", + count); + } + return rc; } diff --git a/drivers/nvdimm/core.c b/drivers/nvdimm/core.c index 1dc527660637..7dbdb80e72be 100644 --- a/drivers/nvdimm/core.c +++ b/drivers/nvdimm/core.c @@ -27,6 +27,12 @@ LIST_HEAD(nvdimm_bus_list); DEFINE_MUTEX(nvdimm_bus_list_mutex); +struct nvdimm_bus *nvdimm_region_to_bus(struct nd_region *nd_region) +{ + return walk_to_nvdimm_bus(&nd_region->dev); +} +EXPORT_SYMBOL(nvdimm_region_to_bus); + void nvdimm_bus_lock(struct device *dev) { struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); diff --git a/include/linux/libnvdimm.h b/include/linux/libnvdimm.h index ff855ed965fb..0c3cb02e5706 100644 --- a/include/linux/libnvdimm.h +++ b/include/linux/libnvdimm.h @@ -200,6 +200,7 @@ u64 nd_fletcher64(void *addr, size_t len, bool le); void nvdimm_flush(struct nd_region *nd_region); int nvdimm_has_flush(struct nd_region *nd_region); int nvdimm_has_cache(struct nd_region *nd_region); +struct nvdimm_bus *nvdimm_region_to_bus(struct nd_region *nd_region); #ifdef CONFIG_ARCH_HAS_PMEM_API #define ARCH_MEMREMAP_PMEM MEMREMAP_WB