Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp2085306ybb; Fri, 29 Mar 2019 18:41:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3yXB1jsDMEMt6R7Fe3ucH/d1GOre29I22x+UrgckXHNz6WOYg+H/fiB87FPEK0AbrhGiH X-Received: by 2002:a63:1003:: with SMTP id f3mr39446227pgl.227.1553910062132; Fri, 29 Mar 2019 18:41:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553910062; cv=none; d=google.com; s=arc-20160816; b=qbTYgVwCdFxXU1clZfryiq8H6sVRiailTtVGqBSwLJvzoHxS1oGDOq3r+8RDE8BT0u UPVuV7gSJM5wn+lunYOlHOSyfdA+Eij9ko+T+QRZGpBrvZcblVOgYt+ciKcHlsdIMgaB pylbJniB+t8x/94hNsK+XvU6IeEX+RKxPlz2mbg43rfrnmmvDkNPaTV9+OTYVBESw4QE JUZ83+MtBNJqR3iHjLfZa7+vCuSnaxebOW5HGOkifA0sZUxSZj6caLIH9WwdExeb+KPv frH1V3/JpsTdD9LFE+gXmDxlfFTmCuLLh/IoJJecsKj25nDhsOrdpeqVpTlGXaAALXHP nkJw== 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=WwlSRww17uMc9p2AlIWkgo70yqQcQYVij84zHCiZFWA=; b=FPmHaPWsaBvgUyZLvwQDEBq1UkL1eT2pHJ1ktSPSs3csjbiILM6jDKQZxw652PATZ+ MwwCTBjkglOkmHrmGHo1oCOVIkqX+jLHXVGzz4sCFJI1mjkCA+X4X5YtaBWU/cRv9iq4 Mv5DPzMrr1BRTf6DkZLPaCiAeIyc7wxk03s7eojZs2AzhSFaPIY9aqafjad6Un0iY5i4 JRZ8oJPSi+w33gPN9/GoO2nD4r/jO+jeblTNC1SCy+Vev7eCaT2ZS15jhiiOsrRr4s1w RDiVr58X9QVzeJiTogQP9hMHUq/azubGgmodcMXctpyn5H43Pd8lZxAept0wED2ZDNsR SS1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Qfdc1Fgg; 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 i1si3126046pgq.528.2019.03.29.18.40.47; Fri, 29 Mar 2019 18:41: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=Qfdc1Fgg; 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 S1731260AbfC3BaB (ORCPT + 99 others); Fri, 29 Mar 2019 21:30:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:36890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730961AbfC3B36 (ORCPT ); Fri, 29 Mar 2019 21:29:58 -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 A1913217F5; Sat, 30 Mar 2019 01:29:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553909398; bh=rxXJWDPvJs2UMJ9Z3PSv4K+5+nO5vXyxgxTSKPp+yjE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qfdc1FggHPrPcESscXO4xsT1bWNAwapAy3Cj/2WS/FYx7/HR/RfbEn1qcM3lhufNf lh+XJhirwcm+3CERvglFTdHaQfu3+19n3X8hTTjj1/TIQmRlw0kPkxet1ORxULgDvq xm3YEenmDVKML2SXK6hFJDFEpux0O8fJGsxK+3Eo= 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.19 28/57] nvme-pci: fix conflicting p2p resource adds Date: Fri, 29 Mar 2019 21:28:21 -0400 Message-Id: <20190330012854.32212-28-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190330012854.32212-1-sashal@kernel.org> References: <20190330012854.32212-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 7b9ef8e734e7..dca87cb485e9 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1649,6 +1649,9 @@ static void nvme_map_cmb(struct nvme_dev *dev) struct pci_dev *pdev = to_pci_dev(dev->dev); int bar; + if (dev->cmb_size) + return; + dev->cmbsz = readl(dev->bar + NVME_REG_CMBSZ); if (!dev->cmbsz) return; @@ -2133,7 +2136,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)) { @@ -2585,6 +2587,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