Received: by 10.213.65.68 with SMTP id h4csp252133imn; Mon, 12 Mar 2018 12:39:46 -0700 (PDT) X-Google-Smtp-Source: AG47ELtgHV++rTF0rOItFLnUf2b4rnNKOoGUneQcNt74Kc4QjGXK6m1BM4bhiDk7RQw6wJI9JJAt X-Received: by 2002:a17:902:7401:: with SMTP id g1-v6mr6319056pll.4.1520883586757; Mon, 12 Mar 2018 12:39:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520883586; cv=none; d=google.com; s=arc-20160816; b=xDFGPuYr9VjGFvUOmkhtu00UPAMyNMDCN08gR7/QbJ0egMq3rUnYJipvwCCyI1Ia37 7QmgqvzxeAVkp7z/c8AZhbRDBzEDTbbLcA3Yqq5khCeX/zsVvwwCpp8f/FWD94kpHyl3 lyumxaUyK1I7rIFVs6kXdGYgcbx31giAm+4l1NoZJFtBo54k23DbFK7YkUIe/PVlqkk8 RS1KFgy3usKsnlMKPeJ1XJMGKe4SAQ0XXX8uTBEtB6LE0mjlHFlNv9DpoDJC73nvh6LB 9HpPj4HcVVXfnUpjNYuorLhJrgAw+HLGeoRaBlZdhai0FXj/auzlVqY2vHeEgxyBcgLq CSjQ== 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=9PSKnmGTcf4z1QvAJPKcNcj+puE1fU9jqjMG1dGItpk=; b=wGXfNP+0nr0LZ6vGqjT3V8WCit6rw+ClvfIHMYgE5nxmg8S7ErU9AF8c+h8UTL1umU XVkkBUVZrMMkf847Mz5m2RA8MPJ0VfEVo/sWizU49yortGTX6cqyIWJmzosu86c6GPxq 8EiLzARDbL+hzuOp53cr1nwItu9+uVrw1nKgK7t5Vb3A6yYISDwLswdLKqObyd5pERlO jbFjHRjPwOAC/tO7MteOXWI6WInVQOtypS1SueJv0uFqxe+V4wnBpjrHEsvE94taDVwE lqjnDA1b1FY/SJIaWSnPpixRaTuaFBB+CK4d5jMo9y1WwIM9ZC3/8SYo+JkLpkOdvANL bTpQ== 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 h8si6102563pfi.117.2018.03.12.12.39.32; Mon, 12 Mar 2018 12:39:46 -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 S932533AbeCLThO (ORCPT + 99 others); Mon, 12 Mar 2018 15:37:14 -0400 Received: from ale.deltatee.com ([207.54.116.67]:54638 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932311AbeCLTfj (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-000668-QD; Mon, 12 Mar 2018 13:35:32 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1evTEG-0000lC-Ui; Mon, 12 Mar 2018 13:35:28 -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:20 -0600 Message-Id: <20180312193525.2855-7-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.5 required=5.0 tests=ALL_TRUSTED,BAYES_00, MYRULES_FREE,MYRULES_NO_TEXT,T_RP_MATCHES_RCVD autolearn=no autolearn_force=no version=3.4.1 Subject: [PATCH v3 06/11] block: Introduce PCI P2P flags for request and request queue 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 QUEUE_FLAG_PCI_P2P is introduced meaning a driver's request queue supports targeting P2P memory. REQ_PCI_P2P is introduced to indicate a particular bio request is directed to/from PCI P2P memory. A request with this flag is not accepted unless the corresponding queues have the QUEUE_FLAG_PCI_P2P flag set. Signed-off-by: Logan Gunthorpe Reviewed-by: Sagi Grimberg --- block/blk-core.c | 3 +++ include/linux/blk_types.h | 18 +++++++++++++++++- include/linux/blkdev.h | 3 +++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/block/blk-core.c b/block/blk-core.c index 6d82c4f7fadd..a2f113738b85 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -2183,6 +2183,9 @@ generic_make_request_checks(struct bio *bio) if ((bio->bi_opf & REQ_NOWAIT) && !queue_is_rq_based(q)) goto not_supported; + if ((bio->bi_opf & REQ_PCI_P2PDMA) && !blk_queue_pci_p2pdma(q)) + goto not_supported; + if (should_fail_bio(bio)) goto end_io; diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index bf18b95ed92d..490122c85b3f 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -274,6 +274,10 @@ enum req_flag_bits { __REQ_BACKGROUND, /* background IO */ __REQ_NOWAIT, /* Don't wait if request will block */ +#ifdef CONFIG_PCI_P2PDMA + __REQ_PCI_P2PDMA, /* request is to/from P2P memory */ +#endif + /* command specific flags for REQ_OP_WRITE_ZEROES: */ __REQ_NOUNMAP, /* do not free blocks when zeroing */ @@ -298,6 +302,18 @@ enum req_flag_bits { #define REQ_BACKGROUND (1ULL << __REQ_BACKGROUND) #define REQ_NOWAIT (1ULL << __REQ_NOWAIT) +#ifdef CONFIG_PCI_P2PDMA +/* + * Currently SGLs do not support mixed P2P and regular memory so + * requests with P2P memory must not be merged. + */ +#define REQ_PCI_P2PDMA (1ULL << __REQ_PCI_P2PDMA) +#define REQ_IS_PCI_P2PDMA(req) ((req)->cmd_flags & REQ_PCI_P2PDMA) +#else +#define REQ_PCI_P2PDMA 0 +#define REQ_IS_PCI_P2PDMA(req) 0 +#endif /* CONFIG_PCI_P2PDMA */ + #define REQ_NOUNMAP (1ULL << __REQ_NOUNMAP) #define REQ_DRV (1ULL << __REQ_DRV) @@ -306,7 +322,7 @@ enum req_flag_bits { (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER) #define REQ_NOMERGE_FLAGS \ - (REQ_NOMERGE | REQ_PREFLUSH | REQ_FUA) + (REQ_NOMERGE | REQ_PREFLUSH | REQ_FUA | REQ_PCI_P2PDMA) #define bio_op(bio) \ ((bio)->bi_opf & REQ_OP_MASK) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index ed63f3b69c12..0b4a386c73ea 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -698,6 +698,7 @@ struct request_queue { #define QUEUE_FLAG_SCSI_PASSTHROUGH 27 /* queue supports SCSI commands */ #define QUEUE_FLAG_QUIESCED 28 /* queue has been quiesced */ #define QUEUE_FLAG_PREEMPT_ONLY 29 /* only process REQ_PREEMPT requests */ +#define QUEUE_FLAG_PCI_P2PDMA 30 /* device supports pci p2p requests */ #define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ (1 << QUEUE_FLAG_SAME_COMP) | \ @@ -793,6 +794,8 @@ static inline void queue_flag_clear(unsigned int flag, struct request_queue *q) #define blk_queue_dax(q) test_bit(QUEUE_FLAG_DAX, &(q)->queue_flags) #define blk_queue_scsi_passthrough(q) \ test_bit(QUEUE_FLAG_SCSI_PASSTHROUGH, &(q)->queue_flags) +#define blk_queue_pci_p2pdma(q) \ + test_bit(QUEUE_FLAG_PCI_P2PDMA, &(q)->queue_flags) #define blk_noretry_request(rq) \ ((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \ -- 2.11.0