mirror of
				git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
				synced 2025-10-31 16:54:21 +00:00 
			
		
		
		
	swiotlb: factor out an io_tlb_offset helper
Replace the very genericly named OFFSET macro with a little inline helper that hardcodes the alignment to the only value ever passed. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Jianxiong Gao <jxgao@google.com> Tested-by: Jianxiong Gao <jxgao@google.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
This commit is contained in:
		
							parent
							
								
									b5d7ccb7aa
								
							
						
					
					
						commit
						c7fbeca757
					
				
					 1 changed files with 13 additions and 7 deletions
				
			
		|  | @ -50,9 +50,6 @@ | |||
| #define CREATE_TRACE_POINTS | ||||
| #include <trace/events/swiotlb.h> | ||||
| 
 | ||||
| #define OFFSET(val,align) ((unsigned long)	\ | ||||
| 	                   ( (val) & ( (align) - 1))) | ||||
| 
 | ||||
| #define SLABS_PER_PAGE (1 << (PAGE_SHIFT - IO_TLB_SHIFT)) | ||||
| 
 | ||||
| /*
 | ||||
|  | @ -192,6 +189,11 @@ void swiotlb_print_info(void) | |||
| 	       bytes >> 20); | ||||
| } | ||||
| 
 | ||||
| static inline unsigned long io_tlb_offset(unsigned long val) | ||||
| { | ||||
| 	return val & (IO_TLB_SEGSIZE - 1); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * Early SWIOTLB allocation may be too early to allow an architecture to | ||||
|  * perform the desired operations.  This function allows the architecture to | ||||
|  | @ -241,7 +243,7 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose) | |||
| 		      __func__, alloc_size, PAGE_SIZE); | ||||
| 
 | ||||
| 	for (i = 0; i < io_tlb_nslabs; i++) { | ||||
| 		io_tlb_list[i] = IO_TLB_SEGSIZE - OFFSET(i, IO_TLB_SEGSIZE); | ||||
| 		io_tlb_list[i] = IO_TLB_SEGSIZE - io_tlb_offset(i); | ||||
| 		io_tlb_orig_addr[i] = INVALID_PHYS_ADDR; | ||||
| 	} | ||||
| 	io_tlb_index = 0; | ||||
|  | @ -375,7 +377,7 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs) | |||
| 		goto cleanup4; | ||||
| 
 | ||||
| 	for (i = 0; i < io_tlb_nslabs; i++) { | ||||
| 		io_tlb_list[i] = IO_TLB_SEGSIZE - OFFSET(i, IO_TLB_SEGSIZE); | ||||
| 		io_tlb_list[i] = IO_TLB_SEGSIZE - io_tlb_offset(i); | ||||
| 		io_tlb_orig_addr[i] = INVALID_PHYS_ADDR; | ||||
| 	} | ||||
| 	io_tlb_index = 0; | ||||
|  | @ -546,7 +548,9 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, phys_addr_t orig_addr, | |||
| 
 | ||||
| 			for (i = index; i < (int) (index + nslots); i++) | ||||
| 				io_tlb_list[i] = 0; | ||||
| 			for (i = index - 1; (OFFSET(i, IO_TLB_SEGSIZE) != IO_TLB_SEGSIZE - 1) && io_tlb_list[i]; i--) | ||||
| 			for (i = index - 1; | ||||
| 			     io_tlb_offset(i) != IO_TLB_SEGSIZE - 1 && | ||||
| 			     io_tlb_list[i]; i--) | ||||
| 				io_tlb_list[i] = ++count; | ||||
| 			tlb_addr = io_tlb_start + (index << IO_TLB_SHIFT); | ||||
| 
 | ||||
|  | @ -632,7 +636,9 @@ void swiotlb_tbl_unmap_single(struct device *hwdev, phys_addr_t tlb_addr, | |||
| 		 * Step 2: merge the returned slots with the preceding slots, | ||||
| 		 * if available (non zero) | ||||
| 		 */ | ||||
| 		for (i = index - 1; (OFFSET(i, IO_TLB_SEGSIZE) != IO_TLB_SEGSIZE -1) && io_tlb_list[i]; i--) | ||||
| 		for (i = index - 1; | ||||
| 		     io_tlb_offset(i) != IO_TLB_SEGSIZE - 1 && | ||||
| 		     io_tlb_list[i]; i--) | ||||
| 			io_tlb_list[i] = ++count; | ||||
| 
 | ||||
| 		io_tlb_used -= nslots; | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Christoph Hellwig
						Christoph Hellwig