Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp996690pxb; Fri, 28 Jan 2022 15:17:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6ZFiLT4dJeuOSdom29wd2VX5ebXW50uVZ/q/Vmp03jxUkjuAHEZeL3g7zaiO3+mun6rMF X-Received: by 2002:a17:907:1b02:: with SMTP id mp2mr8477735ejc.615.1643411841358; Fri, 28 Jan 2022 15:17:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643411841; cv=none; d=google.com; s=arc-20160816; b=u9xQHPWs67vR5f4+Zxuw5ZU1AubgDl7SyUikFFv+BsHqHSxXreF592YHV9SP+IRplX CVGoGE6SZoBCMSLE4tJHUvBU86AeT+Q4dYVAnFDmvOl0X+rKkLk0wTy/Yv5ijgPTWLsg BDXl/6WB3lB083pX1f1+65TIn8UHSG48oX264R/wqZWmdUrsYzvG9bIuSOsokdmBqbzj H78qEnMFk4k5TUaYErXIyfZ8SSmE7qCc+IeiNh+6bLhzUiCmBsx+SmaKpqFrCbJGEcNk lv+jTEt3HXjgOjyyn3NaM9SxmDThkT7tQJMhFu1Th9uRMqA08tLKlE/4dfkVkAE2AGqa RxlA== 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=aCaIC1aGEU3aE4W87JAzdHtyIfK4Tw21zQ04iz9J0qw=; b=g4q2jQUpO4kgk1XUPYskdBkyEKN/kOMLGrqDJ+mQwDe3kB290oA2pKuP5DR+JUIw7u BfF8MnUC23zH7IUVF+3iT9Qjs13+WrTyv6IbZlldI/uCBZHABWObWk2B+1MLW9wNb5PP EPlWbzqIB6MRrIfEDTZaB5bf0aLjFrgtC5bZ1O42d01E4Eni7tdJIHLC4mKY4WzCeWPC j4yXrLBPeomesN+vHivxQ1gHfdg+ijCbhLavQZ5RZOwGR2CLO7Mi9g0JqH20fklDgT3M wjxKvQ5Pr2J1MoJq46l9yNs1mpqrMdusxviVvgpiL+Xf7r87D7r20qT4RWPH1rdfNKMS m36A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=Z69R0PP1; 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 6si3668637ejk.189.2022.01.28.15.16.55; Fri, 28 Jan 2022 15:17:21 -0800 (PST) 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=Z69R0PP1; 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 S1344652AbiA1A0g (ORCPT + 99 others); Thu, 27 Jan 2022 19:26:36 -0500 Received: from ale.deltatee.com ([204.191.154.188]:46994 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236017AbiA1A00 (ORCPT ); Thu, 27 Jan 2022 19:26:26 -0500 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=aCaIC1aGEU3aE4W87JAzdHtyIfK4Tw21zQ04iz9J0qw=; b=Z69R0PP15szxfRgF3lQdDjdoCU wo/mXI4lYi8n/BvLZ9xCK6yUFuAwlswjoRaY/u6opnOYHIK/Gx7JB2KPTj2h0TXcG3h5PRViuSnc/ 5j2UmCO1qqgon+0L5+MSOS7FHf0YXhTl3m1hb68GLJ52n1SG/G7AlNuIqfINyLJbCyQsJ8n5o3Mn8 0s+EKnXr6vLLVTG3bmSE7BwIhTELu+o1NYDb7m/nmgMUPMIF3uuM6tH3PiDhzrzshKt5jlQhCA96N rbA+x2+ZPskhkkYf59tRpEHy8nr8UvTeXF5fapebJ/4AWBYv/BmBwrRARsMHxDbEozilNtK5aYCh5 pEHFhSCg==; 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 1nDF5r-005Oca-Ri; Thu, 27 Jan 2022 17:26:25 -0700 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.94.2) (envelope-from ) id 1nDF5p-0001dL-Jc; Thu, 27 Jan 2022 17:26:21 -0700 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 , Ralph Campbell , Logan Gunthorpe Date: Thu, 27 Jan 2022 17:26:10 -0700 Message-Id: <20220128002614.6136-21-logang@deltatee.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220128002614.6136-1-logang@deltatee.com> References: <20220128002614.6136-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, 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, jhubbard@nvidia.com, rcampbell@nvidia.com, logang@deltatee.com X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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.6 Subject: [PATCH v5 20/24] block: set FOLL_PCI_P2PDMA in __bio_iov_iter_get_pages() 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 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 055fcf159461..cb19689cf9fe 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1121,6 +1121,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; @@ -1133,7 +1134,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