From: willy@linux.intel.com (Matthew Wilcox)
Subject: [PATCH 1/2] Add support for 32 bit DMA for 32 bit machines
Date: Fri, 1 Mar 2013 10:12:19 -0500 [thread overview]
Message-ID: <20130301151219.GF4530@linux.intel.com> (raw)
In-Reply-To: <E821E2F372F08945977BD15EAE588D61097C57E9@SACMBXIP02.sdcorp.global.sandisk.com>
On Thu, Feb 28, 2013@07:49:13PM +0000, Chayan Biswas wrote:
> We set the DMA mask to 32 bit if the system is a 32 bit system. We also
> try to set to 32 bit DMA if setting the 64 bit DMA fails, and clean up
> if both fails.
What problem are you solving here? If the system is 32-bit, setting the
DMA mask to 64-bit should be harmless. The DMA mask tells the system
what the device is capable of -- this doesn't change if the system
happens to be 32-bit.
> Signed-off-by: Chayan Biswas <Chayan.Biswas at sandisk.com>
> ---
> drivers/block/nvme.c | 19 +++++++++++++++++--
> 1 files changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/block/nvme.c b/drivers/block/nvme.c
> index 993c014..4b706b5 100644
> --- a/drivers/block/nvme.c
> +++ b/drivers/block/nvme.c
> @@ -42,6 +42,7 @@
>
> #include <asm-generic/io-64-nonatomic-lo-hi.h>
>
> +#define IS_DMA64 (sizeof(dma_addr_t) == 8)
> #define NVME_Q_DEPTH 1024
> #define SQ_SIZE(depth) (depth * sizeof(struct nvme_command))
> #define CQ_SIZE(depth) (depth * sizeof(struct nvme_completion))
> @@ -1662,8 +1663,21 @@ static int __devinit nvme_probe(struct pci_dev *pdev,
> INIT_LIST_HEAD(&dev->namespaces);
> dev->pci_dev = pdev;
> pci_set_drvdata(pdev, dev);
> - dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
> - dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
> + if (IS_DMA64) {
> + if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) != 0) {
> + if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)) != 0)
> + goto fail_set_dma_mask;
> +
> + dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
> + } else {
> + dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
> + }
> + } else {
> + if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)) != 0)
> + goto fail_set_dma_mask;
> +
> + dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
> + }
> result = nvme_set_instance(dev);
> if (result)
> goto disable;
> @@ -1705,6 +1719,7 @@ static int __devinit nvme_probe(struct pci_dev *pdev,
> iounmap(dev->bar);
> disable_msix:
> pci_disable_msix(pdev);
> + fail_set_dma_mask:
> nvme_release_instance(dev);
> nvme_release_prp_pools(dev);
> disable:
> --
> 1.7.1
>
>
> ________________________________
>
> PLEASE NOTE: The information contained in this electronic mail message is intended only for the use of the designated recipient(s) named above. If the reader of this message is not the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify the sender by telephone or e-mail (as shown above) immediately and destroy any and all copies of this message in your possession (whether hard copies or electronically stored copies).
>
>
> _______________________________________________
> Linux-nvme mailing list
> Linux-nvme at lists.infradead.org
> http://merlin.infradead.org/mailman/listinfo/linux-nvme
next prev parent reply other threads:[~2013-03-01 15:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-28 19:49 [PATCH 1/2] Add support for 32 bit DMA for 32 bit machines Chayan Biswas
2013-03-01 15:12 ` Matthew Wilcox [this message]
2013-03-01 22:05 ` Chayan Biswas
2013-03-04 12:46 ` Matthew Wilcox
2013-03-05 21:57 ` Chayan Biswas
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=20130301151219.GF4530@linux.intel.com \
--to=willy@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).