Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2162690pxb; Fri, 17 Sep 2021 03:47:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKdWcbeMuIGYpi4g5kY6GKtiW9FqO9zjxS8kCM2ctBeLCatKpWXl20GD4wJmQCxetEflgI X-Received: by 2002:a17:906:a018:: with SMTP id p24mr11305952ejy.349.1631875661615; Fri, 17 Sep 2021 03:47:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631875661; cv=none; d=google.com; s=arc-20160816; b=Be8hM9HS+P9ziZtvHdVfePK6YmsWTv21PNfXOk0H7sgCGgeBSIdqrjmTEO5PvSpNqA iZIv025Pr8AVvKuERXyld7KW3EnGX7YRS/+cPmmcdUBS8BHjl+Bme5rcVA0FJ6x0Wine PTvsaXPCvC1tCqmANk0WCFEmOTj2u00T+4pZAG8PM9pzo0OQTpHmCBTCtIx80YJLF5hR DNHFd8PQ2KHszVy/M3M8F6hqYLZd3zrP0Twg0WF/VegJ1KdGFqibvmlM+U5lHwEB0ubX Bj/zwZ2mRZPThZHnjDgk1ZGEo4n1gfgxyvQb7DLL8fAWpHDQlkHKLedZLAmUDrdLy+Xv 2C+Q== 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=DL8FuIfLp21l4Cv1YPFXNkjOJmlPVLg2ptxTU5EjJLs=; b=1BdeVc0vkSXsiJn4fr7KEml1SWA7IQbRzEbP1TCnO1MikMg4JMVbCN8fgtJKbsREzm LW6ZAZGXNjOsx/UwZj04SreCQvku2D55AgVrmcGSf9HBrV8MGvTplfZCffq6ObwfB9fw GsCg+PGrZkg0GXylrWE3dLaDABz2QUbqnJ8QhJXesmvPUujgQAFq1CYgCwTI+wVEqEL5 V0sNQ6m7Cyn2f15VJrkfZqFl08WMtSjlX8V1N4xjMXZY03ai14IWP6IOARKg1W6E5088 SNDu8KSYcZSkHRraw24vVNxgkNj3eVyV1mWzSlFXZCi4FQo6YMC65yb5sFE+INt3YTpI pGSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=iiwN1ZRE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hs3si4892127ejc.368.2021.09.17.03.47.17; Fri, 17 Sep 2021 03:47:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=iiwN1ZRE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S241988AbhIPXmy (ORCPT + 99 others); Thu, 16 Sep 2021 19:42:54 -0400 Received: from ale.deltatee.com ([204.191.154.188]:40604 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241404AbhIPXmc (ORCPT ); Thu, 16 Sep 2021 19:42:32 -0400 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=DL8FuIfLp21l4Cv1YPFXNkjOJmlPVLg2ptxTU5EjJLs=; b=iiwN1ZRE02Rz08NIjhtt5Qi8Bg TqQndz0v6FvvKtpnsaw7xX4AiGV8e+RJ8TJnBrZJOAvrLPklc5SJGydVRak4Meh06AyoE/hgX5w7Q +3EAc652569dtBXXobJRdr1gZC+kO6GYVTKxe8019Mv+lp+WGTIxjBCov7EMWOaNthacaHtBgr81x SJ/OPz2XJR0TMK7ArzgeIAHJ/TE6MKUXwGrohkFYFo9/+pdrxbSu1h2LDuNWpYF98snwijjWqyP/1 8JrOg7jidaApL4PobNWYNuxlqD+K5iLwUkCiem0dSFje8XRUMZmfe6fHvXxexeQJaOiEMqb3XHjD5 N0LoLscw==; Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mR10A-0008I1-Ov; Thu, 16 Sep 2021 17:41:11 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.94.2) (envelope-from ) id 1mR106-000Vri-1x; Thu, 16 Sep 2021 17:41:06 -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, iommu@lists.linux-foundation.org Cc: Stephen Bates , Christoph Hellwig , Dan Williams , Jason Gunthorpe , =?UTF-8?q?Christian=20K=C3=B6nig?= , John Hubbard , Don Dutile , Matthew Wilcox , Daniel Vetter , Jakowski Andrzej , Minturn Dave B , Jason Ekstrand , Dave Hansen , Xiong Jianxin , Bjorn Helgaas , Ira Weiny , Robin Murphy , Martin Oliveira , Chaitanya Kulkarni , Logan Gunthorpe Date: Thu, 16 Sep 2021 17:40:56 -0600 Message-Id: <20210916234100.122368-17-logang@deltatee.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210916234100.122368-1-logang@deltatee.com> References: <20210916234100.122368-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, iommu@lists.linux-foundation.org, sbates@raithlin.com, hch@lst.de, jgg@ziepe.ca, christian.koenig@amd.com, jhubbard@nvidia.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, andrzej.jakowski@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, logang@deltatee.com X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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 autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH v3 16/20] block: set FOLL_PCI_P2PDMA in __bio_iov_iter_get_pages() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +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 O_DIRECT path in iomap based filesystems and direct to block devices. Signed-off-by: Logan Gunthorpe --- block/bio.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/block/bio.c b/block/bio.c index 5df3dd282e40..2436e83fe3b4 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1088,6 +1088,7 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) struct bio_vec *bv = bio->bi_io_vec + bio->bi_vcnt; struct page **pages = (struct page **)bv; bool same_page = false; + unsigned int flags = 0; ssize_t size, left; unsigned len, i; size_t offset; @@ -1100,7 +1101,12 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) BUILD_BUG_ON(PAGE_PTRS_PER_BVEC < 2); pages += entries_left * (PAGE_PTRS_PER_BVEC - 1); - size = iov_iter_get_pages(iter, pages, LONG_MAX, nr_pages, &offset); + if (bio->bi_bdev && bio->bi_bdev->bd_disk && + blk_queue_pci_p2pdma(bio->bi_bdev->bd_disk->queue)) + flags |= FOLL_PCI_P2PDMA; + + size = iov_iter_get_pages_flags(iter, pages, LONG_MAX, nr_pages, + &offset, flags); if (unlikely(size <= 0)) return size ? size : -EFAULT; -- 2.30.2