From: Nishanth Aravamudan <nacc@us.ibm.com>
To: Milton Miller <miltonm@bga.com>
Cc: linux-kernel@vger.kernel.org, Paul Mackerras <paulus@samba.org>,
Will Schmidt <will_schmidt@vnet.ibm.com>,
linuxppc-dev@lists.ozlabs.org
Subject: [PATCH 1/8] pseries/iommu: add additional checks when changing iommu mask
Date: Wed, 11 May 2011 15:24:57 -0700 [thread overview]
Message-ID: <1305152704-4864-2-git-send-email-nacc@us.ibm.com> (raw)
In-Reply-To: <1305152704-4864-1-git-send-email-nacc@us.ibm.com>
From: Milton Miller <miltonm@bga.com>
Do not check dma supported until we have chosen the right dma ops.
Check that the device is pci before treating it as such.
Check the mask is supported by the selected dma ops before
committing it.
We only need to set iommu ops if it is not the current ops; this
avoids searching the tree for the iommu table unnecessarily.
Signed-off-by: Milton Miller <miltonm@bga.com>
Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
---
arch/powerpc/platforms/pseries/iommu.c | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index 44d47ac..05c101e 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -1026,9 +1026,12 @@ static int dma_set_mask_pSeriesLP(struct device *dev, u64 dma_mask)
const void *dma_window = NULL;
u64 dma_offset;
- if (!dev->dma_mask || !dma_supported(dev, dma_mask))
+ if (!dev->dma_mask)
return -EIO;
+ if (!dev_is_pci(dev))
+ goto check_mask;
+
pdev = to_pci_dev(dev);
/* only attempt to use a new window if 64-bit DMA is requested */
@@ -1059,13 +1062,17 @@ static int dma_set_mask_pSeriesLP(struct device *dev, u64 dma_mask)
}
}
- /* fall-through to iommu ops */
- if (!ddw_enabled) {
- dev_info(dev, "Using 32-bit DMA via iommu\n");
+ /* fall back on iommu ops, restore table pointer with ops */
+ if (!ddw_enabled && get_dma_ops(dev) != &dma_iommu_ops) {
+ dev_info(dev, "Restoring 32-bit DMA via iommu\n");
set_dma_ops(dev, &dma_iommu_ops);
pci_dma_dev_setup_pSeriesLP(pdev);
}
+check_mask:
+ if (!dma_supported(dev, dma_mask))
+ return -EIO;
+
*dev->dma_mask = dma_mask;
return 0;
}
--
1.7.4.1
next prev parent reply other threads:[~2011-05-11 22:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-11 22:24 [PATCH 0/8] pseries/iommu: bug-fixes and cleanups for dynamic dma windows Nishanth Aravamudan
2011-05-11 22:24 ` Nishanth Aravamudan [this message]
2011-05-11 22:24 ` [PATCH 2/8] pseries/iommu: remove ddw property when destroying window Nishanth Aravamudan
2011-05-11 22:24 ` [PATCH 3/8] pseries/iommu: find windows after kexec during boot Nishanth Aravamudan
2011-05-11 22:25 ` [PATCH 4/8] pseries/iommu: cleanup ddw naming Nishanth Aravamudan
2011-05-11 22:25 ` [PATCH 5/8] powerpc: override dma_get_required_mask by platform hook and ops Nishanth Aravamudan
2011-05-19 7:43 ` Benjamin Herrenschmidt
2011-05-19 17:46 ` Nishanth Aravamudan
2011-05-25 18:47 ` Nishanth Aravamudan
2011-05-11 22:25 ` [PATCH 7/8] powerpc: use the newly added get_required_mask dma_map_ops hook Nishanth Aravamudan
2011-05-12 5:51 ` Geert Uytterhoeven
2011-05-12 7:32 ` Milton Miller
2011-05-11 22:25 ` [PATCH 8/8] powerpc: tidy up dma_map_ops after adding new hook Nishanth Aravamudan
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=1305152704-4864-2-git-send-email-nacc@us.ibm.com \
--to=nacc@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=miltonm@bga.com \
--cc=paulus@samba.org \
--cc=will_schmidt@vnet.ibm.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).