All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Gurtovoy <mgurtovoy@nvidia.com>
To: <linux-nvme@lists.infradead.org>, <dan.j.williams@intel.com>,
	<logang@deltatee.com>, <linux-mm@kvack.org>, <hch@lst.de>
Cc: <sagi@grimberg.me>, <david@redhat.com>, <oren@nvidia.com>,
	<linux-kernel@vger.kernel.org>, <akpm@linux-foundation.org>,
	Max Gurtovoy <mgurtovoy@nvidia.com>
Subject: [PATCH 3/3] nvme-pci: align CMB size according to P2PMEM alignment
Date: Wed, 2 Jun 2021 14:10:55 +0300	[thread overview]
Message-ID: <20210602111055.10480-4-mgurtovoy@nvidia.com> (raw)
In-Reply-To: <20210602111055.10480-1-mgurtovoy@nvidia.com>

P2PMEM is using mhp framework to connect to the memory subsystem. In
case the CMB size is not compatible to mhp alignment, the CMB mapping
will fail. Use pci_p2pdma_align_size to align CMB size in order to
successfully map non-aligned original CMB.

Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
---
 drivers/nvme/host/pci.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index a29b170701fc..1197263b4cd0 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1817,6 +1817,7 @@ static void nvme_map_cmb(struct nvme_dev *dev)
 	u64 size, offset;
 	resource_size_t bar_size;
 	struct pci_dev *pdev = to_pci_dev(dev->dev);
+	unsigned long nr_pages, min_align;
 	int bar;
 
 	if (dev->cmb_size)
@@ -1856,6 +1857,12 @@ static void nvme_map_cmb(struct nvme_dev *dev)
 	if (size > bar_size - offset)
 		size = bar_size - offset;
 
+	size = pci_p2pdma_align_size(size);
+	if (!size) {
+		dev_warn(dev->ctrl.device, "CMB size is 0 after alignment\n");
+		return;
+	}
+
 	if (pci_p2pdma_add_resource(pdev, bar, size, offset)) {
 		dev_warn(dev->ctrl.device,
 			 "failed to register the CMB\n");
-- 
2.18.1


WARNING: multiple messages have this Message-ID (diff)
From: Max Gurtovoy <mgurtovoy@nvidia.com>
To: <linux-nvme@lists.infradead.org>, <dan.j.williams@intel.com>,
	<logang@deltatee.com>, <linux-mm@kvack.org>, <hch@lst.de>
Cc: <sagi@grimberg.me>, <david@redhat.com>, <oren@nvidia.com>,
	<linux-kernel@vger.kernel.org>, <akpm@linux-foundation.org>,
	Max Gurtovoy <mgurtovoy@nvidia.com>
Subject: [PATCH 3/3] nvme-pci: align CMB size according to P2PMEM alignment
Date: Wed, 2 Jun 2021 14:10:55 +0300	[thread overview]
Message-ID: <20210602111055.10480-4-mgurtovoy@nvidia.com> (raw)
In-Reply-To: <20210602111055.10480-1-mgurtovoy@nvidia.com>

P2PMEM is using mhp framework to connect to the memory subsystem. In
case the CMB size is not compatible to mhp alignment, the CMB mapping
will fail. Use pci_p2pdma_align_size to align CMB size in order to
successfully map non-aligned original CMB.

Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
---
 drivers/nvme/host/pci.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index a29b170701fc..1197263b4cd0 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1817,6 +1817,7 @@ static void nvme_map_cmb(struct nvme_dev *dev)
 	u64 size, offset;
 	resource_size_t bar_size;
 	struct pci_dev *pdev = to_pci_dev(dev->dev);
+	unsigned long nr_pages, min_align;
 	int bar;
 
 	if (dev->cmb_size)
@@ -1856,6 +1857,12 @@ static void nvme_map_cmb(struct nvme_dev *dev)
 	if (size > bar_size - offset)
 		size = bar_size - offset;
 
+	size = pci_p2pdma_align_size(size);
+	if (!size) {
+		dev_warn(dev->ctrl.device, "CMB size is 0 after alignment\n");
+		return;
+	}
+
 	if (pci_p2pdma_add_resource(pdev, bar, size, offset)) {
 		dev_warn(dev->ctrl.device,
 			 "failed to register the CMB\n");
-- 
2.18.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  parent reply	other threads:[~2021-06-02 11:11 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02 11:10 [RFC PATCH 0/3] PCI/P2PMEM: introduce pci_p2pdma_align_size API Max Gurtovoy
2021-06-02 11:10 ` Max Gurtovoy
2021-06-02 11:10 ` [PATCH 1/3] mm,memory_hotplug: export mhp min alignment Max Gurtovoy
2021-06-02 11:10   ` Max Gurtovoy
2021-06-02 12:14   ` David Hildenbrand
2021-06-02 12:14     ` David Hildenbrand
2021-06-03 10:52     ` Max Gurtovoy
2021-06-03 10:52       ` Max Gurtovoy
2021-06-21 16:11       ` Max Gurtovoy
2021-06-21 16:11         ` Max Gurtovoy
2021-06-02 11:10 ` [PATCH 2/3] PCI/P2PMEM: introduce pci_p2pdma_align_size API Max Gurtovoy
2021-06-02 11:10   ` Max Gurtovoy
2021-06-02 11:10 ` Max Gurtovoy [this message]
2021-06-02 11:10   ` [PATCH 3/3] nvme-pci: align CMB size according to P2PMEM alignment Max Gurtovoy
2021-06-02 14:39   ` Keith Busch
2021-06-02 14:39     ` Keith Busch
2021-06-02 14:51     ` Max Gurtovoy
2021-06-02 14:51       ` Max Gurtovoy
2021-06-02 12:08 ` [RFC PATCH 0/3] PCI/P2PMEM: introduce pci_p2pdma_align_size API David Hildenbrand
2021-06-02 12:08   ` David Hildenbrand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210602111055.10480-4-mgurtovoy@nvidia.com \
    --to=mgurtovoy@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=dan.j.williams@intel.com \
    --cc=david@redhat.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=logang@deltatee.com \
    --cc=oren@nvidia.com \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.