Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp809977pxf; Thu, 11 Mar 2021 15:50:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJwySB9pXDf5jblW1y6uVJENRJ5luZJ54MwPZ9Sx07OwLszGHaAcBBaP2KbrJSEiErVssBH3 X-Received: by 2002:aa7:d2d5:: with SMTP id k21mr10942419edr.216.1615506621125; Thu, 11 Mar 2021 15:50:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615506621; cv=none; d=google.com; s=arc-20160816; b=TonJF/lCEhdn6gz00sSWTs2eu0wpogisdL3nyRyqUPhkkgzvzxrQojOlkpULb3UWCR Z+B9EROludiz8SvdSJPLi4PmjwaMwY6KyX1Hl5GqEygxV6DU1vC+xxLp8SfRVkXOVMfM yRgbPSOJrEsR68Pa8zMaO/LuWNSb9LRUCFgTcJZlywueaDisdm1dQQklUuYOEi+AQxmf MYSQNy97j0ttAQhYXKHVv/u73LRf0wi5KlFGvnrA4EBlJLFn8fUctQdZsoWmwPHe4mSU qFMSZCgfAszuri2/lEpyU+CuJHn9Dnb7yRKWP/9hOoMcpUw4SO8aeQoFEh4kaZPyGS7k Shig== 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=f6LQJfU8fKCFP6wYnRzgrCuu/xZDkoPmYFwLlI2G6Nc=; b=MqyaSgkAihmdAeadCVfdV3kFXj2/Chghe2OHysEbwtkJ2yEIsKZmwx9eIUQO89nPzz wvBSwUl1P0PIIPypiFNM2/ZBS/bP8hx3KbvKhDCpd2z5TaGx9eUK2RScpGS9llD2L6L/ MJkmaYjbGfZIROkkZEeXUHQDuoHN+9JKNUotVMsdeXL6a+MPx/355okrFmCf+/CKciRQ uBvsy8KNZMlsb5Ng7L3prlmUREi4BT4YcYQBoNJeGwwKFQ8oSUsQ1aJ6gxkuf8A22bbC lT0fTWjbb0y7BK8poYoS7W3rNarKmEVsUgTjb8D+iXkYcOVHxK10dksScUL8+EZGzKCc p+aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=UuacCDLP; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a10si3126852edf.499.2021.03.11.15.49.58; Thu, 11 Mar 2021 15:50: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=UuacCDLP; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231157AbhCKXs6 (ORCPT + 99 others); Thu, 11 Mar 2021 18:48:58 -0500 Received: from ale.deltatee.com ([204.191.154.188]:49304 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230431AbhCKXsa (ORCPT ); Thu, 11 Mar 2021 18:48:30 -0500 X-Greylist: delayed 993 seconds by postgrey-1.27 at vger.kernel.org; Thu, 11 Mar 2021 18:48:30 EST 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=f6LQJfU8fKCFP6wYnRzgrCuu/xZDkoPmYFwLlI2G6Nc=; b=UuacCDLP+aPTN2kI5xuW2pW3NX wRncdycKWjJFExz+mnxROhQcpVF1gXWZhV65ZpSskTow6KMIgw/J9qqiVNiXAjQdpltZMGKdnPe3H +KW8XVmsTYTyf3+Hj6JYjWScsspdcpnvZqyKFSJQvBI9tt8Z6SpVIiSexUipSeRh8wbTHlnzMTjtp vpuhjUwovWzMn0zaN27WBYnRJe/uB4je0UzXq07sgXaQZ5A2eYRLhIsAvyYUxtC1CQhuVffpwLNPR koYdqe1tUBRPQP259Myn8zm+sN7hQU7gFB42c4U/NZxiahyacl3fCm9wlOCdBL770WTxjTS/WYfXV Q0RBcAjg==; 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 1lKUmd-0003et-Gh; Thu, 11 Mar 2021 16:32:15 -0700 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.92) (envelope-from ) id 1lKUmX-00024n-6O; Thu, 11 Mar 2021 16:31:53 -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?= , Ira Weiny , John Hubbard , Don Dutile , Matthew Wilcox , Daniel Vetter , Jakowski Andrzej , Minturn Dave B , Jason Ekstrand , Dave Hansen , Xiong Jianxin , Logan Gunthorpe Date: Thu, 11 Mar 2021 16:31:40 -0700 Message-Id: <20210311233142.7900-11-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210311233142.7900-1-logang@deltatee.com> References: <20210311233142.7900-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, dan.j.williams@intel.com, iweiny@intel.com, andrzej.jakowski@intel.com, dave.b.minturn@intel.com, jianxin.xiong@intel.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.5 required=5.0 tests=ALL_TRUSTED,BAYES_00, MYRULES_FREE,MYRULES_NO_TEXT autolearn=no autolearn_force=no version=3.4.2 Subject: [RFC PATCH v2 10/11] nvme-pci: Check DMA ops when indicating support for PCI P2PDMA 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 Introduce a supports_pci_p2pdma() operation in nvme_ctrl_ops to replace the fixed NVME_F_PCI_P2PDMA flag such that the dma_map_ops flags can be checked for PCI P2PDMA support. Signed-off-by: Logan Gunthorpe --- drivers/nvme/host/core.c | 3 ++- drivers/nvme/host/nvme.h | 2 +- drivers/nvme/host/pci.c | 11 +++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index e68a8c4ac5a6..501b4a979776 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3928,7 +3928,8 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid, blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, ns->queue); blk_queue_flag_set(QUEUE_FLAG_NONROT, ns->queue); - if (ctrl->ops->flags & NVME_F_PCI_P2PDMA) + if (ctrl->ops->supports_pci_p2pdma && + ctrl->ops->supports_pci_p2pdma(ctrl)) blk_queue_flag_set(QUEUE_FLAG_PCI_P2PDMA, ns->queue); ns->queue->queuedata = ns; diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 07b34175c6ce..9c04df982d2c 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -473,7 +473,6 @@ struct nvme_ctrl_ops { unsigned int flags; #define NVME_F_FABRICS (1 << 0) #define NVME_F_METADATA_SUPPORTED (1 << 1) -#define NVME_F_PCI_P2PDMA (1 << 2) int (*reg_read32)(struct nvme_ctrl *ctrl, u32 off, u32 *val); int (*reg_write32)(struct nvme_ctrl *ctrl, u32 off, u32 val); int (*reg_read64)(struct nvme_ctrl *ctrl, u32 off, u64 *val); @@ -481,6 +480,7 @@ struct nvme_ctrl_ops { void (*submit_async_event)(struct nvme_ctrl *ctrl); void (*delete_ctrl)(struct nvme_ctrl *ctrl); int (*get_address)(struct nvme_ctrl *ctrl, char *buf, int size); + bool (*supports_pci_p2pdma)(struct nvme_ctrl *ctrl); }; #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 17ab3320d28b..7d40c6a9e58e 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2759,17 +2759,24 @@ static int nvme_pci_get_address(struct nvme_ctrl *ctrl, char *buf, int size) return snprintf(buf, size, "%s\n", dev_name(&pdev->dev)); } +static bool nvme_pci_supports_pci_p2pdma(struct nvme_ctrl *ctrl) +{ + struct nvme_dev *dev = to_nvme_dev(ctrl); + + return dma_pci_p2pdma_supported(dev->dev); +} + static const struct nvme_ctrl_ops nvme_pci_ctrl_ops = { .name = "pcie", .module = THIS_MODULE, - .flags = NVME_F_METADATA_SUPPORTED | - NVME_F_PCI_P2PDMA, + .flags = NVME_F_METADATA_SUPPORTED, .reg_read32 = nvme_pci_reg_read32, .reg_write32 = nvme_pci_reg_write32, .reg_read64 = nvme_pci_reg_read64, .free_ctrl = nvme_pci_free_ctrl, .submit_async_event = nvme_pci_submit_async_event, .get_address = nvme_pci_get_address, + .supports_pci_p2pdma = nvme_pci_supports_pci_p2pdma, }; static int nvme_dev_map(struct nvme_dev *dev) -- 2.20.1