Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp2084188ybb; Fri, 29 Mar 2019 18:38:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwYFwNg1z6/tkOYiPcpoOmtFb0c/AG5RP/q0PDQkD9tyOVsUWXq2wQSO660nn54O/Qhnwms X-Received: by 2002:a63:d709:: with SMTP id d9mr32417717pgg.38.1553909931697; Fri, 29 Mar 2019 18:38:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553909931; cv=none; d=google.com; s=arc-20160816; b=MkAssRS51h+rwoEHpSJx6Tl7RK9DzkNpmEZv081ZhQKBtRszOqZVoyLnM+zDgc+LMX 6GZr5ru8C4eNXRBsC2LMUECTDCMONIh5PVKgWS9I+Z16/gu3ZFurP+p6w0KF2AgPH4yK 9KLwICCXaKCHWYe0ifeYg4eEFuJB6+fqcUYNrJb79C1AGq1qnHgKBgIQVJbyLmJ/FqrV iwcwJ7ZFFubXwxEM9gBQVS3EtfCSogMy0XxkX2kIWMShXIL/uzAXOj0YWPeeF2fR+tyW 8DFVK35YerM7+xjVb8ZYfjMVokXvcFqYSEKEA5b51amDUZrMqfSyJvijzKuzGx+gOW2Q v8zA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2WXksF5ugCIqnARiDbiS83yAGp7nfweTOzxerNxrO1E=; b=yBioo45s39CKjxyTdehP7ylJDOZ8a2j4dfWCtIDXA8NrkF1pWyoHdO58Qp7e1IfQeD opf5h/psbD7KwVgj4Mp27X8F8yzVHqNki85Vo3aMVJOnd9ojlgnhCc4AAtlZhRsypm5E yHIPe6XdIdB5xdOqwyVK7YK61gcVOz52ggRIi3ruV1pUaniMByvTwm+uEVjggVALZqn9 8uFA990aYh2mp+kGO8mtFH446A30KP5pSEn6rZ8Qia5HtIsiDA+jHtii4jGSZF6szmBI PzHnOuMqiKwQ3majAk2iQF1siOb1ZzLJtLuwB/Ehgx5LEqOP+2+GfqjBoovUdKmCCJu8 3YdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mNMpoMKO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v31si3224018plg.2.2019.03.29.18.38.36; Fri, 29 Mar 2019 18:38:51 -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=mNMpoMKO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731833AbfC3BbC (ORCPT + 99 others); Fri, 29 Mar 2019 21:31:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:38336 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731817AbfC3BbA (ORCPT ); Fri, 29 Mar 2019 21:31:00 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 23EC021773; Sat, 30 Mar 2019 01:30:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553909459; bh=7wECnrCF++N1FhjFDlTHh7neg8t/BZx/6YS38KLyr+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mNMpoMKOxrB5cMsNIjQldI+EwJmXrRfenOGLf4gB248H6RDDwxYU7l0Neufgg36gP nXNWjilfkDGb0ch6mXmJIXT+Kn6UvPIaHvgwRQz2FwROKcRK+KHMLw911MSKUJ3tLD Tg6uCVpgsdyquO017JcftzgsFQelfiylj0LodWbA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Keith Busch , Christoph Hellwig , Jens Axboe , Sasha Levin , linux-nvme@lists.infradead.org Subject: [PATCH AUTOSEL 4.14 18/37] nvme-pci: fix conflicting p2p resource adds Date: Fri, 29 Mar 2019 21:30:01 -0400 Message-Id: <20190330013020.379-18-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190330013020.379-1-sashal@kernel.org> References: <20190330013020.379-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Keith Busch [ Upstream commit 9fe5c59ff6a1e5e26a39b75489a1420e7eaaf0b1 ] The nvme pci driver had been adding its CMB resource to the P2P DMA subsystem everytime on on a controller reset. This results in the following warning: ------------[ cut here ]------------ nvme 0000:00:03.0: Conflicting mapping in same section WARNING: CPU: 7 PID: 81 at kernel/memremap.c:155 devm_memremap_pages+0xa6/0x380 ... Call Trace: pci_p2pdma_add_resource+0x153/0x370 nvme_reset_work+0x28c/0x17b1 [nvme] ? add_timer+0x107/0x1e0 ? dequeue_entity+0x81/0x660 ? dequeue_entity+0x3b0/0x660 ? pick_next_task_fair+0xaf/0x610 ? __switch_to+0xbc/0x410 process_one_work+0x1cf/0x350 worker_thread+0x215/0x3d0 ? process_one_work+0x350/0x350 kthread+0x107/0x120 ? kthread_park+0x80/0x80 ret_from_fork+0x1f/0x30 ---[ end trace f7ea76ac6ee72727 ]--- nvme nvme0: failed to register the CMB This patch fixes this by registering the CMB with P2P only once. Signed-off-by: Keith Busch Reviewed-by: Logan Gunthorpe Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/nvme/host/pci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 06355ca832db..ae03a5b70324 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1546,6 +1546,9 @@ static void __iomem *nvme_map_cmb(struct nvme_dev *dev) void __iomem *cmb; int bar; + if (dev->cmb_size) + return; + dev->cmbsz = readl(dev->bar + NVME_REG_CMBSZ); if (!(NVME_CMB_SZ(dev->cmbsz))) return NULL; @@ -2034,7 +2037,6 @@ static void nvme_pci_disable(struct nvme_dev *dev) { struct pci_dev *pdev = to_pci_dev(dev->dev); - nvme_release_cmb(dev); pci_free_irq_vectors(pdev); if (pci_is_enabled(pdev)) { @@ -2434,6 +2436,7 @@ static void nvme_remove(struct pci_dev *pdev) nvme_stop_ctrl(&dev->ctrl); nvme_remove_namespaces(&dev->ctrl); nvme_dev_disable(dev, true); + nvme_release_cmb(dev); nvme_free_host_mem(dev); nvme_dev_remove_admin(dev); nvme_free_queues(dev, 0); -- 2.19.1