Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp781432rwe; Thu, 25 Aug 2022 09:01:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR7vfJ/nAxqjiIo9InnaYKEuIG/W5+ui1mbCFmdn/fo/tq2FJ2EUmNQ3Z0gc+Xmd6qKDwOdv X-Received: by 2002:a17:907:2c4a:b0:73d:1d15:4a8f with SMTP id hf10-20020a1709072c4a00b0073d1d154a8fmr2760672ejc.573.1661443309771; Thu, 25 Aug 2022 09:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661443309; cv=none; d=google.com; s=arc-20160816; b=tVJv+6KVUiyVGmH15kLqkMbbzZERkSaM/b4P9Fbycr7ZXepRBmHhZY/YCLmzTF43Wg wVCZGe1n97o5mWRqK1h75Y3gPipUrPqydoTeJQQBp50wohRs2uNUPMt+iy4aESh7H+mT aIIXiyQc9WSVk14EPQlk0/lWCNfuw285qwR8wrbUAzRRvfn8MCFeFHYuMYzn86eXcxzQ fR/CtJZzPozoDaGWsfSdKaUyR9nIcGmtnWSOPT1FdpZRdNurq1ia2GjkzLbrhigmoflu TQNlWFU2Z37ljL/xqc0lPuseVxPnuRFJ+dN9lrxaEZhzjN4tVHRCp/eRGyIQcDTPsM8E NXbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=XnsEhea8heTLvEtJfQaMF6obPzklycKbPSf5ut+0ozc=; b=cyPHo6pbxAgobd9T8PsY9Nq/d0BgPZUpSjuUQ7hDDxalaGYLcuPrXSagJIZKNUX7pS QPjUcrr1YbfHuGpCsLLggWD4qB+p1lnVcszwX+XTZHB0EAlKBWQt3PIElh1uS0G76MfG GxDjqB1jyPMgF+gUB2NQdxs3EpwAy82qqaLw/0WDBSiUieTNhjw/mmeN4ajiAiQiWjVp 6qtk+WPPis3DFVZ8vdZtwZzFBjWyb8IbPkaobBSz8SH1O2KHSQehVspqX0wFvA3ORCX8 5I8Xt6qvnGYM//teIQZk3lKBf0pXmeAzVWpGXPhJ2RNLzx6a1bmFEijm9ggj1DUQTmhg dhIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=svROYF9V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw12-20020a1709066a0c00b00730aa841c5bsi4333654ejc.964.2022.08.25.09.01.22; Thu, 25 Aug 2022 09:01:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=svROYF9V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242574AbiHYPZJ (ORCPT + 99 others); Thu, 25 Aug 2022 11:25:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241486AbiHYPYo (ORCPT ); Thu, 25 Aug 2022 11:24:44 -0400 Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 541D3B99E2; Thu, 25 Aug 2022 08:24:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:MIME-Version:References:In-Reply-To: Message-Id:Date:Cc:To:From:content-disposition; bh=XnsEhea8heTLvEtJfQaMF6obPzklycKbPSf5ut+0ozc=; b=svROYF9VMXM1SZ5ev3XJ01x4LC 132cuMYxm0cuR1UgHM3+ccukTzKWFh4N4zBMoHf2MgOmzFLKWAMUgffufecNmtGwBVG1BfTSfJNgP DQ7SkRZM0drTSk17r0vSpQZMcNyBhMFwFi/NYCKX2/DfsVzJj+4R15Avwr7ZHj44aM3F5kurf1EXk XVGuyvzzF0FOND0stT084IVHnjhtD6wkCt7045x3i0hnT6j0pw4PatKrJmTCTR3vh8JcYX0U6hiIc TZuauDQKHVCn0wr8oOO6st5WkQOKC2Q+aQJadKK/pOvMUI6UaBMKBp1GzoXHe/SMIgfuBUh4yyrbv rU+Dlwxg==; Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oREik-0086MC-P0; Thu, 25 Aug 2022 09:24:39 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.94.2) (envelope-from ) id 1oREie-0001el-Nq; Thu, 25 Aug 2022 09:24:32 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org Cc: Christoph Hellwig , Greg Kroah-Hartman , Dan Williams , Jason Gunthorpe , =?UTF-8?q?Christian=20K=C3=B6nig?= , John Hubbard , Don Dutile , Matthew Wilcox , Daniel Vetter , Minturn Dave B , Jason Ekstrand , Dave Hansen , Xiong Jianxin , Bjorn Helgaas , Ira Weiny , Robin Murphy , Martin Oliveira , Chaitanya Kulkarni , Ralph Campbell , Stephen Bates , Logan Gunthorpe Date: Thu, 25 Aug 2022 09:24:23 -0600 Message-Id: <20220825152425.6296-7-logang@deltatee.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220825152425.6296-1-logang@deltatee.com> References: <20220825152425.6296-1-logang@deltatee.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, hch@lst.de, gregkh@linuxfoundation.org, jgg@ziepe.ca, christian.koenig@amd.com, ddutile@redhat.com, willy@infradead.org, daniel.vetter@ffwll.ch, jason@jlekstrand.net, dave.hansen@linux.intel.com, helgaas@kernel.org, dan.j.williams@intel.com, dave.b.minturn@intel.com, jianxin.xiong@intel.com, ira.weiny@intel.com, robin.murphy@arm.com, martin.oliveira@eideticom.com, ckulkarnilinux@gmail.com, jhubbard@nvidia.com, rcampbell@nvidia.com, sbates@raithlin.com, logang@deltatee.com X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v9 6/8] block: set FOLL_PCI_P2PDMA in bio_map_user_iov() X-SA-Exim-Version: 4.2.1 (built Sat, 13 Feb 2021 17:57:42 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a bio's queue supports PCI P2PDMA, set FOLL_PCI_P2PDMA for iov_iter_get_pages_flags(). This allows PCI P2PDMA pages to be passed from userspace and enables the NVMe passthru requests to use P2PDMA pages. Signed-off-by: Logan Gunthorpe --- block/blk-map.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/block/blk-map.c b/block/blk-map.c index 7196a6b64c80..1378f49ca5ca 100644 --- a/block/blk-map.c +++ b/block/blk-map.c @@ -236,6 +236,7 @@ static int bio_map_user_iov(struct request *rq, struct iov_iter *iter, { unsigned int max_sectors = queue_max_hw_sectors(rq->q); unsigned int nr_vecs = iov_iter_npages(iter, BIO_MAX_VECS); + unsigned int flags = 0; struct bio *bio; int ret; int j; @@ -248,13 +249,17 @@ static int bio_map_user_iov(struct request *rq, struct iov_iter *iter, return -ENOMEM; bio_init(bio, NULL, bio->bi_inline_vecs, nr_vecs, req_op(rq)); + if (blk_queue_pci_p2pdma(rq->q)) + flags |= FOLL_PCI_P2PDMA; + while (iov_iter_count(iter)) { struct page **pages; ssize_t bytes; size_t offs, added = 0; int npages; - bytes = iov_iter_get_pages_alloc2(iter, &pages, LONG_MAX, &offs); + bytes = iov_iter_get_pages_alloc_flags(iter, &pages, LONG_MAX, + &offs, flags); if (unlikely(bytes <= 0)) { ret = bytes ? bytes : -EFAULT; goto out_unmap; -- 2.30.2