Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2195016pxb; Fri, 17 Sep 2021 04:35:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylyeXoeNpCvIcUze6pvm4a0r1Gi9rkV6GEoGb7JRwCikI0H03oSYoODrdEnrLNPP34dvNY X-Received: by 2002:a05:6e02:1be6:: with SMTP id y6mr7895382ilv.106.1631878554634; Fri, 17 Sep 2021 04:35:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631878554; cv=none; d=google.com; s=arc-20160816; b=OaOyWJG8JMILU+1tRPvtYZLWqiMZHK699d7rob8TW1SuUNTsXMYy0y/DSx9/8Gk1Dc jhpv91zTg0gH/VX7OCmeTp+1VLuWFkeneodWzx1hkpt6wVVIV5F1s90tp/Rraio7cnie tswxLPCO5apvgKC8ascdCWUvTakHaBSjj6n21Li4mCUszugAWNPc9CLs70Viih4LhgkH dBOU8c2QPZifHMtkBpvUkzZiR+uuslnfMw4lN5faxiwn0nDBPR7H3gZ8kHtuODfSIn44 pKuFRl6fxRoOeaAYD4ECcgTJWieKswBQlpxH4RoG4RnG4m05xT1+4luWPUpcHO2fTFQ3 iolA== 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=GGVshRirD7E8RzSCZM8OwSLnUMUZfCLdvzVEjiU8aQs=; b=i221X1/Q4sKcRwc9MhouloMtz2IdvHZW88AN1HhOagmy3T/pA1Mvv6EdPh1PDzTime elymgtTyFy+eRDvVfHC4yjOlB9flxJUNxOEOiiDjVmzY++pu7CE5TfGfN0A/VcSco74s 0U+EyZdp1yRJFZg+wmd11oOwk9JXoKx4EBFYSxu9OoREeDB1LYNzQ4aSpD3SyjiQFboC /5sHBcJ76Ang32JQxemMGgeGdcW9ayJmmfRq4Qqi3ugboEmJf34hxP4BOK7PIINU8CzB WJn/tZvXIXc5bEw9oaiFc3HGfV2VOWQVWpkRvV2Ya2218YHLNG8ZYWkMyC1SJYuzOazC LjfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=raROBzSQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q7si6374482ilu.111.2021.09.17.04.35.36; Fri, 17 Sep 2021 04:35:54 -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=raROBzSQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242141AbhIPXnW (ORCPT + 99 others); Thu, 16 Sep 2021 19:43:22 -0400 Received: from ale.deltatee.com ([204.191.154.188]:40722 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241688AbhIPXmi (ORCPT ); Thu, 16 Sep 2021 19:42:38 -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=GGVshRirD7E8RzSCZM8OwSLnUMUZfCLdvzVEjiU8aQs=; b=raROBzSQH8fRo79uTXssKwk37a 2cwPHscXddUuiSIWM15ZkFgmVARMUXkK5lczgid/1F/A9gpU32ATi+Vt1MBGWnFbBJ5taO9IKSrZG if5C3ZUrbYTDytrdwedU94IXVPCj1b59UUpCOkdRBrN+pFgAY7d/Cx9a8AVRi6cyOp+rX/d2ql7ar pUt6rLvWCa4rmFaKqs5Bu81tUDthk0MkCYy/w3LEEfKMj1Z28iqFGC6ycbk/iaZ6oR3R4zBYSq+TF hmlx/VD3h9UgVlyHCOUbwhYtwVUoTZnNQFKNXDU8SpHVYWl32ROxVoV1hpOzGTtAIGTACcffVyVAB uyfFrP6g==; 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 1mR10F-0008I1-Jm; Thu, 16 Sep 2021 17:41:16 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.94.2) (envelope-from ) id 1mR104-000VrF-Op; Thu, 16 Sep 2021 17:41:04 -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 , Martin Oliveira , Chaitanya Kulkarni , Logan Gunthorpe Date: Thu, 16 Sep 2021 17:40:49 -0600 Message-Id: <20210916234100.122368-10-logang@deltatee.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210916234100.122368-1-logang@deltatee.com> References: <20210916234100.122368-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, martin.oliveira@eideticom.com, ckulkarnilinux@gmail.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 v3 09/20] 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 7efb31b87f37..916750a54f60 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3771,7 +3771,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->ctrl = ctrl; diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 9871c0c9374c..fb9bfc52a6d7 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -477,7 +477,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); @@ -485,6 +484,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); }; /* diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index b82492cd7503..7d1ef66eac2e 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2874,17 +2874,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.30.2