~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/netlogic/common/nlm-dma.c

Version: ~ [ linux-5.4-rc7 ] ~ [ linux-5.3.11 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.84 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.154 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.201 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.201 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.77 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2 *  Copyright (C) 2003-2013 Broadcom Corporation
  3 *  All Rights Reserved
  4  *
  5  * This software is available to you under a choice of one of two
  6  * licenses.  You may choose to be licensed under the terms of the GNU
  7  * General Public License (GPL) Version 2, available from the file
  8  * COPYING in the main directory of this source tree, or the Broadcom
  9  * license below:
 10  *
 11  * Redistribution and use in source and binary forms, with or without
 12  * modification, are permitted provided that the following conditions
 13  * are met:
 14  *
 15  * 1. Redistributions of source code must retain the above copyright
 16  *    notice, this list of conditions and the following disclaimer.
 17  * 2. Redistributions in binary form must reproduce the above copyright
 18  *    notice, this list of conditions and the following disclaimer in
 19  *    the documentation and/or other materials provided with the
 20  *    distribution.
 21  *
 22  * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR
 23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 24  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 25  * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE
 26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 29  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 30  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 31  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 32  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 33  */
 34 #include <linux/dma-mapping.h>
 35 #include <linux/scatterlist.h>
 36 #include <linux/bootmem.h>
 37 #include <linux/export.h>
 38 #include <linux/swiotlb.h>
 39 #include <linux/types.h>
 40 #include <linux/init.h>
 41 #include <linux/mm.h>
 42 
 43 #include <asm/bootinfo.h>
 44 
 45 static char *nlm_swiotlb;
 46 
 47 static void *nlm_dma_alloc_coherent(struct device *dev, size_t size,
 48         dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs)
 49 {
 50         /* ignore region specifiers */
 51         gfp &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM);
 52 
 53 #ifdef CONFIG_ZONE_DMA32
 54         if (dev->coherent_dma_mask <= DMA_BIT_MASK(32))
 55                 gfp |= __GFP_DMA32;
 56 #endif
 57 
 58         /* Don't invoke OOM killer */
 59         gfp |= __GFP_NORETRY;
 60 
 61         return swiotlb_alloc_coherent(dev, size, dma_handle, gfp);
 62 }
 63 
 64 static void nlm_dma_free_coherent(struct device *dev, size_t size,
 65         void *vaddr, dma_addr_t dma_handle, unsigned long attrs)
 66 {
 67         swiotlb_free_coherent(dev, size, vaddr, dma_handle);
 68 }
 69 
 70 struct dma_map_ops nlm_swiotlb_dma_ops = {
 71         .alloc = nlm_dma_alloc_coherent,
 72         .free = nlm_dma_free_coherent,
 73         .map_page = swiotlb_map_page,
 74         .unmap_page = swiotlb_unmap_page,
 75         .map_sg = swiotlb_map_sg_attrs,
 76         .unmap_sg = swiotlb_unmap_sg_attrs,
 77         .sync_single_for_cpu = swiotlb_sync_single_for_cpu,
 78         .sync_single_for_device = swiotlb_sync_single_for_device,
 79         .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
 80         .sync_sg_for_device = swiotlb_sync_sg_for_device,
 81         .mapping_error = swiotlb_dma_mapping_error,
 82         .dma_supported = swiotlb_dma_supported
 83 };
 84 
 85 void __init plat_swiotlb_setup(void)
 86 {
 87         size_t swiotlbsize;
 88         unsigned long swiotlb_nslabs;
 89 
 90         swiotlbsize = 1 << 20; /* 1 MB for now */
 91         swiotlb_nslabs = swiotlbsize >> IO_TLB_SHIFT;
 92         swiotlb_nslabs = ALIGN(swiotlb_nslabs, IO_TLB_SEGSIZE);
 93         swiotlbsize = swiotlb_nslabs << IO_TLB_SHIFT;
 94 
 95         nlm_swiotlb = alloc_bootmem_low_pages(swiotlbsize);
 96         swiotlb_init_with_tbl(nlm_swiotlb, swiotlb_nslabs, 1);
 97 }
 98 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp