mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	riscv: add swiotlb support
All RISC-V platforms today lack an IOMMU. However, legacy PCI devices sometimes require DMA-memory to be in the low 32 bits. To make this work, we enable the software-based bounce buffers from swiotlb. They only impose overhead when the device in question cannot address the full 64-bit address space, so a perfect fit. This patch assumes that DMA is coherent with the processor and the PCI bus. It also assumes that the processor and devices share a common address space. This is true for all RISC-V platforms so far. [changelog stolen from an earlier patch by Palmer Dabbelt that did the more complicated swiotlb wireup before the recent consolidation] Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Palmer Dabbelt <palmer@sifive.com>
This commit is contained in:
		
							parent
							
								
									f1306f0423
								
							
						
					
					
						commit
						10314e09d0
					
				
					 3 changed files with 18 additions and 0 deletions
				
			
		| 
						 | 
					@ -114,6 +114,7 @@ config ARCH_RV64I
 | 
				
			||||||
	select HAVE_FTRACE_MCOUNT_RECORD
 | 
						select HAVE_FTRACE_MCOUNT_RECORD
 | 
				
			||||||
	select HAVE_DYNAMIC_FTRACE
 | 
						select HAVE_DYNAMIC_FTRACE
 | 
				
			||||||
	select HAVE_DYNAMIC_FTRACE_WITH_REGS
 | 
						select HAVE_DYNAMIC_FTRACE_WITH_REGS
 | 
				
			||||||
 | 
						select SWIOTLB
 | 
				
			||||||
 | 
					
 | 
				
			||||||
endchoice
 | 
					endchoice
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										15
									
								
								arch/riscv/include/asm/dma-mapping.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								arch/riscv/include/asm/dma-mapping.h
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,15 @@
 | 
				
			||||||
 | 
					// SPDX-License-Identifier: GPL-2.0
 | 
				
			||||||
 | 
					#ifndef _RISCV_ASM_DMA_MAPPING_H
 | 
				
			||||||
 | 
					#define _RISCV_ASM_DMA_MAPPING_H 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef CONFIG_SWIOTLB
 | 
				
			||||||
 | 
					#include <linux/swiotlb.h>
 | 
				
			||||||
 | 
					static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return &swiotlb_dma_ops;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					#include <asm-generic/dma-mapping.h>
 | 
				
			||||||
 | 
					#endif /* CONFIG_SWIOTLB */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* _RISCV_ASM_DMA_MAPPING_H */
 | 
				
			||||||
| 
						 | 
					@ -29,6 +29,7 @@
 | 
				
			||||||
#include <linux/of_fdt.h>
 | 
					#include <linux/of_fdt.h>
 | 
				
			||||||
#include <linux/of_platform.h>
 | 
					#include <linux/of_platform.h>
 | 
				
			||||||
#include <linux/sched/task.h>
 | 
					#include <linux/sched/task.h>
 | 
				
			||||||
 | 
					#include <linux/swiotlb.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <asm/setup.h>
 | 
					#include <asm/setup.h>
 | 
				
			||||||
#include <asm/sections.h>
 | 
					#include <asm/sections.h>
 | 
				
			||||||
| 
						 | 
					@ -206,6 +207,7 @@ void __init setup_arch(char **cmdline_p)
 | 
				
			||||||
	setup_bootmem();
 | 
						setup_bootmem();
 | 
				
			||||||
	paging_init();
 | 
						paging_init();
 | 
				
			||||||
	unflatten_device_tree();
 | 
						unflatten_device_tree();
 | 
				
			||||||
 | 
						swiotlb_init(1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_SMP
 | 
					#ifdef CONFIG_SMP
 | 
				
			||||||
	setup_smp();
 | 
						setup_smp();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue