Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp814853pxj; Thu, 13 May 2021 18:27:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXzIQ+uDcBsutwE2RB4aMCXz8HDf1VYj6tVavE9rpXDYNd3ooeexncFj8XqlqX40GxDHbR X-Received: by 2002:a05:6e02:684:: with SMTP id o4mr10763660ils.149.1620955631740; Thu, 13 May 2021 18:27:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620955631; cv=none; d=google.com; s=arc-20160816; b=V/BPPaGHRgpypjb6tQzWEZ42ZBt72juul3O5sO+uUEJGZm17NjgmP3/dFD3TofVmF0 DxwNp2Tf5RIR/U903cEyXLaDbsPt67WxvRHUa0OyzUM8UdcmRjfUohMPBOWHsYBSwhRZ wswivfbMRKdzH5HdbWVSJArnEJoiTXqUcfSSU9Ta6WP5oXjP793S13+I+t5iqFApBKnF mxM/9X834GovcGTAbUUmRl4tNAF4hwZduAHdodMoluycTK1kIh6WxIrwPCiY7HcySYJ/ Yv1SqNPF1tbHgZBnNJfREtfGK2BvO/vF0bf29D9FKjxe/XLie7uyxY2LpXNCXB06IyRY hg1Q== 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=5qmW9GSKSqCFPU8hZ1VZO15LsnwebzhEB6QU8v/NWKM=; b=oyZW0TIpAvRNx9pKNaevq7/ARdqhGX/URw+0i/c/FLWGkm0FQyB4PxNiO65ipQHXh7 jumwaMYbKPReOmOL1ZpNKkVVQ5s8bNxgdN93OxR+DR4D2/GlpuTAYuqixwy8PVFaDiEj kqlWm5EDT3Y0CKAwhyGgt9qpkrrpivKFWP5WMbqHIsPKNxFtT+dpdqSOJhWuYJo3vHNz LA/UH82Eh3ndlD8EUVKNsfeMgv5h8W5L+bVV6EAOo+MXiMqCVYiHVfbjiaZFAVW1tRvv obAQ5KtxkuHxMzl9JEcwHNUK3ujS7IUAzlcKgPkKHnPqGYjrDdQM2HMYGm6v7iqkOZZL R3iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=QYOyhvfZ; 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 w12si5735206jap.71.2021.05.13.18.26.59; Thu, 13 May 2021 18:27:11 -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=QYOyhvfZ; 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 S233830AbhEMWdr (ORCPT + 99 others); Thu, 13 May 2021 18:33:47 -0400 Received: from ale.deltatee.com ([204.191.154.188]:59022 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233625AbhEMWd3 (ORCPT ); Thu, 13 May 2021 18:33:29 -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=5qmW9GSKSqCFPU8hZ1VZO15LsnwebzhEB6QU8v/NWKM=; b=QYOyhvfZag3VUC/V7R6w2kTee6 fwsvSw3Du3RoCsdnXQj+xombxEYgKYspdRXrK0A+ikw7ayPA9LiDOFiOVni1nOhMkc4Q4TAzGa8Af kPeOIRKqNRS5QZVSQo7UyUmujG3I35O1JituxHNlUwSD+sPJYWMOmplTH10IDwz/pKuKtobsiP0qs cHzIJQnk0JM0ad165rYhOegVFIHtqpEjbn91lDcaP4ulXhymRbHbrozhVL7asiZs18qlwJdhUZjr7 9OL+UnquO0wQKox8J1sLqBg31D4IrYPrI8Fk0XiZ+Wl8HeonylXebp3CUTOe3uPjHXMcGx1pUi/R1 SdEHs4Tw==; 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 1lhJsP-0000nB-SH; Thu, 13 May 2021 16:32:19 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.92) (envelope-from ) id 1lhJsI-0001TK-ED; Thu, 13 May 2021 16:32:10 -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 , Logan Gunthorpe Date: Thu, 13 May 2021 16:31:59 -0600 Message-Id: <20210513223203.5542-19-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210513223203.5542-1-logang@deltatee.com> References: <20210513223203.5542-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, 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: [PATCH v2 18/22] 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 522c9b229f80..9544a8948bc4 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3682,7 +3682,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 05f31a2c64bb..84649ce6c206 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -487,7 +487,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); @@ -495,6 +494,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 a29b170701fc..9912291f43af 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2756,17 +2756,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