use generic DMA mapping code in powerpc V7
Subsystems (7)
Hi all,
this series switches the powerpc port to use the generic swiotlb and noncoherent dma ops, and to use more generic code for the coherent direct mapping, as well as removing a lot of dead code.
As this series is very large and depends on the dma-mapping tree I've also published a git tree:
git://git.infradead.org/users/hch/misc.git powerpc-dma.7
Gitweb:
http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/powerpc-dma.7
Thanks a lot to Christian Zigotzky who spent a lot of time testing iterations on pasemi and FSL boards!
Changes since v4:
- rebased on top of the latests powerpc/next tree
- fix the DART IOMMU bypass selection
- remove the return value from arch_dma_set_mask, which was done incorrectly and isn't actually needed.
- add a new patch to remove swiotlb_dma_supported
- add a new patch to set a dma mask in the pasemi ethernet driver, given that we now validate it
- add a new patch to fix a ZONE_DMA32 assumption in the dma-direct patch
- split up a few patches to improve bisectability
(v5 and v6 were never posted)
Changes since v3:
- rebase on the powerpc fixes tree
- add a new patch to actually make the baseline amigaone config configure without warnings
- only use ZONE_DMA for 64-bit embedded CPUs, on pseries an IOMMU is always present
- fix compile in mem.c for one configuration
- drop the full npu removal for now, will be resent separately
- a few git bisection fixes
The changes since v1 are to big to list and v2 was not posted in public.
arch/powerpc/kernel/dma.c | 362 ------------------------ b/arch/powerpc/Kconfig | 5 b/arch/powerpc/include/asm/device.h | 10 b/arch/powerpc/include/asm/dma-direct.h | 18 - b/arch/powerpc/include/asm/dma-mapping.h | 92 ------ b/arch/powerpc/include/asm/iommu.h | 17 + b/arch/powerpc/include/asm/machdep.h | 4 b/arch/powerpc/include/asm/pci-bridge.h | 5 b/arch/powerpc/include/asm/pci.h | 2 b/arch/powerpc/include/asm/pgtable.h | 1 b/arch/powerpc/include/asm/swiotlb.h | 5 b/arch/powerpc/kernel/Makefile | 3 b/arch/powerpc/kernel/dma-iommu.c | 75 ++++ b/arch/powerpc/kernel/dma-mask.c | 12 b/arch/powerpc/kernel/dma-swiotlb.c | 89 ----- b/arch/powerpc/kernel/pci-common.c | 10 b/arch/powerpc/kernel/setup-common.c | 1 b/arch/powerpc/mm/dma-noncoherent.c | 40 +- b/arch/powerpc/mm/mem.c | 22 - b/arch/powerpc/platforms/44x/ppc476.c | 1 b/arch/powerpc/platforms/44x/warp.c | 2 b/arch/powerpc/platforms/85xx/corenet_generic.c | 5 b/arch/powerpc/platforms/85xx/ge_imp3a.c | 2 b/arch/powerpc/platforms/85xx/mpc8536_ds.c | 2 b/arch/powerpc/platforms/85xx/mpc85xx_ds.c | 4 b/arch/powerpc/platforms/85xx/mpc85xx_mds.c | 4 b/arch/powerpc/platforms/85xx/p1010rdb.c | 1 b/arch/powerpc/platforms/85xx/p1022_ds.c | 2 b/arch/powerpc/platforms/85xx/p1022_rdk.c | 2 b/arch/powerpc/platforms/85xx/qemu_e500.c | 1 b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c | 1 b/arch/powerpc/platforms/Kconfig.cputype | 3 b/arch/powerpc/platforms/cell/iommu.c | 172 +---------- b/arch/powerpc/platforms/pasemi/iommu.c | 2 b/arch/powerpc/platforms/pasemi/setup.c | 51 --- b/arch/powerpc/platforms/powernv/npu-dma.c | 2 b/arch/powerpc/platforms/powernv/pci-ioda.c | 132 +------- b/arch/powerpc/platforms/pseries/iommu.c | 99 +----- b/arch/powerpc/platforms/pseries/vio.c | 95 ++---- b/arch/powerpc/sysdev/dart_iommu.c | 58 +-- b/arch/powerpc/sysdev/fsl_pci.c | 25 - b/drivers/misc/cxl/vphb.c | 3 b/drivers/net/ethernet/pasemi/pasemi_mac.c | 1 b/include/linux/swiotlb.h | 3 b/kernel/dma/Kconfig | 3 b/kernel/dma/direct.c | 3 b/kernel/dma/mapping.c | 11 b/kernel/dma/swiotlb.c | 12 48 files changed, 317 insertions(+), 1158 deletions(-)
PATCH 1/32 net: pasemi: set a 64-bit DMA mask on the DMA device
The pasemi driver never set a DMA mask, and given that the powerpc DMA mapping routines never check it this worked ok so far. But the generic dma-direct code which I plan to switch on for powerpc checks the DMA mask and fails unsupported mapping requests, so we need to make sure the proper 64-bit mask is set.
--- drivers/net/ethernet/pasemi/pasemi_mac.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/pasemi/pasemi_mac.c +1 -0
@@ -1716,6 +1716,7 @@ pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err = -ENODEV ; goto out; } +dma_set_mask (&mac->dma_pdev->dev,DMA_BIT_MASK (64 )); mac->iob_pdev =pci_get_device (PCI_VENDOR_ID_PASEMI ,0xa001 ,NULL );if (!mac->iob_pdev) {
Signature · 1 line
2.20.1
Re: [01/32] net: pasemi: set a 64-bit DMA mask on the DMA device
Quoted 9 lines · Christoph Hellwig
The pasemi driver never set a DMA mask, and given that the powerpc DMA mapping routines never check it this worked ok so far. But the generic dma-direct code which I plan to switch on for powerpc checks the DMA mask and fails unsupported mapping requests, so we need to make sure the proper 64-bit mask is set.
Reported-by Christian Zigotzky <[email protected]>Signed-off-by Christoph Hellwig <[email protected]>Tested-by Christian Zigotzky <[email protected]>
Series applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/74ebe3e733b791f37415b3a1b917ee50
cheers
PATCH 2/32 dma-direct: we might need GFP_DMA for 32-bit dma masks
In reply to Christoph HellwigIf there is no ZONE_DMA32 we might need GFP_DMA to be able to allocate memory that satisfies a 32-bit DMA mask.
--- kernel/dma/direct.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/dma/direct.c +1 -2
@@ -132,8 +132,7 @@ struct page *__dma_direct_alloc_pages(struct device *dev, size_t size, goto again; } -if (IS_ENABLED (CONFIG_ZONE_DMA ) && - phys_mask <DMA_BIT_MASK (32 ) && !(gfp &GFP_DMA )) { +if (IS_ENABLED (CONFIG_ZONE_DMA ) && !(gfp &GFP_DMA )) { gfp = (gfp & ~GFP_DMA32 ) |GFP_DMA ; goto again; }
Signature · 1 line
2.20.1
PATCH 3/32 powerpc/dma: untangle vio_dma_mapping_ops from dma_iommu_ops
In reply to Christoph Hellwigvio_dma_mapping_ops currently does a lot of indirect calls through dma_iommu_ops, which not only make the code harder to follow but are also expensive in the post-spectre world. Unwind the indirect calls by calling the ppc_iommu_* or iommu_* APIs directly applicable, or just use the dma_iommu_* methods directly where we can.
--- arch/powerpc/include/asm/iommu.h | 1 + arch/powerpc/kernel/dma-iommu.c | 2 +- arch/powerpc/platforms/pseries/vio.c | 87 ++++++++++++---------------- 3 files changed, 38 insertions(+), 52 deletions(-)
arch/powerpc/include/asm/iommu.h +1 -0
@@ -237,6 +237,7 @@ static inline void iommu_del_device(struct device *dev) }#endif /* !CONFIG_IOMMU_API */ +u64 dma_iommu_get_required_mask (struct device *dev);#else static inline void *get_iommu_table_base (struct device *dev)
arch/powerpc/kernel/dma-iommu.c +1 -1
@@ -92,7 +92,7 @@ int dma_iommu_dma_supported(struct device *dev, u64 mask)return 1 ; } -static u64 dma_iommu_get_required_mask (struct device *dev) +u64 dma_iommu_get_required_mask (struct device *dev) {struct iommu_table *tbl =get_iommu_table_base (dev);u64 mask;
arch/powerpc/platforms/pseries/vio.c +36 -51
156 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 4/32 powerpc/dma: handle iommu bypass in dma_iommu_ops
In reply to Christoph HellwigAdd a new iommu_bypass flag to struct dev_archdata so that the dma_iommu implementation can handle the direct mapping transparently instead of switiching ops around. Setting of this flag is controlled by new pci_controller_ops method.
--- arch/powerpc/include/asm/device.h | 5 ++ arch/powerpc/include/asm/dma-mapping.h | 8 +++ arch/powerpc/include/asm/pci-bridge.h | 2 + arch/powerpc/kernel/dma-iommu.c | 70 +++++++++++++++++++++++--- arch/powerpc/kernel/dma.c | 19 +++---- 5 files changed, 87 insertions(+), 17 deletions(-)
arch/powerpc/include/asm/device.h +5 -0
@@ -19,6 +19,11 @@ struct iommu_table;* drivers/macintosh/macio_asic.c */ struct dev_archdata { +/* +* Set to %true if the dma_iommu_ops are requested to use a direct +* window instead of dynamically mapping memory. +*/ +bool iommu_bypass :1 ;/* * These two used to be a union. However, with the hybrid ops we need * both so here we store both a DMA offset for direct mappings and
arch/powerpc/include/asm/dma-mapping.h +8 -0
@@ -29,6 +29,14 @@ extern int dma_nommu_mmap_coherent(struct device *dev,struct vm_area_struct *vma, void *cpu_addr, dma_addr_t handle, size_t size, unsigned long attrs); +int dma_nommu_map_sg (struct device *dev,struct scatterlist *sgl, +int nents,enum dma_data_direction direction, +unsigned long attrs); +dma_addr_t dma_nommu_map_page (struct device *dev,struct page *page, +unsigned long offset,size_t size, +enum dma_data_direction dir,unsigned long attrs); +int dma_nommu_dma_supported (struct device *dev,u64 mask); +u64 dma_nommu_get_required_mask (struct device *dev);#ifdef CONFIG_NOT_COHERENT_CACHE /*
arch/powerpc/include/asm/pci-bridge.h +2 -0
@@ -19,6 +19,8 @@ struct device_node;struct pci_controller_ops {void (*dma_dev_setup)(struct pci_dev *pdev);void (*dma_bus_setup)(struct pci_bus *bus); +bool (*iommu_bypass_supported)(struct pci_dev *pdev, +u64 mask);int (*probe_mode)(struct pci_bus *bus);
arch/powerpc/kernel/dma-iommu.c +64 -6
141 lines not on this page · raw message
arch/powerpc/kernel/dma.c +8 -11
@@ -40,7 +40,7 @@ static u64 __maybe_unused get_pfn_limit(struct device *dev)return pfn; } -static int dma_nommu_dma_supported (struct device *dev,u64 mask) +int dma_nommu_dma_supported (struct device *dev,u64 mask) {#ifdef CONFIG_PPC64 u64 limit =get_dma_offset (dev) + (memblock_end_of_DRAM () -1 );
@@ -178,9 +178,9 @@ int dma_nommu_mmap_coherent(struct device *dev, struct vm_area_struct *vma, vma->vm_page_prot); } -static int dma_nommu_map_sg (struct device *dev,struct scatterlist *sgl, -int nents,enum dma_data_direction direction, -unsigned long attrs) +int dma_nommu_map_sg (struct device *dev,struct scatterlist *sgl, +int nents,enum dma_data_direction direction, +unsigned long attrs) {struct scatterlist *sg;int i;
@@ -209,7 +209,7 @@ static void dma_nommu_unmap_sg(struct device *dev, struct scatterlist *sgl,__dma_sync_page (sg_page (sg), sg->offset, sg->length, direction); } -static u64 dma_nommu_get_required_mask (struct device *dev) +u64 dma_nommu_get_required_mask (struct device *dev) {u64 end, mask;
@@ -221,12 +221,9 @@ static u64 dma_nommu_get_required_mask(struct device *dev)return mask; } -static inline dma_addr_t dma_nommu_map_page (struct device *dev, -struct page *page, -unsigned long offset, -size_t size, -enum dma_data_direction dir, -unsigned long attrs) +dma_addr_t dma_nommu_map_page (struct device *dev,struct page *page, +unsigned long offset,size_t size, +enum dma_data_direction dir,unsigned long attrs) {if (!(attrs &DMA_ATTR_SKIP_CPU_SYNC ))__dma_sync_page (page, offset, size, dir);
Signature · 1 line
2.20.1
PATCH 5/32 powerpc/pseries: unwind dma_get_required_mask_pSeriesLP a bit
In reply to Christoph HellwigCall dma_get_required_mask_pSeriesLP directly instead of dma_iommu_ops to simply the code a bit.
--- arch/powerpc/platforms/pseries/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/pseries/iommu.c +1 -1
@@ -1278,7 +1278,7 @@ static u64 dma_get_required_mask_pSeriesLP(struct device *dev)return DMA_BIT_MASK (64 ); } -return dma_iommu_ops.get_required_mask (dev); +return dma_iommu_get_required_mask (dev); } static int iommu_mem_notifier(struct notifier_block *nb, unsigned long action,
Signature · 1 line
2.20.1
PATCH 6/32 powerpc/pseries: use the generic iommu bypass code
In reply to Christoph HellwigUse the generic iommu bypass code instead of overriding set_dma_mask.
--- arch/powerpc/platforms/pseries/iommu.c | 100 +++++++------------------ 1 file changed, 27 insertions(+), 73 deletions(-)
arch/powerpc/platforms/pseries/iommu.c +27 -73
@@ -978,7 +978,7 @@ static phys_addr_t ddw_memory_hotplug_max(void)* pdn: the parent pe node with the ibm,dma_window property * Future: also check if we can remap the base window for our base page size * -* returns the dma offset for use by dma_set_mask +* returns the dma offset for use by the direct mapped DMA code. */ static u64 enable_ddw (struct pci_dev *dev,struct device_node *pdn) {
@@ -1198,87 +1198,40 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)iommu_add_device (pci->table_group, &dev->dev); } -static int dma_set_mask_pSeriesLP (struct device *dev,u64 dma_mask) +static bool iommu_bypass_supported_pSeriesLP (struct pci_dev *pdev,u64 dma_mask) { -bool ddw_enabled = false; -struct device_node *pdn, *dn; -struct pci_dev *pdev; +struct device_node *dn =pci_device_to_OF_node (pdev), *pdn;const __be32 *dma_window =NULL ;u64 dma_offset; -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 */ -if (!disable_ddw && dma_mask ==DMA_BIT_MASK (64 )) { - dn =pci_device_to_OF_node (pdev); -dev_dbg (dev,"node is %pOF\n" , dn); +if (dma_mask <DMA_BIT_MASK (64 )) +return false; -/* -* the device tree might contain the dma-window properties -* per-device and not necessarily for the bus. So we need to -* search upwards in the tree until we either hit a dma-window -* property, OR find a parent with a table already allocated. -*/ -for (pdn = dn; pdn &&PCI_DN (pdn) && !PCI_DN (pdn)->table_group; - pdn = pdn->parent) { - dma_window =of_get_property (pdn,"ibm,dma-window" ,NULL ); -if (dma_window) -break ; - } -if (pdn &&PCI_DN (pdn)) { - dma_offset =enable_ddw (pdev, pdn); -if (dma_offset !=0 ) { -dev_info (dev,"Using 64-bit direct DMA at offset %llx\n" , dma_offset); -set_dma_offset (dev, dma_offset); -set_dma_ops (dev, &dma_nommu_ops); - ddw_enabled = true; - } - } - } +dev_dbg (&pdev->dev,"node is %pOF\n" , dn); -/* fall back on iommu 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); +/* +* the device tree might contain the dma-window properties +* per-device and not necessarily for the bus. So we need to +* search upwards in the tree until we either hit a dma-window +* property, OR find a parent with a table already allocated. +*/ +for (pdn = dn; pdn &&PCI_DN (pdn) && !PCI_DN (pdn)->table_group; + pdn = pdn->parent) { + dma_window =of_get_property (pdn,"ibm,dma-window" ,NULL ); +if (dma_window) +break ; } -check_mask: -if (!dma_supported (dev, dma_mask)) -return -EIO ; - - *dev->dma_mask = dma_mask; -return 0 ; -} - -static u64 dma_get_required_mask_pSeriesLP (struct device *dev) -{ -if (!dev->dma_mask) -return 0 ; - -if (!disable_ddw &&dev_is_pci (dev)) { -struct pci_dev *pdev =to_pci_dev (dev); -struct device_node *dn; - - dn =pci_device_to_OF_node (pdev); - -/* search upwards for ibm,dma-window */ -for (; dn &&PCI_DN (dn) && !PCI_DN (dn)->table_group; - dn = dn->parent) -if (of_get_property (dn,"ibm,dma-window" ,NULL )) -break ; -/* if there is a ibm,ddw-applicable property require 64 bits */ -if (dn &&PCI_DN (dn) && -of_get_property (dn,"ibm,ddw-applicable" ,NULL )) -return DMA_BIT_MASK (64 ); +if (pdn &&PCI_DN (pdn)) { + dma_offset =enable_ddw (pdev, pdn); +if (dma_offset !=0 ) { +set_dma_offset (&pdev->dev, dma_offset); +return true; + } } -return dma_iommu_get_required_mask (dev); +return false; } static int iommu_mem_notifier(struct notifier_block *nb, unsigned long action,
@@ -1373,8 +1326,9 @@ void iommu_init_early_pSeries(void)if (firmware_has_feature (FW_FEATURE_LPAR )) { pseries_pci_controller_ops.dma_bus_setup = pci_dma_bus_setup_pSeriesLP; pseries_pci_controller_ops.dma_dev_setup = pci_dma_dev_setup_pSeriesLP; - ppc_md.dma_set_mask = dma_set_mask_pSeriesLP; - ppc_md.dma_get_required_mask = dma_get_required_mask_pSeriesLP; +if (!disable_ddw) + pseries_pci_controller_ops.iommu_bypass_supported = + iommu_bypass_supported_pSeriesLP; }else { pseries_pci_controller_ops.dma_bus_setup = pci_dma_bus_setup_pSeries; pseries_pci_controller_ops.dma_dev_setup = pci_dma_dev_setup_pSeries;
Signature · 1 line
2.20.1
PATCH 7/32 powerpc/cell: move dma direct window setup out of dma_configure
In reply to Christoph HellwigConfigure the dma settings at device setup time, and stop playing games with get_pci_dma_ops. This prepares for using the common dma_configure code later on.
Includes fixes from Michael Ellerman.
--- arch/powerpc/platforms/cell/iommu.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
arch/powerpc/platforms/cell/iommu.c +15 -9
@@ -656,14 +656,21 @@ static const struct dma_map_ops dma_iommu_fixed_ops = { .unmap_page = dma_fixed_unmap_page, }; +static u64 cell_iommu_get_fixed_address (struct device *dev); +static void cell_dma_dev_setup (struct device *dev) { -if (get_pci_dma_ops () == &dma_iommu_ops) +if (get_pci_dma_ops () == &dma_iommu_ops) { +u64 addr =cell_iommu_get_fixed_address (dev); + +if (addr !=OF_BAD_ADDR ) +set_dma_offset (dev, addr + dma_iommu_fixed_base);set_iommu_table_base (dev,cell_get_iommu_table (dev)); -else if (get_pci_dma_ops () == &dma_nommu_ops) + }else if (get_pci_dma_ops () == &dma_nommu_ops) {set_dma_offset (dev, cell_dma_nommu_offset); -else + }else {BUG (); + } }static void cell_pci_dma_dev_setup (struct pci_dev *dev)
@@ -894,7 +901,11 @@ static u64 cell_iommu_get_fixed_address(struct device *dev)const u32 *ranges =NULL ;int i, len, best, naddr, nsize, pna, range_size; +/* We can be called for platform devices that have no of_node */ np =of_node_get (dev->of_node); +if (!np) + goto out; +while (1 ) { naddr =of_n_addr_cells (np); nsize =of_n_size_cells (np);
@@ -949,19 +960,14 @@ static int dma_suported_and_switch(struct device *dev, u64 dma_mask) {if (dma_mask ==DMA_BIT_MASK (64 ) &&cell_iommu_get_fixed_address (dev) !=OF_BAD_ADDR ) { -u64 addr =cell_iommu_get_fixed_address (dev) + - dma_iommu_fixed_base;dev_dbg (dev,"iommu: 64-bit OK, using fixed ops\n" ); -dev_dbg (dev,"iommu: fixed addr = %llx\n" , addr);set_dma_ops (dev, &dma_iommu_fixed_ops); -set_dma_offset (dev, addr);return 1 ; }if (dma_iommu_dma_supported (dev, dma_mask)) {dev_dbg (dev,"iommu: not 64-bit, using default ops\n" ); -set_dma_ops (dev,get_pci_dma_ops ()); -cell_dma_dev_setup (dev); +set_dma_ops (dev, &dma_iommu_ops);return 1 ; }
Signature · 1 line
2.20.1
PATCH 8/32 powerpc/cell: use the generic iommu bypass code
In reply to Christoph HellwigThis gets rid of a lot of clumsy code and finally allows us to mark dma_iommu_ops const.
Includes fixes from Michael Ellerman.
--- arch/powerpc/include/asm/dma-mapping.h | 2 +- arch/powerpc/include/asm/iommu.h | 6 ++ arch/powerpc/kernel/dma-iommu.c | 7 +- arch/powerpc/platforms/cell/iommu.c | 140 ++----------------------- 4 files changed, 20 insertions(+), 135 deletions(-)
arch/powerpc/include/asm/dma-mapping.h +1 -1
@@ -74,7 +74,7 @@ static inline unsigned long device_to_mask(struct device *dev)* Available generic sets of operations */ #ifdef CONFIG_PPC64 -extern struct dma_map_ops dma_iommu_ops; +extern const struct dma_map_ops dma_iommu_ops;#endif extern const struct dma_map_ops dma_nommu_ops;
arch/powerpc/include/asm/iommu.h +6 -0
@@ -319,5 +319,11 @@ extern void iommu_release_ownership(struct iommu_table *tbl);extern enum dma_data_direction iommu_tce_direction (unsigned long tce);extern unsigned long iommu_direction_to_tce_perm (enum dma_data_direction dir); +#ifdef CONFIG_PPC_CELL_NATIVE +extern bool iommu_fixed_is_weak; +#else +#define iommu_fixed_is_weak false +#endif +#endif /* __KERNEL__ */ #endif /* _ASM_IOMMU_H */
arch/powerpc/kernel/dma-iommu.c +4 -3
@@ -20,14 +20,15 @@*/ static inline bool dma_iommu_alloc_bypass (struct device *dev) { -return dev->archdata.iommu_bypass && +return dev->archdata.iommu_bypass && !iommu_fixed_is_weak &&dma_nommu_dma_supported (dev, dev->coherent_dma_mask); }static inline bool dma_iommu_map_bypass (struct device *dev,unsigned long attrs) { -return dev->archdata.iommu_bypass; +return dev->archdata.iommu_bypass && + (!iommu_fixed_is_weak || (attrs &DMA_ATTR_WEAK_ORDERING )); }/* Allocates a contiguous real buffer and creates mappings over it.
@@ -163,7 +164,7 @@ u64 dma_iommu_get_required_mask(struct device *dev)return mask; } -struct dma_map_ops dma_iommu_ops = { +const struct dma_map_ops dma_iommu_ops = { .alloc = dma_iommu_alloc_coherent, .free = dma_iommu_free_coherent, .mmap = dma_nommu_mmap_coherent,
arch/powerpc/platforms/cell/iommu.c +9 -131
191 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 9/32 powerpc/dart: remove dead cleanup code in iommu_init_early_dart
In reply to Christoph HellwigIf dart_init failed we didn't have a chance to setup dma or controller ops yet, so there is no point in resetting them.
--- arch/powerpc/sysdev/dart_iommu.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
arch/powerpc/sysdev/dart_iommu.c +1 -10
@@ -428,7 +428,7 @@ void __init iommu_init_early_dart(struct pci_controller_ops *controller_ops)/* Initialize the DART HW */ if (dart_init (dn) !=0 ) - goto bail; +return ;/* Setup bypass if supported */ if (dart_is_u4)
@@ -439,15 +439,6 @@ void __init iommu_init_early_dart(struct pci_controller_ops *controller_ops)/* Setup pci_dma ops */ set_pci_dma_ops (&dma_iommu_ops); -return ; - - bail: -/* If init failed, use direct iommu and null setup functions */ - controller_ops->dma_dev_setup =NULL ; - controller_ops->dma_bus_setup =NULL ; - -/* Setup pci_dma ops */ -set_pci_dma_ops (&dma_nommu_ops); }#ifdef CONFIG_PM
Signature · 1 line
2.20.1
PATCH 10/32 powerpc/dart: use the generic iommu bypass code
In reply to Christoph HellwigUse the generic iommu bypass code instead of overriding set_dma_mask.
--- arch/powerpc/sysdev/dart_iommu.c | 47 ++++++++++++-------------------- 1 file changed, 17 insertions(+), 30 deletions(-)
arch/powerpc/sysdev/dart_iommu.c +17 -30
@@ -360,13 +360,6 @@ static void iommu_table_dart_setup(void)set_bit (iommu_table_dart.it_size -1 , iommu_table_dart.it_map); } -static void pci_dma_dev_setup_dart (struct pci_dev *dev) -{ -if (dart_is_u4) -set_dma_offset (&dev->dev,DART_U4_BYPASS_BASE ); -set_iommu_table_base (&dev->dev, &iommu_table_dart); -} -static void pci_dma_bus_setup_dart (struct pci_bus *bus) {if (!iommu_table_dart_inited) {
@@ -390,27 +383,18 @@ static bool dart_device_on_pcie(struct device *dev)return false; } -static int dart_dma_set_mask (struct device *dev,u64 dma_mask) +static void pci_dma_dev_setup_dart (struct pci_dev *dev) { -if (!dev->dma_mask || !dma_supported (dev, dma_mask)) -return -EIO ; - -/* U4 supports a DART bypass, we use it for 64-bit capable -* devices to improve performances. However, that only works -* for devices connected to U4 own PCIe interface, not bridged -* through hypertransport. We need the device to support at -* least 40 bits of addresses. -*/ -if (dart_device_on_pcie (dev) && dma_mask >=DMA_BIT_MASK (40 )) { -dev_info (dev,"Using 64-bit DMA iommu bypass\n" ); -set_dma_ops (dev, &dma_nommu_ops); - }else { -dev_info (dev,"Using 32-bit DMA via iommu\n" ); -set_dma_ops (dev, &dma_iommu_ops); - } +if (dart_is_u4 &&dart_device_on_pcie (&dev->dev)) +set_dma_offset (&dev->dev,DART_U4_BYPASS_BASE ); +set_iommu_table_base (&dev->dev, &iommu_table_dart); +} - *dev->dma_mask = dma_mask; -return 0 ; +static bool iommu_bypass_supported_dart (struct pci_dev *dev,u64 mask) +{ +return dart_is_u4 && +dart_device_on_pcie (&dev->dev) && + mask >=DMA_BIT_MASK (40 ); }void __init iommu_init_early_dart (struct pci_controller_ops *controller_ops)
@@ -430,12 +414,15 @@ void __init iommu_init_early_dart(struct pci_controller_ops *controller_ops)if (dart_init (dn) !=0 )return ; -/* Setup bypass if supported */ -if (dart_is_u4) - ppc_md.dma_set_mask = dart_dma_set_mask; - +/* +* U4 supports a DART bypass, we use it for 64-bit capable devices to +* improve performance. However, that only works for devices connected +* to the U4 own PCIe interface, not bridged through hypertransport. +* We need the device to support at least 40 bits of addresses. +*/ controller_ops->dma_dev_setup = pci_dma_dev_setup_dart; controller_ops->dma_bus_setup = pci_dma_bus_setup_dart; + controller_ops->iommu_bypass_supported = iommu_bypass_supported_dart;/* Setup pci_dma ops */ set_pci_dma_ops (&dma_iommu_ops);
Signature · 1 line
2.20.1
PATCH 11/32 powerpc/powernv: remove pnv_pci_ioda_pe_single_vendor
In reply to Christoph HellwigThis function is completely bogus - the fact that two PCIe devices come from the same vendor has absolutely nothing to say about the DMA capabilities and characteristics.
--- arch/powerpc/platforms/powernv/pci-ioda.c | 28 ++--------------------- 1 file changed, 2 insertions(+), 26 deletions(-)
arch/powerpc/platforms/powernv/pci-ioda.c +2 -26
@@ -1756,31 +1756,6 @@ static void pnv_pci_ioda_dma_dev_setup(struct pnv_phb *phb, struct pci_dev *pdev*/ } -static bool pnv_pci_ioda_pe_single_vendor (struct pnv_ioda_pe *pe) -{ -unsigned short vendor =0 ; -struct pci_dev *pdev; - -if (pe->device_count ==1 ) -return true; - -/* pe->pdev should be set if it's a single device, pe->pbus if not */ -if (!pe->pbus) -return true; - -list_for_each_entry (pdev, &pe->pbus->devices, bus_list) { -if (!vendor) { - vendor = pdev->vendor; -continue ; - } - -if (pdev->vendor != vendor) -return false; - } - -return true; -} -/* * Reconfigure TVE#0 to be usable as 64-bit DMA space. *
@@ -1881,7 +1856,8 @@ static int pnv_pci_ioda_dma_set_mask(struct pci_dev *pdev, u64 dma_mask)*/ if (dma_mask >>32 && dma_mask > (memory_hotplug_max () + (1ULL <<32 )) && -pnv_pci_ioda_pe_single_vendor (pe) && +/* pe->pdev should be set if it's a single device, pe->pbus if not */ + (pe->device_count ==1 || !pe->pbus) && phb->model ==PNV_PHB_MODEL_PHB3 ) {/* Configure the bypass mode */ rc =pnv_pci_ioda_dma_64bit_bypass (pe);
Signature · 1 line
2.20.1
PATCH 12/32 powerpc/powernv: remove pnv_npu_dma_set_mask
In reply to Christoph HellwigThese devices are not PCIe devices and do not have associated dma map ops, so this is just dead code.
--- arch/powerpc/platforms/powernv/pci-ioda.c | 9 --------- 1 file changed, 9 deletions(-)
arch/powerpc/platforms/powernv/pci-ioda.c +0 -9
@@ -3646,14 +3646,6 @@ static const struct pci_controller_ops pnv_pci_ioda_controller_ops = { .shutdown = pnv_pci_ioda_shutdown, }; -static int pnv_npu_dma_set_mask (struct pci_dev *npdev,u64 dma_mask) -{ -dev_err_once (&npdev->dev, -"%s operation unsupported for NVLink devices\n" , - __func__); -return -EPERM ; -} -static const struct pci_controller_ops pnv_npu_ioda_controller_ops = { .dma_dev_setup = pnv_pci_dma_dev_setup, .setup_msi_irqs = pnv_setup_msi_irqs,
@@ -3661,7 +3653,6 @@ static const struct pci_controller_ops pnv_npu_ioda_controller_ops = { .enable_device_hook = pnv_pci_enable_device_hook, .window_alignment = pnv_pci_window_alignment, .reset_secondary_bus = pnv_pci_reset_secondary_bus, - .dma_set_mask = pnv_npu_dma_set_mask, .shutdown = pnv_pci_ioda_shutdown, .disable_device = pnv_npu_disable_device, };
Signature · 1 line
2.20.1
PATCH 13/32 powerpc/powernv: use the generic iommu bypass code
In reply to Christoph HellwigUse the generic iommu bypass code instead of overriding set_dma_mask.
--- arch/powerpc/platforms/powernv/pci-ioda.c | 95 ++++++----------------- 1 file changed, 25 insertions(+), 70 deletions(-)
arch/powerpc/platforms/powernv/pci-ioda.c +25 -70
@@ -1825,89 +1825,45 @@ static int pnv_pci_ioda_dma_64bit_bypass(struct pnv_ioda_pe *pe)return -EIO ; } -static int pnv_pci_ioda_dma_set_mask (struct pci_dev *pdev,u64 dma_mask) +static bool pnv_pci_ioda_iommu_bypass_supported (struct pci_dev *pdev, +u64 dma_mask) {struct pci_controller *hose =pci_bus_to_host (pdev->bus);struct pnv_phb *phb = hose->private_data;struct pci_dn *pdn =pci_get_pdn (pdev);struct pnv_ioda_pe *pe; -uint64_t top; -bool bypass = false; -s64 rc;if (WARN_ON (!pdn || pdn->pe_number ==IODA_INVALID_PE ))return -ENODEV ; pe = &phb->ioda.pe_array[pdn->pe_number];if (pe->tce_bypass_enabled) { - top = pe->tce_bypass_base +memblock_end_of_DRAM () -1 ; - bypass = (dma_mask >= top); +u64 top = pe->tce_bypass_base +memblock_end_of_DRAM () -1 ; +if (dma_mask >= top) +return true; } -if (bypass) { -dev_info (&pdev->dev,"Using 64-bit DMA iommu bypass\n" ); -set_dma_ops (&pdev->dev, &dma_nommu_ops); - }else { -/* -* If the device can't set the TCE bypass bit but still wants -* to access 4GB or more, on PHB3 we can reconfigure TVE#0 to -* bypass the 32-bit region and be usable for 64-bit DMAs. -* The device needs to be able to address all of this space. -*/ -if (dma_mask >>32 && - dma_mask > (memory_hotplug_max () + (1ULL <<32 )) && -/* pe->pdev should be set if it's a single device, pe->pbus if not */ - (pe->device_count ==1 || !pe->pbus) && - phb->model ==PNV_PHB_MODEL_PHB3 ) { -/* Configure the bypass mode */ - rc =pnv_pci_ioda_dma_64bit_bypass (pe); -if (rc) -return rc; -/* 4GB offset bypasses 32-bit space */ -set_dma_offset (&pdev->dev, (1ULL <<32 )); -set_dma_ops (&pdev->dev, &dma_nommu_ops); - }else if (dma_mask >>32 && dma_mask !=DMA_BIT_MASK (64 )) { -/* -* Fail the request if a DMA mask between 32 and 64 bits -* was requested but couldn't be fulfilled. Ideally we -* would do this for 64-bits but historically we have -* always fallen back to 32-bits. -*/ -return -ENOMEM ; - }else { -dev_info (&pdev->dev,"Using 32-bit DMA via iommu\n" ); -set_dma_ops (&pdev->dev, &dma_iommu_ops); - } +/* +* If the device can't set the TCE bypass bit but still wants +* to access 4GB or more, on PHB3 we can reconfigure TVE#0 to +* bypass the 32-bit region and be usable for 64-bit DMAs. +* The device needs to be able to address all of this space. +*/ +if (dma_mask >>32 && + dma_mask > (memory_hotplug_max () + (1ULL <<32 )) && +/* pe->pdev should be set if it's a single device, pe->pbus if not */ + (pe->device_count ==1 || !pe->pbus) && + phb->model ==PNV_PHB_MODEL_PHB3 ) { +/* Configure the bypass mode */ +s64 rc =pnv_pci_ioda_dma_64bit_bypass (pe); +if (rc) +return rc; +/* 4GB offset bypasses 32-bit space */ +set_dma_offset (&pdev->dev, (1ULL <<32 )); +return true; } - *pdev->dev.dma_mask = dma_mask; - -/* Update peer npu devices */ -pnv_npu_try_dma_set_bypass (pdev, bypass); - -return 0 ; -} - -static u64 pnv_pci_ioda_dma_get_required_mask (struct pci_dev *pdev) -{ -struct pci_controller *hose =pci_bus_to_host (pdev->bus); -struct pnv_phb *phb = hose->private_data; -struct pci_dn *pdn =pci_get_pdn (pdev); -struct pnv_ioda_pe *pe; -u64 end, mask; -if (WARN_ON (!pdn || pdn->pe_number ==IODA_INVALID_PE )) -return 0 ; - - pe = &phb->ioda.pe_array[pdn->pe_number]; -if (!pe->tce_bypass_enabled) -return __dma_get_required_mask (&pdev->dev); - - - end = pe->tce_bypass_base +memblock_end_of_DRAM (); - mask =1ULL << (fls64 (end) -1 ); - mask += mask -1 ; - -return mask; +return false; }static void pnv_ioda_setup_bus_dma (struct pnv_ioda_pe *pe,struct pci_bus *bus)
@@ -3634,6 +3590,7 @@ static void pnv_pci_ioda_shutdown(struct pci_controller *hose)static const struct pci_controller_ops pnv_pci_ioda_controller_ops = { .dma_dev_setup = pnv_pci_dma_dev_setup, .dma_bus_setup = pnv_pci_dma_bus_setup, + .iommu_bypass_supported = pnv_pci_ioda_iommu_bypass_supported, .setup_msi_irqs = pnv_setup_msi_irqs, .teardown_msi_irqs = pnv_teardown_msi_irqs, .enable_device_hook = pnv_pci_enable_device_hook,
@@ -3641,8 +3598,6 @@ static const struct pci_controller_ops pnv_pci_ioda_controller_ops = { .window_alignment = pnv_pci_window_alignment, .setup_bridge = pnv_pci_setup_bridge, .reset_secondary_bus = pnv_pci_reset_secondary_bus, - .dma_set_mask = pnv_pci_ioda_dma_set_mask, - .dma_get_required_mask = pnv_pci_ioda_dma_get_required_mask, .shutdown = pnv_pci_ioda_shutdown, };
Signature · 1 line
2.20.1
PATCH 14/32 powerpc/dma: stop overriding dma_get_required_mask
In reply to Christoph HellwigThe ppc_md and pci_controller_ops methods are unused now and can be removed. The dma_nommu implementation is generic to the generic one except for using max_pfn instead of calling into the memblock API, and all other dma_map_ops instances implement a method of their own.
--- arch/powerpc/include/asm/device.h | 2 -- arch/powerpc/include/asm/dma-mapping.h | 2 -- arch/powerpc/include/asm/machdep.h | 2 -- arch/powerpc/include/asm/pci-bridge.h | 1 - arch/powerpc/kernel/dma.c | 29 -------------------------- kernel/dma/mapping.c | 2 -- 6 files changed, 38 deletions(-)
arch/powerpc/include/asm/device.h +0 -2
@@ -59,6 +59,4 @@ struct pdev_archdata { u64 dma_mask; }; -#define ARCH_HAS_DMA_GET_REQUIRED_MASK -#endif /* _ASM_POWERPC_DEVICE_H */
arch/powerpc/include/asm/dma-mapping.h +0 -2
@@ -112,7 +112,5 @@ static inline void set_dma_offset(struct device *dev, dma_addr_t off)#define HAVE_ARCH_DMA_SET_MASK 1 -extern u64 __dma_get_required_mask (struct device *dev); -#endif /* __KERNEL__ */ #endif /* _ASM_DMA_MAPPING_H */
arch/powerpc/include/asm/machdep.h +0 -2
@@ -47,9 +47,7 @@ struct machdep_calls {#endif #endif /* CONFIG_PPC64 */ -/* Platform set_dma_mask and dma_get_required_mask overrides */ int (*dma_set_mask)(struct device *dev,u64 dma_mask); -u64 (*dma_get_required_mask)(struct device *dev);int (*probe)(void );void (*setup_arch)(void );/* Optional, may be NULL */
arch/powerpc/include/asm/pci-bridge.h +0 -1
@@ -46,7 +46,6 @@ struct pci_controller_ops {#endif int (*dma_set_mask)(struct pci_dev *pdev,u64 dma_mask); -u64 (*dma_get_required_mask)(struct pci_dev *pdev);void (*shutdown)(struct pci_controller *hose); };
arch/powerpc/kernel/dma.c +0 -29
@@ -318,35 +318,6 @@ int dma_set_mask(struct device *dev, u64 dma_mask) }EXPORT_SYMBOL (dma_set_mask); -u64 __dma_get_required_mask (struct device *dev) -{ -const struct dma_map_ops *dma_ops =get_dma_ops (dev); - -if (unlikely (dma_ops ==NULL )) -return 0 ; - -if (dma_ops->get_required_mask) -return dma_ops->get_required_mask (dev); - -return DMA_BIT_MASK (8 *sizeof (dma_addr_t)); -} - -u64 dma_get_required_mask (struct device *dev) -{ -if (ppc_md.dma_get_required_mask) -return ppc_md.dma_get_required_mask (dev); - -if (dev_is_pci (dev)) { -struct pci_dev *pdev =to_pci_dev (dev); -struct pci_controller *phb =pci_bus_to_host (pdev->bus); -if (phb->controller_ops.dma_get_required_mask) -return phb->controller_ops.dma_get_required_mask (pdev); - } - -return __dma_get_required_mask (dev); -} -EXPORT_SYMBOL_GPL (dma_get_required_mask); -static int __init dma_init (void ) {#ifdef CONFIG_IBMVIO
kernel/dma/mapping.c +0 -2
@@ -207,7 +207,6 @@ int dma_mmap_attrs(struct device *dev, struct vm_area_struct *vma, }EXPORT_SYMBOL (dma_mmap_attrs); -#ifndef ARCH_HAS_DMA_GET_REQUIRED_MASK static u64 dma_default_get_required_mask (struct device *dev) {u32 low_totalram = ((max_pfn -1 ) <<PAGE_SHIFT );
@@ -238,7 +237,6 @@ u64 dma_get_required_mask(struct device *dev)return dma_default_get_required_mask (dev); }EXPORT_SYMBOL_GPL (dma_get_required_mask); -#endif #ifndef arch_dma_alloc_attrs#define arch_dma_alloc_attrs (dev) (true)
Signature · 1 line
2.20.1
PATCH 15/32 powerpc/pci: remove the dma_set_mask pci_controller ops methods
In reply to Christoph HellwigUnused now.
--- arch/powerpc/include/asm/pci-bridge.h | 2 -- arch/powerpc/kernel/dma.c | 7 ------- 2 files changed, 9 deletions(-)
arch/powerpc/include/asm/pci-bridge.h +0 -2
@@ -45,8 +45,6 @@ struct pci_controller_ops {void (*teardown_msi_irqs)(struct pci_dev *pdev);#endif -int (*dma_set_mask)(struct pci_dev *pdev,u64 dma_mask); -void (*shutdown)(struct pci_controller *hose); };
arch/powerpc/kernel/dma.c +0 -7
@@ -304,13 +304,6 @@ int dma_set_mask(struct device *dev, u64 dma_mask)if (ppc_md.dma_set_mask)return ppc_md.dma_set_mask (dev, dma_mask); -if (dev_is_pci (dev)) { -struct pci_dev *pdev =to_pci_dev (dev); -struct pci_controller *phb =pci_bus_to_host (pdev->bus); -if (phb->controller_ops.dma_set_mask) -return phb->controller_ops.dma_set_mask (pdev, dma_mask); - } -if (!dev->dma_mask || !dma_supported (dev, dma_mask))return -EIO ; *dev->dma_mask = dma_mask;
Signature · 1 line
2.20.1
PATCH 16/32 powerpc/dma: remove the iommu fallback for coherent allocations
In reply to Christoph HellwigAll iommu capable platforms now always use the iommu code with the internal bypass, so there is not need for this magic anymore.
--- arch/powerpc/Kconfig | 4 --- arch/powerpc/kernel/dma.c | 68 ++------------------------------------- 2 files changed, 2 insertions(+), 70 deletions(-)
arch/powerpc/Kconfig +0 -4
@@ -119,9 +119,6 @@ config GENERIC_HWEIGHT bool default y -config ARCH_HAS_DMA_SET_COHERENT_MASK - bool - config PPC bool default y
@@ -130,7 +127,6 @@ config PPC # select ARCH_HAS_DEBUG_VIRTUAL select ARCH_HAS_DEVMEM_IS_ALLOWED - select ARCH_HAS_DMA_SET_COHERENT_MASK select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_GCOV_PROFILE_ALL
arch/powerpc/kernel/dma.c +2 -66
86 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 17/32 powerpc/dma: remove get_pci_dma_ops
In reply to Christoph HellwigThis function is only used by the Cell iommu code, which can keep track if it is using the iommu internally just as good.
--- arch/powerpc/include/asm/pci.h | 2 -- arch/powerpc/kernel/pci-common.c | 6 ------ arch/powerpc/platforms/cell/iommu.c | 17 ++++++++--------- 3 files changed, 8 insertions(+), 17 deletions(-)
arch/powerpc/include/asm/pci.h +0 -2
@@ -52,10 +52,8 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)#ifdef CONFIG_PCI extern void set_pci_dma_ops (const struct dma_map_ops *dma_ops); -extern const struct dma_map_ops *get_pci_dma_ops (void );#else /* CONFIG_PCI */ #define set_pci_dma_ops (d) -#define get_pci_dma_ops () NULL#endif #ifdef CONFIG_PPC64
arch/powerpc/kernel/pci-common.c +0 -6
@@ -69,12 +69,6 @@ void set_pci_dma_ops(const struct dma_map_ops *dma_ops) pci_dma_ops = dma_ops; } -const struct dma_map_ops *get_pci_dma_ops (void ) -{ -return pci_dma_ops; -} -EXPORT_SYMBOL (get_pci_dma_ops); -/* * This function should run under locking protection, specifically * hose_spinlock.
arch/powerpc/platforms/cell/iommu.c +8 -9
@@ -544,6 +544,7 @@ static struct cbe_iommu *cell_iommu_for_node(int nid)static unsigned long cell_dma_nommu_offset;static unsigned long dma_iommu_fixed_base; +static bool cell_iommu_enabled;/* iommu_fixed_is_weak is set if booted with iommu_fixed=weak */ bool iommu_fixed_is_weak;
@@ -572,16 +573,14 @@ static u64 cell_iommu_get_fixed_address(struct device *dev);static void cell_dma_dev_setup (struct device *dev) { -if (get_pci_dma_ops () == &dma_iommu_ops) { +if (cell_iommu_enabled) {u64 addr =cell_iommu_get_fixed_address (dev);if (addr !=OF_BAD_ADDR )set_dma_offset (dev, addr + dma_iommu_fixed_base);set_iommu_table_base (dev,cell_get_iommu_table (dev)); - }else if (get_pci_dma_ops () == &dma_nommu_ops) { -set_dma_offset (dev, cell_dma_nommu_offset); }else { -BUG (); +set_dma_offset (dev, cell_dma_nommu_offset); } }
@@ -599,11 +598,11 @@ static int cell_of_bus_notify(struct notifier_block *nb, unsigned long action,if (action !=BUS_NOTIFY_ADD_DEVICE )return 0 ; -/* We use the PCI DMA ops */ - dev->dma_ops =get_pci_dma_ops (); - +if (cell_iommu_enabled) + dev->dma_ops = &dma_iommu_ops; +else + dev->dma_ops = &dma_nommu_ops;cell_dma_dev_setup (dev); -return 0 ; }
@@ -1093,7 +1092,7 @@ static int __init cell_iommu_init(void) done:/* Setup default PCI iommu ops */ set_pci_dma_ops (&dma_iommu_ops); - + cell_iommu_enabled = true; bail:/* Register callbacks on OF platform device addition/removal * to handle linking them to the right DMA operations
Signature · 1 line
2.20.1
PATCH 18/32 powerpc/dma: move pci_dma_dev_setup_swiotlb to fsl_pci.c
In reply to Christoph Hellwigpci_dma_dev_setup_swiotlb is only used by the fsl_pci code, and closely related to it, so fsl_pci.c seems like a better place for it.
--- arch/powerpc/include/asm/swiotlb.h | 2 -- arch/powerpc/kernel/dma-swiotlb.c | 11 ----------- arch/powerpc/sysdev/fsl_pci.c | 9 +++++++++ 3 files changed, 9 insertions(+), 13 deletions(-)
arch/powerpc/include/asm/swiotlb.h +0 -2
@@ -18,8 +18,6 @@ extern const struct dma_map_ops powerpc_swiotlb_dma_ops;extern unsigned int ppc_swiotlb_enable;int __init swiotlb_setup_bus_notifier (void ); -extern void pci_dma_dev_setup_swiotlb (struct pci_dev *pdev); -#ifdef CONFIG_SWIOTLB void swiotlb_detect_4g (void );#else
arch/powerpc/kernel/dma-swiotlb.c +0 -11
@@ -62,17 +62,6 @@ const struct dma_map_ops powerpc_swiotlb_dma_ops = { .get_required_mask = swiotlb_powerpc_get_required, }; -void pci_dma_dev_setup_swiotlb (struct pci_dev *pdev) -{ -struct pci_controller *hose; -struct dev_archdata *sd; - - hose =pci_bus_to_host (pdev->bus); - sd = &pdev->dev.archdata; - sd->max_direct_dma_addr = - hose->dma_window_base_cur + hose->dma_window_size; -} -static int ppc_swiotlb_bus_notify (struct notifier_block *nb,unsigned long action,void *data) {
arch/powerpc/sysdev/fsl_pci.c +9 -0
@@ -114,6 +114,15 @@ static struct pci_ops fsl_indirect_pcie_ops =static u64 pci64_dma_offset;#ifdef CONFIG_SWIOTLB +static void pci_dma_dev_setup_swiotlb (struct pci_dev *pdev) +{ +struct pci_controller *hose =pci_bus_to_host (pdev->bus); +struct dev_archdata *sd = &pdev->dev.archdata; + + sd->max_direct_dma_addr = + hose->dma_window_base_cur + hose->dma_window_size; +} +static void setup_swiotlb_ops (struct pci_controller *hose) {if (ppc_swiotlb_enable) {
Signature · 1 line
2.20.1
PATCH 19/32 powerpc/dma: remove max_direct_dma_addr
In reply to Christoph HellwigThe max_direct_dma_addr duplicates the bus_dma_mask field in struct device. Use the generic field instead.
--- arch/powerpc/include/asm/device.h | 3 --- arch/powerpc/include/asm/dma-direct.h | 4 +--- arch/powerpc/kernel/dma-swiotlb.c | 21 +-------------------- arch/powerpc/kernel/dma.c | 5 ++--- arch/powerpc/sysdev/fsl_pci.c | 4 ++-- 5 files changed, 6 insertions(+), 31 deletions(-)
arch/powerpc/include/asm/device.h +0 -3
@@ -38,9 +38,6 @@ struct dev_archdata {#ifdef CONFIG_IOMMU_API void *iommu_domain;#endif -#ifdef CONFIG_SWIOTLB -dma_addr_t max_direct_dma_addr; -#endif #ifdef CONFIG_PPC64 struct pci_dn *pci_data;#endif
arch/powerpc/include/asm/dma-direct.h +1 -3
@@ -5,9 +5,7 @@static inline bool dma_capable (struct device *dev,dma_addr_t addr,size_t size) {#ifdef CONFIG_SWIOTLB -struct dev_archdata *sd = &dev->archdata; - -if (sd->max_direct_dma_addr && addr + size > sd->max_direct_dma_addr) +if (dev->bus_dma_mask && addr + size > dev->bus_dma_mask)return false;#endif
arch/powerpc/kernel/dma-swiotlb.c +1 -20
@@ -24,21 +24,6 @@unsigned int ppc_swiotlb_enable; -static u64 swiotlb_powerpc_get_required (struct device *dev) -{ -u64 end, mask, max_direct_dma_addr = dev->archdata.max_direct_dma_addr; - - end =memblock_end_of_DRAM (); -if (max_direct_dma_addr && end > max_direct_dma_addr) - end = max_direct_dma_addr; - end +=get_dma_offset (dev); - - mask =1ULL << (fls64 (end) -1 ); - mask += mask -1 ; - -return mask; -} -/* * At the moment, all platforms that use this code only require * swiotlb to be used if we're operating on HIGHMEM. Since
@@ -59,22 +44,18 @@ const struct dma_map_ops powerpc_swiotlb_dma_ops = { .sync_single_for_device = dma_direct_sync_single_for_device, .sync_sg_for_cpu = dma_direct_sync_sg_for_cpu, .sync_sg_for_device = dma_direct_sync_sg_for_device, - .get_required_mask = swiotlb_powerpc_get_required, + .get_required_mask = dma_direct_get_required_mask, };static int ppc_swiotlb_bus_notify (struct notifier_block *nb,unsigned long action,void *data) {struct device *dev = data; -struct dev_archdata *sd;/* We are only intereted in device addition */ if (action !=BUS_NOTIFY_ADD_DEVICE )return 0 ; - sd = &dev->archdata; - sd->max_direct_dma_addr =0 ; -/* May need to bounce if the device can't address all of DRAM */ if ((dma_get_mask (dev) +1 ) <memblock_end_of_DRAM ())set_dma_ops (dev, &powerpc_swiotlb_dma_ops);
arch/powerpc/kernel/dma.c +2 -3
@@ -30,11 +30,10 @@static u64 __maybe_unused get_pfn_limit (struct device *dev) {u64 pfn = (dev->coherent_dma_mask >>PAGE_SHIFT ) +1 ; -struct dev_archdata __maybe_unused *sd = &dev->archdata;#ifdef CONFIG_SWIOTLB -if (sd->max_direct_dma_addr && dev->dma_ops == &powerpc_swiotlb_dma_ops) - pfn =min_t (u64, pfn, sd->max_direct_dma_addr >>PAGE_SHIFT ); +if (dev->bus_dma_mask && dev->dma_ops == &powerpc_swiotlb_dma_ops) + pfn =min_t (u64, pfn, dev->bus_dma_mask >>PAGE_SHIFT );#endif return pfn;
arch/powerpc/sysdev/fsl_pci.c +2 -2
@@ -117,9 +117,8 @@ static u64 pci64_dma_offset;static void pci_dma_dev_setup_swiotlb (struct pci_dev *pdev) {struct pci_controller *hose =pci_bus_to_host (pdev->bus); -struct dev_archdata *sd = &pdev->dev.archdata; - sd->max_direct_dma_addr = + pdev->dev.bus_dma_mask = hose->dma_window_base_cur + hose->dma_window_size; }
@@ -144,6 +143,7 @@ static int fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask)* mapping that allows addressing any RAM address from across PCI. */ if (dev_is_pci (dev) && dma_mask >= pci64_dma_offset *2 -1 ) { + dev->bus_dma_mask =0 ;set_dma_ops (dev, &dma_nommu_ops);set_dma_offset (dev, pci64_dma_offset); }
Signature · 1 line
2.20.1
PATCH 20/32 powerpc/dma: fix an off-by-one in dma_capable
In reply to Christoph HellwigWe need to compare the last byte in the dma range and not the one after it for the bus_dma_mask, just like we do for the regular dma_mask. Fix this cleanly by merging the two comparisms into one.
--- arch/powerpc/include/asm/dma-direct.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
arch/powerpc/include/asm/dma-direct.h +2 -6
@@ -4,15 +4,11 @@static inline bool dma_capable (struct device *dev,dma_addr_t addr,size_t size) { -#ifdef CONFIG_SWIOTLB -if (dev->bus_dma_mask && addr + size > dev->bus_dma_mask) -return false; -#endif -if (!dev->dma_mask)return false; -return addr + size -1 <= *dev->dma_mask; +return addr + size -1 <= +min_not_zero (*dev->dma_mask, dev->bus_dma_mask); }static inline dma_addr_t __phys_to_dma (struct device *dev,phys_addr_t paddr)
Signature · 1 line
2.20.1
PATCH 21/32 dma-mapping, powerpc: simplify the arch dma_set_mask override
In reply to Christoph HellwigInstead of letting the architecture supply all of dma_set_mask just give it an additional hook selected by Kconfig.
--- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/dma-mapping.h | 2 -- arch/powerpc/include/asm/machdep.h | 2 +- arch/powerpc/kernel/Makefile | 1 + arch/powerpc/kernel/dma-mask.c | 12 ++++++++++++ arch/powerpc/kernel/dma.c | 12 ------------ arch/powerpc/sysdev/fsl_pci.c | 8 +------- kernel/dma/Kconfig | 3 +++ kernel/dma/mapping.c | 9 +++++++-- 9 files changed, 26 insertions(+), 24 deletions(-) create mode 100644 arch/powerpc/kernel/dma-mask.c
arch/powerpc/Kconfig +1 -0
@@ -883,6 +883,7 @@ config FSL_SOC config FSL_PCI bool + select ARCH_HAS_DMA_SET_MASK select PPC_INDIRECT_PCI select PCI_QUIRKS
arch/powerpc/include/asm/dma-mapping.h +0 -2
@@ -110,7 +110,5 @@ static inline void set_dma_offset(struct device *dev, dma_addr_t off) dev->archdata.dma_offset = off; } -#define HAVE_ARCH_DMA_SET_MASK 1 -#endif /* __KERNEL__ */ #endif /* _ASM_DMA_MAPPING_H */
arch/powerpc/include/asm/machdep.h +1 -1
@@ -47,7 +47,7 @@ struct machdep_calls {#endif #endif /* CONFIG_PPC64 */ -int (*dma_set_mask)(struct device *dev,u64 dma_mask); +void (*dma_set_mask)(struct device *dev,u64 dma_mask);int (*probe)(void );void (*setup_arch)(void );/* Optional, may be NULL */
arch/powerpc/kernel/Makefile +1 -0
@@ -105,6 +105,7 @@ obj-$(CONFIG_UPROBES) += uprobes.o obj-$(CONFIG_PPC_UDBG_16550) += legacy_serial.o udbg_16550.o obj-$(CONFIG_STACKTRACE) += stacktrace.o obj-$(CONFIG_SWIOTLB) += dma-swiotlb.o +obj-$(CONFIG_ARCH_HAS_DMA_SET_MASK) += dma-mask.o pci64-$(CONFIG_PPC64) += pci_dn.o pci-hotplug.o isa-bridge.o obj-$(CONFIG_PCI) += pci_$(BITS).o $(pci64-y) \
arch/powerpc/kernel/dma-mask.c new file +12 -0
@@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/dma-mapping.h> +#include <linux/export.h> +#include <asm/machdep.h> + +void arch_dma_set_mask (struct device *dev,u64 dma_mask) +{ +if (ppc_md.dma_set_mask) + ppc_md.dma_set_mask (dev, dma_mask); +} +EXPORT_SYMBOL (arch_dma_set_mask);
arch/powerpc/kernel/dma.c +0 -12
@@ -234,18 +234,6 @@ const struct dma_map_ops dma_nommu_ops = { };EXPORT_SYMBOL (dma_nommu_ops); -int dma_set_mask (struct device *dev,u64 dma_mask) -{ -if (ppc_md.dma_set_mask) -return ppc_md.dma_set_mask (dev, dma_mask); - -if (!dev->dma_mask || !dma_supported (dev, dma_mask)) -return -EIO ; - *dev->dma_mask = dma_mask; -return 0 ; -} -EXPORT_SYMBOL (dma_set_mask); -static int __init dma_init (void ) {#ifdef CONFIG_IBMVIO
arch/powerpc/sysdev/fsl_pci.c +1 -7
@@ -133,11 +133,8 @@ static void setup_swiotlb_ops(struct pci_controller *hose)static inline void setup_swiotlb_ops (struct pci_controller *hose) {}#endif -static int fsl_pci_dma_set_mask (struct device *dev,u64 dma_mask) +static void fsl_pci_dma_set_mask (struct device *dev,u64 dma_mask) { -if (!dev->dma_mask || !dma_supported (dev, dma_mask)) -return -EIO ; -/* * Fix up PCI devices that are able to DMA to the large inbound * mapping that allows addressing any RAM address from across PCI.
@@ -147,9 +144,6 @@ static int fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask)set_dma_ops (dev, &dma_nommu_ops);set_dma_offset (dev, pci64_dma_offset); } - - *dev->dma_mask = dma_mask; -return 0 ; } static int setup_one_atmu(struct ccsr_pci __iomem *pci,
kernel/dma/Kconfig +3 -0
@@ -16,6 +16,9 @@ config ARCH_DMA_ADDR_T_64BIT config ARCH_HAS_DMA_COHERENCE_H bool +config ARCH_HAS_DMA_SET_MASK + bool + config HAVE_GENERIC_DMA_COHERENT bool
kernel/dma/mapping.c +7 -2
@@ -316,18 +316,23 @@ int dma_supported(struct device *dev, u64 mask) }EXPORT_SYMBOL (dma_supported); -#ifndef HAVE_ARCH_DMA_SET_MASK +#ifdef CONFIG_ARCH_HAS_DMA_SET_MASK +void arch_dma_set_mask (struct device *dev,u64 mask); +#else +#define arch_dma_set_mask (dev, mask) do { } while (0) +#endif +int dma_set_mask (struct device *dev,u64 mask) {if (!dev->dma_mask || !dma_supported (dev, mask))return -EIO ; +arch_dma_set_mask (dev, mask);dma_check_mask (dev, mask); *dev->dma_mask = mask;return 0 ; }EXPORT_SYMBOL (dma_set_mask); -#endif #ifndef CONFIG_ARCH_HAS_DMA_SET_COHERENT_MASK int dma_set_coherent_mask (struct device *dev,u64 mask)
Signature · 1 line
2.20.1
PATCH 22/32 powerpc/dma: use phys_to_dma instead of get_dma_offset
In reply to Christoph HellwigUse the standard portable helper instead of the powerpc specific one, which is about to go away.
--- arch/powerpc/kernel/dma.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/powerpc/kernel/dma.c +5 -5
@@ -6,7 +6,7 @@*/ #include <linux/device.h> -#include <linux/dma-mapping.h> +#include <linux/dma-direct.h> #include <linux/dma-debug.h> #include <linux/gfp.h> #include <linux/memblock.h>
@@ -42,7 +42,7 @@ static u64 __maybe_unused get_pfn_limit(struct device *dev)int dma_nommu_dma_supported (struct device *dev,u64 mask) {#ifdef CONFIG_PPC64 -u64 limit =get_dma_offset (dev) + (memblock_end_of_DRAM () -1 ); +u64 limit =phys_to_dma (dev, (memblock_end_of_DRAM () -1 ));/* Limit fits in the mask, we are good */ if (mask >= limit)
@@ -101,7 +101,7 @@ void *__dma_nommu_alloc_coherent(struct device *dev, size_t size,return NULL ; ret =page_address (page);memset (ret,0 , size); - *dma_handle =__pa (ret) +get_dma_offset (dev); + *dma_handle =phys_to_dma (dev,__pa (ret));return ret; }
@@ -140,7 +140,7 @@ int dma_nommu_map_sg(struct device *dev, struct scatterlist *sgl,int i;for_each_sg (sgl, sg, nents, i) { - sg->dma_address =sg_phys (sg) +get_dma_offset (dev); + sg->dma_address =phys_to_dma (dev,sg_phys (sg)); sg->dma_length = sg->length;if (attrs &DMA_ATTR_SKIP_CPU_SYNC )
@@ -182,7 +182,7 @@ dma_addr_t dma_nommu_map_page(struct device *dev, struct page *page,if (!(attrs &DMA_ATTR_SKIP_CPU_SYNC ))__dma_sync_page (page, offset, size, dir); -return page_to_phys (page) + offset +get_dma_offset (dev); +return phys_to_dma (dev,page_to_phys (page)) + offset; } static inline void dma_nommu_unmap_page(struct device *dev,
Signature · 1 line
2.20.1
PATCH 23/32 powerpc/dma: remove dma_nommu_mmap_coherent
In reply to Christoph HellwigThe coherent cache version of this function already is functionally identicall to the default version, and by defining the arch_dma_coherent_to_pfn hook the same is ture for the noncoherent version as well.
--- arch/powerpc/include/asm/dma-mapping.h | 4 ---- arch/powerpc/kernel/dma-iommu.c | 1 - arch/powerpc/kernel/dma-swiotlb.c | 1 - arch/powerpc/kernel/dma.c | 19 ------------------- arch/powerpc/mm/dma-noncoherent.c | 7 +++++-- arch/powerpc/platforms/Kconfig.cputype | 1 + arch/powerpc/platforms/pseries/vio.c | 1 - 7 files changed, 6 insertions(+), 28 deletions(-)
arch/powerpc/include/asm/dma-mapping.h +0 -4
@@ -25,10 +25,6 @@ extern void *__dma_nommu_alloc_coherent(struct device *dev, size_t size,extern void __dma_nommu_free_coherent (struct device *dev,size_t size,void *vaddr,dma_addr_t dma_handle,unsigned long attrs); -extern int dma_nommu_mmap_coherent (struct device *dev, -struct vm_area_struct *vma, -void *cpu_addr,dma_addr_t handle, -size_t size,unsigned long attrs);int dma_nommu_map_sg (struct device *dev,struct scatterlist *sgl,int nents,enum dma_data_direction direction,unsigned long attrs);
arch/powerpc/kernel/dma-iommu.c +0 -1
@@ -167,7 +167,6 @@ u64 dma_iommu_get_required_mask(struct device *dev)const struct dma_map_ops dma_iommu_ops = { .alloc = dma_iommu_alloc_coherent, .free = dma_iommu_free_coherent, - .mmap = dma_nommu_mmap_coherent, .map_sg = dma_iommu_map_sg, .unmap_sg = dma_iommu_unmap_sg, .dma_supported = dma_iommu_dma_supported,
arch/powerpc/kernel/dma-swiotlb.c +0 -1
@@ -34,7 +34,6 @@ unsigned int ppc_swiotlb_enable;const struct dma_map_ops powerpc_swiotlb_dma_ops = { .alloc = __dma_nommu_alloc_coherent, .free = __dma_nommu_free_coherent, - .mmap = dma_nommu_mmap_coherent, .map_sg = dma_direct_map_sg, .unmap_sg = dma_direct_unmap_sg, .dma_supported = swiotlb_dma_supported,
arch/powerpc/kernel/dma.c +0 -19
@@ -114,24 +114,6 @@ void __dma_nommu_free_coherent(struct device *dev, size_t size, }#endif /* !CONFIG_NOT_COHERENT_CACHE */ -int dma_nommu_mmap_coherent (struct device *dev,struct vm_area_struct *vma, -void *cpu_addr,dma_addr_t handle,size_t size, -unsigned long attrs) -{ -unsigned long pfn; - -#ifdef CONFIG_NOT_COHERENT_CACHE - vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); - pfn =__dma_get_coherent_pfn ((unsigned long )cpu_addr); -#else - pfn =page_to_pfn (virt_to_page (cpu_addr)); -#endif -return remap_pfn_range (vma, vma->vm_start, - pfn + vma->vm_pgoff, - vma->vm_end - vma->vm_start, - vma->vm_page_prot); -} -int dma_nommu_map_sg (struct device *dev,struct scatterlist *sgl,int nents,enum dma_data_direction direction,unsigned long attrs)
@@ -218,7 +200,6 @@ static inline void dma_nommu_sync_single(struct device *dev,const struct dma_map_ops dma_nommu_ops = { .alloc = __dma_nommu_alloc_coherent, .free = __dma_nommu_free_coherent, - .mmap = dma_nommu_mmap_coherent, .map_sg = dma_nommu_map_sg, .unmap_sg = dma_nommu_unmap_sg, .dma_supported = dma_nommu_dma_supported,
arch/powerpc/mm/dma-noncoherent.c +5 -2
@@ -30,6 +30,7 @@#include <linux/types.h> #include <linux/highmem.h> #include <linux/dma-direct.h> +#include <linux/dma-noncoherent.h> #include <linux/export.h> #include <asm/tlbflush.h>
@@ -400,14 +401,16 @@ EXPORT_SYMBOL(__dma_sync_page);/* * Return the PFN for a given cpu virtual address returned by -* __dma_nommu_alloc_coherent. This is used by dma_mmap_coherent() +* __dma_nommu_alloc_coherent. */ -unsigned long __dma_get_coherent_pfn (unsigned long cpu_addr) +long arch_dma_coherent_to_pfn (struct device *dev,void *vaddr, +dma_addr_t dma_addr) {/* This should always be populated, so we don't test every * level. If that fails, we'll have a nice crash which * will be as good as a BUG_ON() */ +unsigned long cpu_addr = (unsigned long )vaddr;pgd_t *pgd =pgd_offset_k (cpu_addr);pud_t *pud =pud_offset (pgd, cpu_addr);pmd_t *pmd =pmd_offset (pud, cpu_addr);
arch/powerpc/platforms/Kconfig.cputype +1 -0
@@ -408,6 +408,7 @@ config NOT_COHERENT_CACHE bool depends on 4xx || PPC_8xx || E200 || PPC_MPC512x || \ GAMECUBE_COMMON || AMIGAONE + select ARCH_HAS_DMA_COHERENT_TO_PFN default n if PPC_47x default y
arch/powerpc/platforms/pseries/vio.c +0 -1
@@ -603,7 +603,6 @@ static void vio_dma_iommu_unmap_sg(struct device *dev,static const struct dma_map_ops vio_dma_mapping_ops = { .alloc = vio_dma_iommu_alloc_coherent, .free = vio_dma_iommu_free_coherent, - .mmap = dma_nommu_mmap_coherent, .map_sg = vio_dma_iommu_map_sg, .unmap_sg = vio_dma_iommu_unmap_sg, .map_page = vio_dma_iommu_map_page,
Signature · 1 line
2.20.1
PATCH 24/32 powerpc/dma: remove dma_nommu_get_required_mask
In reply to Christoph HellwigThis function is identical to the generic dma_direct_get_required_mask, except that the generic version also takes the bus_dma_mask account, which could lead to incorrect results in the powerpc version.
--- arch/powerpc/include/asm/dma-mapping.h | 1 - arch/powerpc/kernel/dma-iommu.c | 2 +- arch/powerpc/kernel/dma.c | 14 +------------- 3 files changed, 2 insertions(+), 15 deletions(-)
arch/powerpc/include/asm/dma-mapping.h +0 -1
@@ -32,7 +32,6 @@ dma_addr_t dma_nommu_map_page(struct device *dev, struct page *page, unsigned long offset, size_t size, enum dma_data_direction dir, unsigned long attrs);int dma_nommu_dma_supported (struct device *dev,u64 mask); -u64 dma_nommu_get_required_mask (struct device *dev);#ifdef CONFIG_NOT_COHERENT_CACHE /*
arch/powerpc/kernel/dma-iommu.c +1 -1
@@ -152,7 +152,7 @@ u64 dma_iommu_get_required_mask(struct device *dev)return 0 ;if (dev_is_pci (dev)) { -u64 bypass_mask =dma_nommu_get_required_mask (dev); +u64 bypass_mask =dma_direct_get_required_mask (dev);if (dma_iommu_bypass_supported (dev, bypass_mask))return bypass_mask;
arch/powerpc/kernel/dma.c +1 -13
@@ -145,18 +145,6 @@ static void dma_nommu_unmap_sg(struct device *dev, struct scatterlist *sgl,__dma_sync_page (sg_page (sg), sg->offset, sg->length, direction); } -u64 dma_nommu_get_required_mask (struct device *dev) -{ -u64 end, mask; - - end =memblock_end_of_DRAM () +get_dma_offset (dev); - - mask =1ULL << (fls64 (end) -1 ); - mask += mask -1 ; - -return mask; -} -dma_addr_t dma_nommu_map_page (struct device *dev,struct page *page,unsigned long offset,size_t size,enum dma_data_direction dir,unsigned long attrs)
@@ -205,7 +193,7 @@ const struct dma_map_ops dma_nommu_ops = { .dma_supported = dma_nommu_dma_supported, .map_page = dma_nommu_map_page, .unmap_page = dma_nommu_unmap_page, - .get_required_mask = dma_nommu_get_required_mask, + .get_required_mask = dma_direct_get_required_mask, #ifdef CONFIG_NOT_COHERENT_CACHE .sync_single_for_cpu = dma_nommu_sync_single, .sync_single_for_device = dma_nommu_sync_single,
Signature · 1 line
2.20.1
PATCH 25/32 powerpc/dma: remove dma_nommu_dma_supported
In reply to Christoph HellwigThis function is largely identical to the generic version used everywhere else. Replace it with the generic version.
--- arch/powerpc/include/asm/dma-mapping.h | 1 - arch/powerpc/kernel/dma-iommu.c | 2 +- arch/powerpc/kernel/dma.c | 25 +------------------------ 3 files changed, 2 insertions(+), 26 deletions(-)
arch/powerpc/include/asm/dma-mapping.h +0 -1
@@ -31,7 +31,6 @@ int dma_nommu_map_sg(struct device *dev, struct scatterlist *sgl,dma_addr_t dma_nommu_map_page (struct device *dev,struct page *page,unsigned long offset,size_t size,enum dma_data_direction dir,unsigned long attrs); -int dma_nommu_dma_supported (struct device *dev,u64 mask);#ifdef CONFIG_NOT_COHERENT_CACHE /*
arch/powerpc/kernel/dma-iommu.c +1 -1
@@ -21,7 +21,7 @@static inline bool dma_iommu_alloc_bypass (struct device *dev) {return dev->archdata.iommu_bypass && !iommu_fixed_is_weak && -dma_nommu_dma_supported (dev, dev->coherent_dma_mask); +dma_direct_supported (dev, dev->coherent_dma_mask); } static inline bool dma_iommu_map_bypass(struct device *dev,
arch/powerpc/kernel/dma.c +1 -24
@@ -39,29 +39,6 @@ static u64 __maybe_unused get_pfn_limit(struct device *dev)return pfn; } -int dma_nommu_dma_supported (struct device *dev,u64 mask) -{ -#ifdef CONFIG_PPC64 -u64 limit =phys_to_dma (dev, (memblock_end_of_DRAM () -1 )); - -/* Limit fits in the mask, we are good */ -if (mask >= limit) -return 1 ; - -#ifdef CONFIG_FSL_SOC -/* -* Freescale gets another chance via ZONE_DMA, however -* that will have to be refined if/when they support iommus -*/ -return 1 ; -#endif -/* Sorry ... */ -return 0 ; -#else -return 1 ; -#endif -} -#ifndef CONFIG_NOT_COHERENT_CACHE void *__dma_nommu_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flag,
@@ -190,7 +167,7 @@ const struct dma_map_ops dma_nommu_ops = { .free = __dma_nommu_free_coherent, .map_sg = dma_nommu_map_sg, .unmap_sg = dma_nommu_unmap_sg, - .dma_supported = dma_nommu_dma_supported, + .dma_supported = dma_direct_supported, .map_page = dma_nommu_map_page, .unmap_page = dma_nommu_unmap_page, .get_required_mask = dma_direct_get_required_mask,
Signature · 1 line
2.20.1
PATCH 26/32 swiotlb: remove swiotlb_dma_supported
In reply to Christoph HellwigThe only user left is powerpc, but even there the generic dma-direct version works just as well, given that we guarantee that the swiotlb buffer must always be addressable.
--- arch/powerpc/kernel/dma-swiotlb.c | 2 +- include/linux/swiotlb.h | 3 --- kernel/dma/swiotlb.c | 12 ------------ 3 files changed, 1 insertion(+), 16 deletions(-)
arch/powerpc/kernel/dma-swiotlb.c +1 -1
@@ -36,7 +36,7 @@ const struct dma_map_ops powerpc_swiotlb_dma_ops = { .free = __dma_nommu_free_coherent, .map_sg = dma_direct_map_sg, .unmap_sg = dma_direct_unmap_sg, - .dma_supported = swiotlb_dma_supported, + .dma_supported = dma_direct_supported, .map_page = dma_direct_map_page, .unmap_page = dma_direct_unmap_page, .sync_single_for_cpu = dma_direct_sync_single_for_cpu,
include/linux/swiotlb.h +0 -3
@@ -60,9 +60,6 @@ extern void swiotlb_tbl_sync_single(struct device *hwdev, size_t size, enum dma_data_direction dir, enum dma_sync_target target); -extern int -swiotlb_dma_supported (struct device *hwdev,u64 mask); -#ifdef CONFIG_SWIOTLB extern enum swiotlb_force swiotlb_force;extern phys_addr_t io_tlb_start, io_tlb_end;
kernel/dma/swiotlb.c +0 -12
@@ -648,15 +648,3 @@ bool swiotlb_map(struct device *dev, phys_addr_t *phys, dma_addr_t *dma_addr,return true; } - -/* -* Return whether the given device DMA address mask can be supported -* properly. For example, if your device can only drive the low 24-bits -* during bus mastering, then you would pass 0x00ffffff as the mask to -* this function. -*/ -int -swiotlb_dma_supported (struct device *hwdev,u64 mask) -{ -return __phys_to_dma (hwdev, io_tlb_end -1 ) <= mask; -}
Signature · 1 line
2.20.1
PATCH 27/32 powerpc/dma: use the dma-direct allocator for coherent platforms
In reply to Christoph HellwigThe generic code allows a few nice things such as node local allocations and dipping into the CMA area. The lookup of the right zone for a given dma mask works a little different, but the results should be the same.
--- arch/powerpc/include/asm/pgtable.h | 1 - arch/powerpc/kernel/dma-iommu.c | 5 +-- arch/powerpc/kernel/dma-swiotlb.c | 4 +- arch/powerpc/kernel/dma.c | 69 +++--------------------------- arch/powerpc/mm/mem.c | 22 ---------- 5 files changed, 9 insertions(+), 92 deletions(-)
arch/powerpc/include/asm/pgtable.h +0 -1
@@ -66,7 +66,6 @@ extern unsigned long empty_zero_page[];extern pgd_t swapper_pg_dir[]; -int dma_pfn_limit_to_zone (u64 pfn_limit);extern void paging_init (void );/*
arch/powerpc/kernel/dma-iommu.c +2 -3
@@ -40,8 +40,7 @@ static void *dma_iommu_alloc_coherent(struct device *dev, size_t size, unsigned long attrs) {if (dma_iommu_alloc_bypass (dev)) -return __dma_nommu_alloc_coherent (dev, size, dma_handle, flag, - attrs); +return dma_direct_alloc (dev, size, dma_handle, flag, attrs);return iommu_alloc_coherent (dev,get_iommu_table_base (dev), size, dma_handle, dev->coherent_dma_mask, flag,dev_to_node (dev));
@@ -52,7 +51,7 @@ static void dma_iommu_free_coherent(struct device *dev, size_t size, unsigned long attrs) {if (dma_iommu_alloc_bypass (dev)) -__dma_nommu_free_coherent (dev, size, vaddr, dma_handle, attrs); +dma_direct_free (dev, size, vaddr, dma_handle, attrs);else iommu_free_coherent (get_iommu_table_base (dev), size, vaddr, dma_handle);
arch/powerpc/kernel/dma-swiotlb.c +2 -2
@@ -32,8 +32,8 @@ unsigned int ppc_swiotlb_enable;* for everything else. */ const struct dma_map_ops powerpc_swiotlb_dma_ops = { - .alloc = __dma_nommu_alloc_coherent, - .free = __dma_nommu_free_coherent, + .alloc = dma_direct_alloc, + .free = dma_direct_free, .map_sg = dma_direct_map_sg, .unmap_sg = dma_direct_unmap_sg, .dma_supported = dma_direct_supported,
arch/powerpc/kernel/dma.c +5 -64
83 lines not on this page · raw message
arch/powerpc/mm/mem.c +0 -22
@@ -69,15 +69,12 @@ pte_t *kmap_pte;EXPORT_SYMBOL (kmap_pte);pgprot_t kmap_prot;EXPORT_SYMBOL (kmap_prot); -#define TOP_ZONE ZONE_HIGHMEMstatic inline pte_t *virt_to_kpte (unsigned long vaddr) {return pte_offset_kernel (pmd_offset (pud_offset (pgd_offset_k (vaddr), vaddr), vaddr), vaddr); } -#else -#define TOP_ZONE ZONE_NORMAL#endif pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
@@ -228,25 +225,6 @@ static int __init mark_nonram_nosave(void)*/ static unsigned long max_zone_pfns[MAX_NR_ZONES ]; -/* -* Find the least restrictive zone that is entirely below the -* specified pfn limit. Returns < 0 if no suitable zone is found. -* -* pfn_limit must be u64 because it can exceed 32 bits even on 32-bit -* systems -- the DMA limit can be higher than any possible real pfn. -*/ -int dma_pfn_limit_to_zone (u64 pfn_limit) -{ -int i; - -for (i =TOP_ZONE ; i >=0 ; i--) { -if (max_zone_pfns[i] <= pfn_limit) -return i; - } - -return -EPERM ; -} -/* * paging_init() sets up the page tables - in fact we've already done this. */
Signature · 1 line
2.20.1
PATCH 28/32 powerpc/dma: use the dma_direct mapping routines
In reply to Christoph HellwigSwitch the streaming DMA mapping and ownership transfer methods to the functionally identical dma_direct_ versions. Factor the cache maintainance helpers into the form expected by the common code for that.
--- arch/powerpc/include/asm/dma-mapping.h | 30 --------- arch/powerpc/kernel/dma-iommu.c | 4 +- arch/powerpc/kernel/dma.c | 87 +++----------------------- arch/powerpc/mm/dma-noncoherent.c | 29 ++++++--- arch/powerpc/platforms/Kconfig.cputype | 2 + 5 files changed, 32 insertions(+), 120 deletions(-)
arch/powerpc/include/asm/dma-mapping.h +0 -30
@@ -25,36 +25,6 @@ extern void *__dma_nommu_alloc_coherent(struct device *dev, size_t size,extern void __dma_nommu_free_coherent (struct device *dev,size_t size,void *vaddr,dma_addr_t dma_handle,unsigned long attrs); -int dma_nommu_map_sg (struct device *dev,struct scatterlist *sgl, -int nents,enum dma_data_direction direction, -unsigned long attrs); -dma_addr_t dma_nommu_map_page (struct device *dev,struct page *page, -unsigned long offset,size_t size, -enum dma_data_direction dir,unsigned long attrs); - -#ifdef CONFIG_NOT_COHERENT_CACHE -/* -* DMA-consistent mapping functions for PowerPCs that don't support -* cache snooping. These allocate/free a region of uncached mapped -* memory space for use with DMA devices. Alternatively, you could -* allocate the space "normally" and use the cache management functions -* to ensure it is consistent. -*/ -struct device ; -extern void __dma_sync (void *vaddr,size_t size,int direction); -extern void __dma_sync_page (struct page *page,unsigned long offset, -size_t size,int direction); -extern unsigned long __dma_get_coherent_pfn (unsigned long cpu_addr); - -#else /* ! CONFIG_NOT_COHERENT_CACHE */ -/* -* Cache coherent cores. -*/ - -#define __dma_sync (addr, size, rw) ((void)0) -#define __dma_sync_page (pg, off, sz, rw) ((void)0) - -#endif /* ! CONFIG_NOT_COHERENT_CACHE */ static inline unsigned long device_to_mask (struct device *dev) {
arch/powerpc/kernel/dma-iommu.c +2 -2
@@ -68,7 +68,7 @@ static dma_addr_t dma_iommu_map_page(struct device *dev, struct page *page, unsigned long attrs) {if (dma_iommu_map_bypass (dev, attrs)) -return dma_nommu_map_page (dev, page, offset, size, direction, +return dma_direct_map_page (dev, page, offset, size, direction, attrs);return iommu_map_page (dev,get_iommu_table_base (dev), page, offset, size,device_to_mask (dev), direction, attrs);
@@ -90,7 +90,7 @@ static int dma_iommu_map_sg(struct device *dev, struct scatterlist *sglist, unsigned long attrs) {if (dma_iommu_map_bypass (dev, attrs)) -return dma_nommu_map_sg (dev, sglist, nelems, direction, attrs); +return dma_direct_map_sg (dev, sglist, nelems, direction, attrs);return ppc_iommu_map_sg (dev,get_iommu_table_base (dev), sglist, nelems,device_to_mask (dev), direction, attrs); }
arch/powerpc/kernel/dma.c +8 -79
102 lines not on this page · raw message
arch/powerpc/mm/dma-noncoherent.c +20 -9
@@ -314,7 +314,7 @@ void __dma_nommu_free_coherent(struct device *dev, size_t size, void *vaddr,/* * make an area consistent. */ -void __dma_sync (void *vaddr,size_t size,int direction) +static void __dma_sync (void *vaddr,size_t size,int direction) {unsigned long start = (unsigned long )vaddr;unsigned long end = start + size;
@@ -340,7 +340,6 @@ void __dma_sync(void *vaddr, size_t size, int direction)break ; } } -EXPORT_SYMBOL (__dma_sync);#ifdef CONFIG_HIGHMEM /*
@@ -387,21 +386,33 @@ static inline void __dma_sync_page_highmem(struct page *page,* __dma_sync_page makes memory consistent. identical to __dma_sync, but * takes a struct page instead of a virtual address */ -void __dma_sync_page (struct page *page,unsigned long offset, -size_t size,int direction) +static void __dma_sync_page (phys_addr_t paddr,size_t size,int dir) { +struct page *page =pfn_to_page (paddr >>PAGE_SHIFT ); +unsigned offset = paddr & ~PAGE_MASK ; +#ifdef CONFIG_HIGHMEM -__dma_sync_page_highmem (page, offset, size, direction); +__dma_sync_page_highmem (page, offset, size, dir);#else unsigned long start = (unsigned long )page_address (page) + offset; -__dma_sync ((void *)start, size, direction); +__dma_sync ((void *)start, size, dir);#endif } -EXPORT_SYMBOL (__dma_sync_page); + +void arch_sync_dma_for_device (struct device *dev,phys_addr_t paddr, +size_t size,enum dma_data_direction dir) +{ +__dma_sync_page (paddr, size, dir); +} + +void arch_sync_dma_for_cpu (struct device *dev,phys_addr_t paddr, +size_t size,enum dma_data_direction dir) +{ +__dma_sync_page (paddr, size, dir); +}/* -* Return the PFN for a given cpu virtual address returned by -* __dma_nommu_alloc_coherent. +* Return the PFN for a given cpu virtual address returned by arch_dma_alloc. */ long arch_dma_coherent_to_pfn (struct device *dev,void *vaddr,dma_addr_t dma_addr)
arch/powerpc/platforms/Kconfig.cputype +2 -0
@@ -409,6 +409,8 @@ config NOT_COHERENT_CACHE depends on 4xx || PPC_8xx || E200 || PPC_MPC512x || \ GAMECUBE_COMMON || AMIGAONE select ARCH_HAS_DMA_COHERENT_TO_PFN + select ARCH_HAS_SYNC_DMA_FOR_DEVICE + select ARCH_HAS_SYNC_DMA_FOR_CPU default n if PPC_47x default y
Signature · 1 line
2.20.1
PATCH 29/32 powerpc/dma: use the generic direct mapping bypass
In reply to Christoph HellwigNow that we've switched all the powerpc nommu and swiotlb methods to use the generic dma_direct_* calls we can remove these ops vectors entirely and rely on the common direct mapping bypass that avoids indirect function calls entirely. This also allows to remove a whole lot of boilerplate code related to setting up these operations.
--- arch/powerpc/include/asm/dma-mapping.h | 9 --- arch/powerpc/include/asm/swiotlb.h | 3 - arch/powerpc/kernel/Makefile | 2 +- arch/powerpc/kernel/dma-swiotlb.c | 58 ----------------- arch/powerpc/kernel/dma.c | 62 ------------------- arch/powerpc/kernel/pci-common.c | 2 +- arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/dma-noncoherent.c | 6 +- arch/powerpc/platforms/44x/warp.c | 2 +- arch/powerpc/platforms/85xx/corenet_generic.c | 4 -- arch/powerpc/platforms/85xx/ge_imp3a.c | 2 - arch/powerpc/platforms/85xx/mpc8536_ds.c | 2 - arch/powerpc/platforms/85xx/mpc85xx_ds.c | 4 -- arch/powerpc/platforms/85xx/mpc85xx_mds.c | 4 -- arch/powerpc/platforms/85xx/p1010rdb.c | 1 - arch/powerpc/platforms/85xx/p1022_ds.c | 2 - arch/powerpc/platforms/85xx/p1022_rdk.c | 2 - arch/powerpc/platforms/86xx/mpc86xx_hpcn.c | 1 - arch/powerpc/platforms/cell/iommu.c | 3 - arch/powerpc/platforms/pasemi/iommu.c | 2 +- arch/powerpc/platforms/pasemi/setup.c | 51 --------------- arch/powerpc/platforms/powernv/npu-dma.c | 2 +- arch/powerpc/platforms/pseries/vio.c | 7 +++ arch/powerpc/sysdev/fsl_pci.c | 5 +- drivers/misc/cxl/vphb.c | 1 - 25 files changed, 16 insertions(+), 222 deletions(-) delete mode 100644 arch/powerpc/kernel/dma.c
arch/powerpc/include/asm/dma-mapping.h +0 -9
@@ -18,14 +18,6 @@#include <asm/io.h> #include <asm/swiotlb.h> -/* Some dma direct funcs must be visible for use in other dma_ops */ -extern void *__dma_nommu_alloc_coherent (struct device *dev,size_t size, -dma_addr_t *dma_handle,gfp_t flag, -unsigned long attrs); -extern void __dma_nommu_free_coherent (struct device *dev,size_t size, -void *vaddr,dma_addr_t dma_handle, -unsigned long attrs); -static inline unsigned long device_to_mask (struct device *dev) {if (dev->dma_mask && *dev->dma_mask)
@@ -40,7 +32,6 @@ static inline unsigned long device_to_mask(struct device *dev)#ifdef CONFIG_PPC64 extern const struct dma_map_ops dma_iommu_ops;#endif -extern const struct dma_map_ops dma_nommu_ops;static inline const struct dma_map_ops *get_arch_dma_ops (struct bus_type *bus) {
arch/powerpc/include/asm/swiotlb.h +0 -3
@@ -13,10 +13,7 @@#include <linux/swiotlb.h> -extern const struct dma_map_ops powerpc_swiotlb_dma_ops; -extern unsigned int ppc_swiotlb_enable; -int __init swiotlb_setup_bus_notifier (void );#ifdef CONFIG_SWIOTLB void swiotlb_detect_4g (void );
arch/powerpc/kernel/Makefile +1 -1
@@ -36,7 +36,7 @@ obj-y := cputable.o ptrace.o syscalls.o \ process.o systbl.o idle.o \ signal.o sysfs.o cacheinfo.o time.o \ prom.o traps.o setup-common.o \ - udbg.o misc.o io.o dma.o misc_$(BITS).o \ + udbg.o misc.o io.o misc_$(BITS).o \ of_platform.o prom_parse.o obj-$(CONFIG_PPC64) += setup_64.o sys_ppc32.o \ signal_64.o ptrace32.o \
arch/powerpc/kernel/dma-swiotlb.c +0 -58
70 lines not on this page · raw message
arch/powerpc/kernel/dma.c deleted +0 -62
62 lines not on this page · raw message
arch/powerpc/kernel/pci-common.c +1 -1
@@ -62,7 +62,7 @@ resource_size_t isa_mem_base;EXPORT_SYMBOL (isa_mem_base); -static const struct dma_map_ops *pci_dma_ops = &dma_nommu_ops; +static const struct dma_map_ops *pci_dma_ops;void set_pci_dma_ops (const struct dma_map_ops *dma_ops) {
arch/powerpc/kernel/setup-common.c +0 -1
@@ -791,7 +791,6 @@ void arch_setup_pdev_archdata(struct platform_device *pdev) { pdev->archdata.dma_mask =DMA_BIT_MASK (32 ); pdev->dev.dma_mask = &pdev->archdata.dma_mask; -set_dma_ops (&pdev->dev, &dma_nommu_ops); }static __init void print_system_info (void )
arch/powerpc/mm/dma-noncoherent.c +3 -3
@@ -152,8 +152,8 @@ static struct ppc_vm_region *ppc_vm_region_find(struct ppc_vm_region *head, unsi* Allocate DMA-coherent memory space and return both the kernel remapped * virtual and bus address for that space. */ -void *__dma_nommu_alloc_coherent (struct device *dev,size_t size, -dma_addr_t *dma_handle,gfp_t gfp,unsigned long attrs) +void *arch_dma_alloc (struct device *dev,size_t size,dma_addr_t *dma_handle, +gfp_t gfp,unsigned long attrs) {struct page *page;struct ppc_vm_region *c;
@@ -254,7 +254,7 @@ void *__dma_nommu_alloc_coherent(struct device *dev, size_t size,/* * free a page as defined by the above mapping. */ -void __dma_nommu_free_coherent (struct device *dev,size_t size,void *vaddr, +void arch_dma_free (struct device *dev,size_t size,void *vaddr,dma_addr_t dma_handle,unsigned long attrs) {struct ppc_vm_region *c;
arch/powerpc/platforms/44x/warp.c +1 -1
@@ -47,7 +47,7 @@ static int __init warp_probe(void)if (!of_machine_is_compatible ("pika,warp" ))return 0 ; -/* For __dma_nommu_alloc_coherent */ +/* For arch_dma_alloc */ ISA_DMA_THRESHOLD = ~0L ;return 1 ;
arch/powerpc/platforms/85xx/corenet_generic.c +0 -4
@@ -223,7 +223,3 @@ define_machine(corenet_generic) { };machine_arch_initcall (corenet_generic, corenet_gen_publish_devices); - -#ifdef CONFIG_SWIOTLB -machine_arch_initcall (corenet_generic, swiotlb_setup_bus_notifier); -#endif
arch/powerpc/platforms/85xx/ge_imp3a.c +0 -2
@@ -202,8 +202,6 @@ static int __init ge_imp3a_probe(void)machine_arch_initcall (ge_imp3a, mpc85xx_common_publish_devices); -machine_arch_initcall (ge_imp3a, swiotlb_setup_bus_notifier); -define_machine (ge_imp3a) { .name = "GE_IMP3A", .probe = ge_imp3a_probe,
arch/powerpc/platforms/85xx/mpc8536_ds.c +0 -2
@@ -57,8 +57,6 @@ static void __init mpc8536_ds_setup_arch(void)machine_arch_initcall (mpc8536_ds, mpc85xx_common_publish_devices); -machine_arch_initcall (mpc8536_ds, swiotlb_setup_bus_notifier); -/* * Called very early, device-tree isn't unflattened */
arch/powerpc/platforms/85xx/mpc85xx_ds.c +0 -4
@@ -174,10 +174,6 @@ machine_arch_initcall(mpc8544_ds, mpc85xx_common_publish_devices);machine_arch_initcall (mpc8572_ds, mpc85xx_common_publish_devices);machine_arch_initcall (p2020_ds, mpc85xx_common_publish_devices); -machine_arch_initcall (mpc8544_ds, swiotlb_setup_bus_notifier); -machine_arch_initcall (mpc8572_ds, swiotlb_setup_bus_notifier); -machine_arch_initcall (p2020_ds, swiotlb_setup_bus_notifier); -/* * Called very early, device-tree isn't unflattened */
arch/powerpc/platforms/85xx/mpc85xx_mds.c +0 -4
@@ -367,10 +367,6 @@ machine_arch_initcall(mpc8568_mds, mpc85xx_publish_devices);machine_arch_initcall (mpc8569_mds, mpc85xx_publish_devices);machine_arch_initcall (p1021_mds, mpc85xx_common_publish_devices); -machine_arch_initcall (mpc8568_mds, swiotlb_setup_bus_notifier); -machine_arch_initcall (mpc8569_mds, swiotlb_setup_bus_notifier); -machine_arch_initcall (p1021_mds, swiotlb_setup_bus_notifier); -static void __init mpc85xx_mds_pic_init (void ) { struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN |
arch/powerpc/platforms/85xx/p1010rdb.c +0 -1
@@ -55,7 +55,6 @@ static void __init p1010_rdb_setup_arch(void) }machine_arch_initcall (p1010_rdb, mpc85xx_common_publish_devices); -machine_arch_initcall (p1010_rdb, swiotlb_setup_bus_notifier);/* * Called very early, device-tree isn't unflattened
arch/powerpc/platforms/85xx/p1022_ds.c +0 -2
@@ -548,8 +548,6 @@ static void __init p1022_ds_setup_arch(void)machine_arch_initcall (p1022_ds, mpc85xx_common_publish_devices); -machine_arch_initcall (p1022_ds, swiotlb_setup_bus_notifier); -/* * Called very early, device-tree isn't unflattened */
arch/powerpc/platforms/85xx/p1022_rdk.c +0 -2
@@ -128,8 +128,6 @@ static void __init p1022_rdk_setup_arch(void)machine_arch_initcall (p1022_rdk, mpc85xx_common_publish_devices); -machine_arch_initcall (p1022_rdk, swiotlb_setup_bus_notifier); -/* * Called very early, device-tree isn't unflattened */
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c +0 -1
@@ -121,7 +121,6 @@ static int __init declare_of_platform_devices(void)return 0 ; }machine_arch_initcall (mpc86xx_hpcn, declare_of_platform_devices); -machine_arch_initcall (mpc86xx_hpcn, swiotlb_setup_bus_notifier);define_machine (mpc86xx_hpcn) { .name = "MPC86xx HPCN",
arch/powerpc/platforms/cell/iommu.c +0 -3
@@ -600,8 +600,6 @@ static int cell_of_bus_notify(struct notifier_block *nb, unsigned long action,if (cell_iommu_enabled) dev->dma_ops = &dma_iommu_ops; -else - dev->dma_ops = &dma_nommu_ops;cell_dma_dev_setup (dev);return 0 ; }
@@ -727,7 +725,6 @@ static int __init cell_iommu_init_disabled(void)unsigned long base =0 , size;/* When no iommu is present, we use direct DMA ops */ -set_pci_dma_ops (&dma_nommu_ops);/* First make sure all IOC translation is turned off */ cell_disable_iommus ();
arch/powerpc/platforms/pasemi/iommu.c +1 -1
@@ -186,7 +186,7 @@ static void pci_dma_dev_setup_pasemi(struct pci_dev *dev)*/ if (dev->vendor ==0x1959 && dev->device ==0xa007 && !firmware_has_feature (FW_FEATURE_LPAR )) { - dev->dev.dma_ops = &dma_nommu_ops; + dev->dev.dma_ops =NULL ;/* * Set the coherent DMA mask to prevent the iommu * being used unnecessarily
arch/powerpc/platforms/pasemi/setup.c +0 -51
63 lines not on this page · raw message
arch/powerpc/platforms/powernv/npu-dma.c +1 -1
@@ -216,7 +216,7 @@ static void pnv_npu_dma_set_32(struct pnv_ioda_pe *npe)* their parent device so drivers shouldn't be doing DMA * operations directly on these devices. */ -set_dma_ops (&npe->pdev->dev,NULL ); +set_dma_ops (&npe->pdev->dev, &dma_dummy_ops); }/*
arch/powerpc/platforms/pseries/vio.c +7 -0
@@ -1699,3 +1699,10 @@ int vio_disable_interrupts(struct vio_dev *dev) }EXPORT_SYMBOL (vio_disable_interrupts);#endif /* CONFIG_PPC_PSERIES */ + +static int __init vio_init (void ) +{ +dma_debug_add_bus (&vio_bus_type); +return 0 ; +} +fs_initcall (vio_init);
arch/powerpc/sysdev/fsl_pci.c +1 -4
@@ -124,10 +124,8 @@ static void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev)static void setup_swiotlb_ops (struct pci_controller *hose) { -if (ppc_swiotlb_enable) { +if (ppc_swiotlb_enable) hose->controller_ops.dma_dev_setup = pci_dma_dev_setup_swiotlb; -set_pci_dma_ops (&powerpc_swiotlb_dma_ops); - } }#else static inline void setup_swiotlb_ops (struct pci_controller *hose) {}
@@ -141,7 +139,6 @@ static void fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask)*/ if (dev_is_pci (dev) && dma_mask >= pci64_dma_offset *2 -1 ) { dev->bus_dma_mask =0 ; -set_dma_ops (dev, &dma_nommu_ops);set_dma_offset (dev, pci64_dma_offset); } }
drivers/misc/cxl/vphb.c +0 -1
@@ -43,7 +43,6 @@ static bool cxl_pci_enable_device_hook(struct pci_dev *dev)return false; } -set_dma_ops (&dev->dev, &dma_nommu_ops);set_dma_offset (&dev->dev,PAGE_OFFSET );/*
Signature · 1 line
2.20.1
PATCH 30/32 powerpc/dma: remove get_dma_offset
In reply to Christoph HellwigJust fold the calculation into __phys_to_dma/__dma_to_phys as those are the only places that should know about it.
--- arch/powerpc/include/asm/dma-direct.h | 8 ++++++-- arch/powerpc/include/asm/dma-mapping.h | 16 ---------------- 2 files changed, 6 insertions(+), 18 deletions(-)
arch/powerpc/include/asm/dma-direct.h +6 -2
@@ -13,11 +13,15 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)static inline dma_addr_t __phys_to_dma (struct device *dev,phys_addr_t paddr) { -return paddr +get_dma_offset (dev); +if (!dev) +return paddr +PCI_DRAM_OFFSET ; +return paddr + dev->archdata.dma_offset; }static inline phys_addr_t __dma_to_phys (struct device *dev,dma_addr_t daddr) { -return daddr -get_dma_offset (dev); +if (!dev) +return daddr -PCI_DRAM_OFFSET ; +return daddr - dev->archdata.dma_offset; }#endif /* ASM_POWERPC_DMA_DIRECT_H */
arch/powerpc/include/asm/dma-mapping.h +0 -16
@@ -43,22 +43,6 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)return NULL ; } -/* -* get_dma_offset() -* -* Get the dma offset on configurations where the dma address can be determined -* from the physical address by looking at a simple offset. Direct dma and -* swiotlb use this function, but it is typically not used by implementations -* with an iommu. -*/ -static inline dma_addr_t get_dma_offset (struct device *dev) -{ -if (dev) -return dev->archdata.dma_offset; - -return PCI_DRAM_OFFSET ; -} -static inline void set_dma_offset (struct device *dev,dma_addr_t off) {if (dev)
Signature · 1 line
2.20.1
PATCH 31/32 powerpc/dma: remove set_dma_offset
In reply to Christoph HellwigThere is no good reason for this helper, just opencode it.
--- arch/powerpc/include/asm/dma-mapping.h | 6 ------ arch/powerpc/kernel/pci-common.c | 2 +- arch/powerpc/platforms/cell/iommu.c | 4 ++-- arch/powerpc/platforms/powernv/pci-ioda.c | 6 +++--- arch/powerpc/platforms/pseries/iommu.c | 7 ++----- arch/powerpc/sysdev/dart_iommu.c | 2 +- arch/powerpc/sysdev/fsl_pci.c | 2 +- drivers/misc/cxl/vphb.c | 2 +- 8 files changed, 11 insertions(+), 20 deletions(-)
arch/powerpc/include/asm/dma-mapping.h +0 -6
@@ -43,11 +43,5 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)return NULL ; } -static inline void set_dma_offset (struct device *dev,dma_addr_t off) -{ -if (dev) - dev->archdata.dma_offset = off; -} -#endif /* __KERNEL__ */ #endif /* _ASM_DMA_MAPPING_H */
arch/powerpc/kernel/pci-common.c +1 -1
@@ -966,7 +966,7 @@ static void pcibios_setup_device(struct pci_dev *dev)/* Hook up default DMA ops */ set_dma_ops (&dev->dev, pci_dma_ops); -set_dma_offset (&dev->dev,PCI_DRAM_OFFSET ); + dev->dev.archdata.dma_offset =PCI_DRAM_OFFSET ;/* Additional platform DMA/iommu setup */ phb =pci_bus_to_host (dev->bus);
arch/powerpc/platforms/cell/iommu.c +2 -2
@@ -577,10 +577,10 @@ static void cell_dma_dev_setup(struct device *dev)u64 addr =cell_iommu_get_fixed_address (dev);if (addr !=OF_BAD_ADDR ) -set_dma_offset (dev, addr + dma_iommu_fixed_base); + dev->archdata.dma_offset = addr + dma_iommu_fixed_base;set_iommu_table_base (dev,cell_get_iommu_table (dev)); }else { -set_dma_offset (dev, cell_dma_nommu_offset); + dev->archdata.dma_offset = cell_dma_nommu_offset; } }
arch/powerpc/platforms/powernv/pci-ioda.c +3 -3
@@ -1746,7 +1746,7 @@ static void pnv_pci_ioda_dma_dev_setup(struct pnv_phb *phb, struct pci_dev *pdev pe = &phb->ioda.pe_array[pdn->pe_number];WARN_ON (get_dma_ops (&pdev->dev) != &dma_iommu_ops); -set_dma_offset (&pdev->dev, pe->tce_bypass_base); + pdev->dev.archdata.dma_offset = pe->tce_bypass_base;set_iommu_table_base (&pdev->dev, pe->table_group.tables[0 ]);/* * Note: iommu_add_device() will fail here as
@@ -1859,7 +1859,7 @@ static bool pnv_pci_ioda_iommu_bypass_supported(struct pci_dev *pdev,if (rc)return rc;/* 4GB offset bypasses 32-bit space */ -set_dma_offset (&pdev->dev, (1ULL <<32 )); + pdev->dev.archdata.dma_offset = (1ULL <<32 );return true; }
@@ -1872,7 +1872,7 @@ static void pnv_ioda_setup_bus_dma(struct pnv_ioda_pe *pe, struct pci_bus *bus)list_for_each_entry (dev, &bus->devices, bus_list) {set_iommu_table_base (&dev->dev, pe->table_group.tables[0 ]); -set_dma_offset (&dev->dev, pe->tce_bypass_base); + dev->dev.archdata.dma_offset = pe->tce_bypass_base;if ((pe->flags &PNV_IODA_PE_BUS_ALL ) && dev->subordinate)pnv_ioda_setup_bus_dma (pe, dev->subordinate);
arch/powerpc/platforms/pseries/iommu.c +2 -5
@@ -1202,7 +1202,6 @@ static bool iommu_bypass_supported_pSeriesLP(struct pci_dev *pdev, u64 dma_mask) {struct device_node *dn =pci_device_to_OF_node (pdev), *pdn;const __be32 *dma_window =NULL ; -u64 dma_offset;/* only attempt to use a new window if 64-bit DMA is requested */ if (dma_mask <DMA_BIT_MASK (64 ))
@@ -1224,11 +1223,9 @@ static bool iommu_bypass_supported_pSeriesLP(struct pci_dev *pdev, u64 dma_mask) }if (pdn &&PCI_DN (pdn)) { - dma_offset =enable_ddw (pdev, pdn); -if (dma_offset !=0 ) { -set_dma_offset (&pdev->dev, dma_offset); + pdev->dev.archdata.dma_offset =enable_ddw (pdev, pdn); +if (pdev->dev.archdata.dma_offset)return true; - } }return false;
arch/powerpc/sysdev/dart_iommu.c +1 -1
@@ -386,7 +386,7 @@ static bool dart_device_on_pcie(struct device *dev)static void pci_dma_dev_setup_dart (struct pci_dev *dev) {if (dart_is_u4 &&dart_device_on_pcie (&dev->dev)) -set_dma_offset (&dev->dev,DART_U4_BYPASS_BASE ); + dev->dev.archdata.dma_offset =DART_U4_BYPASS_BASE ;set_iommu_table_base (&dev->dev, &iommu_table_dart); }
arch/powerpc/sysdev/fsl_pci.c +1 -1
@@ -139,7 +139,7 @@ static void fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask)*/ if (dev_is_pci (dev) && dma_mask >= pci64_dma_offset *2 -1 ) { dev->bus_dma_mask =0 ; -set_dma_offset (dev, pci64_dma_offset); + dev->archdata.dma_offset = pci64_dma_offset; } }
drivers/misc/cxl/vphb.c +1 -1
@@ -43,7 +43,7 @@ static bool cxl_pci_enable_device_hook(struct pci_dev *dev)return false; } -set_dma_offset (&dev->dev,PAGE_OFFSET ); + dev->dev.archdata.dma_offset =PAGE_OFFSET ;/* * Allocate a context to do cxl things too. If we eventually do real
Signature · 1 line
2.20.1
PATCH 32/32 powerpc/dma: trim the fat from <asm/dma-mapping.h>
In reply to Christoph HellwigThere is no need to provide anything but get_arch_dma_ops to <linux/dma-mapping.h>. More the remaining declarations to <asm/iommu.h> and drop all the includes.
--- arch/powerpc/include/asm/dma-mapping.h | 29 ------------------- arch/powerpc/include/asm/iommu.h | 10 +++++++ arch/powerpc/platforms/44x/ppc476.c | 1 + arch/powerpc/platforms/85xx/corenet_generic.c | 1 + arch/powerpc/platforms/85xx/qemu_e500.c | 1 + arch/powerpc/sysdev/fsl_pci.c | 1 + 6 files changed, 14 insertions(+), 29 deletions(-)
arch/powerpc/include/asm/dma-mapping.h +0 -29
@@ -1,37 +1,9 @@/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2004 IBM -* -* Implements the generic device dma API for powerpc. -* the pci and vio busses */ #ifndef _ASM_DMA_MAPPING_H#define _ASM_DMA_MAPPING_H -#ifdef __KERNEL__ - -#include <linux/types.h> -#include <linux/cache.h> -/* need struct page definitions */ -#include <linux/mm.h> -#include <linux/scatterlist.h> -#include <linux/dma-debug.h> -#include <asm/io.h> -#include <asm/swiotlb.h> - -static inline unsigned long device_to_mask(struct device *dev) -{ - if (dev->dma_mask && *dev->dma_mask) - return *dev->dma_mask; - /* Assume devices without mask can take 32 bit addresses */ - return 0xfffffffful; -} - -/* - * Available generic sets of operations - */ -#ifdef CONFIG_PPC64 -extern const struct dma_map_ops dma_iommu_ops; -#endifstatic inline const struct dma_map_ops *get_arch_dma_ops (struct bus_type *bus) {
@@ -43,5 +15,4 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) return NULL; } -#endif /* __KERNEL__ */ #endif /* _ASM_DMA_MAPPING_H */
arch/powerpc/include/asm/iommu.h +10 -0
@@ -325,5 +325,15 @@ extern bool iommu_fixed_is_weak;#define iommu_fixed_is_weak false#endif +extern const struct dma_map_ops dma_iommu_ops; + +static inline unsigned long device_to_mask (struct device *dev) +{ +if (dev->dma_mask && *dev->dma_mask) +return *dev->dma_mask; +/* Assume devices without mask can take 32 bit addresses */ +return 0xfffffffful ; +} +#endif /* __KERNEL__ */ #endif /* _ASM_IOMMU_H */
arch/powerpc/platforms/44x/ppc476.c +1 -0
@@ -34,6 +34,7 @@#include <asm/ppc4xx.h> #include <asm/mpic.h> #include <asm/mmu.h> +#include <asm/swiotlb.h> #include <linux/pci.h> #include <linux/i2c.h>
arch/powerpc/platforms/85xx/corenet_generic.c +1 -0
@@ -27,6 +27,7 @@#include <asm/udbg.h> #include <asm/mpic.h> #include <asm/ehv_pic.h> +#include <asm/swiotlb.h> #include <soc/fsl/qe/qe_ic.h> #include <linux/of_platform.h>
arch/powerpc/platforms/85xx/qemu_e500.c +1 -0
@@ -22,6 +22,7 @@#include <asm/time.h> #include <asm/udbg.h> #include <asm/mpic.h> +#include <asm/swiotlb.h> #include <sysdev/fsl_soc.h> #include <sysdev/fsl_pci.h> #include "smp.h"
arch/powerpc/sysdev/fsl_pci.c +1 -0
@@ -40,6 +40,7 @@#include <asm/mpc85xx.h> #include <asm/disassemble.h> #include <asm/ppc-opcode.h> +#include <asm/swiotlb.h> #include <sysdev/fsl_soc.h> #include <sysdev/fsl_pci.h>
Signature · 1 line
2.20.1
Hi powerpc maintainers,
what is the plan for this serries? I've not received any comments, and although the series briefly appeared in the powerpc next-test branch it disappeared again..