Received: by 10.213.65.68 with SMTP id h4csp252059imn; Mon, 12 Mar 2018 12:39:36 -0700 (PDT) X-Google-Smtp-Source: AG47ELtUKTFJMoyxWMUX38Q729UuQrO63ckqQpaErBVSo7GhxwCeJDOpiH/3ncyTnxxQ/ITzKkpq X-Received: by 10.99.106.202 with SMTP id f193mr5286718pgc.334.1520883576622; Mon, 12 Mar 2018 12:39:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520883576; cv=none; d=google.com; s=arc-20160816; b=HILDnntoVV1Uber0X59AusoZA31eb54efVJ4kv0kHXD+cejgUiburSIrn4Me36GjI8 dUGNruacayAi96SkbM0v9QpLrBzqXl9pXNyntUeCMtsh7WCnj8cYPxwv4GpSGPqnaTvW G9yR9tW1ZV5eO9qXxZitOmulLBgpZRLKGQ8Kf+7/yIMq568ZJA5SPpfdZld12WPcnTdH ERubSMs8Vp5OmYhw1XT8yEQu8uuogKiZqmpWgTZ7erFE5a1HrgS9Fq8tgvmXOwPUqQ/l Vsg19gY2SbJ59Bm3TyaiByhuwD/a4FnoV7skHz89I5Y7VzWwRxO2rtaFfq6fkT5MqUnE 6b6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:references:in-reply-to:message-id :date:cc:to:from:arc-authentication-results; bh=ZelAhpcHSs9Kr/cCyIaYdMhYj1mudTaCjYBES8llK1w=; b=hoQorag6c+/0aXaxWxVHJGC4cM9aLGPzINOy/zorTkm4L1OijeLK83RymDE9hzANM6 MowjS+gdQfdcLp9vnU9NqYYKkxH+FrVZ3rNvcr55TwM14vc3xDwpvyaRRBWDVnnUZhk8 xN47nPV/eQDq8utVT4ROXNuWp+BYWiuvPVTREpGCvsBS3KX0Vv+E0EAdZyqtboRaayGo pB3kSuEhE6HO44lvCAwNx0CkkdolyDj2RyW4rduQuM9odxTz/a6umoVnzxePqbZZdy2D TR7qtmwY7YOPEXmTgxDv81RlaGPcgM/Zlkgu6yyrSkixOYV5flUtaB0PrymunGefHlv6 cwdQ== ARC-Authentication-Results: i=1; mx.google.com; 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 x6si5427456pgp.254.2018.03.12.12.39.21; Mon, 12 Mar 2018 12:39:36 -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; 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 S932512AbeCLThN (ORCPT + 99 others); Mon, 12 Mar 2018 15:37:13 -0400 Received: from ale.deltatee.com ([207.54.116.67]:54648 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932292AbeCLTfj (ORCPT ); Mon, 12 Mar 2018 15:35:39 -0400 Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1evTEJ-000669-QD; Mon, 12 Mar 2018 13:35:33 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1evTEH-0000lF-1Q; Mon, 12 Mar 2018 13:35:29 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-nvme@lists.infradead.org, linux-rdma@vger.kernel.org, linux-nvdimm@lists.01.org, linux-block@vger.kernel.org Cc: Stephen Bates , Christoph Hellwig , Jens Axboe , Keith Busch , Sagi Grimberg , Bjorn Helgaas , Jason Gunthorpe , Max Gurtovoy , Dan Williams , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Benjamin Herrenschmidt , Alex Williamson , Logan Gunthorpe Date: Mon, 12 Mar 2018 13:35:21 -0600 Message-Id: <20180312193525.2855-8-logang@deltatee.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180312193525.2855-1-logang@deltatee.com> References: <20180312193525.2855-1-logang@deltatee.com> X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-nvme@lists.infradead.org, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-rdma@vger.kernel.org, linux-block@vger.kernel.org, sbates@raithlin.com, hch@lst.de, axboe@kernel.dk, sagi@grimberg.me, bhelgaas@google.com, jgg@mellanox.com, maxg@mellanox.com, keith.busch@intel.com, dan.j.williams@intel.com, benh@kernel.crashing.org, jglisse@redhat.com, alex.williamson@redhat.com, logang@deltatee.com X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-6.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, MYRULES_NO_TEXT,T_RP_MATCHES_RCVD autolearn=no autolearn_force=no version=3.4.1 Subject: [PATCH v3 07/11] IB/core: Ensure we map P2P memory correctly in rdma_rw_ctx_[init|destroy]() X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to use PCI P2P memory pci_p2pmem_[un]map_sg() functions must be called to map the correct PCI bus address. To do this, check the first page in the scatter list to see if it is P2P memory or not. At the moment, scatter lists that contain P2P memory must be homogeneous so if the first page is P2P the entire SGL should be P2P. Signed-off-by: Logan Gunthorpe --- drivers/infiniband/core/rw.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/rw.c b/drivers/infiniband/core/rw.c index c8963e91f92a..f495e8a7f8ac 100644 --- a/drivers/infiniband/core/rw.c +++ b/drivers/infiniband/core/rw.c @@ -12,6 +12,7 @@ */ #include #include +#include #include #include @@ -280,7 +281,11 @@ int rdma_rw_ctx_init(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u8 port_num, struct ib_device *dev = qp->pd->device; int ret; - ret = ib_dma_map_sg(dev, sg, sg_cnt, dir); + if (is_pci_p2pdma_page(sg_page(sg))) + ret = pci_p2pdma_map_sg(dev->dma_device, sg, sg_cnt, dir); + else + ret = ib_dma_map_sg(dev, sg, sg_cnt, dir); + if (!ret) return -ENOMEM; sg_cnt = ret; @@ -602,7 +607,11 @@ void rdma_rw_ctx_destroy(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u8 port_num, break; } - ib_dma_unmap_sg(qp->pd->device, sg, sg_cnt, dir); + if (is_pci_p2pdma_page(sg_page(sg))) + pci_p2pdma_unmap_sg(qp->pd->device->dma_device, sg, + sg_cnt, dir); + else + ib_dma_unmap_sg(qp->pd->device, sg, sg_cnt, dir); } EXPORT_SYMBOL(rdma_rw_ctx_destroy); -- 2.11.0