Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp650258pxf; Thu, 8 Apr 2021 10:06:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2z5vNfT4m2YMBm7HlJk09WUl/Q2eU0114UxeziBuJj9d2S6k8helNuL4bixANAGug99oS X-Received: by 2002:a17:906:4347:: with SMTP id z7mr10203174ejm.246.1617901561227; Thu, 08 Apr 2021 10:06:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617901561; cv=none; d=google.com; s=arc-20160816; b=n9nRVj/D8W2S3MYQvz5rPS6aUYyMtktTKnoKzdo8OaJRipzB3XuaEimzbOynwO5bAg JvQkKW3xp6GlK4OZrsHXH858zdnV/PjYDQHesOJmKnN+cWXgLz0w5lRepItI3J0NRmV3 tok5/ATVuYYt+j5gaBg0hf3ZmOZqPdnYe/ibLqiyfSRzLy14TdzBP9zwPHyuSKN/deyR Fju2W9sR9J6Ikgc2qvCyxwgCDHrrbWTDgzX51LmIAkUqX6dRbHD31DdQPK/F8mHfolsU heR/TanaQKM3sM3/135WGkv5IiWmFXJH9yFXG21cJAtaf23uACdk/JQPoh7znnNJ5fCG tStQ== 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=e4nFtZ9eIzk7XhQ6GfieUVA4TNHz6gGxAh+sM5UV0Tk=; b=ruZnlMMYWoA7sLLTi2yi296SGzZu175wnPwK5JxWrQ5Bzno/9PZMyKA0MLsyUlWWx2 9u2h4ETXUp0OdaOC6Rah2VsMs0Sz+XLBfG8069P0hg9TNNAbClxl3S8Q1/4OxeAEWVw9 50vwW6svtfw7svL7WIyXYskZvvLyTa92bLelMDU31KD7EvRoqM0s7u1LSWGWNAW3UJo1 dntW/Te3uy7uOSWiMryGEjKD8nu4fktnV4TIj223cJFn1vY8fZHWRn1Af6E1u2SskOgV 4+f/JouRRxmLDLRUQtoDzUbuYNbU7QfBu63/aUx/geHYl38Xabr43sWjNNW0lO5KnOY2 GRRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=rfqvnGA7; 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 hb30si23514996ejc.218.2021.04.08.10.05.37; Thu, 08 Apr 2021 10:06:01 -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=rfqvnGA7; 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 S232573AbhDHRC0 (ORCPT + 99 others); Thu, 8 Apr 2021 13:02:26 -0400 Received: from ale.deltatee.com ([204.191.154.188]:36074 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232438AbhDHRBu (ORCPT ); Thu, 8 Apr 2021 13:01:50 -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=e4nFtZ9eIzk7XhQ6GfieUVA4TNHz6gGxAh+sM5UV0Tk=; b=rfqvnGA7loT9D1lWVvySKX1+Bb 23abxioysy1FlGsfI3ksw76VWNTic/FiwWVZWmF2oWnTDECpc9x6Jp5fGK2MSfqfE5MsMK/Ms4Gq4 XW2B4im7HKMg1gqracq7RRl6stSRtWmB8n5h2rG+XfSluanlzzz+DFUgbdLDMRo8jyHWlnD/T/zWv Gl5ocL65JqrBkOYVpvPC+OuCDq/fNBv2BLqU/S5QJovuoOSHi8Ds2MpGbPBXxCMVzRCBR1hZv7eoT tP+ydDzvXF/TbmUYRTGPgqceKI/ydQDZh7saGeh7L8FZyJQje2UH0nZ+tmDxAaYTv5r30y/IBszrl fi+2rCgQ==; 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 1lUY2B-0002Lk-0b; Thu, 08 Apr 2021 11:01:38 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.92) (envelope-from ) id 1lUY26-0002JI-Jy; Thu, 08 Apr 2021 11:01:30 -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, 8 Apr 2021 11:01:19 -0600 Message-Id: <20210408170123.8788-13-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210408170123.8788-1-logang@deltatee.com> References: <20210408170123.8788-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 12/16] 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 0896e21642be..223419454516 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3907,7 +3907,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 7249ae74f71f..14f092973792 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