Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752283AbeAESTl (ORCPT + 1 other); Fri, 5 Jan 2018 13:19:41 -0500 Received: from ale.deltatee.com ([207.54.116.67]:46408 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752063AbeAESTj (ORCPT ); Fri, 5 Jan 2018 13:19:39 -0500 To: Keith Busch Cc: 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, Stephen Bates , Christoph Hellwig , Jens Axboe , Sagi Grimberg , Bjorn Helgaas , Jason Gunthorpe , Max Gurtovoy , Dan Williams , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Benjamin Herrenschmidt References: <20180104190137.7654-1-logang@deltatee.com> <20180104190137.7654-10-logang@deltatee.com> <20180105181152.GA10657@localhost.localdomain> From: Logan Gunthorpe Message-ID: <6c89e4b4-1854-c251-a5ec-7e54bc8085fc@deltatee.com> Date: Fri, 5 Jan 2018 11:19:28 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20180105181152.GA10657@localhost.localdomain> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: benh@kernel.crashing.org, jglisse@redhat.com, dan.j.williams@intel.com, maxg@mellanox.com, jgg@mellanox.com, bhelgaas@google.com, sagi@grimberg.me, axboe@kernel.dk, hch@lst.de, sbates@raithlin.com, linux-block@vger.kernel.org, linux-nvdimm@lists.01.org, linux-rdma@vger.kernel.org, linux-nvme@lists.infradead.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, keith.busch@intel.com X-SA-Exim-Mail-From: logang@deltatee.com Subject: Re: [PATCH 09/12] nvme-pci: Use PCI p2pmem subsystem to manage the CMB 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 List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 05/01/18 11:11 AM, Keith Busch wrote: > On Thu, Jan 04, 2018 at 12:01:34PM -0700, Logan Gunthorpe wrote: >> Register the CMB buffer as p2pmem and use the appropriate allocation >> functions to create and destroy the IO SQ. >> >> If the CMB supports WDS and RDS, publish it for use as p2p memory >> by other devices. > > <> > >> + if (qid && dev->cmb_use_sqes) { >> + nvmeq->sq_cmds = pci_alloc_p2pmem(pdev, SQ_SIZE(depth)); > >> + nvmeq->sq_dma_addr = pci_p2pmem_virt_to_bus(pdev, >> + nvmeq->sq_cmds); >> + nvmeq->sq_cmds_is_io = true; >> + } > > This gets into some spec type trouble for creating an IO submission > queue. We use the sq_dma_addr as the PRP entry to the Create I/O > SQ command, which has some requirements: > > "the PRP Entry shall have an offset of 0h." > > So this has to be 4k aligned, but pci_alloc_p2pmem doesn't guarantee > that. I doubt the spec's intention was to require such alignment for > CMB SQs, but there may be controllers enforcing the rule as written. Although it is not explicitly stated anywhere, pci_alloc_p2pmem() should always be at least 4k aligned. This is because the gen_pool that implements it is created with PAGE_SHIFT for its min_alloc_order. Logan