Commit 2db4928b authored by Benjamin Herrenschmidt's avatar Benjamin Herrenschmidt Committed by Michael Ellerman

powerpc/iommu: Remove dma_data union

To support "hybrid" DMA ops in a subsequent patch, we will need both
a direct DMA offset and an iommu pointer. Those are currently exclusive
(a union), so change them to be separate fields.

While there, also type iommu_table_base properly and make exist only
on CONFIG_PPC64 since it's not referenced on 32-bit at all.
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent de369538
...@@ -10,6 +10,7 @@ struct dma_map_ops; ...@@ -10,6 +10,7 @@ struct dma_map_ops;
struct device_node; struct device_node;
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
struct pci_dn; struct pci_dn;
struct iommu_table;
#endif #endif
/* /*
...@@ -23,13 +24,15 @@ struct dev_archdata { ...@@ -23,13 +24,15 @@ struct dev_archdata {
struct dma_map_ops *dma_ops; struct dma_map_ops *dma_ops;
/* /*
* When an iommu is in use, dma_data is used as a ptr to the base of the * These two used to be a union. However, with the hybrid ops we need
* iommu_table. Otherwise, it is a simple numerical offset. * both so here we store both a DMA offset for direct mappings and
* an iommu_table for remapped DMA.
*/ */
union { dma_addr_t dma_offset;
dma_addr_t dma_offset;
void *iommu_table_base; #ifdef CONFIG_PPC64
} dma_data; struct iommu_table *iommu_table_base;
#endif
#ifdef CONFIG_IOMMU_API #ifdef CONFIG_IOMMU_API
void *iommu_domain; void *iommu_domain;
......
...@@ -106,7 +106,7 @@ static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops) ...@@ -106,7 +106,7 @@ static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops)
static inline dma_addr_t get_dma_offset(struct device *dev) static inline dma_addr_t get_dma_offset(struct device *dev)
{ {
if (dev) if (dev)
return dev->archdata.dma_data.dma_offset; return dev->archdata.dma_offset;
return PCI_DRAM_OFFSET; return PCI_DRAM_OFFSET;
} }
...@@ -114,7 +114,7 @@ static inline dma_addr_t get_dma_offset(struct device *dev) ...@@ -114,7 +114,7 @@ static inline dma_addr_t get_dma_offset(struct device *dev)
static inline void set_dma_offset(struct device *dev, dma_addr_t off) static inline void set_dma_offset(struct device *dev, dma_addr_t off)
{ {
if (dev) if (dev)
dev->archdata.dma_data.dma_offset = off; dev->archdata.dma_offset = off;
} }
/* this will be removed soon */ /* this will be removed soon */
......
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
* Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation
* Rewrite, cleanup: * Rewrite, cleanup:
* Copyright (C) 2004 Olof Johansson <olof@lixom.net>, IBM Corporation * Copyright (C) 2004 Olof Johansson <olof@lixom.net>, IBM Corporation
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
...@@ -131,16 +131,21 @@ int get_iommu_order(unsigned long size, struct iommu_table *tbl) ...@@ -131,16 +131,21 @@ int get_iommu_order(unsigned long size, struct iommu_table *tbl)
struct scatterlist; struct scatterlist;
static inline void set_iommu_table_base(struct device *dev, void *base) #ifdef CONFIG_PPC64
static inline void set_iommu_table_base(struct device *dev,
struct iommu_table *base)
{ {
dev->archdata.dma_data.iommu_table_base = base; dev->archdata.iommu_table_base = base;
} }
static inline void *get_iommu_table_base(struct device *dev) static inline void *get_iommu_table_base(struct device *dev)
{ {
return dev->archdata.dma_data.iommu_table_base; return dev->archdata.iommu_table_base;
} }
extern int dma_iommu_dma_supported(struct device *dev, u64 mask);
/* Frees table for an individual device node */ /* Frees table for an individual device node */
extern void iommu_free_table(struct iommu_table *tbl, const char *node_name); extern void iommu_free_table(struct iommu_table *tbl, const char *node_name);
...@@ -225,6 +230,20 @@ static inline int __init tce_iommu_bus_notifier_init(void) ...@@ -225,6 +230,20 @@ static inline int __init tce_iommu_bus_notifier_init(void)
} }
#endif /* !CONFIG_IOMMU_API */ #endif /* !CONFIG_IOMMU_API */
#else
static inline void *get_iommu_table_base(struct device *dev)
{
return NULL;
}
static inline int dma_iommu_dma_supported(struct device *dev, u64 mask)
{
return 0;
}
#endif /* CONFIG_PPC64 */
extern int ppc_iommu_map_sg(struct device *dev, struct iommu_table *tbl, extern int ppc_iommu_map_sg(struct device *dev, struct iommu_table *tbl,
struct scatterlist *sglist, int nelems, struct scatterlist *sglist, int nelems,
unsigned long mask, unsigned long mask,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment