Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sh: introduce a sh_cacheop_vaddr helper

And use it in the maple bus code to avoid a dma API dependency.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Yoshinori Sato <ysato@users.sourceforge.jp>

+12 -8
+7
arch/sh/include/asm/cacheflush.h
··· 101 101 102 102 void cpu_cache_init(void); 103 103 104 + static inline void *sh_cacheop_vaddr(void *vaddr) 105 + { 106 + if (__in_29bit_mode()) 107 + vaddr = (void *)CAC_ADDR((unsigned long)vaddr); 108 + return vaddr; 109 + } 110 + 104 111 #endif /* __KERNEL__ */ 105 112 #endif /* __ASM_SH_CACHEFLUSH_H */
+1 -5
arch/sh/mm/consistent.c
··· 74 74 void sh_sync_dma_for_device(void *vaddr, size_t size, 75 75 enum dma_data_direction direction) 76 76 { 77 - void *addr; 78 - 79 - addr = __in_29bit_mode() ? 80 - (void *)CAC_ADDR((unsigned long)vaddr) : vaddr; 77 + void *addr = sh_cacheop_vaddr(vaddr); 81 78 82 79 switch (direction) { 83 80 case DMA_FROM_DEVICE: /* invalidate only */ ··· 90 93 BUG(); 91 94 } 92 95 } 93 - EXPORT_SYMBOL(sh_sync_dma_for_device); 94 96 95 97 static int __init memchunk_setup(char *str) 96 98 {
+4 -3
drivers/sh/maple/maple.c
··· 300 300 mutex_unlock(&maple_wlist_lock); 301 301 if (maple_packets > 0) { 302 302 for (i = 0; i < (1 << MAPLE_DMA_PAGES); i++) 303 - sh_sync_dma_for_device(maple_sendbuf + i * PAGE_SIZE, 304 - PAGE_SIZE, DMA_BIDIRECTIONAL); 303 + __flush_purge_region(maple_sendbuf + i * PAGE_SIZE, 304 + PAGE_SIZE); 305 305 } 306 306 307 307 finish: ··· 642 642 list_for_each_entry_safe(mq, nmq, &maple_sentq, list) { 643 643 mdev = mq->dev; 644 644 recvbuf = mq->recvbuf->buf; 645 - sh_sync_dma_for_device(recvbuf, 0x400, DMA_FROM_DEVICE); 645 + __flush_invalidate_region(sh_cacheop_vaddr(recvbuf), 646 + 0x400); 646 647 code = recvbuf[0]; 647 648 kfree(mq->sendbuf); 648 649 list_del_init(&mq->list);