linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Implement pci_set_dma_mask() in terms of the dma_ops
@ 2007-12-17  6:35 Michael Ellerman
  2007-12-17 10:02 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Ellerman @ 2007-12-17  6:35 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

Powerpc currently doesn't implement pci_set_dma_mask(), which means drivers
calling it will get the generic version in drivers/pci/pci.c.

The Powerpc dma mapping ops include a dma_set_mask() hook, which luckily is
not implemented by anyone - so there is no bug in the fact that the hook
is currently never called.

However in future we'll add implementation(s) of dma_set_mask(), and so we
need pci_set_dma_mask() to call the hook.

To save adding a hook to the dma mapping ops, pci-set_consistent_dma_mask()
simply calls the dma_set_mask() hook and then copies the new mask into
dev.coherenet_dma_mask.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/kernel/pci_64.c      |   16 ++++++++++++++++
 include/asm-powerpc/dma-mapping.h |    3 +++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index bf06926..f5c4628 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -69,6 +69,22 @@ struct dma_mapping_ops *get_pci_dma_ops(void)
 }
 EXPORT_SYMBOL(get_pci_dma_ops);
 
+
+int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
+{
+	return dma_set_mask(&dev->dev, mask);
+}
+
+int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
+{
+	int rc;
+
+	rc = dma_set_mask(&dev->dev, mask);
+	dev->dev.coherent_dma_mask = dev->dma_mask;
+
+	return rc;
+}
+
 static void fixup_broken_pcnet32(struct pci_dev* dev)
 {
 	if ((dev->class>>8 == PCI_CLASS_NETWORK_ETHERNET)) {
diff --git a/include/asm-powerpc/dma-mapping.h b/include/asm-powerpc/dma-mapping.h
index ff52013..e974876 100644
--- a/include/asm-powerpc/dma-mapping.h
+++ b/include/asm-powerpc/dma-mapping.h
@@ -87,6 +87,9 @@ static inline int dma_supported(struct device *dev, u64 mask)
 	return dma_ops->dma_supported(dev, mask);
 }
 
+/* We have our own implementation of pci_set_dma_mask() */
+#define HAVE_ARCH_PCI_SET_DMA_MASK
+
 static inline int dma_set_mask(struct device *dev, u64 dma_mask)
 {
 	struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
-- 
1.5.2.rc1.1884.g59b20

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Implement pci_set_dma_mask() in terms of the dma_ops
  2007-12-17  6:35 [PATCH] Implement pci_set_dma_mask() in terms of the dma_ops Michael Ellerman
@ 2007-12-17 10:02 ` Christoph Hellwig
  2007-12-18  0:40   ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2007-12-17 10:02 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, Paul Mackerras

On Mon, Dec 17, 2007 at 05:35:53PM +1100, Michael Ellerman wrote:
> To save adding a hook to the dma mapping ops, pci-set_consistent_dma_mask()
> simply calls the dma_set_mask() hook and then copies the new mask into
> dev.coherenet_dma_mask.

How is this supposed to work?  There are various devices around that
want different mask for coherent vs streaming dma mappings, and we need
to tell the iommu that we're setting it for either the former or the
latter.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Implement pci_set_dma_mask() in terms of the dma_ops
  2007-12-17 10:02 ` Christoph Hellwig
@ 2007-12-18  0:40   ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 3+ messages in thread
From: Benjamin Herrenschmidt @ 2007-12-18  0:40 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linuxppc-dev, Paul Mackerras


On Mon, 2007-12-17 at 11:02 +0100, Christoph Hellwig wrote:
> On Mon, Dec 17, 2007 at 05:35:53PM +1100, Michael Ellerman wrote:
> > To save adding a hook to the dma mapping ops, pci-set_consistent_dma_mask()
> > simply calls the dma_set_mask() hook and then copies the new mask into
> > dev.coherenet_dma_mask.
> 
> How is this supposed to work?  There are various devices around that
> want different mask for coherent vs streaming dma mappings, and we need
> to tell the iommu that we're setting it for either the former or the
> latter.

I don't think we ever supported that difference. Too broken HW for us.

We don't use coherent_dma_mask for anything at the moment on powerpc.

Ben.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-12-18  0:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-17  6:35 [PATCH] Implement pci_set_dma_mask() in terms of the dma_ops Michael Ellerman
2007-12-17 10:02 ` Christoph Hellwig
2007-12-18  0:40   ` Benjamin Herrenschmidt

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).