cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

dma-coherent.c (782B)


      1// SPDX-License-Identifier: GPL-2.0
      2/*
      3 * Copyright (C) 2004 - 2007  Paul Mundt
      4 */
      5#include <linux/mm.h>
      6#include <linux/dma-map-ops.h>
      7#include <asm/cacheflush.h>
      8#include <asm/addrspace.h>
      9
     10void arch_dma_prep_coherent(struct page *page, size_t size)
     11{
     12	__flush_purge_region(page_address(page), size);
     13}
     14
     15void arch_sync_dma_for_device(phys_addr_t paddr, size_t size,
     16		enum dma_data_direction dir)
     17{
     18	void *addr = sh_cacheop_vaddr(phys_to_virt(paddr));
     19
     20	switch (dir) {
     21	case DMA_FROM_DEVICE:		/* invalidate only */
     22		__flush_invalidate_region(addr, size);
     23		break;
     24	case DMA_TO_DEVICE:		/* writeback only */
     25		__flush_wback_region(addr, size);
     26		break;
     27	case DMA_BIDIRECTIONAL:		/* writeback and invalidate */
     28		__flush_purge_region(addr, size);
     29		break;
     30	default:
     31		BUG();
     32	}
     33}