Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* iommu_common.h: UltraSparc SBUS/PCI common iommu declarations.
0003  *
0004  * Copyright (C) 1999, 2008 David S. Miller (davem@davemloft.net)
0005  */
0006 
0007 #ifndef _IOMMU_COMMON_H
0008 #define _IOMMU_COMMON_H
0009 
0010 #include <linux/kernel.h>
0011 #include <linux/types.h>
0012 #include <linux/sched.h>
0013 #include <linux/mm.h>
0014 #include <linux/scatterlist.h>
0015 #include <linux/device.h>
0016 #include <linux/iommu-helper.h>
0017 
0018 #include <asm/iommu.h>
0019 
0020 /*
0021  * These give mapping size of each iommu pte/tlb.
0022  */
0023 #define IO_PAGE_SHIFT           13
0024 #define IO_PAGE_SIZE            (1UL << IO_PAGE_SHIFT)
0025 #define IO_PAGE_MASK            (~(IO_PAGE_SIZE-1))
0026 #define IO_PAGE_ALIGN(addr)     ALIGN(addr, IO_PAGE_SIZE)
0027 
0028 #define IO_TSB_ENTRIES          (128*1024)
0029 #define IO_TSB_SIZE         (IO_TSB_ENTRIES * 8)
0030 
0031 /*
0032  * This is the hardwired shift in the iotlb tag/data parts.
0033  */
0034 #define IOMMU_PAGE_SHIFT        13
0035 
0036 #define SG_ENT_PHYS_ADDRESS(SG) (__pa(sg_virt((SG))))
0037 
0038 static inline int is_span_boundary(unsigned long entry,
0039                    unsigned long shift,
0040                    unsigned long boundary_size,
0041                    struct scatterlist *outs,
0042                    struct scatterlist *sg)
0043 {
0044     unsigned long paddr = SG_ENT_PHYS_ADDRESS(outs);
0045     int nr = iommu_num_pages(paddr, outs->dma_length + sg->length,
0046                  IO_PAGE_SIZE);
0047 
0048     return iommu_is_span_boundary(entry, nr, shift, boundary_size);
0049 }
0050 
0051 #endif /* _IOMMU_COMMON_H */