Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3803058ybi; Mon, 29 Jul 2019 12:57:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzaYRyjczQQCL1+82gXSu55TulJgNjwVEWafvgQdydwaoBAAWvQFOD+k8kduT4NHjy70/2F X-Received: by 2002:a17:902:7887:: with SMTP id q7mr113463805pll.129.1564430222845; Mon, 29 Jul 2019 12:57:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564430222; cv=none; d=google.com; s=arc-20160816; b=MarTGazfgyo76PrHP/cqeuNb4z1eX4ah8tvEYvGKeJsFv6e8ZYhLrh/N7/yCW34j8T 7gLO/R3wFbFwSt25fXhJO4gcdMKyH15axX4IQmwNKMruMV7/UKc0FycK1WDIic0Psr/f h/RmC/6nkUxIo1DOfNB4XfDQgKbq64SUsphgIAxXcgq0yFzKUqxwG5Hf+IhRmYDmkClp ifRjETwm31YW599gGg4ZVVeBc9/3WsrWh+lY3N55LIB98CDTcMQ+db19EIuItvYxsRpM X0RmCjR6a+hyE7wk8MU1/8RRcR4vNTqIkibIsfTdrkowO+HFQ49EWdladnT9hYL0cLAM oaSw== 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:subject:cc:to :from:dkim-signature; bh=y4z57WNUPcCLSu3pTgreR2TiU6O+fmGrLK39SaWhZjU=; b=LhRimf+9mi1z041fN9QpVFpg08eifU2uUNqMJMxrIPJppWWdP3CgNz+lGfy3AAtT+C C2szrxCQcJnh4Lq0SKQ4ac17gRVMeZYr78klnHbKXJSIWdV0yfXkJnoFZQ4gQ9JImmBL AytrToIdY6uyslE0ikdMFxwUs+MxB/ZqhcxKgZwp6lKElUQOYnZ52zu7/qxHtaSWmcFp Rf2aPrrWLkug6dKPOOf7LS7+/zv6yLbgTdsgNIoQ2KTNkBzhoO0pzeFo2Mxanx5r5f/2 meBN6jb0u/ChVSWvq5bJ7d8bWEWkcV+WFjxs7bzfgEYTXlGbuaUBc55hYrF1LO/M07aT CEvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tQpjcGXR; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bx21si27626429pjb.21.2019.07.29.12.56.47; Mon, 29 Jul 2019 12:57:02 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=tQpjcGXR; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390896AbfG2Tzg (ORCPT + 99 others); Mon, 29 Jul 2019 15:55:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:48370 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404223AbfG2Tzc (ORCPT ); Mon, 29 Jul 2019 15:55:32 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9FE9C204EC; Mon, 29 Jul 2019 19:55:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564430131; bh=rB73xvJpdEcFSjH9TyP6peeD9RRA82j1t5fr13TMwFM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tQpjcGXRh1oudxNHtUJ+Xhkyq7ZmIthIJjEiQ54wwygnp83kDqo/Ajn/rIwjchDBt Wy/vQUw4nQwaquRoBb1Uzu9jqHIzMdWaL9MMeJuaAqYGG+RNmwFx5xkUThfx4QItik EtCEbhGuBCCH5Jw5uMK1H4wOFwh8nfN80EucBuks= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vishal Verma , Dan Williams Subject: [PATCH 5.2 207/215] libnvdimm/region: Register badblocks before namespaces Date: Mon, 29 Jul 2019 21:23:23 +0200 Message-Id: <20190729190815.879490144@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Williams commit 700cd033a82d466ad8f9615f9985525e45f8960a upstream. Namespace activation expects to be able to reference region badblocks. The following warning sometimes triggers when asynchronous namespace activation races in front of the completion of namespace probing. Move all possible namespace probing after region badblocks initialization. Otherwise, lockdep sometimes catches the uninitialized state of the badblocks seqlock with stack trace signatures like: INFO: trying to register non-static key. pmem2: detected capacity change from 0 to 136365211648 the code is fine but needs lockdep annotation. turning off the locking correctness validator. CPU: 9 PID: 358 Comm: kworker/u80:5 Tainted: G OE 5.2.0-rc4+ #3382 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 0.0.0 02/06/2015 Workqueue: events_unbound async_run_entry_fn Call Trace: dump_stack+0x85/0xc0 pmem1.12: detected capacity change from 0 to 8589934592 register_lock_class+0x56a/0x570 ? check_object+0x140/0x270 __lock_acquire+0x80/0x1710 ? __mutex_lock+0x39d/0x910 lock_acquire+0x9e/0x180 ? nd_pfn_validate+0x28f/0x440 [libnvdimm] badblocks_check+0x93/0x1f0 ? nd_pfn_validate+0x28f/0x440 [libnvdimm] nd_pfn_validate+0x28f/0x440 [libnvdimm] ? lockdep_hardirqs_on+0xf0/0x180 nd_dax_probe+0x9a/0x120 [libnvdimm] nd_pmem_probe+0x6d/0x180 [nd_pmem] nvdimm_bus_probe+0x90/0x2c0 [libnvdimm] Fixes: 48af2f7e52f4 ("libnvdimm, pfn: during init, clear errors...") Cc: Cc: Vishal Verma Reviewed-by: Vishal Verma Link: https://lore.kernel.org/r/156341208365.292348.1547528796026249120.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams Signed-off-by: Greg Kroah-Hartman --- drivers/nvdimm/region.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) --- a/drivers/nvdimm/region.c +++ b/drivers/nvdimm/region.c @@ -34,17 +34,6 @@ static int nd_region_probe(struct device if (rc) return rc; - rc = nd_region_register_namespaces(nd_region, &err); - if (rc < 0) - return rc; - - ndrd = dev_get_drvdata(dev); - ndrd->ns_active = rc; - ndrd->ns_count = rc + err; - - if (rc && err && rc == err) - return -ENODEV; - if (is_nd_pmem(&nd_region->dev)) { struct resource ndr_res; @@ -60,6 +49,17 @@ static int nd_region_probe(struct device nvdimm_badblocks_populate(nd_region, &nd_region->bb, &ndr_res); } + rc = nd_region_register_namespaces(nd_region, &err); + if (rc < 0) + return rc; + + ndrd = dev_get_drvdata(dev); + ndrd->ns_active = rc; + ndrd->ns_count = rc + err; + + if (rc && err && rc == err) + return -ENODEV; + nd_region->btt_seed = nd_btt_create(nd_region); nd_region->pfn_seed = nd_pfn_create(nd_region); nd_region->dax_seed = nd_dax_create(nd_region);