All of lore.kernel.org
 help / color / mirror / Atom feed
From: marek.vasut@gmail.com
To: linux-ide@vger.kernel.org, linux-nvme@lists.infradead.org
Cc: Marek Vasut <marek.vasut+renesas@gmail.com>,
	Christoph Hellwig <hch@lst.de>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Jens Axboe <axboe@fb.com>, Jens Axboe <axboe@kernel.dk>,
	Keith Busch <keith.busch@intel.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Sagi Grimberg <sagi@grimberg.me>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	linux-renesas-soc@vger.kernel.org
Subject: [PATCH 2/2] [RFC] nvme-pci: Respect bus DMA constraints
Date: Thu,  7 Mar 2019 01:04:40 +0100	[thread overview]
Message-ID: <20190307000440.8708-2-marek.vasut@gmail.com> (raw)
In-Reply-To: <20190307000440.8708-1-marek.vasut@gmail.com>

From: Marek Vasut <marek.vasut+renesas@gmail.com>

Since commit 6c2fb2ea7636 ("of/device: Set bus DMA mask as appropriate"),
the upstream bus can constraint device DMA range. Respect that constraint
and do not change the device DMA masks if they were already set.

This is applicable e.g. on systems where the PCIe controller cannot expose
the full address space range. Such a system may have a 64bit CPU with DRAM
mapped both below and above the 32bit address space, yet the PCIe devices
can not perform DMA directly to/from the DRAM range above the 32bit limit.
Hence, for such setup to work, all the buffers must exist below the 32bit
limit.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Jens Axboe <axboe@fb.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Keith Busch <keith.busch@intel.com>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-renesas-soc@vger.kernel.org
To: linux-ide@vger.kernel.org
To: linux-nvme@lists.infradead.org
---
 drivers/nvme/host/pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 92bad1c810ac..8ec873fb86b1 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2323,7 +2323,8 @@ static int nvme_pci_enable(struct nvme_dev *dev)
 
 	pci_set_master(pdev);
 
-	if (dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(64)) &&
+	if (!dev->dev->coherent_dma_mask &&
+	    dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(64)) &&
 	    dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(32)))
 		goto disable;
 
-- 
2.20.1


WARNING: multiple messages have this Message-ID (diff)
From: marek.vasut@gmail.com (marek.vasut@gmail.com)
Subject: [PATCH 2/2] [RFC] nvme-pci: Respect bus DMA constraints
Date: Thu,  7 Mar 2019 01:04:40 +0100	[thread overview]
Message-ID: <20190307000440.8708-2-marek.vasut@gmail.com> (raw)
In-Reply-To: <20190307000440.8708-1-marek.vasut@gmail.com>

From: Marek Vasut <marek.vasut+renesas@gmail.com>

Since commit 6c2fb2ea7636 ("of/device: Set bus DMA mask as appropriate"),
the upstream bus can constraint device DMA range. Respect that constraint
and do not change the device DMA masks if they were already set.

This is applicable e.g. on systems where the PCIe controller cannot expose
the full address space range. Such a system may have a 64bit CPU with DRAM
mapped both below and above the 32bit address space, yet the PCIe devices
can not perform DMA directly to/from the DRAM range above the 32bit limit.
Hence, for such setup to work, all the buffers must exist below the 32bit
limit.

Signed-off-by: Marek Vasut <marek.vasut+renesas at gmail.com>
Cc: Christoph Hellwig <hch at lst.de>
Cc: Geert Uytterhoeven <geert+renesas at glider.be>
Cc: Jens Axboe <axboe at fb.com>
Cc: Jens Axboe <axboe at kernel.dk>
Cc: Keith Busch <keith.busch at intel.com>
Cc: Robin Murphy <robin.murphy at arm.com>
Cc: Sagi Grimberg <sagi at grimberg.me>
Cc: Wolfram Sang <wsa+renesas at sang-engineering.com>
Cc: linux-renesas-soc at vger.kernel.org
To: linux-ide at vger.kernel.org
To: linux-nvme at lists.infradead.org
---
 drivers/nvme/host/pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 92bad1c810ac..8ec873fb86b1 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2323,7 +2323,8 @@ static int nvme_pci_enable(struct nvme_dev *dev)
 
 	pci_set_master(pdev);
 
-	if (dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(64)) &&
+	if (!dev->dev->coherent_dma_mask &&
+	    dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(64)) &&
 	    dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(32)))
 		goto disable;
 
-- 
2.20.1

  reply	other threads:[~2019-03-07  0:05 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-07  0:04 [PATCH 1/2] [RFC] ata: ahci: Respect bus DMA constraints marek.vasut
2019-03-07  0:04 ` marek.vasut
2019-03-07  0:04 ` marek.vasut [this message]
2019-03-07  0:04   ` [PATCH 2/2] [RFC] nvme-pci: " marek.vasut
2019-03-07  9:32 ` [PATCH 1/2] [RFC] ata: ahci: " Robin Murphy
2019-03-07  9:32   ` Robin Murphy
2019-03-07  9:37   ` Marek Vasut
2019-03-07  9:37     ` Marek Vasut
2019-03-07  9:48     ` Robin Murphy
2019-03-07  9:48       ` Robin Murphy
2019-03-07 11:14       ` Marek Vasut
2019-03-07 11:14         ` Marek Vasut
2019-03-08  7:18         ` Christoph Hellwig
2019-03-08  7:18           ` Christoph Hellwig
2019-03-08 23:23           ` Marek Vasut
2019-03-08 23:23             ` Marek Vasut
2019-03-13 18:30             ` Christoph Hellwig
2019-03-13 18:30               ` Christoph Hellwig
2019-03-16 21:25               ` Marek Vasut
2019-03-16 21:25                 ` Marek Vasut
2019-03-16 23:04                 ` Marek Vasut
2019-03-16 23:04                   ` Marek Vasut
2019-03-17 10:29                   ` Geert Uytterhoeven
2019-03-17 10:29                     ` Geert Uytterhoeven
2019-03-17 23:36                     ` Marek Vasut
2019-03-17 23:36                       ` Marek Vasut
2019-03-18 13:14                       ` Robin Murphy
2019-03-18 13:14                         ` Robin Murphy
2019-03-18 23:25                         ` Marek Vasut
2019-03-18 23:25                           ` Marek Vasut
2019-03-28  3:25                           ` Marek Vasut
2019-03-28  3:25                             ` Marek Vasut
2019-04-09 12:16                             ` Marek Vasut
2019-04-09 12:16                               ` Marek Vasut
2019-03-17 10:24                 ` Geert Uytterhoeven
2019-03-17 10:24                   ` Geert Uytterhoeven

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=20190307000440.8708-2-marek.vasut@gmail.com \
    --to=marek.vasut@gmail.com \
    --cc=axboe@fb.com \
    --cc=axboe@kernel.dk \
    --cc=geert+renesas@glider.be \
    --cc=hch@lst.de \
    --cc=keith.busch@intel.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=marek.vasut+renesas@gmail.com \
    --cc=robin.murphy@arm.com \
    --cc=sagi@grimberg.me \
    --cc=wsa+renesas@sang-engineering.com \
    /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.