convert parisc to the generic dma-noncoherent code
This should address all the comments raised last time.
PATCH 1/3 parisc: merge pcx_dma_ops and pcxl_dma_ops
In reply to a message not in the archiveThe only difference is that pcxl supports dma coherent allocations, while pcx only supports non-consistent allocations and otherwise fails.
But dma_alloc* is not in the fast path, and merging these two allows an easy migration path to the generic dma-noncoherent implementation, so do it.
--- arch/parisc/include/asm/dma-mapping.h | 3 +- arch/parisc/kernel/pci-dma.c | 80 ++++++++++++--------------- arch/parisc/kernel/setup.c | 8 +-- arch/parisc/mm/init.c | 11 +--- 4 files changed, 43 insertions(+), 59 deletions(-)
arch/parisc/include/asm/dma-mapping.h +1 -2
@@ -22,8 +22,7 @@*/ #ifdef CONFIG_PA11 -extern const struct dma_map_ops pcxl_dma_ops; -extern const struct dma_map_ops pcx_dma_ops; +extern const struct dma_map_ops pa11_dma_ops;#endif extern const struct dma_map_ops *hppa_dma_ops;
arch/parisc/kernel/pci-dma.c +36 -44
105 lines not on this page · raw message
arch/parisc/kernel/setup.c +3 -5
@@ -97,14 +97,12 @@ void __init dma_ops_init(void)panic ("PA-RISC Linux currently only supports machines that conform to\n" "the PA-RISC 1.1 or 2.0 architecture specification.\n" ); -case pcxs: -case pcxt: - hppa_dma_ops = &pcx_dma_ops; -break ;case pcxl2:pa7300lc_init ();case pcxl:/* falls through */ - hppa_dma_ops = &pcxl_dma_ops; +case pcxs: +case pcxt: + hppa_dma_ops = &pa11_dma_ops;break ;default :break ;
arch/parisc/mm/init.c +3 -8
@@ -19,7 +19,6 @@#include <linux/gfp.h> #include <linux/delay.h> #include <linux/init.h> -#include <linux/pci.h> /* for hppa_dma_ops and pcxl_dma_ops */ #include <linux/initrd.h> #include <linux/swap.h> #include <linux/unistd.h>
@@ -616,17 +615,13 @@ void __init mem_init(void)free_all_bootmem ();#ifdef CONFIG_PA11 -if (hppa_dma_ops == &pcxl_dma_ops) { +if (boot_cpu_data.cpu_type == pcxl2 || boot_cpu_data.cpu_type == pcxl) { pcxl_dma_start = (unsigned long )SET_MAP_OFFSET (MAP_START ); parisc_vmalloc_start =SET_MAP_OFFSET (pcxl_dma_start +PCXL_DMA_MAP_SIZE ); - }else { - pcxl_dma_start =0 ; - parisc_vmalloc_start =SET_MAP_OFFSET (MAP_START ); - } -#else - parisc_vmalloc_start =SET_MAP_OFFSET (MAP_START ); + } else#endif + parisc_vmalloc_start =SET_MAP_OFFSET (MAP_START );mem_init_print_info (NULL );
Signature · 1 line
2.17.1
PATCH 2/3 parisc: always use flush_kernel_dcache_range for DMA cache maintainance
In reply to a message not in the archiveCurrent the S/G list based DMA ops use flush_kernel_vmap_range which contains a few UP optimizations, while the rest of the DMA operations uses flush_kernel_dcache_range. The single vs sg operations are supposed to have the same effect, so they should use the same routines. Use the more conservation version for now, but if people more familiar with parisc think the vmap version is generally fine for DMA we should switch all interfaces over to it.
--- arch/parisc/kernel/pci-dma.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/parisc/kernel/pci-dma.c +3 -3
@@ -537,7 +537,7 @@ static void pa11_dma_unmap_sg(struct device *dev, struct scatterlist *sglist,/* once we do combining we'll need to use phys_to_virt(sg_dma_address(sglist)) */ for_each_sg (sglist, sg, nents, i) -flush_kernel_vmap_range (sg_virt (sg), sg->length); +flush_kernel_dcache_range (sg_virt (sg), sg->length); } static void pa11_dma_sync_single_for_cpu(struct device *dev,
@@ -568,7 +568,7 @@ static void pa11_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sgl/* once we do combining we'll need to use phys_to_virt(sg_dma_address(sglist)) */ for_each_sg (sglist, sg, nents, i) -flush_kernel_vmap_range (sg_virt (sg), sg->length); +flush_kernel_dcache_range (sg_virt (sg), sg->length); }static void pa11_dma_sync_sg_for_device (struct device *dev,struct scatterlist *sglist,int nents,enum dma_data_direction direction)
@@ -579,7 +579,7 @@ static void pa11_dma_sync_sg_for_device(struct device *dev, struct scatterlist */* once we do combining we'll need to use phys_to_virt(sg_dma_address(sglist)) */ for_each_sg (sglist, sg, nents, i) -flush_kernel_vmap_range (sg_virt (sg), sg->length); +flush_kernel_dcache_range (sg_virt (sg), sg->length); } static void pa11_dma_cache_sync(struct device *dev, void *vaddr, size_t size,
Signature · 1 line
2.17.1
PATCH 3/3 parisc: use generic dma_noncoherent_ops
In reply to a message not in the archiveSwitch to the generic noncoherent direct mapping implementation.
Fix sync_single_for_cpu to do skip the cache flush unless the transfer is to the device to match the more tested unmap_single path which should have the same cache coherency implications.
--- arch/parisc/Kconfig | 4 + arch/parisc/include/asm/dma-mapping.h | 4 - arch/parisc/kernel/pci-dma.c | 145 ++------------------------ arch/parisc/kernel/setup.c | 2 +- 4 files changed, 16 insertions(+), 139 deletions(-)
arch/parisc/Kconfig +4 -0
@@ -188,6 +188,10 @@ config PA20 config PA11 def_bool y depends on PA7000 || PA7100LC || PA7200 || PA7300LC + select ARCH_HAS_SYNC_DMA_FOR_CPU + select ARCH_HAS_SYNC_DMA_FOR_DEVICE + select DMA_NONCOHERENT_OPS + select DMA_NONCOHERENT_CACHE_SYNC config PREFETCH def_bool y
arch/parisc/include/asm/dma-mapping.h +0 -4
@@ -21,10 +21,6 @@** flush/purge and allocate "regular" cacheable pages for everything. */ -#ifdef CONFIG_PA11 -extern const struct dma_map_ops pa11_dma_ops; -#endif -extern const struct dma_map_ops *hppa_dma_ops;static inline const struct dma_map_ops *get_arch_dma_ops (struct bus_type *bus)
arch/parisc/kernel/pci-dma.c +11 -134
180 lines not on this page · raw message
arch/parisc/kernel/setup.c +1 -1
@@ -102,7 +102,7 @@ void __init dma_ops_init(void)case pcxl:/* falls through */ case pcxs:case pcxt: - hppa_dma_ops = &pa11_dma_ops; + hppa_dma_ops = &dma_noncoherent_ops;break ;default :break ;
Signature · 1 line
2.17.1
ping? Any comments?
Quoted 7 lines · Christoph Hellwig
This should address all the comments raised last time.
_______________________________________________
iommu mailing list iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
---end quoted text---
Quoted 1 line · Christoph Hellwig
ping? Any comments?
I applied those 3 patches on top of git head, and booted the 32-bit kernel on a HP 715/64 (PCX-L) and a HP B160L (PCX-L2). On both machines I had problems with those drivers which use DMA (I checked specifically the lasi NIC card, which is the main onboard NIC card in both machines).
Getting IP via DHCP was unreliable, pings on the same network to both machines gave lost packets, login via ssh sometimes failed and so on.
So, there is definitively some cache-flush missing in this patchset.
I'm happy to test any further patches, but I'l be blocked at least until end of next week. It would be good if James could do some testing on his PCX-machine too, since that machine is different than mine.
Thanks for your efforts to clean that up!
Helge
Quoted 2 lines · Christoph Hellwig
Quoted 1 line
This should address all the comments raised last time.
For the record: Here is the link to the patchbundle:
https://patchwork.kernel.org/bundle/helge/DMA_OP/
Quoted 11 lines · Helge Deller
Quoted 1 line · Christoph Hellwig
ping? Any comments?
I applied those 3 patches on top of git head, and booted the 32-bit kernel on a HP 715/64 (PCX-L) and a HP B160L (PCX-L2). On both machines I had problems with those drivers which use DMA (I checked specifically the lasi NIC card, which is the main onboard NIC card in both machines).
Getting IP via DHCP was unreliable, pings on the same network to both machines gave lost packets, login via ssh sometimes failed and so on.
Quoted 1 line
So, there is definitively some cache-flush missing in this patchset.
Possibly, the code should use flush_kernel_vmap_range() as it purges the TLB entries used for the cache flush. Some of the routines in pci-dma.c currently use it.
Dave
Signature · 6 lines
John David Anglin [email protected] _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Quoted 12 lines · John David Anglin
Quoted 11 lines · Helge Deller
Quoted 1 line · Christoph Hellwig
ping? Any comments?
I applied those 3 patches on top of git head, and booted the 32-bit kernel on a HP 715/64 (PCX-L) and a HP B160L (PCX-L2). On both machines I had problems with those drivers which use DMA (I checked specifically the lasi NIC card, which is the main onboard NIC card in both machines).
Getting IP via DHCP was unreliable, pings on the same network to both machines gave lost packets, login via ssh sometimes failed and so on.
Quoted 4 lines
Quoted 1 line
So, there is definitively some cache-flush missing in this patchset.
Possibly, the code should use
flush_kernel_vmap_range()as it purges the TLB entries used
for the cache flush. Some of the routines inpci-dma.ccurrently use it.
That might be worth a try and is already discussed in my description.
Also it might be good to check that the last patch really is the culprit, I'm pretty certain it is, but a double check never hurts.
Helge Deller
Tested-byQuoted 14 lines · Christoph Hellwig
Quoted 13 lines · John David Anglin
Quoted 12 lines · Helge Deller
Quoted 1 line · Christoph Hellwig
ping? Any comments?
I applied those 3 patches on top of git head, and booted the 32-bit kernel on a HP 715/64 (PCX-L) and a HP B160L (PCX-L2). On both machines I had problems with those drivers which use DMA (I checked specifically the lasi NIC card, which is the main onboard NIC card in both machines).
Getting IP via DHCP was unreliable, pings on the same network to both machines gave lost packets, login via ssh sometimes failed and so on.So, there is definitively some cache-flush missing in this patchset.
Quoted 8 lines
Quoted 3 lines
Possibly, the code should use
flush_kernel_vmap_range()as it purges the TLB entries used
for the cache flush. Some of the routines inpci-dma.ccurrently use it.That might be worth a try and is already discussed in my description.
Also it might be good to check that the last patch really is the culprit, I'm pretty certain it is, but a double check never hurts.
Somehow I now can't reproduce the cache issues any longer. Both, your original patch and when using flush_kernel_vmap_range(), both work.
So, you can add a
to your original patch series.
Helge
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Quoted 6 lines · Helge Deller
Somehow I now can't reproduce the cache issues any longer. Both, your original patch and when using
flush_kernel_vmap_range(), both work.So, you can add a
Tested-by Helge Deller <[email protected]>to your original patch series.
I can merge this through the dma-mapping tree, but given that it touches only arch/parisc/ it might make more sense to merge it through the parisc tree.
Quoted 11 lines · Christoph Hellwig
Quoted 6 lines · Helge Deller
Somehow I now can't reproduce the cache issues any longer. Both, your original patch and when using
flush_kernel_vmap_range(), both work.So, you can add a
Tested-by Helge Deller <[email protected]>to your original patch series.
I can merge this through the dma-mapping tree, but given that it touches only
arch/parisc/it might make more sense to merge it through the parisc tree.
Sure, I will take it through the parisc tree.
Thanks!
Helge