Received: by 10.223.185.116 with SMTP id b49csp7283981wrg; Thu, 1 Mar 2018 03:03:31 -0800 (PST) X-Google-Smtp-Source: AG47ELtEY31N7c4VptEw/RREzI9yv3EV8GaOa37jqcW9j9aCSJ7VRGB2r7fmPQpXj0Y6mou+o7tT X-Received: by 10.98.202.23 with SMTP id n23mr1553259pfg.52.1519902211161; Thu, 01 Mar 2018 03:03:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519902211; cv=none; d=google.com; s=arc-20160816; b=WKmcKr52nhu0EwEKkBA/Q1r3l/GrhPmLcX4+8kzvec+3Da1wosUqBYNS2x82MDpcfb Qu5tF1qypkEQ+KJ3BDEmUeMcfQQAc8bUC4q26CxHK6IM/stT9plI/jvIYJQkZc6MjE9s wLH+JjoRKNPEyC2o4/ten3H29tTNUpSxuPLCtNm4vy4aMVNKx8oOTQyhKnBrykFla0x0 N5EEMQhitfXuGs9/fNWoA68x4a9gquRFCegZuU2yyVeGTWyfx6yUn25eWUevJv6CUPaw LL8oDVYpJmZFq85dgVzpwhfya6yeDZ7TYTa98OtTYCwR8yoP/gmIFow+Lz7yInb7mAWs XcAg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=K+WvZenw8uSOiNhBtrXro3l3sABLjPjsU7UkSi2gGTA=; b=hLWboffzT65he5EuRnKSyWpW4WGHR0GN0/hhVCb0allHja/Jg0SauJlo26XRdXp08T O+7aZKEvYiXkAQetPgHy4weNtvSkwtiPTGTiZEnFORUkRO5j6Bq8CYAWnR6sSAIWjlaK 2Rz0ugKcwpPnlZ3Lkd6p71P66qWfQbvV8dYaGqJ0MtVDdtlaQV1WsoboIWx7idsjLYWF sSUfQJuLrR6MVpAjUAt8cz7LfekcwHPKa71oweicJkZFqBdniTOzFz+XiuTAWe0ie6QV DOM5V0ddy7p6NOiHmrj43GibLsR8+okBSN92BJ4Q8mhVnSh3/hRltc6ipwL/zqtdEZWF rOSA== 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 f4-v6si2874348plt.765.2018.03.01.03.03.13; Thu, 01 Mar 2018 03:03:31 -0800 (PST) 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 S967384AbeCAKcx (ORCPT + 99 others); Thu, 1 Mar 2018 05:32:53 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:33924 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966058AbeCAKcu (ORCPT ); Thu, 1 Mar 2018 05:32:50 -0500 Received: by mail-wr0-f196.google.com with SMTP id m5so5544719wrg.1; Thu, 01 Mar 2018 02:32:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=K+WvZenw8uSOiNhBtrXro3l3sABLjPjsU7UkSi2gGTA=; b=Eso4v9lDHfPgmKZMGkHJGVNqgEWBTY9AHT4Jdr3Tc51UGHt7bJax8OvM7/dOHXlZG9 cHlDmNjwyAU9p+dWvsUjk5am9Iu+dzpwGLJF6PrhEG+0sbVIh3W9fnVJFYTKtg/KwOfA bMCwOpt9yq7qTdASIqmphN5fXiNW251SSGr7Z6hg9AN1B87X5tK5/YJwsuMY5GKZLmPm OjrQA8VH039v+Cdsnf+7+82wIC8Gz5zdr78LCNvP27l0EDLP16Aeck9wJAPl8BnKBmLC 9THjZchCoDSll/6RJnPlIg2wqKHGvtzsfvVl9puV6wnpBKy7fo1OA4u7JYQWvUKhRRjq 9Zdg== X-Gm-Message-State: APf1xPDQn52HHkNpWb8yP2IVZ4Mh86pINMVn6vUxiSZDrNbI2p9rLvaI Pj8o7VsxElC6ahNUPL5ErsA= X-Received: by 10.223.198.199 with SMTP id c7mr1203234wrh.125.1519900368664; Thu, 01 Mar 2018 02:32:48 -0800 (PST) Received: from [192.168.64.110] (bzq-219-42-90.isdn.bezeqint.net. [62.219.42.90]) by smtp.gmail.com with ESMTPSA id p104sm5664385wrb.47.2018.03.01.02.32.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 02:32:47 -0800 (PST) Subject: Re: [PATCH v2 06/10] IB/core: Add optional PCI P2P flag to rdma_rw_ctx_[init|destroy]() To: Logan Gunthorpe , 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 , Bjorn Helgaas , Jason Gunthorpe , Max Gurtovoy , Dan Williams , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Benjamin Herrenschmidt , Alex Williamson References: <20180228234006.21093-1-logang@deltatee.com> <20180228234006.21093-7-logang@deltatee.com> From: Sagi Grimberg Message-ID: <72e90cc2-c05a-3ed8-42c7-e4d7a0d535d8@grimberg.me> Date: Thu, 1 Mar 2018 12:32:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180228234006.21093-7-logang@deltatee.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/01/2018 01:40 AM, Logan Gunthorpe wrote: > In order to use PCI P2P memory pci_p2pmem_[un]map_sg() functions must be > called to map the correct DMA address. To do this, we add a flags > variable and the RDMA_RW_CTX_FLAG_PCI_P2P flag. When the flag is > specified use the appropriate map function. > > Signed-off-by: Logan Gunthorpe > --- > drivers/infiniband/core/rw.c | 21 +++++++++++++++++---- > drivers/infiniband/ulp/isert/ib_isert.c | 5 +++-- > drivers/infiniband/ulp/srpt/ib_srpt.c | 7 ++++--- > drivers/nvme/target/rdma.c | 6 +++--- > include/rdma/rw.h | 7 +++++-- > net/sunrpc/xprtrdma/svc_rdma_rw.c | 6 +++--- > 6 files changed, 35 insertions(+), 17 deletions(-) > > diff --git a/drivers/infiniband/core/rw.c b/drivers/infiniband/core/rw.c > index c8963e91f92a..775a9f8b15a6 100644 > --- a/drivers/infiniband/core/rw.c > +++ b/drivers/infiniband/core/rw.c > @@ -12,6 +12,7 @@ > */ > #include > #include > +#include > #include > #include > > @@ -269,18 +270,24 @@ static int rdma_rw_init_single_wr(struct rdma_rw_ctx *ctx, struct ib_qp *qp, > * @remote_addr:remote address to read/write (relative to @rkey) > * @rkey: remote key to operate on > * @dir: %DMA_TO_DEVICE for RDMA WRITE, %DMA_FROM_DEVICE for RDMA READ > + * @flags: any of the RDMA_RW_CTX_FLAG_* flags > * > * Returns the number of WQEs that will be needed on the workqueue if > * successful, or a negative error code. > */ > int rdma_rw_ctx_init(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u8 port_num, > struct scatterlist *sg, u32 sg_cnt, u32 sg_offset, > - u64 remote_addr, u32 rkey, enum dma_data_direction dir) > + u64 remote_addr, u32 rkey, enum dma_data_direction dir, > + unsigned int flags) > { > struct ib_device *dev = qp->pd->device; > int ret; > > - ret = ib_dma_map_sg(dev, sg, sg_cnt, dir); > + if (flags & RDMA_RW_CTX_FLAG_PCI_P2PDMA) > + ret = pci_p2pdma_map_sg(dev->dma_device, sg, sg_cnt, dir); > + else > + ret = ib_dma_map_sg(dev, sg, sg_cnt, dir); > + Why not use is_pci_p2pdma_page(sg) instead of a flag? It would be so much cleaner...